diff --git a/.gitignore b/.gitignore index b7a121b8b..1f7d3f58d 100644 --- a/.gitignore +++ b/.gitignore @@ -121,7 +121,7 @@ build/ # Test reports coverage/ playwright-report/ -playwright/ +client/playwright/ test_results/ # Mac temp files diff --git a/client/package.json b/client/package.json index 99c74f152..2e94624e4 100644 --- a/client/package.json +++ b/client/package.json @@ -28,7 +28,7 @@ "stop": "npx kill-port 4000", "syntax": "npx eslint . --fix", "test:all": "yarn test:unit && yarn test:int && yarn test:e2e", - "test:e2e": "yarn build && yarn config:test && npx kill-port 4000 && yarn start >/dev/null & playwright test && npx kill-port 4000", + "test:e2e": "yarn build && yarn config:test && playwright test", "test:int": "jest -c ./jest.integration.config.json ../test/integration --coverage", "test:unit": "jest -c ./jest.config.json ../test/unitTests --coverage" }, diff --git a/client/playwright.config.ts b/client/playwright.config.ts index b4eb033d6..68de31039 100644 --- a/client/playwright.config.ts +++ b/client/playwright.config.ts @@ -13,16 +13,22 @@ dotenv.config({ path: './test/.env' }); const BASE_URI = process.env.REACT_APP_URL.toString() ?? ''; export default defineConfig({ + webServer: { + command: 'yarn start', + port: 4000, + }, timeout: 45000, globalTimeout: 600000, testDir: './test/e2e', testMatch: /.*\.test\.ts/, - reporter: [ - ['html', { outputFile: 'playwright-report/index.html' }], - ['list'], - ['junit', { outputFile: 'playwright-report/results.xml' }], - ['json', { outputFile: 'playwright-report/results.json' }], - ], + reporter: process.env.CI + ? 'github' + : [ + ['html', { outputFile: 'playwright-report/index.html' }], + ['list'], + ['junit', { outputFile: 'playwright-report/results.xml' }], + ['json', { outputFile: 'playwright-report/results.json' }], + ], use: { baseURL: BASE_URI, }, diff --git a/client/test/e2e/playwright/Auth.test.ts b/client/test/e2e/playwright/Auth.test.ts index b7d555967..1d57ef99e 100644 --- a/client/test/e2e/playwright/Auth.test.ts +++ b/client/test/e2e/playwright/Auth.test.ts @@ -1,7 +1,7 @@ // src: https://playwright.dev/docs/writing-tests import { test, expect } from '@playwright/test'; -import links from './Links.ts'; // Extension is required with Playwright import +import links from './Links'; // Extension is required with Playwright import test.describe('Tests on Authentication Flow', () => { test.beforeEach(async ({ page }) => { @@ -12,6 +12,7 @@ test.describe('Tests on Authentication Flow', () => { await page .getByRole('button', { name: 'GitLab logo Sign In with GitLab' }) .click(); + await page.getByRole('button', { name: 'Authorize' }).click(); await expect( page.getByRole('button', { name: 'Open settings' }), ).toBeVisible(); @@ -22,6 +23,7 @@ test.describe('Tests on Authentication Flow', () => { await page .getByRole('button', { name: 'GitLab logo Sign In with GitLab' }) .click(); + await page.getByRole('button', { name: 'Authorize' }).click(); await expect( page.getByRole('button', { name: 'Open settings' }), ).toBeVisible(); diff --git a/client/test/e2e/playwright/Menu.test.ts b/client/test/e2e/playwright/Menu.test.ts index 97ff3e193..661e918ed 100644 --- a/client/test/e2e/playwright/Menu.test.ts +++ b/client/test/e2e/playwright/Menu.test.ts @@ -1,7 +1,7 @@ // src: https://playwright.dev/docs/writing-tests import { test, expect } from '@playwright/test'; -import links from './Links.ts'; // Extension is required with Playwright import +import links from './Links'; // Extension is required with Playwright import test.describe('Menu Links from first page (Layout)', () => { test.beforeEach(async ({ page }) => { @@ -9,6 +9,7 @@ test.describe('Menu Links from first page (Layout)', () => { await page .getByRole('button', { name: 'GitLab logo Sign In with GitLab' }) .click(); + await page.getByRole('button', { name: 'Authorize' }).click(); await expect( page.getByRole('button', { name: 'Open settings' }), ).toBeVisible(); diff --git a/client/test/e2e/playwright/auth.setup.ts b/client/test/e2e/playwright/auth.setup.ts index a97468ae9..fdbe74718 100644 --- a/client/test/e2e/playwright/auth.setup.ts +++ b/client/test/e2e/playwright/auth.setup.ts @@ -32,12 +32,10 @@ setup('authenticate', async ({ page }) => { } await page.fill('#user_login', testUsername.toString()); // Insert valid GitLab testing username. await page.fill('#user_password', testPassword.toString()); // Insert valid GitLab testing password. + await page.locator('label').filter({ hasText: 'Remember me' }).click(); await page.getByRole('button', { name: 'Sign in' }).click(); try { - await page.waitForSelector('input[type="submit"][value="Authorize"]', { - timeout: 10000, - }); - await page.click('input[type="submit"][value="Authorize"]'); + await page.getByRole('button', { name: 'Authorize' }).click(); } catch (error) { // 'Authorize' button did not appear within 4 seconds, so just ignore and continue. }