Skip to content

Commit 7664d65

Browse files
authored
Setting up e2e under test GitHub ci setup (#253)
1 parent d6924ad commit 7664d65

File tree

6 files changed

+31
-23
lines changed

6 files changed

+31
-23
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

package.json

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
"main": "main.js",
77
"scripts": {
88
"start": "webpack --mode development && electron . --development",
9+
"compile": "webpack --mode development",
910
"build": "webpack --mode production && electron .",
1011
"test": "jest --coverage --coverageDirectory=coverage",
1112
"test:jest": "jest --coverage --coverageDirectory=coverage",
@@ -108,10 +109,10 @@
108109
"react-test-renderer": "^18.3.1",
109110
"style-loader": "^3.3.4",
110111
"webpack": "^5.90.1",
112+
"@playwright/test": "^1.48.1",
111113
"webpack-cli": "^5.1.4"
112114
},
113115
"dependencies": {
114-
"@playwright/test": "^1.48.1",
115116
"antd": "^5.15.4",
116117
"electron-log": "^5.1.2",
117118
"electron-store": "^8.2.0",
@@ -130,4 +131,4 @@
130131
"type": "git",
131132
"url": "https://github.com/os-fpga/rapid_power_estimator.git"
132133
}
133-
}
134+
}

playwright.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,6 @@ module.exports = {
3737
timeout: 60000,
3838
retries: 1,
3939
use: {
40-
headless: false,
40+
headless: process.env.CI ? true : false,
4141
},
4242
};

tests/e2e/acpu.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ test('Launch Electron app, select device, toggle ACPU power, and click Add slowl
2727
await new Promise((resolve) => setTimeout(resolve, 2000));
2828

2929
// 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');
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');
3131
await okButton.click();
3232
await new Promise((resolve) => setTimeout(resolve, 2000));
3333

tests/e2e/clocking.test.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ test('Launch Electron app, select device, toggle ACPU power, click Clocking, Add
4141
await new Promise((resolve) => setTimeout(resolve, 1000)); // Wait for 1 second
4242

4343
// 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';
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';
4545
const okButton = await window.waitForSelector(okButtonSelector);
4646
await okButton.click();
4747

tests/e2e/dsp.test.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -41,11 +41,12 @@ test('Launch Electron app, add clocking source, navigate to DSP block, configure
4141
await new Promise((resolve) => setTimeout(resolve, 1000)); // Wait for 1 second
4242

4343
// 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';
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';
4545
const okButton = await window.waitForSelector(okButtonSelector);
4646
await okButton.click();
4747
await new Promise((resolve) => setTimeout(resolve, 2000)); // Wait for the form to submit
4848

49+
4950
// Navigate to the DSP block
5051
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';
5152
const dspBlock = await window.waitForSelector(dspBlockSelector);
@@ -95,7 +96,7 @@ test('Launch Electron app, add clocking source, navigate to DSP block, configure
9596
// 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)
9697

9798
// 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 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-apn68.ant-btn-primary.ant-btn-color-primary.ant-btn-variant-solid';
99100
const dspOkButton = await window.waitForSelector(dspOkButtonSelector);
100101
await dspOkButton.click();
101102
await new Promise((resolve) => setTimeout(resolve, 2000)); // Wait for the form to submit

0 commit comments

Comments
 (0)