forked from webdriverio-community/wdio-electron-service
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinteraction.spec.ts
75 lines (70 loc) · 2.8 KB
/
interaction.spec.ts
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
import { expect } from '@wdio/globals';
import { browser } from 'wdio-electron-service';
import { setupBrowser, type WebdriverIOQueries } from '@testing-library/webdriverio';
import type { BrowserWindow } from 'electron';
describe('interaction', () => {
let screen: WebdriverIOQueries;
before(() => {
screen = setupBrowser(browser);
});
describe('keyboard input', () => {
it('should detect keyboard input', async () => {
await browser.keys(['y', 'o']);
expect(await (await screen.getByTestId('keypress-count')).getText()).toEqual('YO');
});
});
describe('click events', () => {
describe('when the make larger button is clicked', () => {
it('should increase the window height and width by 10 pixels', async () => {
let bounds = (await browser.electron.execute((electron) => {
const browserWindow = electron.BrowserWindow.getAllWindows()[0] as BrowserWindow;
return browserWindow.getBounds();
})) as {
width: number;
height: number;
};
expect(bounds.width).toEqual(200);
expect(bounds.height).toEqual(300);
let biggerClickCount = await (await browser.$('.click-count .bigger')).getText();
expect(biggerClickCount).toEqual('0');
const elem = await browser.$('.make-bigger');
await elem.click();
biggerClickCount = await (await browser.$('.click-count .bigger')).getText();
expect(biggerClickCount).toEqual('1');
bounds = (await browser.electron.execute((electron) => {
const browserWindow = electron.BrowserWindow.getAllWindows()[0] as BrowserWindow;
return browserWindow.getBounds();
})) as {
width: number;
height: number;
};
expect(bounds.width).toEqual(210);
expect(bounds.height).toEqual(310);
});
});
describe('when the make smaller button is clicked', () => {
it('should decrease the window height and width by 10 pixels', async () => {
let bounds = (await browser.electron.execute((electron) => {
const browserWindow = electron.BrowserWindow.getAllWindows()[0] as BrowserWindow;
return browserWindow.getBounds();
})) as {
width: number;
height: number;
};
expect(bounds.width).toEqual(210);
expect(bounds.height).toEqual(310);
const elem = await browser.$('.make-smaller');
await elem.click();
bounds = (await browser.electron.execute((electron) => {
const browserWindow = electron.BrowserWindow.getAllWindows()[0] as BrowserWindow;
return browserWindow.getBounds();
})) as {
width: number;
height: number;
};
expect(bounds.width).toEqual(200);
expect(bounds.height).toEqual(300);
});
});
});
});