Example #1
0
	before('start electron', function() {
		app = new Application({
			path: Path.join(__dirname, '../node_modules/.bin/electron'),
			args: [Path.join(__dirname, '..')],
		});
		return app.start();
	});
Example #2
0
 beforeEach(() => {
   app = new Application({
     path: electronPath,
     args: [path.join(__dirname, '..', '..', 'src', 'bootstrap.js')]
   });
   return app.start();
 });
 beforeAll(async () => {
     jest.setTimeout(10000)
     app = new Application({
         path: electronPath,
         args: [path.join(__dirname, './app/main_oauth2.js')]
     })
     await app.start()
 }) 
Example #4
0
  const startApp = function () {
    app = new Application({
      path: path.join(__dirname, '..', 'node_modules', '.bin', 'electron'),
      args: [
        path.join(__dirname, '..')
      ],
      waitTimeout: 10000
    })

    return app.start().then(setupApp)
  }
Example #5
0
File: app.js Project: m0g/ansel
 stop(done) {
   if (this.app && this.app.isRunning()) {
     this.app.stop()
       .then(() => {
         return knex.destroy();
       })
       .then(() => {
         rimraf(testsPath, done);
       });
   }
 }
 beforeAll(async () => {
   await buildTestBundle();
   app = new Application({
     path: electronPath,
     args: ['--user-dir=__e2e__/tmp', 'dist'],
     env: {
       E2E_TEST: 1,
     },
   });
   return app.start();
 });
Example #7
0
  const startApp = function () {
    app = new Application({
      path: electron,
      args: [
        path.join(__dirname, '..')
      ],
      waitTimeout: timeout
    })

    return app.start().then(setupApp)
  }
Example #8
0
  const startApp = () => {
    app = new Application({
      path: electron,
      args: [
        path.join(__dirname, '..')
      ],
      waitTimeout: timeout
    })

    return app.start().then((ret) => {
      setup.setupApp(ret)
    })
  }
exports.startApplication = function(options) {
	options.path = exports.getElectronPath();
	if (process.env.CI) {
		options.startTimeout = 30000;
	}

	var app = new Application(options);
	return app.start().then(function() {
		assert.equal(app.isRunning(), true);
		chaiAsPromised.transferPromiseness = app.transferPromiseness;
		return app;
	});
};
 before(() => {
   app = new Application({
     path: appPath,
     env: {
       TEST_SPEC: true,
     },
     args: ['.'],
   });
   return app.start()
     .then(() => {
       chaiAsPromised.transferPromiseness = app.transferPromiseness;
       return app;
     });
 });
Example #11
0
describe('Edit > Copy', function () {
	const app = new Application({
		path: APP_PATH,
		env: {
			ELECTRON_ENABLE_LOGGING: true,
			ELECTRON_ENABLE_STACK_DUMPING: true,
			NEGATIVE_IGNORE_SETTINGS: false,
			NEGATIVE_SKIP_RESET_DIALOG: true,
			NEGATIVE_SETTINGS_PATH: '../test/fixtures/two-windows-with-data.json',
			NODE_ENV: 'development'
		}
	});
	
	this.timeout(60000);
	
	beforeEach(() => {
		return app.start();
	});

	afterEach(() => {
		if (app && app.isRunning()) {
			return app.stop();
		}
	});
	
	it('Should copy', () => {
		return app.client.waitUntilWindowLoaded()
			.then(() => app.electron.ipcRenderer.send('test-copy'))
			.then(() => app.electron.clipboard.readImage())
			.then((image) => {
				assert.isDefined(image);
				assert.isDefined(image.getSize);
			});
	});
});
Example #12
0
	it("should not open dev console when absent", function () {
		app.args = [appPath];

		return app.start().then(function() {
			return expect(app.browserWindow.isDevToolsOpened()).to.eventually.equal(false);
		});
	});
Example #13
0
describe('Negative > Quit', function () {
	const app = new Application({
		path: APP_PATH,
		env: {
			ELECTRON_ENABLE_LOGGING: true,
			ELECTRON_ENABLE_STACK_DUMPING: true,
			NEGATIVE_IGNORE_SETTINGS: true,
			NEGATIVE_SKIP_RESET_DIALOG: true,
			NODE_ENV: 'development'
		}
	});
	
	this.timeout(60000);
	
	beforeEach(() => {
		return app.start();
	});

	afterEach(() => {
		if (app && app.isRunning()) {
			return app.stop();
		}
	});
	
	it('Should quit', () => {
		// @TODO - This should test that settings are saved (or at least written)
		return app.client.waitUntilWindowLoaded()
			.then(() => {
				return app.stop().then(() => assert.isFalse(app.isRunning()))
			})
	});
});
Example #14
0
	it("should open dev console when provided", function () {
		app.args = [appPath, "dev"];

		return app.start().then(function() {
			return expect(app.browserWindow.isDevToolsOpened()).to.eventually.equal(true);
		});
	});
test.before(async t => {
  await app.start()
  await app.client.waitUntilWindowLoaded()

  // open the default start page
  await app.client.windowByIndex(1)
  await app.client.waitForExist('body > *')
})
Example #16
0
test.before(async t => {
  // open the window
  await app.start()

  // share the test runner dat
  testRunnerDat = await shareDat(__dirname + '/scaffold/test-runner-dat')
  testRunnerDatURL = 'dat://' + testRunnerDat.archive.key.toString('hex') + '/'

  // open the test-runner dat
  await browserDriver.navigateTo(app, testRunnerDatURL)
  await app.client.windowByIndex(1)
  await app.client.waitForExist('h1#loaded')
})
Example #17
0
test.before(async t => {
  // open the window
  await app.start()
  await app.client.waitUntilWindowLoaded(20e3)

  // share the test runner dat
  testRunnerDat = await shareDat(__dirname + '/scaffold/test-runner-dat')
  testRunnerDatURL = 'dat://' + testRunnerDat.archive.key.toString('hex') + '/'

  // open the default start page
  await app.client.windowByIndex(1)
  await app.client.waitForExist('body > *')
})
Example #18
0
describe('View > Zoom In', function () {
	const app = new Application({
		path: APP_PATH,
		env: {
			ELECTRON_ENABLE_LOGGING: true,
			ELECTRON_ENABLE_STACK_DUMPING: true,
			NEGATIVE_IGNORE_SETTINGS: false,
			NEGATIVE_SKIP_RESET_DIALOG: true,
			NEGATIVE_SETTINGS_PATH: '../test/fixtures/two-windows-with-data.json',
			NODE_ENV: 'development'
		}
	});
	
	this.timeout(60000);
	
	beforeEach(() => {
		return app.start();
	});

	afterEach(() => {
		if (app && app.isRunning()) {
			return app.stop();
		}
	});
	
	it('Should zoom in', () => {
		return app.client.waitUntilWindowLoaded()
			.then(() => app.electron.ipcRenderer.send('test-zoom-in'))
			.then(() => {
				return app.client.waitUntil(() => {
					return app.client.selectorExecute(IMAGE_ID, (element) => element[0].getAttribute('data-zoom-level'))
						.then((zoomLevel) => zoomLevel === '1.25');
				}, 2000);
			})
			.then(() => app.electron.ipcRenderer.send('test-zoom-in'))
			.then(() => app.electron.ipcRenderer.send('test-zoom-in'))
			.then(() => app.electron.ipcRenderer.send('test-zoom-in'))
			.then(() => app.electron.ipcRenderer.send('test-zoom-in'))
			.then(() => {
				return app.client.waitUntil(() => {
					return app.client.selectorExecute(IMAGE_ID, (element) => element[0].getAttribute('data-zoom-level'))
						.then((zoomLevel) => zoomLevel === '2');
				}, 2000);
			})
	});
});
Example #19
0
describe('View > Dark Mode', function () {
	const app = new Application({
		path: APP_PATH,
		env: {
			ELECTRON_ENABLE_LOGGING: true,
			ELECTRON_ENABLE_STACK_DUMPING: true,
			NEGATIVE_IGNORE_SETTINGS: true,
			NEGATIVE_SKIP_RESET_DIALOG: true,
			NODE_ENV: 'development'
		}
	});
	
	this.timeout(60000);
	
	beforeEach(() => {
		return app.start();
	});

	afterEach(() => {
		if (app && app.isRunning()) {
			return app.stop();
		}
	});
	
	it('Should toggle dark mode', () => {
		return app.client.waitUntilWindowLoaded()
			.then(() => {
				return app.client.selectorExecute('//body', (elements) => {
					return elements[0].classList.contains('light-mode');
				});
			})
			.then((hasNoTipsClass) => assert.isFalse(hasNoTipsClass, 'The body element should not have the .light-mode class when on startup.'))
			.then(() => app.electron.ipcRenderer.send('test-dark-mode'))
			.then(() => {
				return app.client.waitUntil(() => {
					return app.client.selectorExecute('//body', (elements) => {
						return elements[0].classList.contains('light-mode');
					});
				}, 2000);
			})
			.then((hasNoTipsClass) => assert.isTrue(hasNoTipsClass, 'The body element should have the .light-mode class Dark Mode is off.'))
			
	});
});
Example #20
0
describe('Window > Next Tab', function () {
	const app = new Application({
		path: APP_PATH,
		env: {
			ELECTRON_ENABLE_LOGGING: true,
			ELECTRON_ENABLE_STACK_DUMPING: true,
			NEGATIVE_IGNORE_SETTINGS: false,
			NEGATIVE_SKIP_RESET_DIALOG: true,
			NEGATIVE_SETTINGS_PATH: '../test/fixtures/window-with-two-tabs.json',
			NODE_ENV: 'development'
		}
	});
	
	this.timeout(60000);
	
	beforeEach(() => {
		return app.start();
	});

	afterEach(() => {
		if (app && app.isRunning()) {
			return app.stop();
		}
	});
	
	it('Should go to next tab', () => {
		return app.client.waitUntilWindowLoaded()
			.then(() => app.electron.ipcRenderer.send('test-next-tab'))
			.then(() => {
				return app.client.selectorExecute(TABS_ID, (element) => {
					return Array.from(element[0].children).findIndex((child) => child.classList.contains('selected'));
				});
			})
			.then((selectedIndex) => assert.equal(selectedIndex, 1))
			.then(() => app.electron.ipcRenderer.send('test-next-tab'))
			.then(() => {
				return app.client.selectorExecute(TABS_ID, (element) => {
					return Array.from(element[0].children).findIndex((child) => child.classList.contains('selected'));
				});
			})
			.then((selectedIndex) => assert.equal(selectedIndex, 0))
	});
});
Example #21
0
describe('Launch', function () {
	const app = new Application({
		path: APP_PATH,
		env: {
			ELECTRON_ENABLE_LOGGING: true,
			ELECTRON_ENABLE_STACK_DUMPING: true,
			NEGATIVE_IGNORE_SETTINGS: true,
			NEGATIVE_SKIP_RESET_DIALOG: true,
			NODE_ENV: 'development'
		}
	});
	
	this.timeout(60000);
	
	beforeEach(() => {
		return app.start();
	});

	afterEach(() => {
		if (app && app.isRunning()) {
			return app.stop();
		}
	});
	
	it('Shows a window', () => {
		return app.client.waitUntilWindowLoaded()
			.then(() => app.client.getWindowCount())
			.then((count) => assert.isAtLeast(count, 1))
			.then(() => {
				return app.client.selectorExecute('//body', (elements) => {
					return elements[0].classList;
				})
			})
			.then((classList) => {
				assert.isFalse(classList.includes('blur'));
				assert.isTrue(classList.includes('focus'));
				assert.isTrue(classList.includes('primary'));
			});
			
	});
});
Example #22
0
describe('File > New Tab', function () {
	const app = new Application({
		path: APP_PATH,
		env: {
			ELECTRON_ENABLE_LOGGING: true,
			ELECTRON_ENABLE_STACK_DUMPING: true,
			NEGATIVE_IGNORE_SETTINGS: true,
			NEGATIVE_SKIP_RESET_DIALOG: true,
			NODE_ENV: 'development'
		}
	});
	
	this.timeout(60000);
	
	beforeEach(() => {
		return app.start();
	});

	afterEach(() => {
		if (app && app.isRunning()) {
			return app.stop();
		}
	});
	
	it('Should add a tab', () => {
		return app.client.waitUntilWindowLoaded()
			.then(() => app.electron.ipcRenderer.send('test-new-tab'))
			.then(() => {
				return app.client.selectorExecute(TABS_ID, (element) => {
					const el = element[0];
					
					return el.children && el.children.length;
				});
			})
			.then((tabCount) => assert.equal(tabCount, 2));
	});
});
Example #23
0
describe('Edit > Paste', function () {
	const app = new Application({
		path: APP_PATH,
		env: {
			ELECTRON_ENABLE_LOGGING: true,
			ELECTRON_ENABLE_STACK_DUMPING: true,
			NEGATIVE_IGNORE_SETTINGS: true,
			NEGATIVE_SKIP_RESET_DIALOG: true,
			NODE_ENV: 'development'
		}
	});
	
	this.timeout(60000);
	
	beforeEach(() => {
		return app.start();
	});

	afterEach(() => {
		if (app && app.isRunning()) {
			return app.stop();
		}
	});
	
	it('Should paste', () => {
		return app.client.waitUntilWindowLoaded()
			.then(() => app.electron.clipboard.writeImage('./test/fixtures/image.png'))
			.then(() => app.electron.ipcRenderer.send('test-paste'))
			.then(() => {
				return app.client.waitUntil(() => {
					return app.client.selectorExecute(IMAGE_ID, (element) => element[0].getAttribute('src'))
						.then((src) => REGEX_PNG.test(src));
				}, 2000);
			});
	});
});
Example #24
0
			.then(() => {
				return app.stop().then(() => assert.isFalse(app.isRunning()))
			})
Example #25
0
	afterEach(() => {
		if (app && app.isRunning()) {
			return app.stop();
		}
	});
Example #26
0
	beforeEach(() => {
		return app.start();
	});
Example #27
0
}).then(function () {
  // Stop the application
  return app.stop()
}).catch(function (error) {
Example #28
0
// A simple test to verify a visible window is opened with a title
var Application = require('spectron').Application
var assert = require('assert')

var app = new Application({
  path: '/Applications/MyApp.app/Contents/MacOS/MyApp'
})

app.start().then(function () {
  // Check if the window is visible
  return app.browserWindow.isVisible()
}).then(function (isVisible) {
  // Verify the window is visible
  assert.equal(isVisible, true)
}).then(function () {
  // Get the window's title
  return app.client.getTitle()
}).then(function (title) {
  // Verify the window's title
  assert.equal(title, 'Doogie')
}).then(function () {
  // Stop the application
  return app.stop()
}).catch(function (error) {
  // Log any failures
  console.error('Test failed', error.message)
})
Example #29
0
test.after.always('cleanup', async t => {
  console.log(JSON.stringify(await app.client.getMainProcessLogs(), null, 2))
  await app.stop()
})
	afterEach(function (done) {
		app.stop().then(function() { done(); });
	});