-
Notifications
You must be signed in to change notification settings - Fork 176
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2344 from headlamp-k8s/playwright-test-modes
Initial Playwright E2E Test for App Mode in Electron
- Loading branch information
Showing
9 changed files
with
557 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
node_modules/ | ||
/test-results/ | ||
/playwright-report/ | ||
/blob-report/ | ||
/playwright/.cache/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
{ | ||
"name": "e2e-tests", | ||
"version": "1.0.0", | ||
"main": "index.js", | ||
"scripts": { | ||
"test-app": "PLAYWRIGHT_TEST_MODE=app playwright test", | ||
"test-web": "PLAYWRIGHT_TEST_MODE=web playwright test" | ||
}, | ||
"keywords": [], | ||
"author": "", | ||
"license": "ISC", | ||
"description": "", | ||
"devDependencies": { | ||
"@playwright/test": "^1.48.1", | ||
"@types/node": "^22.7.5" | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { defineConfig, devices } from '@playwright/test'; | ||
|
||
/** | ||
* Read environment variables from file. | ||
* https://github.com/motdotla/dotenv | ||
*/ | ||
// import dotenv from 'dotenv'; | ||
// import path from 'path'; | ||
// dotenv.config({ path: path.resolve(__dirname, '.env') }); | ||
|
||
/** | ||
* See https://playwright.dev/docs/test-configuration. | ||
*/ | ||
export default defineConfig({ | ||
testDir: './tests', | ||
/* Run tests in files in parallel */ | ||
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: 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. */ | ||
use: { | ||
/* Base URL to use in actions like `await page.goto('/')`. */ | ||
// baseURL: 'http://127.0.0.1:3000', | ||
|
||
/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */ | ||
trace: 'on-first-retry', | ||
}, | ||
|
||
/* Configure projects for major browsers */ | ||
projects: [ | ||
{ | ||
name: 'chromium', | ||
use: { ...devices['Desktop Chrome'] }, | ||
}, | ||
], | ||
|
||
/* Run your local dev server before starting the tests */ | ||
// webServer: { | ||
// command: 'npm run start', | ||
// url: 'http://127.0.0.1:3000', | ||
// reuseExistingServer: !process.env.CI, | ||
// }, | ||
}); |
Oops, something went wrong.