Skip to content

Commit

Permalink
Tests for the Chrome app
Browse files Browse the repository at this point in the history
  • Loading branch information
zalmoxisus committed Oct 17, 2015
1 parent a6f1914 commit 7b0d1c4
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
46 changes: 46 additions & 0 deletions test/chromeApp/window.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
import webdriver from 'selenium-webdriver';
import expect from 'expect';
import { check, doBefore, doAfter } from '../shared/functions';
import * as Test from '../shared/tests';
import { appName, appTitle } from '../config';

let appHandle;

describe('Chrome app window', function() {

before(function(done) {
doBefore.call(this, done, () => {
return this.driver.get('chrome://extensions-frame').then(() => {
this.driver.findElement(webdriver.By.className('launch-link')).click();
return this.driver.wait(() =>
this.driver.getAllWindowHandles()
.then(windows => {
if (windows.length === 2) {
appHandle = windows[1];
return true;
}
return false;
})
, 15000, 'Chrome app not launched');
});
}, './build/app');
});

after(doAfter);

it('should switch to app\'s handle', function(done) {
expect(appHandle).toExist();

this.driver.switchTo().window(appHandle).then(() => {
this.driver.getWindowHandle().then(
(handle) => {
expect(handle).toEqual(appHandle);
done();
});
});
});

Test.hasTitle(appTitle);
Test.hasValue(0);

});
1 change: 1 addition & 0 deletions test/config.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
export const injectClassName = 'browser-redux';
export const extensionName = 'browser-extension';
export const appName = 'browser-app';
export const appTitle = 'Redux Counter Example';
2 changes: 1 addition & 1 deletion test/shared/functions.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ export function doBefore(done, action, load = './build/extension', port = 9515,
})
.forBrowser(browser)
.build();
action().then(done);
action().then(() => done());
}

export function doAfter(done, timeout = 20000) {
Expand Down

0 comments on commit 7b0d1c4

Please sign in to comment.