Skip to content

Commit 7dfac82

Browse files
committed
CCM-11889: merge
2 parents 68800ad + 5fbff7c commit 7dfac82

File tree

53 files changed

+3169
-577
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

53 files changed

+3169
-577
lines changed

.github/CODEOWNERS

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,9 @@
77
/docs/ @NHSDigital/nhs-notify-web-template-management
88
/infrastructure/terraform/ @NHSDigital/nhs-notify-platform
99

10+
# Root level AGENTS.md owned by platform.
11+
AGENTS.md @NHSDigital/nhs-notify-platform
12+
1013
# Codeowners must be final check
1114
/.github/CODEOWNERS @NHSDigital/nhs-notify-code-owners
1215
/CODEOWNERS @NHSDigital/nhs-notify-code-owners

AGENTS.md

Lines changed: 95 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,95 @@
1+
# AGENTS.md
2+
<!-- vale off -->
3+
4+
## Scope
5+
6+
This file is for **AI agents** working within NHS Notify repositories.
7+
Humans should read `README.md` and the docs for how we actually work day to day.
8+
Keep anything language or tool-specific in nested `AGENTS.md` files (for example under `infrastructure/terraform` or `lambdas`).
9+
10+
## Repository Layout (high level)
11+
12+
At a glance, the main areas are:
13+
14+
- `infrastructure/terraform/` – Terraform components, and shared modules for AWS accounts and environments.
15+
- `lambdas/` – TypeScript lambda projects (each with their own `package.json`, Jest config, etc.). Root level packages.json defines workspaces and scripts. Tests for the lambda are stored in `lambdas/{name}/src/__test`.
16+
- `src/` and `utils/` – Shared code and utilities (for example `utils/logger`).
17+
- `docs/` – Documentation site, ADRs, RFCS, and other long‑form docs.
18+
- `.github/workflows/` and `.github/actions/` – GitHub Actions workflows and composite actions.
19+
- `scripts/` – Helper scripts and tooling used by humans and workflows.
20+
- `tests/` – Cross‑cutting tests and harnesses for the repo.
21+
22+
Agents should look for a nested `AGENTS.md` in or near these areas before making non‑trivial changes.
23+
24+
## Root package.json – role and usage
25+
26+
The root `package.json` is the orchestration manifestgit co for this repo. It does not ship application code; it wires up shared dev tooling and delegates to workspace-level projects.
27+
28+
- Workspaces: Declares the set of npm workspaces (e.g. under `lambdas/`, `utils/`, `tests/`, `scripts/`). Agents should add a new workspace path here when introducing a new npm project.
29+
- Scripts: Provides top-level commands that fan out across workspaces using `--workspaces` (lint, typecheck, unit tests) and project-specific runners (e.g. `lambda-build`).
30+
- Dev tool dependencies: Centralises Jest, TypeScript, ESLint configurations and plugins to keep versions consistent across workspaces. Workspace projects should rely on these unless a local override is strictly needed.
31+
- Overrides/resolutions: Pins transitive dependencies (e.g. Jest/react-is) to avoid ecosystem conflicts. Agents must not remove overrides without verifying tests across all workspaces.
32+
33+
Agent guidance:
34+
35+
- Before adding or removing a workspace, update the root `workspaces` array and ensure CI scripts still succeed with `npm run lint`, `npm run typecheck`, and `npm run test:unit` at the repo root.
36+
- When adding repo-wide scripts, keep names consistent with existing patterns (e.g. `lint`, `lint:fix`, `typecheck`, `test:unit`, `lambda-build`) and prefer `--workspaces` fan-out.
37+
- Do not publish from the root. If adding a new workspace intended for publication, mark that workspace package as `private: false` and keep the root as private.
38+
- Validate changes by running the repo pre-commit hooks: `make githooks-run`.
39+
40+
Success criteria for changes affecting the root `package.json`:
41+
42+
- `npm run lint`, `npm run typecheck`, and `npm run test:unit` pass at the repo root.
43+
- Workspace discovery is correct (new projects appear under `npm run typecheck --workspaces`).
44+
- No regression in lambda build tooling (`npm run lambda-build`).
45+
46+
## What Agents Can / Can’t Do
47+
48+
Agents **can**:
49+
50+
- Propose changes to code, tests, GitHub workflows, Terraform, and docs.
51+
- Suggest new scripts, Make targets, or composite actions by copying existing patterns.
52+
- Run tests to validate proposed solutions.
53+
54+
Agents **must not**:
55+
56+
- Create, push, or merge branches or PRs.
57+
- Introduce new technologies, providers, or big architectural patterns without clearly calling out that an ADR is needed.
58+
- Invent secrets or hard‑code real credentials anywhere.
59+
60+
## Working With This Repo
61+
62+
- All dependencies can be setup using the command `make config` from the repository root.
63+
- **Don’t guess commands.** Derive them from what’s already here or ask for guidance form the human user:
64+
- Prefer `Makefile` targets, `scripts/`, `.github/workflows/`, and `.github/actions/`.
65+
- For Terraform, follow `infrastructure/terraform/{components,modules}` and respect `versions.tf`.
66+
- Keep diffs small and focused. Avoid mixing refactors with behaviour changes unless you explain why.
67+
68+
## Quality Expectations
69+
70+
When proposing a change, agents should:
71+
72+
- Keep code formatted and idiomatic (Terraform, TypeScript, Bash, YAML).
73+
- Stick to existing patterns where available (for example `utils/logger`, composite actions under `.github/actions`).
74+
- Use available information on best practices within the specific area of the codebase.
75+
- **Always** run local pre-commit hooks from the repo root with:
76+
77+
```sh
78+
pre-commit run \
79+
--config scripts/config/pre-commit.yaml
80+
```
81+
82+
to catch formatting and basic lint issues. Domain specific checks will be defined in appropriate nested AGENTS.md files.
83+
84+
- Suggest at least one extra validation step (for example `npm test` in a lambda, or triggering a specific workflow).
85+
- Any required follow up activites which fall outside of the current task's scope should be clearly marked with a 'TODO: CCM-12345' comment. The human user should be prompted to create and provide a JIRA ticket ID to be added to the comment.
86+
87+
## Security & Safety
88+
89+
- All agent-generated changes **must** be reviewed and merged by a human.
90+
- Provide a concise, clear summary of the proposed changes to make human review easier (what changed, why (refer directly to the guidance in relevant Agents.MD files when applicable), and how it was validated). It should be directly pastable into the PR description and make it clear that AI assistance was used.
91+
- Never output real secrets or tokens. Use placeholders and rely on the GitHub/AWS secrets already wired into workflows.
92+
93+
## Escalation / Blockers
94+
95+
If you are blocked by an unavailable secret, unclear architectural constraint, missing upstream module, or failing tooling you cannot safely fix, stop and ask a single clear clarifying question rather than guessing.

frontend/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
"jwt-decode": "^4.0.0",
1111
"markdown-it": "^13.0.2",
1212
"markdown-to-jsx": "^7.7.10",
13-
"next": "^15.2.3",
13+
"next": "^15.5.7",
1414
"next-client-cookies": "^2.0.1",
1515
"nhs-notify-backend-client": "^0.0.1",
1616
"nhs-notify-web-template-management-utils": "^0.0.1",

frontend/src/__tests__/app/choose-templates/__snapshots__/page.test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -674,7 +674,7 @@ exports[`ChooseTemplatesPage renders correctly for a message plan with multiple
674674
class="nhsuk-button"
675675
data-testid="move-to-production-cta"
676676
draggable="false"
677-
href="/message-plans/move-to-production/fbb81055-79b9-4759-ac07-d191ae57be34"
677+
href="/message-plans/get-ready-to-move/fbb81055-79b9-4759-ac07-d191ae57be34"
678678
role="button"
679679
>
680680
Move to production

frontend/src/__tests__/app/message-plans/create-message-plan/server-action.test.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,14 +4,14 @@ import type { CascadeItem, RoutingConfig } from 'nhs-notify-backend-client';
44
import type { MessageOrder } from 'nhs-notify-web-template-management-utils';
55
import { createMessagePlanServerAction } from '@app/message-plans/create-message-plan/server-action';
66
import { NextRedirectError } from '@testhelpers/next-redirect';
7-
import { createRoutingConfig } from '@utils/form-actions';
7+
import { createRoutingConfig } from '@utils/message-plans';
88

99
jest.mock('next/navigation');
1010
jest.mocked(redirect).mockImplementation((url, type) => {
1111
throw new NextRedirectError(url, type);
1212
});
1313

14-
jest.mock('@utils/form-actions');
14+
jest.mock('@utils/message-plans');
1515
jest.mocked(createRoutingConfig).mockResolvedValue(
1616
mock<RoutingConfig>({
1717
id: 'mock-routing-config-id',
Lines changed: 136 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,136 @@
1+
// Jest Snapshot v1, https://goo.gl/fbAQLP
2+
3+
exports[`matches snapshot 1`] = `
4+
<DocumentFragment>
5+
<main
6+
class="nhsuk-main-wrapper"
7+
id="maincontent"
8+
role="main"
9+
>
10+
<div
11+
class="nhsuk-grid-row"
12+
>
13+
<div
14+
class="nhsuk-grid-column-two-thirds"
15+
>
16+
<span
17+
class="nhsuk-caption-xl"
18+
>
19+
Step 1 of 2
20+
</span>
21+
<h1
22+
class="nhsuk-heading-xl"
23+
>
24+
Get ready to move message plan to production
25+
</h1>
26+
<dl
27+
class="nhsuk-summary-list"
28+
>
29+
<div
30+
class="nhsuk-summary-list__row"
31+
>
32+
<dt
33+
class="nhsuk-summary-list__key"
34+
>
35+
Name
36+
</dt>
37+
<dd
38+
class="nhsuk-summary-list__value"
39+
>
40+
My Routing Config
41+
</dd>
42+
</div>
43+
</dl>
44+
<p>
45+
Moving message plans from draft to production means they are ready to send.
46+
</p>
47+
<p>
48+
Any templates used in these message plans will be locked.
49+
</p>
50+
<p>
51+
Messages will only be sent to recipients when you make a request with
52+
<a
53+
href="https://digital.nhs.uk/developer/api-catalogue/nhs-notify"
54+
rel="noopener noreferrer"
55+
target="_blank"
56+
>
57+
NHS Notify API (opens in a new tab)
58+
</a>
59+
or
60+
<a
61+
href="https://digital.nhs.uk/developer/api-catalogue/nhs-notify-mesh"
62+
rel="noopener noreferrer"
63+
target="_blank"
64+
>
65+
NHS Notify MESH (opens in a new tab)
66+
</a>
67+
.
68+
</p>
69+
<h2
70+
class="nhsuk-heading-m"
71+
id="before-you-continue"
72+
>
73+
Before you continue
74+
</h2>
75+
<p>
76+
Make sure:
77+
</p>
78+
<ul
79+
class="nhsuk-list nhsuk-list--bullet"
80+
>
81+
<li>
82+
the relevant stakeholders in your team have approved your templates and message plan
83+
</li>
84+
<li>
85+
your templates have no errors
86+
</li>
87+
</ul>
88+
<div
89+
class="nhsuk-warning-callout"
90+
>
91+
<h3
92+
class="nhsuk-warning-callout__label"
93+
>
94+
Important
95+
<span
96+
class="nhsuk-u-visually-hidden"
97+
>
98+
:
99+
</span>
100+
</h3>
101+
<p>
102+
You cannot edit anything that is in production.
103+
</p>
104+
<p>
105+
If you need to edit your templates or message plans, you can copy and replace them.
106+
</p>
107+
</div>
108+
<div
109+
class="nhsuk-form-group"
110+
>
111+
<a
112+
aria-disabled="false"
113+
class="nhsuk-button"
114+
data-testid="continue-link"
115+
draggable="false"
116+
href="/templates/message-plans/review-and-move-to-production/routing-config-id"
117+
role="button"
118+
>
119+
Continue
120+
</a>
121+
<a
122+
aria-disabled="false"
123+
class="nhsuk-button nhsuk-button--secondary nhsuk-u-margin-left-3"
124+
data-testid="cancel-link"
125+
draggable="false"
126+
href="/templates/message-plans"
127+
role="button"
128+
>
129+
Keep in draft
130+
</a>
131+
</div>
132+
</div>
133+
</div>
134+
</main>
135+
</DocumentFragment>
136+
`;
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
import { render } from '@testing-library/react';
2+
import { mock } from 'jest-mock-extended';
3+
import { redirect, RedirectType } from 'next/navigation';
4+
import { RoutingConfig } from 'nhs-notify-backend-client';
5+
import { getRoutingConfig } from '@utils/message-plans';
6+
import Page, {
7+
metadata,
8+
} from '../../../../app/message-plans/get-ready-to-move/[routingConfigId]/page';
9+
10+
jest.mock('next/navigation');
11+
jest.mock('@utils/message-plans');
12+
13+
const routingConfig = mock<RoutingConfig>({
14+
name: 'My Routing Config',
15+
});
16+
17+
beforeEach(() => {
18+
jest.clearAllMocks();
19+
});
20+
21+
test('metadata', () => {
22+
expect(metadata).toEqual({
23+
title: 'Get ready to move message plan to production - NHS Notify',
24+
});
25+
});
26+
27+
test('matches snapshot', async () => {
28+
jest.mocked(getRoutingConfig).mockResolvedValueOnce(routingConfig);
29+
30+
const page = await Page({
31+
params: Promise.resolve({ routingConfigId: 'routing-config-id' }),
32+
});
33+
34+
const container = render(page);
35+
36+
expect(container.asFragment()).toMatchSnapshot();
37+
});
38+
39+
test('redirects if routing config is not found from path parameter', async () => {
40+
await Page({
41+
params: Promise.resolve({ routingConfigId: 'routing-config-id' }),
42+
});
43+
44+
expect(getRoutingConfig).toHaveBeenCalledWith('routing-config-id');
45+
46+
expect(redirect).toHaveBeenCalledWith(
47+
'/message-plans/invalid',
48+
RedirectType.replace
49+
);
50+
});

0 commit comments

Comments
 (0)