forked from finos/SymphonyElectron
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathbringToFront.spectron.js
55 lines (50 loc) · 2.04 KB
/
bringToFront.spectron.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
const Application = require('./spectronSetup');
const specconst = require('./spectronConstants.js');
const WindowsAction = require('./spectronWindowsActions');
let windowAction;
let app = new Application({});
describe('Tests for Bring to front', () => {
let originalTimeout = jasmine.DEFAULT_TIMEOUT_INTERVAL;
jasmine.DEFAULT_TIMEOUT_INTERVAL = Application.getTimeOut();
beforeAll(async (done) => {
try {
app = await new Application({}).startApplication({ testedHost: specconst.TESTED_HOST, alwaysOnTop: true });
windowAction = await new WindowsAction(app);
done();
} catch (err) {
done.fail(new Error(`Unable to start application error: ${err}`));
};
});
afterAll(async (done) => {
try {
if (app && app.isRunning()) {
jasmine.DEFAULT_TIMEOUT_INTERVAL = await originalTimeout;
await app.stop();
await webdriver.quit();
done();
}
} catch (err) {
done.fail(new Error(`Failed at post-condition: ${err}`));
};
});
it('should show the browser window and verify window focus', async (done) => {
await windowAction.blurBrowserWindow()
await app.browserWindow.minimize();
let isMinimized = await app.browserWindow.isMinimized();
await expect(isMinimized).toBe(true);
await app.browserWindow.showInactive();
let isFocused = await app.browserWindow.isFocused();
await expect(isFocused).toBe(false);
done();
});
it('should restore the browser window and verify window focus', async (done) => {
await windowAction.blurBrowserWindow()
await app.browserWindow.minimize();
let isMinimized = await app.browserWindow.isMinimized();
await expect(isMinimized).toBe(true);
await app.browserWindow.restore();
let isFocused = await app.browserWindow.isFocused();
await expect(isFocused).toBe(true);
done();
});
});