Skip to content

Commit 16d47e9

Browse files
authored
[Issue #8184] allow usage of playwright tags in e2e test jobs (#8960)
Adds support for limiting which playwright tests are run in our e2e testing ci jobs by passing playwright tags. Includes definition of groups to two tests - these are meant to facilitate verification and manual testing of this PR, but the assigned groups are also the correct groups for these, so leaving them in the PR. Also cleans up the implementation of the "api_logs" param in the local ci job, which was previously accepting free text
1 parent 158fadb commit 16d47e9

File tree

4 files changed

+60
-20
lines changed

4 files changed

+60
-20
lines changed

.github/actions/e2e/action.yml

Lines changed: 20 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ inputs:
1515
description: "password for staging test user"
1616
staging_test_user_mfa_key:
1717
description: "mfa key for staging test user"
18+
playwright_tags:
19+
description: "pipe separated list of tags denoting groups of tests to run"
1820
total_shards:
1921
description: "total number of test shards in parent run"
2022
default: "1"
@@ -77,7 +79,8 @@ runs:
7779
npm install @playwright/test
7880
npx playwright install --with-deps
7981
80-
- name: Run e2e tests (Shard ${{ inputs.shard }}/${{ inputs.total_shards }})
82+
- name: Run all e2e tests (Shard ${{ inputs.current_shard }}/${{ inputs.total_shards }})
83+
if: ${{ inputs.playwright_tags == '' }}
8184
working-directory: ./frontend
8285
env:
8386
CI: true
@@ -88,10 +91,25 @@ runs:
8891
STAGING_TEST_USER_PASSWORD: ${{ inputs.staging_test_user_password }}
8992
STAGING_TEST_USER_MFA_KEY: ${{ inputs.staging_test_user_mfa_key }}
9093
run: |
91-
echo $STAGING_TEST_USER_EMAIL
9294
npm run test:e2e
9395
shell: bash
9496

97+
98+
- name: Run e2e tests for ${{ inputs.playwright_tags }} (Shard ${{ inputs.current_shard }}/${{ inputs.total_shards }})
99+
if: ${{ inputs.playwright_tags != '' }}
100+
working-directory: ./frontend
101+
env:
102+
CI: true
103+
TOTAL_SHARDS: ${{ inputs.total_shards }}
104+
CURRENT_SHARD: ${{ inputs.current_shard }}
105+
PLAYWRIGHT_TARGET_ENV: ${{ inputs.target }}
106+
STAGING_TEST_USER_EMAIL: ${{ inputs.staging_test_user_email }}
107+
STAGING_TEST_USER_PASSWORD: ${{ inputs.staging_test_user_password }}
108+
STAGING_TEST_USER_MFA_KEY: ${{ inputs.staging_test_user_mfa_key }}
109+
run: |
110+
npm run test:e2e -- --grep "${{ inputs.playwright_tags }}"
111+
shell: bash
112+
95113
- name: Debug logging on failure
96114
if: ${{ failure() && inputs.api_logs == 'true' }}
97115
working-directory: ./frontend

.github/workflows/ci-frontend-e2e.yml

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,22 @@ on:
1414
inputs:
1515
api_logs:
1616
description: "print api logs on failure?"
17+
default: false
18+
type: boolean
19+
playwright_tags:
20+
description: "pipe separated list of @tags denoting groups of tests to run"
21+
required: false
1722
type: string
1823
workflow_call:
24+
inputs:
25+
api_logs:
26+
description: "print api logs on failure?"
27+
default: false
28+
type: boolean
29+
playwright_tags:
30+
description: "pipe separated list of @tags denoting groups of tests to run"
31+
required: false
32+
type: string
1933
pull_request:
2034
paths:
2135
- frontend/**
@@ -99,7 +113,8 @@ jobs:
99113
needs_node_setup: "false"
100114
total_shards: ${{ matrix.total_shards }}
101115
current_shard: ${{ matrix.shard }}
102-
api_logs: ${{ inputs.api_logs }}
116+
api_logs: ${{ inputs.api_logs && 'true' || 'false' }}
117+
playwright_tags: ${{ inputs.playwright_tags }}
103118
staging_test_user_email: ${{ secrets.STAGING_TEST_USER_EMAIL }}
104119
staging_test_user_password: ${{ secrets.STAGING_TEST_USER_PASSWORD }}
105120
staging_test_user_mfa_key: ${{ secrets.STAGING_TEST_USER_MFA_KEY }}

.github/workflows/e2e-staging.yml

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,10 @@ on:
1616
type: choice
1717
options:
1818
- staging
19+
playwright_tags:
20+
description: "pipe separated list of @tags denoting groups of tests to run"
21+
required: false
22+
type: string
1923

2024
concurrency:
2125
group: ${{ github.workflow }}-${{ github.ref }}
@@ -35,14 +39,16 @@ jobs:
3539
uses: actions/checkout@v6
3640

3741
- name: Set target
38-
run: if [[ -z "${{ inputs.target }}" ]]; then echo "defaulted_target=staging" >> "$GITHUB_ENV"; else echo 'defaulted_target="${{ inputs.target }}"' >> "$GITHUB_ENV"; fi
42+
run: if [[ -z "${{ inputs.target }}" ]]; then echo "defaulted_target=staging" >> "$GITHUB_ENV"; else echo "defaulted_target=${{ inputs.target }}" >> "$GITHUB_ENV"; fi
3943

40-
- uses: ./.github/actions/e2e
44+
- name: Run E2E tests
45+
uses: ./.github/actions/e2e
4146
with:
4247
version: ${{ inputs.version || github.ref }}
4348
target: ${{ env.defaulted_target }}
4449
total_shards: ${{ matrix.total_shards }}
4550
current_shard: ${{ matrix.shard }}
51+
playwright_tags: ${{ inputs.playwright_tags }}
4652
staging_test_user_email: ${{ secrets.STAGING_TEST_USER_EMAIL }}
4753
staging_test_user_password: ${{ secrets.STAGING_TEST_USER_PASSWORD }}
4854
staging_test_user_mfa_key: ${{ secrets.STAGING_TEST_USER_MFA_KEY }}

frontend/tests/e2e/index.spec.ts

Lines changed: 16 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,23 +10,24 @@ test.beforeEach(async ({ page }) => {
1010
await page.goto("/", { waitUntil: "domcontentloaded", timeout });
1111
});
1212

13-
test("has title", async ({ page }) => {
14-
await expect(page).toHaveTitle(/Simpler.Grants.gov/);
13+
test("has title", { tag: "@smoke" }, async ({ page }) => {
14+
await expect(page).toHaveTitle(/Simpler\.Grants\.gov/);
1515
});
1616

17-
test("clicking 'follow on GitHub' link opens a new tab pointed at Github repository", async ({
18-
page,
19-
context,
20-
}) => {
21-
const pagePromise = context.waitForEvent("page");
22-
// Click the Follow on GitHub link
23-
await page.getByRole("link", { name: "Follow on GitHub" }).click();
24-
const newPage = await pagePromise;
25-
await newPage.waitForLoadState();
26-
await expect(newPage).toHaveURL(
27-
/https:\/\/github.com\/HHS\/simpler-grants-gov/,
28-
);
29-
});
17+
test(
18+
"clicking 'follow on GitHub' link opens a new tab pointed at Github repository",
19+
{ tag: "@full-regression" },
20+
async ({ page, context }) => {
21+
const pagePromise = context.waitForEvent("page");
22+
// Click the Follow on GitHub link
23+
await page.getByRole("link", { name: "Follow on GitHub" }).click();
24+
const newPage = await pagePromise;
25+
await newPage.waitForLoadState();
26+
await expect(newPage).toHaveURL(
27+
"https://github.com/HHS/simpler-grants-gov",
28+
);
29+
},
30+
);
3031

3132
test("skips to main content when navigating via keyboard", async ({
3233
page,

0 commit comments

Comments
 (0)