Skip to content

Commit 769de50

Browse files
authored
feat(e2e)!: move from cypress to playwright (#1991)
Signed-off-by: OMPRAKASH MISHRA <[email protected]>
1 parent 2f2c60c commit 769de50

File tree

13 files changed

+208
-1692
lines changed

13 files changed

+208
-1692
lines changed

.github/workflows/.tests.yml

Lines changed: 26 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -44,39 +44,44 @@ jobs:
4444
npm ci
4545
node src/main.js
4646
47-
cypress-e2e-tests:
47+
e2e-tests:
4848
name: E2E
49+
defaults:
50+
run:
51+
working-directory: frontend
4952
runs-on: ubuntu-22.04
53+
timeout-minutes: 5
5054
strategy:
5155
matrix:
52-
browser: [chrome, firefox, edge]
53-
timeout-minutes: 5
56+
project: [ chromium, Google Chrome, firefox, safari, Microsoft Edge ]
5457
steps:
5558
- uses: actions/checkout@v4
56-
- id: cache-npm
57-
uses: actions/cache@v4
59+
name: Checkout
60+
- uses: actions/setup-node@v4
61+
name: Setup Node
5862
with:
59-
path: ~/.npm
60-
key: ${{ runner.os }}-build-cache-node-modules-${{ hashFiles('**/package-lock.json') }}
61-
restore-keys: |
62-
${{ runner.os }}-build-cache-node-modules-
63-
${{ runner.os }}-build-
64-
${{ runner.os }}-
63+
node-version: 20
64+
cache: 'npm'
65+
cache-dependency-path: frontend/package-lock.json
66+
- name: Install dependencies
67+
run: |
68+
npm ci
69+
npx playwright install --with-deps
6570
66-
- uses: cypress-io/github-action@v6
71+
- name: Run Tests
6772
env:
68-
CYPRESS_baseUrl: https://${{ github.event.repository.name }}-${{ inputs.target }}-frontend.${{ env.DOMAIN }}/
69-
with:
70-
config: pageLoadTimeout=10000
71-
working-directory: ./frontend
72-
browser: ${{ matrix.browser }}
73+
E2E_BASE_URL: https://${{ github.event.repository.name }}-${{ inputs.target }}-frontend.${{ env.DOMAIN }}/
74+
CI: 'true'
75+
run: |
76+
npx playwright test --project="${{ matrix.project }}" --reporter=html
7377
7478
- uses: actions/upload-artifact@v4
75-
if: failure()
79+
if: ${{ !cancelled() }}
80+
name: upload results
7681
with:
77-
name: cypress-screenshots
78-
path: ./cypress/screenshots
79-
if-no-files-found: ignore # 'warn' or 'error' are also available, defaults to `warn`
82+
name: playwright-report-${{ matrix.project }}
83+
path: "./frontend/playwright-report" # path from current folder
84+
retention-days: 7
8085

8186
load-tests:
8287
name: Load

frontend/cypress.config.ts

Lines changed: 0 additions & 12 deletions
This file was deleted.

frontend/cypress/e2e/home-page.cy.ts

Lines changed: 0 additions & 8 deletions
This file was deleted.

frontend/cypress/e2e/user-table.cy.ts

Lines changed: 0 additions & 29 deletions
This file was deleted.

frontend/cypress/support/e2e.ts

Whitespace-only changes.

frontend/cypress/support/index.ts

Lines changed: 0 additions & 2 deletions
This file was deleted.

frontend/e2e/pages/dashboard.ts

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { expect } from '@playwright/test';
2+
import { baseURL } from '../utils';
3+
import { Page } from 'playwright';
4+
5+
export const dashboard_page = async (page: Page) => {
6+
await page.goto(baseURL);
7+
await expect(page.getByRole('img', { name: 'Logo' })).toBeVisible();
8+
await expect(page.locator('#root')).toContainText('QuickStart OpenShift');
9+
await expect(page.getByText('Employee ID')).toBeVisible();
10+
await expect(page.getByText('Employee Name')).toBeVisible();
11+
await expect(page.getByText('Employee Email')).toBeVisible();
12+
await expect(page.getByRole('link', { name: 'Home' })).toBeVisible();
13+
await expect(page.getByRole('link', { name: 'About gov.bc.ca' })).toBeVisible();
14+
await expect(page.getByRole('link', { name: 'Disclaimer' })).toBeVisible();
15+
await expect(page.getByRole('link', { name: 'Privacy' })).toBeVisible();
16+
await expect(page.getByRole('link', { name: 'Accessibility' })).toBeVisible();
17+
await expect(page.getByRole('link', { name: 'Copyright' })).toBeVisible();
18+
await expect(page.getByRole('link', { name: 'Contact Us' })).toBeVisible();
19+
await page.getByPlaceholder('Search…').click();
20+
await page.getByPlaceholder('Search…').fill('john');
21+
await expect(page.locator('#root')).toContainText('1–1 of 1');
22+
};

frontend/e2e/qsos.spec.ts

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
import { test } from '@playwright/test';
2+
import { dashboard_page } from './pages/dashboard';
3+
4+
test.describe.parallel('QSOS', () => {
5+
test('Dashboard Page', async ({ page }) => {
6+
await dashboard_page(page);
7+
});
8+
9+
});

frontend/e2e/utils/index.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
export const baseURL = process.env.E2E_BASE_URL || 'https://quickstart-openshift-test-frontend.apps.silver.devops.gov.bc.ca/';

0 commit comments

Comments
 (0)