Skip to content

Commit 7a4314e

Browse files
committed
CCM-12732: Component tests framework
1 parent 03c07a4 commit 7a4314e

File tree

6 files changed

+57
-31
lines changed

6 files changed

+57
-31
lines changed

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

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -155,13 +155,9 @@ jobs:
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:
158-
build_datetime: "${{ needs.metadata.outputs.build_datetime }}"
159-
build_timestamp: "${{ needs.metadata.outputs.build_timestamp }}"
160-
build_epoch: "${{ needs.metadata.outputs.build_epoch }}"
161-
nodejs_version: "${{ needs.metadata.outputs.nodejs_version }}"
162-
python_version: "${{ needs.metadata.outputs.python_version }}"
163-
terraform_version: "${{ needs.metadata.outputs.terraform_version }}"
164158
version: "${{ needs.metadata.outputs.version }}"
159+
target_environment: "pr${{ needs.metadata.outputs.pr_number }}"
160+
target_account_group: nhs-notify-digital-letters-dev
165161
secrets: inherit
166162
publish-stage: # Recommended maximum execution time is 10 minutes
167163
name: "Publish stage"

.github/workflows/pr_closed.yaml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -62,3 +62,13 @@ jobs:
6262
--targetAccountGroup "nhs-notify-digital-letters-dev" \
6363
--targetComponent "${{ matrix.component }}" \
6464
--terraformAction "apply"
65+
66+
acceptance-stage: # Recommended maximum execution time is 10 minutes
67+
name: "Acceptance stage"
68+
needs: [ deploy-main]
69+
uses: ./.github/workflows/stage-4-acceptance.yaml
70+
with:
71+
version: "main"
72+
target_environment: "main"
73+
target_account_group: nhs-notify-digital-letters-dev
74+
secrets: inherit

.github/workflows/stage-4-acceptance.yaml

Lines changed: 7 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,16 @@ name: "Acceptance stage"
33
on:
44
workflow_call:
55
inputs:
6-
build_datetime:
7-
description: "Build datetime, set by the CI/CD pipeline workflow"
8-
required: true
9-
type: string
10-
build_timestamp:
11-
description: "Build timestamp, set by the CI/CD pipeline workflow"
12-
required: true
13-
type: string
14-
build_epoch:
15-
description: "Build epoch, set by the CI/CD pipeline workflow"
16-
required: true
17-
type: string
18-
nodejs_version:
19-
description: "Node.js version, set by the CI/CD pipeline workflow"
20-
required: true
21-
type: string
22-
python_version:
23-
description: "Python version, set by the CI/CD pipeline workflow"
6+
version:
7+
description: "Version of the software, set by the CI/CD pipeline workflow"
248
required: true
25-
type: string
26-
terraform_version:
27-
description: "Terraform version, set by the CI/CD pipeline workflow"
9+
type: string#
10+
target_environment:
11+
description: "Environment being tested"
2812
required: true
2913
type: string
30-
version:
31-
description: "Version of the software, set by the CI/CD pipeline workflow"
14+
target_account_group:
15+
description: "Account for the environment being tested"
3216
required: true
3317
type: string
3418

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
// Envar Based
2+
// Environment Configuration
3+
export const ENV = process.env.ENVIRONMENT || 'main';
4+
5+
// Compound Scope Indicator
6+
export const CSI = `nhs-${ENV}-dl`;
7+
8+
// Lambda Names
9+
export const MESH_POLL_LAMBDA_NAME = `${CSI}-mesh-poll`;
10+
export const TTL_CREATE_LAMBDA_NAME = `${CSI}-ttl-create`;
11+
export const TTL_POLL_LAMBDA_NAME = `${CSI}-ttl-poll`;
12+
13+
// Queue Names
14+
export const TTL_QUEUE_NAME = `${CSI}-ttl-queue`;
15+
export const TTL_DLQ_NAME = `${CSI}-ttl-dlq`;
Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
import { expect, test } from '@playwright/test';
2+
import { ENV } from 'constants/backend-constants';
3+
import { listBuckets } from 'helpers/s3-helpers';
24

35
test.describe('Digital Letters', () => {
4-
test('should pass', async () => {
5-
expect(true).toBeTruthy();
6+
test('should contain a bucket with dl-letters in its name', async () => {
7+
const buckets = await listBuckets(ENV);
8+
expect(buckets.some(b => b.includes('dl-letters'))).toBeTruthy();
69
});
710
});
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
import { S3Client, ListBucketsCommand } from "@aws-sdk/client-s3";
2+
3+
const s3 = new S3Client({
4+
region: process.env.AWS_REGION || "eu-west-2",
5+
});
6+
7+
8+
export async function listBuckets(substring: string): Promise<string[]> {
9+
const resp = await s3.send(new ListBucketsCommand({}));
10+
const buckets = resp.Buckets ?? [];
11+
if (!substring) {
12+
return buckets.map(b => b.Name!).filter(Boolean);
13+
}
14+
const needle = substring.toLowerCase();
15+
return buckets
16+
.map(b => b.Name)
17+
.filter((name): name is string => !!name && name.toLowerCase().includes(needle));
18+
}

0 commit comments

Comments
 (0)