From 810053a866a79e0938cddea5f0cbc577e3368e16 Mon Sep 17 00:00:00 2001 From: Olga Bulat Date: Thu, 25 May 2023 20:17:25 +0300 Subject: [PATCH] Revert PW changes from #1920 --- frontend/docker-compose.playwright.yml | 1 - frontend/package.json | 4 +-- frontend/test/playwright/playwright.config.ts | 31 ++++++++++--------- 3 files changed, 17 insertions(+), 19 deletions(-) diff --git a/frontend/docker-compose.playwright.yml b/frontend/docker-compose.playwright.yml index 0ed5435abad..01e1f3cf33b 100644 --- a/frontend/docker-compose.playwright.yml +++ b/frontend/docker-compose.playwright.yml @@ -18,5 +18,4 @@ services: - DEBUG=pw:webserver - DISABLE_SENTRY=true - UPDATE_TAPES=${UPDATE_TAPES:-false} - - FASTSTART=${FASTSTART:-false} cpus: 0.000 diff --git a/frontend/package.json b/frontend/package.json index 9208e4934b1..49cc39f9c4a 100644 --- a/frontend/package.json +++ b/frontend/package.json @@ -16,7 +16,6 @@ "docker:run": "docker run --rm -it -p 127.0.0.1:8443:8443/tcp openverse-frontend:latest", "generate": "nuxt generate", "start": "nuxt start", - "start:playwright": "pnpm i18n:copy-test-locales && pnpm start", "prod": "pnpm build:only && pnpm start", "prod:playwright": "pnpm i18n:copy-test-locales && pnpm prod", "storybook": "nuxt storybook --port=54000", @@ -30,12 +29,11 @@ "test:unit": "jest", "test:unit:watch": "pnpm test:unit --collectCoverage=false --watch", "test:playwright": "./bin/playwright.sh", - "test:playwright:local": "DISABLE_SENTRY=true pnpm exec playwright test -c test/playwright", + "test:playwright:local": "DISABLE_SENTRY=true playwright test -c test/playwright", "test:playwright:debug": "PWDEBUG=1 pnpm test:playwright:local", "test:playwright:recreate-tapes": "rimraf test/tapes && pnpm test:playwright:update-tapes", "test:playwright:update-tapes": "UPDATE_TAPES=true pnpm test:playwright", "test:playwright:gen": "playwright codegen localhost:8443/", - "test:playwright:faststart": "FASTSTART=true pnpm test:playwright", "test:storybook": "TEST_COMMAND=test:storybook:local ./bin/playwright.sh", "test:storybook:local": "playwright test -c test/storybook", "test:storybook:debug": "PWDEBUG=1 pnpm test:storybook:local", diff --git a/frontend/test/playwright/playwright.config.ts b/frontend/test/playwright/playwright.config.ts index d91b7cc63bc..8b0d4377097 100644 --- a/frontend/test/playwright/playwright.config.ts +++ b/frontend/test/playwright/playwright.config.ts @@ -11,23 +11,24 @@ addAliases({ const UPDATE_TAPES = process.env.UPDATE_TAPES || "false" -/** - * Enabling `FASTSTART` allows you to bypass running the nuxt build - * when rapidly debugging tests locally within the container. If you - * already have the Docker image, this is an easy way to iterate on - * tests and do log-based debugging without needing to download the - * enormous browser binaries (on top of the already huge Docker image - * download). - * - * Note that visual-regression tests can be quite flaky when using - * `FASTSTART`. - */ -const pwCommand = - process.env.FASTSTART !== "false" ? "start:playwright" : "prod:playwright" - const config: PlaywrightTestConfig = { webServer: { - command: `./node_modules/.bin/npm-run-all -p -r talkback ${pwCommand}`, + /** + * Note: You can speed up local testing by switching `prod` out for `start` + * to skip the build, but be aware that then talkback and the Nuxt server + * will be racing to warm up and the tests could start before talkback is + * ready to start serving API responses. Playwright only lets you specify + * one port to wait for a ready response from so there's no way around it. + * Normally the build introduces more than enough time for talkback to + * be ready by the time the Nuxt server is actually started. + * + * This doesn't mean _don't_ use `start`, it just means that once you've + * debugged everything else, make sure to inspect the trace output for any + * ConsoleMessage strings that refer to incorrect responses. Once you've + * verified that there is indeed a tape saved for the response in question, + * switch this back to `prod` and see if your tests pass. + */ + command: "./node_modules/.bin/npm-run-all -p -r talkback prod:playwright", cwd: "/app", timeout: process.env.CI ? 60_000 * 5 : 60_000 * 10, // 5 minutes in CI, 10 in other envs port: 8443,