Skip to content

Commit

Permalink
test: document ui e2e with backend test instructions for local (#9005)
Browse files Browse the repository at this point in the history
* local config

* update readme with running instructions

* linter fixes

* move tests to folder

* linting

* exculde typo

---------

Co-authored-by: Justin Comins <[email protected]>
  • Loading branch information
djanicekpach and JComins000 authored Mar 18, 2024
1 parent bc1b431 commit eac7ddf
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 7 deletions.
2 changes: 1 addition & 1 deletion webui/react/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@
"format-check:misc": "prettier --check \"src/**/*.{md,json}\"",
"test": "vitest",
"e2e": "playwright test",
"test:coverage": "vitest --run --coverage --silent",
"test:coverage": "vitest --run --coverage --silent --exclude \"src/e2e/tests/**\"",
"analyze": "source-map-explorer --no-border-checks 'build/assets/*.js'",
"unimported": "unimported"
},
Expand Down
14 changes: 12 additions & 2 deletions webui/react/playwright.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,16 @@ export default defineConfig({
projects: [
{
name: 'chromium',
use: { ...devices['Desktop Chrome'], channel: 'chrome' },
use: { ...devices['Desktop Chrome'], channel: 'chrome' }
},

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

{
Expand Down Expand Up @@ -78,7 +87,8 @@ export default defineConfig({
baseURL: 'http://localhost:3001/',

/* Collect trace when retrying the failed test. See https://playwright.dev/docs/trace-viewer */
trace: 'on-first-retry',
trace: 'retain-on-failure',
video: 'retain-on-failure'
},

/* Run your local dev server before starting the tests */
Expand Down
11 changes: 11 additions & 0 deletions webui/react/src/e2e/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,17 @@ Deteremined AI uses [Playwright 🎭](https://playwright.dev/).

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

### Quick start testing using det deploy

If you don't want to use dev cluster, you can use det deploy to initiate the backend. These commands should run and pass tests on chrome:

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`
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.

## CI

CI is setup as `test-e2e-react` in `.circleci/config.yml`.
Expand Down
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
import { test as base } from '@playwright/test';

import { AuthFixture } from './fixtures/auth.fixture';
import { DevFixture } from './fixtures/dev.fixture';
import { AuthFixture } from './auth.fixture';
import { DevFixture } from './dev.fixture';

type CustomFixtures = {
dev: DevFixture;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from '@playwright/test';

import { test } from './global-fixtures';
import { test } from 'e2e/fixtures/global-fixtures';

test.describe('Authentication', () => {
test.beforeEach(async ({ dev }) => {
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { expect } from '@playwright/test';

import { test } from './global-fixtures';
import { test } from 'e2e/fixtures/global-fixtures';

test.describe('Navigation', () => {
const USERNAME = process.env.PW_USER_NAME ?? '';
Expand Down

0 comments on commit eac7ddf

Please sign in to comment.