Skip to content

Commit 262aa6a

Browse files
committed
frontend: Add playwright app test
Add working scripts Signed-off-by: Vincent T <[email protected]>
1 parent 9173319 commit 262aa6a

9 files changed

+395
-488
lines changed

app/e2e-tests/README.md

+69
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
# e2e test for local playwright app mode
2+
3+
Currently we have the original e2e tests for the web mode in the `e2e-tests` directory. We are adding new tests for the app mode in the `app-e2e-tests` directory for local testing. Unlike the other tests, these tests do not require a token to run so the setup is as followed:
4+
5+
## Running app mode tests
6+
7+
## Setup
8+
9+
- Before running the tests, be sure to have an instance of Minikube running with the name `minikube`
10+
11+
### Running the tests
12+
13+
To run the tests for the app mode, follow the steps below:
14+
15+
- cd into the e2e-tests directory within the headlamp repository
16+
`cd headlamp/app/e2e-tests`
17+
18+
- npm install the needed packages
19+
`npm install`
20+
21+
- run the following command
22+
`npm run test-app`
23+
(optional: include `-- --headed` to run the tests in headed mode)
24+
(optional: include `-- --ui` to run the tests in ui mode)
25+
26+
## Running web mode tests
27+
28+
Running the tests for the web mode requires the backend and frontend to be running. Follow the steps below to run the tests for the web mode:
29+
30+
Note: You may encouter issues switching from the app mode tests to the web mode tests. If you do, search for any running headlamp server processes and end them before running the web mode tests or app mode tests.
31+
32+
## Setup
33+
34+
- Before running the tests, be sure to have an instance of Minikube running with the name `minikube`
35+
36+
### Backend
37+
38+
To run the tests for the web mode, you will need to have the backend running. Follow the steps below to run the backend:
39+
40+
- cd into the headlamp directory in a singular terminal
41+
`cd headlamp`
42+
43+
- run the following command
44+
`make backend` followed by `make run-backend`
45+
46+
### Frontend
47+
48+
To run the tests for the web mode, you will need to have the frontend running. Follow the steps below to run the frontend:
49+
50+
- cd into the headlamp directory in a separate terminal
51+
`cd headlamp/frontend`
52+
53+
- run the following command
54+
`make frontend` followed by `make run-frontend`
55+
56+
### Running the tests
57+
58+
To run the tests for the web mode, follow the steps below:
59+
60+
- cd into the e2e-tests directory within the headlamp repository in a separate terminal
61+
`cd headlamp/app/e2e-tests`
62+
63+
- npm install the needed packages
64+
`npm install`
65+
66+
- run the following command
67+
`npm run test-web`
68+
(optional: include `-- --headed` to run the tests in headed mode)
69+
(optional: include `-- --ui` to run the tests in ui mode)

app/e2e-tests/package.json

+4-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,10 @@
22
"name": "e2e-tests",
33
"version": "1.0.0",
44
"main": "index.js",
5-
"scripts": {},
5+
"scripts": {
6+
"test-app": "PLAYWRIGHT_TEST_MODE=app playwright test",
7+
"test-web": "PLAYWRIGHT_TEST_MODE=web playwright test"
8+
},
69
"keywords": [],
710
"author": "",
811
"license": "ISC",

app/e2e-tests/playwright.config.ts

+10-32
Original file line numberDiff line numberDiff line change
@@ -14,13 +14,21 @@ import { defineConfig, devices } from '@playwright/test';
1414
export default defineConfig({
1515
testDir: './tests',
1616
/* Run tests in files in parallel */
17-
fullyParallel: true,
17+
timeout: 60 * 1000,
18+
expect: {
19+
/**
20+
* Maximum time expect() should wait for the condition to be met.
21+
* For example in `await expect(locator).toHaveText();`
22+
*/
23+
timeout: 120000,
24+
},
25+
fullyParallel: false,
1826
/* Fail the build on CI if you accidentally left test.only in the source code. */
1927
forbidOnly: !!process.env.CI,
2028
/* Retry on CI only */
2129
retries: process.env.CI ? 2 : 0,
2230
/* Opt out of parallel tests on CI. */
23-
workers: process.env.CI ? 1 : undefined,
31+
workers: 1,
2432
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
2533
reporter: 'html',
2634
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
@@ -38,36 +46,6 @@ export default defineConfig({
3846
name: 'chromium',
3947
use: { ...devices['Desktop Chrome'] },
4048
},
41-
42-
{
43-
name: 'firefox',
44-
use: { ...devices['Desktop Firefox'] },
45-
},
46-
47-
{
48-
name: 'webkit',
49-
use: { ...devices['Desktop Safari'] },
50-
},
51-
52-
/* Test against mobile viewports. */
53-
// {
54-
// name: 'Mobile Chrome',
55-
// use: { ...devices['Pixel 5'] },
56-
// },
57-
// {
58-
// name: 'Mobile Safari',
59-
// use: { ...devices['iPhone 12'] },
60-
// },
61-
62-
/* Test against branded browsers. */
63-
// {
64-
// name: 'Microsoft Edge',
65-
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
66-
// },
67-
// {
68-
// name: 'Google Chrome',
69-
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
70-
// },
7149
],
7250

7351
/* Run your local dev server before starting the tests */

0 commit comments

Comments
 (0)