Skip to content

Commit 7d553c7

Browse files
authored
Merge branch 'main' into task/RPE-102/delete_etc_n_pwr_cfg_code_enhance
2 parents 0532e08 + efcd133 commit 7d553c7

File tree

10 files changed

+348
-22
lines changed

10 files changed

+348
-22
lines changed

.github/workflows/rpe_test.yml

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -6,14 +6,15 @@ on:
66
- '*'
77
branches:
88
- '*'
9+
- '*/**'
910
pull_request:
1011

1112
concurrency:
1213
group: ${{ github.workflow }}-${{ github.ref }}
1314
cancel-in-progress: true
1415

1516
jobs:
16-
build:
17+
test:
1718
strategy:
1819
fail-fast: false
1920
matrix:
@@ -22,6 +23,7 @@ jobs:
2223
- ubuntu-22.04 # This is CentOS 7 under the hood
2324
- macos-12
2425
- windows-latest
26+
2527
runs-on: ${{ matrix.os }}
2628
env:
2729
MODE: ${{ matrix.os }}
@@ -70,16 +72,28 @@ jobs:
7072
node --version
7173
python3 -V
7274
73-
- name: Install packages ${{ matrix.os }}
75+
- name: Install Dep. packages Linux latest & windows & MacOS
7476
if: ${{ matrix.os != 'ubuntu-22.04' }}
7577
run: |
76-
npm install
77-
python3 -m pip install -r requirements.txt
78+
npm install
79+
python3 -m pip install -r requirements.txt
80+
npx playwright install --with-deps
81+
82+
- name: Unit Pytest Linux latest & windows & MacOS
83+
if: ${{ matrix.os != 'ubuntu-22.04' }}
84+
run: python3 -m pytest
85+
86+
- name: Unit Jtest Linux latest & windows & MacOS
87+
if: ${{ matrix.os != 'ubuntu-22.04' }}
88+
run: npm test
89+
90+
# - name: E2E Playwright tests on Linux latest & MacOS
91+
# if: ${{ matrix.os == 'ubuntu-latest' }}
92+
# run: npm run compile && xvfb-run --auto-servernum --server-args="-screen 0 1280x960x24" -- npx playwright test
7893

7994
- name: Run ESLint only on ubuntu-latest
8095
if: ${{ matrix.os == 'ubuntu-latest' }}
81-
run: |
82-
npx eslint src/
96+
run: npx eslint src/
8397

8498
- name: Install packages CentOS 7 & Run pytest & frontend test
8599
if: ${{ matrix.os == 'ubuntu-22.04' }}
@@ -95,24 +109,16 @@ jobs:
95109
python3 -m pytest
96110
npm test
97111
98-
- name: Run pytest on ${{ matrix.os }}
99-
if: ${{ matrix.os != 'ubuntu-22.04' }}
100-
run: python3 -m pytest
101-
102-
- name: Run frontend unit test on ${{ matrix.os }}
103-
if: ${{ matrix.os != 'ubuntu-22.04' }}
104-
run: |
105-
npm test
106-
107112
publish:
108-
needs: build
113+
needs: test
109114
strategy:
110115
fail-fast: false
111116
matrix:
112117
os:
113118
- ubuntu-22.04 # This is CentOS 7 under the hood
114119
- macos-12
115120
- windows-latest
121+
116122
runs-on: ${{ matrix.os }}
117123
permissions:
118124
contents: write

.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/

jest.config.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,15 @@ module.exports = {
77

88
collectCoverage: true,
99
collectCoverageFrom: [
10-
"src/**/*.{js,jsx}",
11-
"src/tests/**/*.{js,jsx}"
10+
"src/**/*.{js,jsx}",
11+
"!src/**/*.test.{js,jsx}",
12+
"!src/tests/**/*.{js,jsx}"
1213
],
13-
coverageReporters: ['text', 'lcov'],
14+
coverageReporters: ['text', 'lcov', 'json', 'html'],
1415
coverageDirectory: "coverage",
16+
17+
testPathIgnorePatterns: [
18+
"/node_modules/",
19+
"/e2e/"
20+
],
1521
};

package.json

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,11 @@
66
"main": "main.js",
77
"scripts": {
88
"start": "webpack --mode development && electron . --development",
9+
"compile": "webpack --mode development",
910
"build": "webpack --mode production && electron .",
10-
"test": "jest --coverage --coverageDirectory=coverage",
11+
"test": "jest --coverage --coverageDirectory=coverage",
12+
"test:jest": "jest --coverage --coverageDirectory=coverage",
13+
"test:playwright": "npx playwright test",
1114
"postinstall": "electron-builder install-app-deps",
1215
"pack": "electron-builder --dir",
1316
"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 +94,7 @@
9194
"@testing-library/user-event": "^14.5.2",
9295
"babel-jest": "^29.7.0",
9396
"babel-loader": "^9.1.3",
94-
"babel-plugin-istanbul": "^7.0.0",
97+
"babel-plugin-istanbul": "^7.0.0",
9598
"css-loader": "^6.10.0",
9699
"electron": "^28.2.2",
97100
"electron-builder": "^24.13.3",
@@ -102,9 +105,11 @@
102105
"identity-obj-proxy": "^3.0.0",
103106
"jest": "^29.7.0",
104107
"jest-environment-jsdom": "^29.7.0",
108+
"playwright": "^1.48.1",
105109
"react-test-renderer": "^18.3.1",
106110
"style-loader": "^3.3.4",
107111
"webpack": "^5.90.1",
112+
"@playwright/test": "^1.48.1",
108113
"webpack-cli": "^5.1.4"
109114
},
110115
"dependencies": {
@@ -126,4 +131,4 @@
126131
"type": "git",
127132
"url": "https://github.com/os-fpga/rapid_power_estimator.git"
128133
}
129-
}
134+
}

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: process.env.CI ? true : 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-apn68.ant-btn-primary.ant-btn-color-primary.ant-btn-variant-solid > span');
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-apn68.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+

0 commit comments

Comments
 (0)