Skip to content

Commit 870bac1

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

4 files changed

Lines changed: 110 additions & 2 deletions

File tree

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

12-
// Check that the page loaded
13-
await expect(page).toHaveTitle(/SEBT Portal/i)
12+
// Check that the page loaded (homepage redirects to login; title includes state + SUN Bucks)
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: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,13 @@
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
59
* Cross-browser testing with mobile viewport support
10+
* webServer runs from project root to start both API and Web (pnpm dev)
611
*/
712
export default defineConfig({
813
testDir: './e2e',
@@ -44,6 +49,7 @@ export default defineConfig({
4449
webServer: {
4550
command: 'pnpm dev',
4651
url: process.env.BASE_URL || 'http://localhost:3000',
52+
cwd: path.resolve(__dirname, '../..'),
4753
reuseExistingServer: !process.env.CI
4854
}
4955
})

0 commit comments

Comments
 (0)