Skip to content

Commit 47603ea

Browse files
committed
adding e2e folder under tests
1 parent 2ce7972 commit 47603ea

File tree

8 files changed

+314
-2
lines changed

8 files changed

+314
-2
lines changed

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,3 +56,7 @@ coverage/
5656
venv/
5757
ENV/
5858
env/
59+
/test-results/
60+
/playwright-report/
61+
/blob-report/
62+
/playwright/.cache/

package.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@
77
"scripts": {
88
"start": "webpack --mode development && electron . --development",
99
"build": "webpack --mode production && electron .",
10-
"test": "jest --coverage --coverageDirectory=coverage",
10+
"test": "jest --coverage --coverageDirectory=coverage",
11+
"test:jest": "jest --coverage --coverageDirectory=coverage",
12+
"test:playwright": "npx playwright test",
1113
"postinstall": "electron-builder install-app-deps",
1214
"pack": "electron-builder --dir",
1315
"dist": "pyinstaller --distpath backend --workpath dist -y --clean -n restapi_server.exe --onefile backend/restapi_server.py && webpack --mode production && electron-builder -p never"
@@ -91,7 +93,7 @@
9193
"@testing-library/user-event": "^14.5.2",
9294
"babel-jest": "^29.7.0",
9395
"babel-loader": "^9.1.3",
94-
"babel-plugin-istanbul": "^7.0.0",
96+
"babel-plugin-istanbul": "^7.0.0",
9597
"css-loader": "^6.10.0",
9698
"electron": "^28.2.2",
9799
"electron-builder": "^24.13.3",
@@ -102,12 +104,14 @@
102104
"identity-obj-proxy": "^3.0.0",
103105
"jest": "^29.7.0",
104106
"jest-environment-jsdom": "^29.7.0",
107+
"playwright": "^1.48.1",
105108
"react-test-renderer": "^18.3.1",
106109
"style-loader": "^3.3.4",
107110
"webpack": "^5.90.1",
108111
"webpack-cli": "^5.1.4"
109112
},
110113
"dependencies": {
114+
"@playwright/test": "^1.48.1",
111115
"antd": "^5.15.4",
112116
"electron-log": "^5.1.2",
113117
"electron-store": "^8.2.0",

playwright.config.js

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
const { defineConfig, devices } = require('@playwright/test');
2+
3+
module.exports = defineConfig({
4+
testDir: './tests/e2e',
5+
fullyParallel: true,
6+
forbidOnly: !!process.env.CI,
7+
retries: process.env.CI ? 2 : 0,
8+
workers: process.env.CI ? 1 : undefined,
9+
reporter: 'html',
10+
use: {
11+
baseURL: 'http://127.0.0.1:8081',
12+
trace: 'on-first-retry',
13+
},
14+
projects: [
15+
{
16+
name: 'chromium',
17+
use: { ...devices['Desktop Chrome'] },
18+
},
19+
{
20+
name: 'firefox',
21+
use: { ...devices['Desktop Firefox'] },
22+
},
23+
{
24+
name: 'webkit',
25+
use: { ...devices['Desktop Safari'] },
26+
},
27+
],
28+
webServer: {
29+
command: 'npm run playwright-server',
30+
url: 'http://127.0.0.1:8081',
31+
reuseExistingServer: !process.env.CI,
32+
},
33+
});
34+
35+
module.exports = {
36+
testDir: './tests/e2e',
37+
timeout: 60000,
38+
retries: 1,
39+
use: {
40+
headless: false,
41+
},
42+
};

tests/e2e/acpu.test.js

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
const { _electron: electron } = require('playwright');
2+
const { test, expect } = require('@playwright/test');
3+
4+
test('Launch Electron app, select device, toggle ACPU power, and click Add slowly', async () => {
5+
const app = await electron.launch({ args: ['main.js'] });
6+
7+
const window = await app.firstWindow();
8+
9+
// selecting the device (MPW1 Gemini)
10+
const deviceDropdown = await window.waitForSelector('#deviceId');
11+
await deviceDropdown.selectOption('MPW1');
12+
await new Promise((resolve) => setTimeout(resolve, 2000)); // wait 2 seconds (not really needed, just for demo)
13+
14+
// clicking on ACPU block
15+
const acpuBlock = await window.waitForSelector('#app > div > div.top-row-container > div.main-table-container.main-border > div.top-l2 > div.top-l2-col1 > div.top-l2-col1-row1 > div:nth-child(1) > div');
16+
await acpuBlock.click();
17+
await new Promise((resolve) => setTimeout(resolve, 2000));
18+
19+
// toggling ACPU power, basically turning on the power on
20+
const acpuPowerToggle = await window.waitForSelector('#app > div > div.table-container.main-border > div > div.toggle-container > label.toggle-switch > span');
21+
await acpuPowerToggle.click();
22+
await new Promise((resolve) => setTimeout(resolve, 2000));
23+
24+
// Click on Add button
25+
const addButton = await window.waitForSelector('#app > div > div.table-container.main-border > div > div.cpu-container > div.table-wrapper > button');
26+
await addButton.click();
27+
await new Promise((resolve) => setTimeout(resolve, 2000));
28+
29+
// Click OK in the popup
30+
const okButton = await window.waitForSelector('body > div:nth-child(3) > div > div.ant-modal-wrap > div > div:nth-child(1) > div > div.ant-modal-footer > button.ant-btn.css-dev-only-do-not-override-ni1kz0.ant-btn-primary.ant-btn-color-primary.ant-btn-variant-solid');
31+
await okButton.click();
32+
await new Promise((resolve) => setTimeout(resolve, 2000));
33+
34+
console.log('Test case executed successfully.');
35+
36+
await app.close();
37+
});

tests/e2e/bcpu.test.js

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
const { _electron: electron } = require('playwright');
2+
const { test, expect } = require('@playwright/test');
3+
4+
test('Launch Electron app, select device MPW1 Gemini, and click on BCPU block', async () => {
5+
const app = await electron.launch({ args: ['main.js'], headless: false });
6+
7+
const window = await app.firstWindow();
8+
9+
// selecting MPW1 Gemini from device dropdown
10+
const deviceDropdown = await window.waitForSelector('#deviceId');
11+
await deviceDropdown.selectOption('MPW1');
12+
await window.waitForTimeout(2000); // wait for UI update
13+
14+
// click on the BCPU block
15+
const bcpuSelector = '#app > div > div.top-row-container > div.main-table-container.main-border > div.top-l2 > div.top-l2-col1 > div.top-l2-col1-row1 > div:nth-child(2) > div';
16+
await window.waitForSelector(bcpuSelector);
17+
await window.click(bcpuSelector);
18+
19+
// click on "Add" button
20+
const addButtonSelector = '#app > div > div.table-container.main-border > div > div.cpu-container > div.table-wrapper > button';
21+
await window.waitForSelector(addButtonSelector, { state: 'visible' });
22+
await window.click(addButtonSelector);
23+
24+
// click on "OK" button
25+
const okButtonSelector = 'button.ant-btn-primary';
26+
await window.waitForSelector(okButtonSelector, { state: 'visible' });
27+
await window.click(okButtonSelector);
28+
29+
// click on Peripherals tab
30+
const peripheralsTabSelector = '#app > div > div.top-row-container > div.main-table-container.main-border > div.top-l2 > div.top-l2-col1 > div:nth-child(3) > div > div:nth-child(2) > div:nth-child(2) > div.periph-internal-font-header';
31+
await window.waitForSelector(peripheralsTabSelector, { state: 'visible' });
32+
await window.click(peripheralsTabSelector);
33+
34+
// check SPI/QSPI block
35+
const spiQspiCheckSelector = '#\\30';
36+
await window.waitForSelector(spiQspiCheckSelector, { state: 'visible' });
37+
await window.click(spiQspiCheckSelector);
38+
39+
// waiting to observe result on UI
40+
await window.waitForTimeout(5000);
41+
42+
// closing RPE
43+
await app.close();
44+
});

tests/e2e/clocking.test.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
const { _electron: electron } = require('playwright');
2+
const { test, expect } = require('@playwright/test');
3+
4+
test('Launch Electron app, select device, toggle ACPU power, click Clocking, Add clock source, and submit form', async () => {
5+
const app = await electron.launch({ args: ['main.js'] });
6+
const window = await app.firstWindow();
7+
8+
// Selecting the device (MPW1 Gemini)
9+
const deviceDropdown = await window.waitForSelector('#deviceId');
10+
await deviceDropdown.selectOption('MPW1');
11+
await new Promise((resolve) => setTimeout(resolve, 2000)); // Wait for 2 seconds
12+
13+
// Selecting Clocking block
14+
const clockingBlockSelector = '#app > div > div.top-row-container > div.main-table-container.main-border > div.top-l2 > div.top-l2-col2 > div.top-l2-col2-elem > div > div:nth-child(2) > div:nth-child(1) > div';
15+
const clockingBlock = await window.waitForSelector(clockingBlockSelector);
16+
await clockingBlock.click();
17+
await new Promise((resolve) => setTimeout(resolve, 2000)); // Wait for 2 seconds
18+
19+
// Clicking on Add button
20+
const addButtonSelector = '#app > div > div.table-container.main-border > div > div.power-and-table-wrapper > div.table-wrapper > button';
21+
const addButton = await window.waitForSelector(addButtonSelector);
22+
await addButton.click();
23+
await new Promise((resolve) => setTimeout(resolve, 2000)); // Wait for 2 seconds
24+
25+
// Ensure modal is visible before interacting
26+
const modalSelector = 'body > div:nth-child(3) > div > div.ant-modal-wrap > div';
27+
await window.waitForSelector(modalSelector, { state: 'visible', timeout: 5000 }); // Wait for modal
28+
29+
// Typing description as 'test'
30+
const descriptionSelector = 'body > div:nth-child(3) > div > div.ant-modal-wrap > div > div:nth-child(1) > div > div.ant-modal-body > div > form > div:nth-child(2) > input[type=text]';
31+
const descriptionInput = await window.waitForSelector(descriptionSelector);
32+
await descriptionInput.click();
33+
await descriptionInput.fill('test');
34+
await new Promise((resolve) => setTimeout(resolve, 1000)); // Wait for 1 second
35+
36+
// Typing Port/Signal name as 'test'
37+
const portSignalSelector = 'body > div:nth-child(3) > div > div.ant-modal-wrap > div > div:nth-child(1) > div > div.ant-modal-body > div > form > div:nth-child(3) > input[type=text]';
38+
const portSignalInput = await window.waitForSelector(portSignalSelector);
39+
await portSignalInput.click();
40+
await portSignalInput.fill('test');
41+
await new Promise((resolve) => setTimeout(resolve, 1000)); // Wait for 1 second
42+
43+
// Clicking OK to submit the form
44+
const okButtonSelector = 'body > div:nth-child(3) > div > div.ant-modal-wrap > div > div:nth-child(1) > div > div.ant-modal-footer > button.ant-btn.css-dev-only-do-not-override-ni1kz0.ant-btn-primary.ant-btn-color-primary.ant-btn-variant-solid';
45+
const okButton = await window.waitForSelector(okButtonSelector);
46+
await okButton.click();
47+
48+
// Closing the test
49+
await app.close();
50+
});
51+

tests/e2e/dsp.test.js

Lines changed: 105 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
const { _electron: electron } = require('playwright');
2+
const { test, expect } = require('@playwright/test');
3+
4+
test('Launch Electron app, add clocking source, navigate to DSP block, configure DSP, and submit form', async () => {
5+
const app = await electron.launch({ args: ['main.js'] });
6+
const window = await app.firstWindow();
7+
8+
// Selecting the device (MPW1 Gemini)
9+
const deviceDropdown = await window.waitForSelector('#deviceId');
10+
await deviceDropdown.selectOption('MPW1');
11+
await new Promise((resolve) => setTimeout(resolve, 2000)); // Wait for 2 seconds
12+
13+
// Selecting Clocking block
14+
const clockingBlockSelector = '#app > div > div.top-row-container > div.main-table-container.main-border > div.top-l2 > div.top-l2-col2 > div.top-l2-col2-elem > div > div:nth-child(2) > div:nth-child(1) > div';
15+
const clockingBlock = await window.waitForSelector(clockingBlockSelector);
16+
await clockingBlock.click();
17+
await new Promise((resolve) => setTimeout(resolve, 2000)); // Wait for 2 seconds
18+
19+
// Clicking on Add button for Clocking
20+
const addButtonSelector = '#app > div > div.table-container.main-border > div > div.power-and-table-wrapper > div.table-wrapper > button';
21+
const addButton = await window.waitForSelector(addButtonSelector);
22+
await addButton.click();
23+
await new Promise((resolve) => setTimeout(resolve, 2000)); // Wait for 2 seconds
24+
25+
// Ensure modal is visible before interacting
26+
const modalSelector = 'body > div:nth-child(3) > div > div.ant-modal-wrap > div';
27+
await window.waitForSelector(modalSelector, { state: 'visible', timeout: 5000 }); // Wait for modal
28+
29+
// Typing description as 'test'
30+
const descriptionSelector = 'body > div:nth-child(3) > div > div.ant-modal-wrap > div > div:nth-child(1) > div > div.ant-modal-body > div > form > div:nth-child(2) > input[type=text]';
31+
const descriptionInput = await window.waitForSelector(descriptionSelector);
32+
await descriptionInput.click();
33+
await descriptionInput.fill('test');
34+
await new Promise((resolve) => setTimeout(resolve, 1000)); // Wait for 1 second
35+
36+
// Typing Port/Signal name as 'test'
37+
const portSignalSelector = 'body > div:nth-child(3) > div > div.ant-modal-wrap > div > div:nth-child(1) > div > div.ant-modal-body > div > form > div:nth-child(3) > input[type=text]';
38+
const portSignalInput = await window.waitForSelector(portSignalSelector);
39+
await portSignalInput.click();
40+
await portSignalInput.fill('test');
41+
await new Promise((resolve) => setTimeout(resolve, 1000)); // Wait for 1 second
42+
43+
// Clicking OK to submit the clocking form
44+
const okButtonSelector = 'body > div:nth-child(3) > div > div.ant-modal-wrap > div > div:nth-child(1) > div > div.ant-modal-footer > button.ant-btn.css-dev-only-do-not-override-ni1kz0.ant-btn-primary.ant-btn-color-primary.ant-btn-variant-solid';
45+
const okButton = await window.waitForSelector(okButtonSelector);
46+
await okButton.click();
47+
await new Promise((resolve) => setTimeout(resolve, 2000)); // Wait for the form to submit
48+
49+
// Navigate to the DSP block
50+
const dspBlockSelector = '#app > div > div.top-row-container > div.main-table-container.main-border > div.top-l2 > div.top-l2-col2 > div.top-l2-col2-elem > div > div:nth-child(3) > div:nth-child(2) > div';
51+
const dspBlock = await window.waitForSelector(dspBlockSelector);
52+
await dspBlock.click();
53+
await new Promise((resolve) => setTimeout(resolve, 2000)); // Wait for 2 seconds
54+
55+
// Clicking on Add button for DSP
56+
const addDSPButton = await window.waitForSelector(addButtonSelector); // Reusing the same addButtonSelector
57+
await addDSPButton.click();
58+
await new Promise((resolve) => setTimeout(resolve, 2000)); // Wait for 2 seconds
59+
60+
// Typing Name/Hierarchy as 'test'
61+
const nameHierarchySelector = 'body > div:nth-child(3) > div > div.ant-modal-wrap > div > div:nth-child(1) > div > div.ant-modal-body > div > form > div:nth-child(1) > input[type=text]';
62+
const nameHierarchyInput = await window.waitForSelector(nameHierarchySelector);
63+
await nameHierarchyInput.click();
64+
await nameHierarchyInput.fill('test');
65+
await new Promise((resolve) => setTimeout(resolve, 1000)); // Wait for 1 second
66+
67+
// Typing XX as 32
68+
const xxSelector = 'body > div:nth-child(3) > div > div.ant-modal-wrap > div > div:nth-child(1) > div > div.ant-modal-body > div > form > div:nth-child(2) > input[type=number]';
69+
const xxInput = await window.waitForSelector(xxSelector);
70+
await xxInput.click();
71+
await xxInput.fill('32');
72+
await new Promise((resolve) => setTimeout(resolve, 1000)); // Wait for 1 second
73+
74+
// Typing A-input width as 64
75+
const aInputWidthSelector = 'body > div:nth-child(3) > div > div.ant-modal-wrap > div > div:nth-child(1) > div > div.ant-modal-body > div > form > div:nth-child(4) > input[type=number]';
76+
const aInputWidthInput = await window.waitForSelector(aInputWidthSelector);
77+
await aInputWidthInput.click();
78+
await aInputWidthInput.fill('64');
79+
await new Promise((resolve) => setTimeout(resolve, 1000)); // Wait for 1 second
80+
81+
// Typing B-input width as 64
82+
const bInputWidthSelector = 'body > div:nth-child(3) > div > div.ant-modal-wrap > div > div:nth-child(1) > div > div.ant-modal-body > div > form > div:nth-child(5) > input[type=number]';
83+
const bInputWidthInput = await window.waitForSelector(bInputWidthSelector);
84+
await bInputWidthInput.click();
85+
await bInputWidthInput.fill('64');
86+
await new Promise((resolve) => setTimeout(resolve, 1000)); // Wait for 1 second
87+
88+
// Typing toggle rate as 50
89+
const toggleRateSelector = 'body > div:nth-child(3) > div > div.ant-modal-wrap > div > div:nth-child(1) > div > div.ant-modal-body > div > form > div:nth-child(8) > input[type=number]';
90+
const toggleRateInput = await window.waitForSelector(toggleRateSelector);
91+
await toggleRateInput.click();
92+
await toggleRateInput.fill('50');
93+
await new Promise((resolve) => setTimeout(resolve, 1000)); // Wait for 1 second
94+
95+
// Take note of the DSP power generated (assuming it's shown in the UI somewhere, you can add the selector for DSP power if needed)
96+
97+
// Clicking OK to submit the DSP form
98+
const dspOkButtonSelector = 'body > div:nth-child(3) > div > div.ant-modal-wrap > div > div:nth-child(1) > div > div.ant-modal-footer > button.ant-btn.css-dev-only-do-not-override-ni1kz0.ant-btn-primary.ant-btn-color-primary.ant-btn-variant-solid';
99+
const dspOkButton = await window.waitForSelector(dspOkButtonSelector);
100+
await dspOkButton.click();
101+
await new Promise((resolve) => setTimeout(resolve, 2000)); // Wait for the form to submit
102+
103+
// Closing the test
104+
await app.close();
105+
});

tests/e2e/fle.test.js

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
const { _electron: electron } = require('playwright');
2+
const { test, expect } = require('@playwright/test');
3+
4+
test('Launch Electron app and click on FLE block', async () => {
5+
const app = await electron.launch({ args: ['main.js'] });
6+
7+
const window = await app.firstWindow();
8+
9+
// selecting the device (MPW1 Gemini)
10+
const deviceDropdown = await window.waitForSelector('#deviceId');
11+
await deviceDropdown.selectOption('MPW1');
12+
await new Promise((resolve) => setTimeout(resolve, 2000));
13+
14+
const fleBlock = await window.waitForSelector('#app > div > div.top-row-container > div.main-table-container.main-border > div.top-l2 > div.top-l2-col2 > div.top-l2-col2-elem > div > div:nth-child(2) > div:nth-child(2) > div');
15+
await fleBlock.click();
16+
17+
const flePowerVisible = await window.isVisible('div.title-comp-total-text');
18+
expect(flePowerVisible).toBeTruthy();
19+
20+
console.log('FLE block clicked and verified.');
21+
22+
await new Promise((resolve) => setTimeout(resolve, 5000));
23+
24+
await app.close();
25+
});

0 commit comments

Comments
 (0)