Skip to content

Commit

Permalink
frontend: Add playwright app test
Browse files Browse the repository at this point in the history
Add working scripts

Signed-off-by: Vincent T <[email protected]>
  • Loading branch information
vyncent-t committed Nov 27, 2024
1 parent 9173319 commit 262aa6a
Show file tree
Hide file tree
Showing 9 changed files with 395 additions and 488 deletions.
69 changes: 69 additions & 0 deletions app/e2e-tests/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
# e2e test for local playwright app mode

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:

## Running app mode tests

## Setup

- Before running the tests, be sure to have an instance of Minikube running with the name `minikube`

### Running the tests

To run the tests for the app mode, follow the steps below:

- cd into the e2e-tests directory within the headlamp repository
`cd headlamp/app/e2e-tests`

- npm install the needed packages
`npm install`

- run the following command
`npm run test-app`
(optional: include `-- --headed` to run the tests in headed mode)
(optional: include `-- --ui` to run the tests in ui mode)

## Running web mode tests

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:

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.

## Setup

- Before running the tests, be sure to have an instance of Minikube running with the name `minikube`

### Backend

To run the tests for the web mode, you will need to have the backend running. Follow the steps below to run the backend:

- cd into the headlamp directory in a singular terminal
`cd headlamp`

- run the following command
`make backend` followed by `make run-backend`

### Frontend

To run the tests for the web mode, you will need to have the frontend running. Follow the steps below to run the frontend:

- cd into the headlamp directory in a separate terminal
`cd headlamp/frontend`

- run the following command
`make frontend` followed by `make run-frontend`

### Running the tests

To run the tests for the web mode, follow the steps below:

- cd into the e2e-tests directory within the headlamp repository in a separate terminal
`cd headlamp/app/e2e-tests`

- npm install the needed packages
`npm install`

- run the following command
`npm run test-web`
(optional: include `-- --headed` to run the tests in headed mode)
(optional: include `-- --ui` to run the tests in ui mode)
5 changes: 4 additions & 1 deletion app/e2e-tests/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,10 @@
"name": "e2e-tests",
"version": "1.0.0",
"main": "index.js",
"scripts": {},
"scripts": {
"test-app": "PLAYWRIGHT_TEST_MODE=app playwright test",
"test-web": "PLAYWRIGHT_TEST_MODE=web playwright test"
},
"keywords": [],
"author": "",
"license": "ISC",
Expand Down
42 changes: 10 additions & 32 deletions app/e2e-tests/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,13 +14,21 @@ import { defineConfig, devices } from '@playwright/test';
export default defineConfig({
testDir: './tests',
/* Run tests in files in parallel */
fullyParallel: true,
timeout: 60 * 1000,
expect: {
/**
* Maximum time expect() should wait for the condition to be met.
* For example in `await expect(locator).toHaveText();`
*/
timeout: 120000,
},
fullyParallel: false,
/* Fail the build on CI if you accidentally left test.only in the source code. */
forbidOnly: !!process.env.CI,
/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 1 : undefined,
workers: 1,
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
reporter: 'html',
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
Expand All @@ -38,36 +46,6 @@ export default defineConfig({
name: 'chromium',
use: { ...devices['Desktop Chrome'] },
},

{
name: 'firefox',
use: { ...devices['Desktop Firefox'] },
},

{
name: 'webkit',
use: { ...devices['Desktop Safari'] },
},

/* Test against mobile viewports. */
// {
// name: 'Mobile Chrome',
// use: { ...devices['Pixel 5'] },
// },
// {
// name: 'Mobile Safari',
// use: { ...devices['iPhone 12'] },
// },

/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
// name: 'Google Chrome',
// use: { ...devices['Desktop Chrome'], channel: 'chrome' },
// },
],

/* Run your local dev server before starting the tests */
Expand Down
Loading

0 comments on commit 262aa6a

Please sign in to comment.