Skip to content

Commit 03c07a4

Browse files
committed
CCM-12732: Component tests framework
CCM-12732: Component tests framework CCM-12732: Component tests framework CCM-12732: Component tests framework
1 parent 6703a70 commit 03c07a4

File tree

13 files changed

+903
-195
lines changed

13 files changed

+903
-195
lines changed

.github/workflows/cicd-1-pull-request.yaml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ jobs:
151151
--overrides "branch_name=${GITHUB_HEAD_REF:-${GITHUB_REF#refs/heads/}}"
152152
acceptance-stage: # Recommended maximum execution time is 10 minutes
153153
name: "Acceptance stage"
154-
needs: [metadata, build-stage]
154+
needs: [pr-create-dynamic-environment]
155155
uses: ./.github/workflows/stage-4-acceptance.yaml
156156
if: needs.metadata.outputs.does_pull_request_exist == 'true' || (github.event_name == 'pull_request' && (github.event.action == 'opened' || github.event.action == 'reopened')) || (github.event_name == 'push' && github.ref == 'refs/heads/main')
157157
with:

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,5 @@ node_modules
2222
dist
2323
.DS_Store
2424
.reports
25+
**/playwright-report
26+
**/test-results

.tool-versions

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ terraform 1.10.1
77
terraform-docs 0.19.0
88
trivy 0.61.0
99
vale 3.6.0
10+
python 3.11.8
1011

1112

1213
# ==============================================================================

package-lock.json

Lines changed: 783 additions & 193 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
"lambdas/mesh-poll",
5454
"lambdas/ttl-create-lambda",
5555
"lambdas/ttl-poll-lambda",
56-
"utils/utils"
56+
"utils/utils",
57+
"tests/playwright"
5758
]
5859
}

scripts/tests/integration.sh

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
#!/bin/bash
2+
3+
set -euo pipefail
4+
5+
cd "$(git rev-parse --show-toplevel)"
6+
7+
npm install
8+
npx playwright install --with-deps > /dev/null
9+
10+
cd tests/playwright
11+
12+
npm run test:component
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
import { defineConfig } from '@playwright/test';
2+
import baseConfig from 'config/playwright.config';
3+
4+
export default defineConfig({
5+
...baseConfig,
6+
7+
timeout: 120_000, // 30 seconds in the playwright default
8+
expect: {
9+
timeout: 10_000, // default is 5 seconds. After creating and previewing sometimes the load is slow on a cold start
10+
},
11+
projects: [
12+
{
13+
name: 'component',
14+
testMatch: '*.component.spec.ts',
15+
teardown: 'component:teardown',
16+
},
17+
{
18+
name: 'component:teardown',
19+
testMatch: 'component.teardown.ts',
20+
},
21+
],
22+
});
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
import { test as teardown } from '@playwright/test';
2+
3+
teardown('component test teardown', async () => {
4+
// component test teardown
5+
});
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
import { randomUUID } from 'node:crypto';
2+
3+
async function globalSetup() {
4+
process.env.PLAYWRIGHT_RUN_ID = randomUUID();
5+
}
6+
7+
export default globalSetup;
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
import { defineConfig } from '@playwright/test';
2+
import path from 'node:path';
3+
4+
export default defineConfig({
5+
testDir: path.resolve(__dirname, '../'),
6+
fullyParallel: false,
7+
/* Fail the build on CI if you accidentally left test.only in the source code. */
8+
forbidOnly: !!process.env.CI,
9+
retries: 0,
10+
/* Opt out of parallel tests on CI. */
11+
workers: process.env.CI ? 4 : undefined,
12+
/* Reporter to use. See https://playwright.dev/docs/test-reporters */
13+
reporter: [
14+
['line'],
15+
[
16+
'html',
17+
{
18+
outputFolder: path.resolve(__dirname, '../playwright-report'),
19+
open: process.env.CI ? 'never' : 'on-failure',
20+
},
21+
],
22+
],
23+
/* Shared settings for all the projects below. See https://playwright.dev/docs/api/class-testoptions. */
24+
use: {
25+
/* Collect trace when a test fails. See https://playwright.dev/docs/trace-viewer */
26+
trace: 'retain-on-failure',
27+
},
28+
globalSetup: path.resolve(__dirname, 'global.setup.ts'),
29+
});

0 commit comments

Comments
 (0)