Skip to content

Commit

Permalink
test: playwright config and browser usability (#9024)
Browse files Browse the repository at this point in the history
* config tweaks for testing

* lint
  • Loading branch information
djanicekpach authored Mar 21, 2024
1 parent f6b9ac8 commit e4bc377
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 18 deletions.
18 changes: 4 additions & 14 deletions webui/react/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export default defineConfig({
forbidOnly: !!process.env.CI,

/* Run tests in files in parallel */
fullyParallel: true,
fullyParallel: !!process.env.CI,

/* https://playwright.dev/docs/test-timeouts#global-timeout */
globalTimeout: 3 * 60 * 1000, // 3 min
Expand All @@ -28,15 +28,6 @@ export default defineConfig({
name: 'chromium',
use: { ...devices['Desktop Chrome'], channel: 'chrome' }
},

{
name: 'chromium-no-cors',
use: { ...devices['Desktop Chrome'], channel: 'chrome',
bypassCSP: true,
launchOptions: {
args: ['--disable-web-security']
}},
},

{
name: 'firefox',
Expand All @@ -60,7 +51,7 @@ export default defineConfig({

/* Test against branded browsers. */
// {
// name: 'Microsoft Edge',
// name: 'edge',
// use: { ...devices['Desktop Edge'], channel: 'msedge' },
// },
// {
Expand All @@ -77,7 +68,7 @@ export default defineConfig({
],

/* Retry on CI only */
retries: process.env.CI ? 2 : 0,
retries: process.env.CI ? 1 : 0,

testDir: './src/e2e',

Expand All @@ -98,6 +89,5 @@ export default defineConfig({
reuseExistingServer: !process.env.CI,
},

/* Opt out of parallel tests on CI. */
workers: process.env.CI ? 4 : undefined,
workers: process.env.CI ? 4 : 1,
});
8 changes: 4 additions & 4 deletions webui/react/src/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ Deteremined AI uses [Playwright 🎭](https://playwright.dev/).
- Run `npx playwright install`
- Run `SERVER_ADDRESS={set server address} npm run build` in `webui/react`
- It is `SERVER_ADDRESS` here. not `PW_SERVER_ADDRESS`, but the both values should be the same
- Run `npm run e2e` in `webui/react`
- Run `npm run e2e` in `webui/react`. Use `-- --project=<browsername>` to run a specific browser.

\*\*Avoid using `make` command because it does not take env variables

Expand All @@ -24,10 +24,10 @@ If you don't want to use dev cluster, you can use det deploy to initiate the bac

1. `det deploy local cluster-up --det-version="0.29.0" --no-gpu --master-port=8080`
- use whatever det-version you want here.
2. `SERVER_ADDRESS="http://localhost:8080" npm run build --prefix webui/react`
2. `SERVER_ADDRESS="http://localhost:3001" npm run build --prefix webui/react`
3. Optional if you want an experiment created for the test: `det experiment create ./examples/tutorials/mnist_pytorch/const.yaml ./examples/tutorials/mnist_pytorch/`
4. To run the tests: `CI=true PW_SERVER_ADDRESS="http://localhost:8080" PW_USER_NAME="admin" PW_PASSWORD="" npm run e2e --prefix webui/react -- --project=chromium-no-cors`
- `CI=true` currently causes Playwright to start a frontend webserver for the test. If `CI=false` you'll need to do `npm run preview` manually and point the tests at the right port.
4. `npm run preview --prefix webui/react` to run the preview app. Not necessary if CI=true
5. To run the tests: `PW_SERVER_ADDRESS="http://localhost:3001" PW_USER_NAME="admin" PW_PASSWORD="" npm run e2e --prefix webui/react`

## CI

Expand Down
8 changes: 8 additions & 0 deletions webui/react/vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,14 @@ export default defineConfig(({ mode }) => ({
],
preview: {
port: 3001,
proxy: {
'/api': { target: webpackProxyUrl},
'/proxy': { target: webpackProxyUrl},
'/stream': {
target: websocketProxyUrl,
ws: true,
},
},
strictPort: true,
},
resolve: {
Expand Down

0 comments on commit e4bc377

Please sign in to comment.