Skip to content

Commit fd039b1

Browse files
committed
DC-207 Add: Run Playwright tests in CI; fix: example spec
1 parent 3bb3575 commit fd039b1

4 files changed

Lines changed: 104 additions & 1 deletion

File tree

Lines changed: 97 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,97 @@
1+
name: Playwright E2E
2+
3+
on:
4+
push:
5+
branches: ["main"]
6+
pull_request:
7+
branches: ["main"]
8+
9+
jobs:
10+
e2e:
11+
name: E2E Tests
12+
runs-on: ubuntu-latest
13+
timeout-minutes: 15
14+
15+
services:
16+
mssql:
17+
image: mcr.microsoft.com/mssql/server:2022-latest
18+
env:
19+
ACCEPT_EULA: Y
20+
MSSQL_SA_PASSWORD: YourStrong@Passw0rd
21+
ports:
22+
- 1433:1433
23+
options: >-
24+
--health-cmd="/opt/mssql-tools18/bin/sqlcmd -S localhost -U sa -P YourStrong@Passw0rd -Q 'SELECT 1' -C -b -o /dev/null || exit 1"
25+
--health-interval=10s
26+
--health-timeout=5s
27+
--health-retries=10
28+
--health-start-period=10s
29+
30+
steps:
31+
- name: Checkout code
32+
uses: actions/checkout@v4
33+
34+
- name: Determine state connector ref
35+
id: connector-ref
36+
run: |
37+
BRANCH="${{ github.event_name == 'pull_request' && github.head_ref || github.ref_name }}"
38+
FALLBACK="${{ github.event_name == 'pull_request' && github.base_ref || 'main' }}"
39+
REPO_URL="https://x-access-token:${{ secrets.GITHUB_TOKEN }}@github.com/${{ github.repository_owner }}/sebt-self-service-portal-state-connector.git"
40+
if git ls-remote --exit-code --heads "$REPO_URL" "refs/heads/${BRANCH}" 1>/dev/null 2>&1; then
41+
echo "ref=${BRANCH}" >> "$GITHUB_OUTPUT"
42+
else
43+
echo "ref=${FALLBACK}" >> "$GITHUB_OUTPUT"
44+
fi
45+
46+
- name: Checkout state connector
47+
uses: actions/checkout@v4
48+
with:
49+
repository: codeforamerica/sebt-self-service-portal-state-connector
50+
ref: ${{ steps.connector-ref.outputs.ref }}
51+
path: state-connector
52+
53+
- name: Setup .NET
54+
uses: actions/setup-dotnet@v5
55+
with:
56+
dotnet-version: "10.0.200"
57+
58+
- name: Setup pnpm
59+
uses: pnpm/action-setup@v4
60+
with:
61+
version: "10"
62+
63+
- name: Setup Node.js
64+
uses: actions/setup-node@v4
65+
with:
66+
node-version: "24"
67+
cache: "pnpm"
68+
69+
- name: Install dependencies
70+
run: pnpm install --frozen-lockfile --prefer-offline
71+
72+
- name: Build backend
73+
run: ./.github/workflows/scripts/build-backend.sh --configuration Release
74+
75+
- name: Install Playwright browsers
76+
run: cd src/SEBT.Portal.Web && pnpm exec playwright install --with-deps chromium
77+
78+
- name: Run Playwright tests
79+
env:
80+
CI: true
81+
STATE: dc
82+
NEXT_PUBLIC_STATE: dc
83+
ASPNETCORE_ENVIRONMENT: Development
84+
ConnectionStrings__DefaultConnection: "Server=localhost,1433;Database=SebtPortal;User Id=sa;Password=YourStrong@Passw0rd;TrustServerCertificate=True;"
85+
JwtSettings__SecretKey: "ci-e2e-jwt-secret-at-least-32-characters-long"
86+
IdentifierHasher__SecretKey: "ci-e2e-identifier-hasher-key-32chars"
87+
Oidc__CompleteLoginSigningKey: "ci-e2e-oidc-signing-key-at-least-32-chars"
88+
UseMockHouseholdData: "true"
89+
run: cd src/SEBT.Portal.Web && pnpm exec playwright test --project=chromium
90+
91+
- name: Upload Playwright report
92+
uses: actions/upload-artifact@v4
93+
if: ${{ !cancelled() }}
94+
with:
95+
name: playwright-report
96+
path: src/SEBT.Portal.Web/playwright-report/
97+
retention-days: 7

package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
"ci:build:frontend": "./scripts/ci/build-frontend.sh",
1515
"ci:build:backend": "./scripts/ci/build-backend.sh",
1616
"ci:test": "./scripts/ci/test-backend.sh && ./scripts/ci/test-frontend.sh",
17+
"ci:test:e2e": "cd src/SEBT.Portal.Web && pnpm test:e2e",
1718
"ci:test:frontend": "./scripts/ci/test-frontend.sh",
1819
"ci:test:backend": "./scripts/ci/test-backend.sh",
1920
"ci:list": "./act-test.sh list",

src/SEBT.Portal.Web/e2e/example.spec.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ test.describe('Homepage', () => {
1010
await page.goto('/')
1111

1212
// Check that the page loaded
13-
await expect(page).toHaveTitle(/SEBT Portal/i)
13+
await expect(page).toHaveTitle(/SUN Bucks/i)
1414

1515
// Check for USWDS JavaScript initialization
1616
const html = page.locator('html')

src/SEBT.Portal.Web/playwright.config.ts

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,8 @@
11
import { defineConfig, devices } from '@playwright/test'
2+
import path from 'node:path'
3+
import { fileURLToPath } from 'node:url'
4+
5+
const __dirname = path.dirname(fileURLToPath(import.meta.url))
26

37
/**
48
* Playwright E2E Testing Configuration
@@ -44,6 +48,7 @@ export default defineConfig({
4448
webServer: {
4549
command: 'pnpm dev',
4650
url: process.env.BASE_URL || 'http://localhost:3000',
51+
cwd: path.resolve(__dirname, '../..'),
4752
reuseExistingServer: !process.env.CI
4853
}
4954
})

0 commit comments

Comments
 (0)