test: Update Playwright E2E test settings (#2247)
- Moves E2E test user to dedicated env variables - Fixes playwright test redirect issue --------- Co-authored-by: Emma Segal-Grossman <hi@emma.cafe>
This commit is contained in:
parent
daae82191f
commit
02eeaca245
6
.github/workflows/ui-tests-playwright.yml
vendored
6
.github/workflows/ui-tests-playwright.yml
vendored
@ -14,7 +14,8 @@ jobs:
|
|||||||
timeout-minutes: 60
|
timeout-minutes: 60
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
env:
|
env:
|
||||||
DEV_PASSWORD: ${{ secrets.DEV_PASSWORD }}
|
E2E_USER_EMAIL: ${{ secrets.E2E_USER_EMAIL }}
|
||||||
|
E2E_USER_PASSWORD: ${{ secrets.E2E_USER_PASSWORD }}
|
||||||
API_BASE_URL: ${{ secrets.API_BASE_URL }}
|
API_BASE_URL: ${{ secrets.API_BASE_URL }}
|
||||||
working-directory: ./frontend
|
working-directory: ./frontend
|
||||||
steps:
|
steps:
|
||||||
@ -65,7 +66,8 @@ jobs:
|
|||||||
run: |
|
run: |
|
||||||
cd frontend
|
cd frontend
|
||||||
touch .env
|
touch .env
|
||||||
echo DEV_PASSWORD="${{ secrets.DEV_PASSWORD }}" >> .env
|
echo E2E_USER_EMAIL="${{ secrets.E2E_USER_EMAIL }}" >> .env
|
||||||
|
echo E2E_USER_PASSWORD="${{ secrets.E2E_USER_PASSWORD }}" >> .env
|
||||||
echo API_BASE_URL=${{ secrets.API_BASE_URL }} >> .env
|
echo API_BASE_URL=${{ secrets.API_BASE_URL }} >> .env
|
||||||
cat .env
|
cat .env
|
||||||
|
|
||||||
|
@ -125,7 +125,8 @@
|
|||||||
"@open-wc/testing": "^3.2.0",
|
"@open-wc/testing": "^3.2.0",
|
||||||
"@playwright/test": "1.49.0",
|
"@playwright/test": "1.49.0",
|
||||||
"@web/test-runner": "^0.13.22",
|
"@web/test-runner": "^0.13.22",
|
||||||
"@web/test-runner-playwright": "^0.11.0"
|
"@web/test-runner-playwright": "^0.11.0",
|
||||||
|
"http-proxy-middleware": "^2.0.7"
|
||||||
},
|
},
|
||||||
"lint-staged": {
|
"lint-staged": {
|
||||||
"*.{ts,js,html,css,json,webmanifest}": "prettier --write"
|
"*.{ts,js,html,css,json,webmanifest}": "prettier --write"
|
||||||
|
@ -1,10 +1,14 @@
|
|||||||
import { defineConfig, devices } from "@playwright/test";
|
import { defineConfig, devices } from "@playwright/test";
|
||||||
|
|
||||||
/**
|
if (!process.env.CI) {
|
||||||
|
/**
|
||||||
* Read environment variables from file.
|
* Read environment variables from file.
|
||||||
* https://github.com/motdotla/dotenv
|
* https://github.com/motdotla/dotenv
|
||||||
*/
|
*/
|
||||||
// require('dotenv').config();
|
require("dotenv").config({
|
||||||
|
path: ".env.local",
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* See https://playwright.dev/docs/test-configuration.
|
* See https://playwright.dev/docs/test-configuration.
|
||||||
|
@ -1,3 +1,5 @@
|
|||||||
API_BASE_URL=
|
API_BASE_URL=
|
||||||
DOCS_URL=https://docs.browsertrix.com/
|
DOCS_URL=https://docs.browsertrix.com/
|
||||||
|
E2E_USER_EMAIL=
|
||||||
|
E2E_USER_PASSWORD=
|
||||||
GLITCHTIP_DSN=
|
GLITCHTIP_DSN=
|
||||||
|
@ -27,8 +27,8 @@ Object.keys(devServer.proxy).forEach((path) => {
|
|||||||
app.use(
|
app.use(
|
||||||
path,
|
path,
|
||||||
createProxyMiddleware({
|
createProxyMiddleware({
|
||||||
target: devServer.proxy[path],
|
...devServer.proxy[path],
|
||||||
changeOrigin: true,
|
followRedirects: true,
|
||||||
}),
|
}),
|
||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
@ -11,15 +11,22 @@ test("test", async ({ baseURL }) => {
|
|||||||
await page.waitForLoadState("load");
|
await page.waitForLoadState("load");
|
||||||
await page.waitForSelector('input[name="username"]');
|
await page.waitForSelector('input[name="username"]');
|
||||||
await page.click('input[name="username"]');
|
await page.click('input[name="username"]');
|
||||||
await page.fill('input[name="username"]', "dev@webrecorder.net");
|
|
||||||
await page.click('input[name="password"]');
|
const e2eEmail = process.env.E2E_USER_EMAIL;
|
||||||
const devPassword = process.env.DEV_PASSWORD;
|
if (!e2eEmail) {
|
||||||
if (!devPassword) {
|
|
||||||
throw new Error(
|
throw new Error(
|
||||||
"DEV_PASSWORD environment variable is not defined or null.",
|
"E2E_USER_EMAIL environment variable is not defined or null.",
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
await page.fill('input[name="password"]', devPassword);
|
await page.fill('input[name="username"]', e2eEmail);
|
||||||
|
await page.click('input[name="password"]');
|
||||||
|
const e2ePassword = process.env.E2E_USER_PASSWORD;
|
||||||
|
if (!e2ePassword) {
|
||||||
|
throw new Error(
|
||||||
|
"E2E_USER_PASSWORD environment variable is not defined or null.",
|
||||||
|
);
|
||||||
|
}
|
||||||
|
await page.fill('input[name="password"]', e2ePassword);
|
||||||
await page.click('sl-button:has-text("Log In")');
|
await page.click('sl-button:has-text("Log In")');
|
||||||
} finally {
|
} finally {
|
||||||
await browser.close();
|
await browser.close();
|
||||||
|
11
frontend/yarn.lock
generated
11
frontend/yarn.lock
generated
@ -5096,6 +5096,17 @@ http-proxy-middleware@^2.0.3:
|
|||||||
is-plain-obj "^3.0.0"
|
is-plain-obj "^3.0.0"
|
||||||
micromatch "^4.0.2"
|
micromatch "^4.0.2"
|
||||||
|
|
||||||
|
http-proxy-middleware@^2.0.7:
|
||||||
|
version "2.0.7"
|
||||||
|
resolved "https://registry.yarnpkg.com/http-proxy-middleware/-/http-proxy-middleware-2.0.7.tgz#915f236d92ae98ef48278a95dedf17e991936ec6"
|
||||||
|
integrity sha512-fgVY8AV7qU7z/MmXJ/rxwbrtQH4jBQ9m7kp3llF0liB7glmFeVZFBepQb32T3y8n8k2+AEYuMPCpinYW+/CuRA==
|
||||||
|
dependencies:
|
||||||
|
"@types/http-proxy" "^1.17.8"
|
||||||
|
http-proxy "^1.18.1"
|
||||||
|
is-glob "^4.0.1"
|
||||||
|
is-plain-obj "^3.0.0"
|
||||||
|
micromatch "^4.0.2"
|
||||||
|
|
||||||
http-proxy@^1.18.1:
|
http-proxy@^1.18.1:
|
||||||
version "1.18.1"
|
version "1.18.1"
|
||||||
resolved "https://registry.npmjs.org/http-proxy/-/http-proxy-1.18.1.tgz"
|
resolved "https://registry.npmjs.org/http-proxy/-/http-proxy-1.18.1.tgz"
|
||||||
|
Loading…
Reference in New Issue
Block a user