-
Notifications
You must be signed in to change notification settings - Fork 33
feat: enhance e2e tests #2242
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
feat: enhance e2e tests #2242
Changes from 18 commits
6aeea4a
bbebb79
6bf195c
2ca1334
ad8c20c
8e1a3b1
551a761
f7f108f
82797c8
60f94a5
f86b949
cc9e90a
4543a67
e87440c
c10aaff
599941b
454dcc7
ea3fd96
d1e65bb
a756c2a
97691d6
bec8d73
10122b6
9c0a8e4
e807dc5
594c4fe
9b9bc26
d2a5592
989cc1c
ea2722b
0deccce
d1d969f
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -7,43 +7,44 @@ on: | |
| jobs: | ||
| e2e-test: | ||
| runs-on: ubuntu-latest | ||
| # services: | ||
| # mysql: | ||
| # image: mysql:8.0.39 | ||
| # env: | ||
| # MYSQL_ROOT_PASSWORD: userfeedback | ||
| # MYSQL_DATABASE: e2e | ||
| # MYSQL_USER: userfeedback | ||
| # MYSQL_PASSWORD: userfeedback | ||
| # TZ: UTC | ||
| # ports: | ||
| # - 13307:3306 | ||
| # options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | ||
| # smtp: | ||
| # image: rnwood/smtp4dev:v3 | ||
| # ports: | ||
| # - 5080:80 | ||
| # - 25:25 | ||
| # - 143:143 | ||
| # opensearch: | ||
| # image: opensearchproject/opensearch:2.4.1 | ||
| # ports: | ||
| # - 9200:9200 | ||
| services: | ||
| mysql: | ||
| image: mysql:8.0.39 | ||
| env: | ||
| MYSQL_ROOT_PASSWORD: userfeedback | ||
| MYSQL_DATABASE: e2e | ||
| MYSQL_USER: userfeedback | ||
| MYSQL_PASSWORD: userfeedback | ||
| TZ: UTC | ||
| ports: | ||
| - 13307:3306 | ||
| options: --health-cmd="mysqladmin ping" --health-interval=10s --health-timeout=5s --health-retries=3 | ||
| smtp: | ||
| image: rnwood/smtp4dev:v3 | ||
| ports: | ||
| - 5080:80 | ||
| - 25:25 | ||
| - 143:143 | ||
| opensearch: | ||
| image: opensearchproject/opensearch:2.4.1 | ||
| ports: | ||
| - 9200:9200 | ||
|
Comment on lines
10
to
40
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Services are not connected to the application via environment variables. The workflow defines MySQL, SMTP, and OpenSearch services, but doesn't configure environment variables for the application to discover and connect to them. The e2e test environment needs to know how to reach these services (e.g., database URL, SMTP host, search engine endpoint). This is a critical gap that will likely cause tests to fail if they attempt to use these services. Add an runs-on: ubuntu-latest
+ env:
+ DATABASE_URL: "mysql://userfeedback:userfeedback@localhost:13307/e2e"
+ OPENSEARCH_URL: "http://localhost:9200"
+ SMTP_HOST: "localhost"
+ SMTP_PORT: "25"
services:Adjust the values to match your application's expected environment variable names and service configuration.
🤖 Prompt for AI Agents |
||
| steps: | ||
| - name: Check out repository code | ||
| uses: actions/checkout@v4 | ||
| # - name: Build and run | ||
| # run: | | ||
| # docker compose -f "./docker/docker-compose.e2e.yml" up -d | ||
| - name: Build and run | ||
| run: | | ||
| docker compose -f "./docker/docker-compose.e2e.yml" up -d | ||
|
|
||
| # - name: Setup e2e test | ||
| # run: | | ||
| # cd apps/e2e | ||
| # npm install -g corepack@latest | ||
| # pnpm install --frozen-lockfile | ||
| # pnpm playwright install | ||
| - name: Setup e2e test | ||
| run: | | ||
| cd apps/e2e | ||
| npm install -g corepack@latest | ||
| corepack enable | ||
| pnpm install --frozen-lockfile | ||
| pnpm playwright install | ||
|
|
||
| # - name: Run e2e tests | ||
| # run: | | ||
| # pnpm build | ||
| # pnpm test:e2e | ||
| - name: Run e2e tests | ||
| run: | | ||
| pnpm build | ||
| pnpm test:e2e | ||
This file was deleted.
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -1,54 +1,80 @@ | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { expect, test as setup } from "@playwright/test"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const authFile = "playwright/.auth/user.json"; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setup("tenant create and authenticate", async ({ page }) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.goto("http://localhost:3000/tenant/create"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { expect, test as setup } from '@playwright/test'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { initializeDatabaseForTest } from './utils/database-utils'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| import { initializeOpenSearchForTest } from './utils/opensearch-utils'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| const authFile = 'playwright/.auth/user.json'; | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| setup('tenant create and authenticate', async ({ page }) => { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await initializeDatabaseForTest(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.log('Database initialized for test'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch (error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.warn( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'Database initialization failed, continuing without database cleanup:', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| error, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| try { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await initializeOpenSearchForTest(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.log('OpenSearch initialized for test'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } catch (error) { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| console.warn( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'OpenSearch initialization failed, continuing without OpenSearch:', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| error, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.goto('http://localhost:3000/tenant/create'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.waitForTimeout(1000); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.locator("input[name='siteName']").click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.locator("input[name='siteName']").fill("TestTenant"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.getByRole("button", { name: "Next", exact: true }).click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.locator("input[name='siteName']").fill('TestTenant'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.getByRole('button', { name: 'Next', exact: true }).click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.waitForTimeout(1000); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.locator("input[name='email']").click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.locator("input[name='email']").fill("[email protected]"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.locator("input[name='email']").fill('[email protected]'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.getByRole("button", { name: "Request Code", exact: true }).click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.getByRole('button', { name: 'Request Code', exact: true }).click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.waitForSelector('input[name="code"]', { state: "visible" }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.waitForSelector('input[name="code"]', { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| state: 'visible', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| timeout: 60000, | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.locator("input[name='code']").click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.locator("input[name='code']").fill("000000"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.locator("input[name='code']").fill('000000'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.getByRole("button", { name: "Verify Code", exact: true }).click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.getByRole('button', { name: 'Verify Code', exact: true }).click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.locator("input[name='password']").click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.locator("input[name='password']").fill("12345678!"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.locator("input[name='password']").fill('Abcd1234!'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.locator("input[name='confirmPassword']").click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.locator("input[name='confirmPassword']").fill("12345678!"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.locator("input[name='confirmPassword']").fill('Abcd1234!'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.getByRole("button", { name: "Next", exact: true }).click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.getByRole('button', { name: 'Next', exact: true }).click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.waitForTimeout(1000); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.getByRole("button", { name: "Confirm", exact: true }).click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.getByRole('button', { name: 'Confirm', exact: true }).click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
9
to
+60
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replace hard-coded credentials with environment variables. Hard-coded credentials and a fixed verification code ('000000') pose security risks and reduce test portability. The fixed code suggests email verification is bypassed in tests. Refactor to use environment variables: await page.locator("input[name='siteName']").click();
- await page.locator("input[name='siteName']").fill('TestTenant');
+ await page.locator("input[name='siteName']").fill(process.env.TEST_TENANT_NAME || 'TestTenant');
await page.locator("input[name='email']").click();
- await page.locator("input[name='email']").fill('[email protected]');
+ await page.locator("input[name='email']").fill(process.env.TEST_USER_EMAIL || '[email protected]');
await page.locator("input[name='code']").click();
- await page.locator("input[name='code']").fill('000000');
+ await page.locator("input[name='code']").fill(process.env.TEST_VERIFICATION_CODE || '000000');
await page.locator("input[name='password']").click();
- await page.locator("input[name='password']").fill('Abcd1234!');
+ await page.locator("input[name='password']").fill(process.env.TEST_USER_PASSWORD || 'Abcd1234!');📝 Committable suggestion
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.waitForTimeout(1000); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.goto("http://localhost:3000/auth/sign-in"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.goto('http://localhost:3000/auth/sign-in'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.waitForTimeout(1000); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await expect(page.locator("body", { hasText: "TestTenant" })).toContainText( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "TestTenant" | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await expect(page.locator('body', { hasText: 'TestTenant' })).toContainText( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| 'TestTenant', | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.locator("input[name='email']").click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.locator("input[name='email']").fill("[email protected]"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.locator("input[name='email']").fill('[email protected]'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.locator("input[name='password']").click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.locator("input[name='password']").fill("12345678!"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.getByRole("button", { name: "Sign In", exact: true }).click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.locator("input[name='password']").fill('Abcd1234!'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.getByRole('button', { name: 'Sign In', exact: true }).click(); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.waitForTimeout(1000); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.waitForURL("http://localhost:3000/main/project/create"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.waitForURL('http://localhost:3000/main/project/create'); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| await page.context().storageState({ path: authFile }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| }); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,32 +1,22 @@ | ||
| import { test as teardown } from '@playwright/test'; | ||
|
|
||
| import { createConnection } from './database-utils'; | ||
|
|
||
| export async function globalTeardown() { | ||
| const connection = await createConnection(); | ||
| try { | ||
| await connection.execute(`DELETE FROM tenant WHERE site_name = ?`, [ | ||
| 'TestTenant', | ||
| ]); | ||
| await connection.execute('ALTER TABLE tenant AUTO_INCREMENT = 1'); | ||
| await connection.execute('ALTER TABLE projects AUTO_INCREMENT = 1'); | ||
| await connection.execute('ALTER TABLE channels AUTO_INCREMENT = 1'); | ||
| await connection.execute('ALTER TABLE fields AUTO_INCREMENT = 1'); | ||
| await connection.execute('ALTER TABLE feedbacks AUTO_INCREMENT = 1'); | ||
| await connection.execute(`DELETE FROM users WHERE email = ?`, [ | ||
| '[email protected]', | ||
| ]); | ||
| await connection.execute('ALTER TABLE users AUTO_INCREMENT = 1'); | ||
| await connection.execute('DELETE FROM histories'); | ||
| await connection.execute('ALTER TABLE histories AUTO_INCREMENT = 1'); | ||
| } finally { | ||
| await connection.end(); | ||
| } | ||
| } | ||
| import { cleanupDatabaseAfterTest } from './utils/database-utils'; | ||
| import { cleanupOpenSearchAfterTest } from './utils/opensearch-utils'; | ||
|
|
||
| teardown('teardown', async () => { | ||
| try { | ||
| await globalTeardown(); | ||
| try { | ||
| await cleanupDatabaseAfterTest(); | ||
| } catch (error) { | ||
| console.warn('Database cleanup failed:', error); | ||
| } | ||
|
|
||
| try { | ||
| await cleanupOpenSearchAfterTest(); | ||
| } catch (error) { | ||
| console.warn('OpenSearch cleanup failed:', error); | ||
| } | ||
|
|
||
| console.log('Tearing down succeeds.'); | ||
| } catch (e) { | ||
| console.log('Tearing down fails.', e); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.