Skip to content

Commit 258fe6c

Browse files
authored
Merge pull request #39 from NHSDigital/enhance-checkin
Progressively enhance checkin button
2 parents c3210d3 + 200f0e8 commit 258fe6c

27 files changed

Lines changed: 5205 additions & 456 deletions

.browserslistrc

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,5 @@
11
[javascripts]
22
supports es6-module
3+
4+
[node]
5+
node 22

.github/workflows/stage-2-test.yaml

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -91,15 +91,27 @@ jobs:
9191
name: "Linting"
9292
runs-on: ubuntu-latest
9393
timeout-minutes: 5
94+
9495
steps:
9596
- name: "Checkout code"
9697
uses: actions/checkout@v4
97-
- name: "Run linting"
98-
run: |
99-
make test-lint
100-
- name: "Save the linting result"
101-
run: |
102-
echo "Nothing to save"
98+
99+
- name: Install poetry
100+
run: pipx install poetry
101+
102+
- name: Set up Python
103+
uses: actions/setup-python@a26af69be951a213d495a4c3e4e4022e16d87065
104+
with:
105+
python-version: "${{inputs.python_version}}"
106+
cache: poetry
107+
cache-dependency-path: ./poetry.lock
108+
109+
- name: Install dependencies
110+
run: make dependencies
111+
112+
- name: Run linting
113+
run: make test-lint
114+
103115
perform-static-analysis:
104116
name: "Perform static analysis"
105117
needs: [test]

.gitignore

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,5 +20,10 @@ __pycache__
2020
staticfiles/
2121

2222
# npm
23+
*.tsbuildinfo
2324
node_modules/
2425
manage_breast_screening/assets/compiled
26+
27+
# jest
28+
.cache
29+
coverage

.prettierignore

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
# Temporary only
2+
.cache/
3+
4+
# Node.js modules
5+
node_modules/
6+
7+
# Test coverage
8+
coverage/
9+
10+
# Build output
11+
dist/
12+
13+
# Files to ignore
14+
package-lock.json

.prettierrc.cjs

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
module.exports = {
2+
semi: false,
3+
singleQuote: true,
4+
trailingComma: 'none',
5+
overrides: [
6+
{
7+
files: '*.md',
8+
options: {
9+
embeddedLanguageFormatting: 'off',
10+
singleQuote: false
11+
}
12+
},
13+
{
14+
files: '*.scss',
15+
options: {
16+
printWidth: 120,
17+
singleQuote: false
18+
}
19+
}
20+
]
21+
}

Dockerfile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ WORKDIR /app
1010
RUN apk add --no-cache bash
1111

1212
# Compile static assets
13-
COPY .browserslistrc babel.config.json package.json package-lock.json rollup.config.mjs ./
13+
COPY .browserslistrc babel.config.json package.json package-lock.json rollup.config.js ./
1414
COPY manage_breast_screening ./manage_breast_screening
1515
RUN npm ci
1616
RUN npm run compile

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,9 +44,10 @@ test: test-unit test-ui test-lint # Run all tests @Testing
4444

4545
test-unit: # Run unit tests @Testing
4646
poetry run pytest -m 'not system'
47+
npm test -- --coverage
4748

4849
test-lint: # Lint files @Testing
49-
# TODO
50+
npm run lint
5051

5152
test-ui: # Run UI tests @Testing
5253
poetry run pytest -m system

babel.config.json

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,13 @@
55
"@babel/preset-env",
66
{
77
"bugfixes": true,
8-
"modules": false,
98
"loose": true
109
}
1110
]
12-
]
11+
],
12+
"env": {
13+
"test": {
14+
"browserslistEnv": "node"
15+
}
16+
}
1317
}

jest.config.js

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
/**
2+
* Jest project config defaults
3+
*
4+
* @type {ProjectConfig}
5+
*/
6+
const config = {
7+
cacheDirectory: '<rootDir>/.cache/jest',
8+
coveragePathIgnorePatterns: ['.eslintrc.js', '.test.(cjs|js)'],
9+
10+
// Enable Babel transforms until Jest supports ESM and `import()`
11+
// See: https://jestjs.io/docs/ecmascript-modules
12+
transform: {
13+
'^.+\\.(cjs|js)$': ['babel-jest', { rootMode: 'upward' }]
14+
}
15+
}
16+
17+
/**
18+
* Jest config
19+
*
20+
* @type {Config}
21+
*/
22+
export default {
23+
collectCoverageFrom: ['**/assets/js/**/*.{cjs,js}'],
24+
coverageProvider: 'v8',
25+
projects: [
26+
{
27+
...config,
28+
displayName: 'JavaScript behaviour tests',
29+
setupFilesAfterEnv: ['<rootDir>/jest.setup.js'],
30+
testEnvironment: 'jsdom',
31+
testMatch: ['<rootDir>/**/*.test.{cjs,js}']
32+
}
33+
],
34+
35+
// Reset mocks between tests
36+
resetMocks: true,
37+
resetModules: true,
38+
restoreMocks: true,
39+
clearMocks: true,
40+
41+
// Enable GitHub Actions reporter UI
42+
reporters: ['default', 'github-actions']
43+
}
44+
45+
/**
46+
* @typedef {Exclude<Config['projects'][0], string>} ProjectConfig
47+
*/
48+
49+
/**
50+
* @import { Config } from 'jest'
51+
*/

jest.setup.js

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
import '@testing-library/jest-dom'
2+
3+
/**
4+
* Mock fetch() function for jsdom
5+
*/
6+
Object.defineProperty(window, 'fetch', {
7+
configurable: true,
8+
writable: true,
9+
value: jest.fn().mockResolvedValue(undefined)
10+
})

0 commit comments

Comments
 (0)