Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
14 commits
Select commit Hold shift + click to select a range
46e13ff
task/CDD-3279-BE-SPIKE-investigate-tooling-for-javascript-testing-CMS
jeanpierrefouche-ukhsa May 6, 2026
e22c0fa
task/CDD-3279-BE-SPIKE-investigate-tooling-for-javascript-testing-CMS
jeanpierrefouche-ukhsa May 6, 2026
e803299
task/CDD-3279-BE-SPIKE-investigate-tooling-for-javascript-testing-CMS
jeanpierrefouche-ukhsa May 7, 2026
662b1e8
task/CDD-3279-BE-SPIKE-investigate-tooling-for-javascript-testing-CMS
jeanpierrefouche-ukhsa May 7, 2026
0ec3e5f
task/CDD-3279-BE-SPIKE-investigate-tooling-for-javascript-testing-CMS
jeanpierrefouche-ukhsa May 7, 2026
514c421
task/CDD-3279-BE-SPIKE-investigate-tooling-for-javascript-testing-CMS
jeanpierrefouche-ukhsa May 7, 2026
3dfe7a0
task/CDD-3279-BE-SPIKE-investigate-tooling-for-javascript-testing-CMS
jeanpierrefouche-ukhsa May 7, 2026
edcb40e
task/CDD-3279-BE-SPIKE-investigate-tooling-for-javascript-testing-CMS
jeanpierrefouche-ukhsa May 7, 2026
6a67361
Remove junit.xml from cache
jeanpierrefouche-ukhsa May 7, 2026
c0147ed
task/CDD-3279-BE-SPIKE-investigate-tooling-for-javascript-testing-CMS
jeanpierrefouche-ukhsa May 8, 2026
2c6bf5a
task/CDD-3279-BE-SPIKE-investigate-tooling-for-javascript-testing-CMS
jeanpierrefouche-ukhsa May 8, 2026
1c74bbb
Merge branch 'main' into task/CDD-3279-BE-SPIKE-investigate-tooling-f…
jeanpierrefouche-ukhsa May 8, 2026
1c9ca4f
task/CDD-3279-BE-SPIKE-investigate-tooling-for-javascript-testing-CMS
jeanpierrefouche-ukhsa May 8, 2026
b94fb9b
task/CDD-3279-BE-SPIKE-investigate-tooling-for-javascript-testing-CMS
jeanpierrefouche-ukhsa May 11, 2026
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
3 changes: 3 additions & 0 deletions .dockerignore
Original file line number Diff line number Diff line change
Expand Up @@ -34,3 +34,6 @@ venv/

# Existing local SQLite database
db.sqlite3

Comment thread
jeanpierrefouche-ukhsa marked this conversation as resolved.
# Spec files used for jest tests
**/*.spec.js
12 changes: 12 additions & 0 deletions .github/workflows/actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -131,6 +131,18 @@ jobs:
run: |
source uhd.sh
uhd tests unit
- name: Run jest tests
run: |
source uhd.sh
uhd tests jest-ci
- name: Unit tests coverage comment
# must use the full sha1 to satisfy Sonar.
# we are using v1 - full sha1 below.
uses: ukhsa-internal/jest-coverage-comment-action@35f93b7420c590576a1484506b85578f87a6bb4a
with:
coverage-summary-path: ./coverage/coverage-summary.json
junitxml-path: ./junit.xml
title: Unit tests coverage

###############################################################################
# Integration tests
Expand Down
14 changes: 13 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -248,4 +248,16 @@ fabric.properties


# Static files collected by the Django app
metrics/static/
metrics/static/

# Node dependencies
node_modules/

# Jest coverage output
coverage/

# Jest cache
.jest-cache/

# npm logs
npm-debug.log*
21 changes: 21 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -11,12 +11,33 @@ on your development system. For Mac users this will require `homebrew`.

For a guide on setting up home brew please find details on the following link https://brew.sh/

### Install Postgresql

Once homebrew has been set up you can run the following command to install `postgressql`

```bash
brew install postgresql
```

### Install node / npm and packages
Comment thread
jeanpierrefouche-ukhsa marked this conversation as resolved.

Run the following command to install both node and npm - we need this to support jest for JavaScript testing:

```bash
brew install node

node -v && npm -v
v25.9.0 # <== current node version
11.12.1 # <== current npm version
```

Run the following command to install node packages

```bash
npm install
```


## Standard command tooling

To unify commonly used commands for local development, there is a script at the root level of the project.
Expand Down
4 changes: 3 additions & 1 deletion auth_content/static/js/permission_set.js
Comment thread
jeanpierrefouche-ukhsa marked this conversation as resolved.
Original file line number Diff line number Diff line change
Expand Up @@ -342,4 +342,6 @@

// Initialize when DOM is ready
document.addEventListener("DOMContentLoaded", initialize);
})();
module.exports = { setToWildcard, WILDCARD_ID_VALUE };
Comment thread
jeanpierrefouche-ukhsa marked this conversation as resolved.
}
)();
30 changes: 30 additions & 0 deletions auth_content/static/js/permission_set.spec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
/**
* @jest-environment jsdom
*/

const { setToWildcard, WILDCARD_ID_VALUE } = require("./permission_set.js");
Comment thread
jeanpierrefouche-ukhsa marked this conversation as resolved.

describe("setToWildcard", () => {
test("sets dropdown to wildcard state correctly", () => {
// Arrange: create a fake select element
const select = document.createElement("select");

// Add some existing options to ensure it gets cleared
const oldOption = document.createElement("option");
oldOption.value = "123";
oldOption.textContent = "Old";
select.appendChild(oldOption);
select.value = "123";

// Act
setToWildcard(select, "* All Items");
Comment thread
jeanpierrefouche-ukhsa marked this conversation as resolved.

// Assert
expect(select.children.length).toBe(1);

const option = select.children[0];
expect(option.value).toBe(WILDCARD_ID_VALUE);
expect(option.textContent).toBe("* All Items");
expect(select.value).toBe(WILDCARD_ID_VALUE);
});
});
72 changes: 72 additions & 0 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
/** @type {import('jest').Config} */
module.exports = {
testEnvironment: 'jsdom',

// 1. Where Jest looks for tests
roots: [
'<rootDir>/auth_content/static/js',
'<rootDir>/cms/dashboard/static/js'
],

// 2. How Jest finds test files
testMatch: [
'**/*.spec.js',
],

// 3. Ignore junk when discovering tests
testPathIgnorePatterns: [
'/node_modules/',
'/static/admin/',
'/static/vendor/',
'/static/rest_framework/',
'/static/debug_toolbar/',
'/static/wagtail',
'/staticfiles/',
'/collected_static/',
String.raw`/static/.*\.[0-9a-f]{6,}\.js$`
],

// 4. Coverage ON
collectCoverage: true,

// 5. What files to include in coverage
collectCoverageFrom: [
'<rootDir>/auth_content/static/js/**/*.js',
'<rootDir>/cms/dashboard/static/js/**/*.js',

// EXCLUDE everything we don’t own
'!**/node_modules/**',
'!**/static/**/vendor/**',
'!**/static/admin/**',
'!**/static/rest_framework/**',
'!**/static/debug_toolbar/**',
'!**/static/wagtail*/**',
],

// 6. Coverage output
coverageDirectory: '<rootDir>/coverage',

// 7. Coverage formats
coverageReporters: ['json-summary', 'text'],

// 8. Optional but useful
modulePathIgnorePatterns: [
'<rootDir>/node_modules/',
],

// 9. Coverage threshold
coverageThreshold: {
global: {
statements: 100,
branches: 100,
functions: 100,
lines: 100,
},
},

// 10. After jest environment has been loaded, run custom setup
setupFilesAfterEnv: ['./jest.setup.js'],

// 11. Reporters
reporters: ['default', 'jest-junit'],
};
2 changes: 2 additions & 0 deletions jest.setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
// Extend Jest with DOM matchers for all tests
require("@testing-library/jest-dom");
Loading
Loading