Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
47 changes: 47 additions & 0 deletions .github/actions/acceptance-tests-setup/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
name: Acceptance tests
description: "Run acceptance tests for this repo"

inputs:

targetComponent:
description: Name of the component under test
required: true

skipRestore:
description: 'Skips restoring from caches'
required: false
default: true

runs:
using: "composite"

steps:
- name: Fetch terraform output
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5
with:
name: terraform-output-${{ inputs.targetComponent }}

- name: "Restore node_modules from cache"
uses: ./.github/actions/node-modules-cache
with:
node_version: "22.22.0"
skip_restore: "${{ inputs.skipRestore }}"

- name: Generate outputs file
shell: bash
run: |
root_dir=${GITHUB_WORKSPACE}
mv ./terraform_output.json ./sandbox_tf_outputs.json
npm run generate-outputs sandbox-output

- name: "Restore playwright dependencies from cache"
uses: ./.github/actions/playwright-cache
with:
playwright_version: "1.59.1"
skip_restore: "${{ inputs.skipRestore }}"

- name: "Restore next build from cache"
uses: ./.github/actions/next-build-cache
with:
node_version: "22.22.0"
skip_restore: "${{ inputs.skipRestore }}"
17 changes: 4 additions & 13 deletions .github/actions/acceptance-tests/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -23,21 +23,12 @@ runs:
using: "composite"

steps:
- name: Fetch terraform output
uses: actions/download-artifact@634f93cb2916e3fdff6788551b99b062d0335ce0 # v5
- name: Acceptance tests setup
uses: ./.github/actions/acceptance-tests-setup
with:
name: terraform-output-${{ inputs.targetComponent }}
- name: "Repo setup"
shell: bash
run: |
npm ci
skipRestore: false
targetComponent: "${{ inputs.targetComponent }}"

- name: Generate outputs file
shell: bash
run: |
root_dir=${GITHUB_WORKSPACE}
mv ./terraform_output.json ./sandbox_tf_outputs.json
npm run generate-outputs sandbox-output

- name: Run test - ${{ inputs.testType }}
shell: bash
Expand Down
34 changes: 34 additions & 0 deletions .github/actions/next-build-cache/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: 'Node modules cache + setup'
description: 'Run nextjs build, restoring from cache if possible'

inputs:
node_version:
description: 'Node.js version'
required: true
cache_lock_path:
description: 'Path(s) to package-lock.json for cache key'
required: false
default: '**/package-lock.json'
skip_restore:
description: 'Skips restoring next build'
required: false
default: false

runs:
using: 'composite'
steps:

- name: 'Restore next build from cache'
id: next-build-cache
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
with:
path: |
frontend/.next
key: ${{ runner.os }}-next-build-${{ inputs.node_version }}-${{ hashFiles(inputs.cache_lock_path) }}
lookup-only: ${{ inputs.skip_restore }}

- name: 'Install dependencies (cache miss)'
if: steps.node-modules-cache.outputs.cache-hit != 'true'
shell: bash
run: |
INCLUDE_AUTH_PAGES=true npm run build
2 changes: 0 additions & 2 deletions .github/actions/node-modules-cache/action.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -33,8 +33,6 @@ runs:
node_modules
**/node_modules
key: ${{ runner.os }}-node-${{ inputs.node_version }}-${{ hashFiles(inputs.cache_lock_path) }}
restore-keys: |
${{ runner.os }}-node-${{ inputs.node_version }}-
lookup-only: ${{ inputs.skip_restore }}

- name: 'Install dependencies (cache miss)'
Expand Down
34 changes: 34 additions & 0 deletions .github/actions/playwright-cache/action.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
name: 'Playwright browser cache'
description: 'Cache Playwright browser binaries and install system dependencies'

inputs:
playwright_version:
description: 'Playwright version to cache.'
required: true
default: ''
skip_restore:
description: 'Skips restoring playwright browser cache'
required: false
default: false

runs:
using: 'composite'
steps:

- name: 'Restore Playwright browsers from cache'
id: playwright-cache
uses: actions/cache@0057852bfaa89a56745cba8c7296529d2fc39830 # v4
with:
path: ~/.cache/ms-playwright
key: ${{ runner.os }}-playwright-${{ inputs.playwright_version }}
lookup-only: ${{ inputs.skip_restore }}

- name: 'Install Playwright browsers (cache miss)'
if: steps.playwright-cache.outputs.cache-hit != 'true'
shell: bash
run: npx playwright install --with-deps

- name: 'Install Playwright system dependencies (cache hit)'
if: steps.playwright-cache.outputs.cache-hit == 'true'
shell: bash
run: npx playwright install-deps
3 changes: 2 additions & 1 deletion .github/workflows/stage-4-acceptance.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -46,4 +46,5 @@ jobs:
--targetWorkflow "dispatch-contextual-tests-dynamic-env.yaml" \
--targetEnvironment "pr${{ inputs.pr_number }}" \
--targetAccountGroup "nhs-notify-template-management-dev" \
--targetComponent "sbx"
--targetComponent "sbx" \
--internalRef "feature/CCM-18086_acceptance-tests-setup"
4 changes: 1 addition & 3 deletions scripts/tests/api.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/bin/bash

set -euo pipefail
cd "$(git rev-parse --show-toplevel)"
npx playwright install --with-deps > /dev/null
cd tests/test-team
cd "$(git rev-parse --show-toplevel)/tests/test-team"
TEST_EXIT_CODE=0
npm run test:api || TEST_EXIT_CODE=$?
echo "TEST_EXIT_CODE=$TEST_EXIT_CODE"
Expand Down
4 changes: 1 addition & 3 deletions scripts/tests/backend.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/bin/bash

set -euo pipefail
cd "$(git rev-parse --show-toplevel)"
npx playwright install --with-deps > /dev/null
cd tests/test-team
cd "$(git rev-parse --show-toplevel)/tests/test-team"
TEST_EXIT_CODE=0
npm run test:backend || TEST_EXIT_CODE=$?
echo "TEST_EXIT_CODE=$TEST_EXIT_CODE"
Expand Down
4 changes: 1 addition & 3 deletions scripts/tests/event.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/bin/bash

set -euo pipefail
cd "$(git rev-parse --show-toplevel)"
npx playwright install --with-deps > /dev/null
cd tests/test-team
cd "$(git rev-parse --show-toplevel)/tests/test-team"
TEST_EXIT_CODE=0
npm run test:event || TEST_EXIT_CODE=$?
echo "TEST_EXIT_CODE=$TEST_EXIT_CODE"
Expand Down
4 changes: 1 addition & 3 deletions scripts/tests/ui-accessibility.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/bin/bash

set -euo pipefail
cd "$(git rev-parse --show-toplevel)"
npx playwright install --with-deps > /dev/null
cd tests/test-team
cd "$(git rev-parse --show-toplevel)/tests/test-team"
TEST_EXIT_CODE=0
npm run test:accessibility || TEST_EXIT_CODE=$?
echo "TEST_EXIT_CODE=$TEST_EXIT_CODE"
Expand Down
4 changes: 1 addition & 3 deletions scripts/tests/ui-component.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/bin/bash

set -euo pipefail
cd "$(git rev-parse --show-toplevel)"
npx playwright install --with-deps > /dev/null
cd tests/test-team
cd "$(git rev-parse --show-toplevel)/tests/test-team"
TEST_EXIT_CODE=0
npm run test:component || TEST_EXIT_CODE=$?
echo "TEST_EXIT_CODE=$TEST_EXIT_CODE"
Expand Down
4 changes: 1 addition & 3 deletions scripts/tests/ui-e2e.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/bin/bash

set -euo pipefail
cd "$(git rev-parse --show-toplevel)"
npx playwright install --with-deps > /dev/null
cd tests/test-team
cd "$(git rev-parse --show-toplevel)/tests/test-team"
TEST_EXIT_CODE=0
npm run test:e2e || TEST_EXIT_CODE=$?
echo "TEST_EXIT_CODE=$TEST_EXIT_CODE"
Expand Down
4 changes: 1 addition & 3 deletions scripts/tests/ui-user-timeout.sh
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
#!/bin/bash

set -euo pipefail
cd "$(git rev-parse --show-toplevel)"
npx playwright install --with-deps > /dev/null
cd tests/test-team
cd "$(git rev-parse --show-toplevel)/tests/test-team"
TEST_EXIT_CODE=0
npm run test:user-timeout || TEST_EXIT_CODE=$?
echo "TEST_EXIT_CODE=$TEST_EXIT_CODE"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ import path from 'node:path';
import { defineConfig, devices } from '@playwright/test';
import baseConfig from '../playwright.config';

const buildCommand = [
'INCLUDE_AUTH_PAGES=true',
'npm run build && npm run start',
].join(' ');

export default defineConfig({
...baseConfig,
fullyParallel: true,
Expand Down Expand Up @@ -46,7 +41,7 @@ export default defineConfig({
/* Run your local dev server before starting the tests */
webServer: {
timeout: 4 * 60 * 1000, // 4 minutes
command: buildCommand,
command: 'npm run start',
cwd: path.resolve(__dirname, '../../../..'),
url: 'http://localhost:3000/templates/create-and-submit-templates',
reuseExistingServer: !process.env.CI,
Expand Down
2 changes: 2 additions & 0 deletions tests/test-team/config/api/api.setup.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@ import { BackendConfigHelper } from 'nhs-notify-web-template-management-util-bac
import { getTestContext } from 'helpers/context/context';

setup('api test setup', async () => {
setup.setTimeout(60_000);

const backendConfig = BackendConfigHelper.fromTerraformOutputsFile(
path.join(__dirname, '..', '..', '..', '..', 'sandbox_tf_outputs.json')
);
Expand Down
7 changes: 1 addition & 6 deletions tests/test-team/config/component/component.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ import path from 'node:path';
import { defineConfig, devices } from '@playwright/test';
import baseConfig from '../playwright.config';

const buildCommand = [
'INCLUDE_AUTH_PAGES=true',
'npm run build && npm run start',
].join(' ');

export default defineConfig({
...baseConfig,

Expand Down Expand Up @@ -46,7 +41,7 @@ export default defineConfig({
/* Run your local dev server before starting the tests */
webServer: {
timeout: 4 * 60 * 1000, // 4 minutes
command: buildCommand,
command: 'npm run start',
cwd: path.resolve(__dirname, '../../../..'),
url: 'http://localhost:3000/templates/create-and-submit-templates',
reuseExistingServer: !process.env.CI,
Expand Down
7 changes: 1 addition & 6 deletions tests/test-team/config/e2e/e2e.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,6 @@ import path from 'node:path';
import { defineConfig, devices } from '@playwright/test';
import baseConfig from '../playwright.config';

const buildCommand = [
'INCLUDE_AUTH_PAGES=true',
'npm run build && npm run start',
].join(' ');

export default defineConfig({
...baseConfig,
fullyParallel: true,
Expand Down Expand Up @@ -46,7 +41,7 @@ export default defineConfig({
/* Run your local dev server before starting the tests */
webServer: {
timeout: 4 * 60 * 1000, // 4 minutes
command: buildCommand,
command: 'npm run start',
cwd: path.resolve(__dirname, '../../../..'),
url: 'http://localhost:3000/templates/create-and-submit-templates',
reuseExistingServer: !process.env.CI,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,6 @@ import path from 'node:path';
import { defineConfig, devices } from '@playwright/test';
import baseConfig from '../playwright.config';

const buildCommand = [
'INCLUDE_AUTH_PAGES=true',
'NEXT_PUBLIC_TIME_TILL_LOGOUT_SECONDS=25',
'NEXT_PUBLIC_PROMPT_SECONDS_BEFORE_LOGOUT=5',
'npm run build && npm run start',
].join(' ');

export default defineConfig({
...baseConfig,

Expand Down Expand Up @@ -50,7 +43,7 @@ export default defineConfig({
/* Run your local dev server before starting the tests */
webServer: {
timeout: 4 * 60 * 1000, // 4 minutes
command: buildCommand,
command: 'npm run start',
cwd: path.resolve(__dirname, '../../../..'),
url: 'http://localhost:3000/templates/create-and-submit-templates',
reuseExistingServer: !process.env.CI,
Expand Down
Loading