Skip to content
Merged
Show file tree
Hide file tree
Changes from 13 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
Original file line number Diff line number Diff line change
Expand Up @@ -54,4 +54,30 @@ describe('PreviewLetterTemplate component', () => {

expect(container.asFragment()).toMatchSnapshot();
});

it('matches snapshot when template status is PENDING_PROOF_REQUEST', () => {
const container = render(
<PreviewLetterTemplate
template={{
id: '53525D03-1BC1-4563-ABF9-A74FF04142AF',
name: 'letter',
templateType: 'LETTER',
templateStatus: 'PENDING_PROOF_REQUEST',
letterType: 'q4',
language: 'ar',
files: {
pdfTemplate: {
fileName: 'file.pdf',
currentVersion: 'a',
virusScanStatus: 'PASSED',
},
},
createdAt: '2025-04-02T09:33:25.729Z',
updatedAt: '2025-04-02T09:33:25.729Z',
}}
/>
);

expect(container.asFragment()).toMatchSnapshot();
});
});
Original file line number Diff line number Diff line change
Expand Up @@ -134,10 +134,10 @@ exports[`PreviewLetterTemplate component matches snapshot 1`] = `
<a
aria-disabled="false"
class="nhsuk-button"
data-testid="submit-button"
data-testid="preview-letter-template-cta"
draggable="false"
href="/templates/submit-letter-template/53525D03-1BC1-4563-ABF9-A74FF04142AF"
id="preview-letter-template-submit-button"
id="preview-letter-template-cta"
role="button"
>
Submit template
Expand All @@ -155,6 +155,161 @@ exports[`PreviewLetterTemplate component matches snapshot 1`] = `
</DocumentFragment>
`;

exports[`PreviewLetterTemplate component matches snapshot when template status is PENDING_PROOF_REQUEST 1`] = `
<DocumentFragment>
<div
class="nhsuk-back-link"
>
<a
class="nhsuk-back-link__link"
href="/templates/message-templates"
id="back-link"
>
<svg
aria-hidden="true"
class="nhsuk-icon nhsuk-icon__chevron-left"
height="24"
viewBox="0 0 24 24"
width="24"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M8.5 12c0-.3.1-.5.3-.7l5-5c.4-.4 1-.4 1.4 0s.4 1 0 1.4L10.9 12l4.3 4.3c.4.4.4 1 0 1.4s-1 .4-1.4 0l-5-5c-.2-.2-.3-.4-.3-.7z"
/>
</svg>
Back to all templates
</a>
</div>
<main
class="nhsuk-main-wrapper"
id="maincontent"
role="main"
>
<div
class="nhsuk-grid-row"
>
<div
class="nhsuk-grid-column-full"
>
<h1
class="preview__heading"
data-testid="preview-message__heading"
>
letter
</h1>
<div
class="nhsuk-width-container nhsuk-u-margin-bottom-6 nhsuk-body-m"
>
<dl
class="nhsuk-summary-list nhsuk-u-margin-bottom-4 preview"
>
<div
class="nhsuk-summary-list__row"
>
<dt
class="nhsuk-summary-list__key"
>
Template ID
</dt>
<dd
class="nhsuk-summary-list__value"
>
53525D03-1BC1-4563-ABF9-A74FF04142AF
</dd>
</div>
<div
class="nhsuk-summary-list__row"
>
<dt
class="nhsuk-summary-list__key"
>
Type
</dt>
<dd
class="nhsuk-summary-list__value"
>
British Sign Language letter - Arabic
</dd>
</div>
<div
class="nhsuk-summary-list__row"
>
<dt
class="nhsuk-summary-list__key"
>
Status
</dt>
<dd
class="nhsuk-summary-list__value"
>
<strong
class="nhsuk-tag"
>
Files uploaded
</strong>
</dd>
</div>
<div
class="nhsuk-summary-list__row"
>
<dt
class="nhsuk-summary-list__key"
>
Template file
</dt>
<dd
class="nhsuk-summary-list__value"
>
<div
class="container"
>
<svg
class="icon"
fill="none"
height="26"
viewBox="0 0 20 26"
width="20"
xmlns="http://www.w3.org/2000/svg"
>
<path
d="M0 0V26H20V6.59375L19.7188 6.28125L13.7188 0.28125L13.4062 0H0ZM2 2H12V8H18V24H2V2ZM14 3.4375L16.5625 6H14V3.4375Z"
fill="#4C6272"
/>
</svg>
<p
class="text"
>
file.pdf
</p>
</div>
</dd>
</div>
</dl>
</div>
<a
aria-disabled="false"
class="nhsuk-button"
data-testid="preview-letter-template-cta"
draggable="false"
href="/templates/submit-letter-template/53525D03-1BC1-4563-ABF9-A74FF04142AF"
id="preview-letter-template-cta"
role="button"
>
Request a proof
</a>
<p>
<a
href="/message-templates"
>
Back to all templates
</a>
</p>
</div>
</div>
</main>
</DocumentFragment>
`;

exports[`PreviewLetterTemplate component matches snapshot when template status is VIRUS_SCAN_FAILED 1`] = `
<DocumentFragment>
<div
Expand Down Expand Up @@ -289,10 +444,10 @@ exports[`PreviewLetterTemplate component matches snapshot when template status i
<a
aria-disabled="false"
class="nhsuk-button"
data-testid="submit-button"
data-testid="preview-letter-template-cta"
draggable="false"
href="/templates/submit-letter-template/template-id"
id="preview-letter-template-submit-button"
id="preview-letter-template-cta"
role="button"
>
Submit template
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,13 @@ import { NHSNotifyButton } from '@atoms/NHSNotifyButton/NHSNotifyButton';
export function PreviewLetterTemplate({
template,
}: Readonly<{ template: LetterTemplate }>) {
const { backLinkText, buttonText } = content.components.previewLetterTemplate;
const { backLinkText, submitText, requestProofText } =
content.components.previewLetterTemplate;
const buttonText =
template.templateStatus === 'PENDING_PROOF_REQUEST'
? requestProofText
: submitText;

const basePath = getBasePath();

return (
Expand All @@ -25,8 +31,8 @@ export function PreviewLetterTemplate({
<div className='nhsuk-grid-column-full'>
<PreviewTemplateDetails.Letter template={template} />
<NHSNotifyButton
data-testid='submit-button'
id='preview-letter-template-submit-button'
data-testid='preview-letter-template-cta'
id='preview-letter-template-cta'
href={`${basePath}/submit-letter-template/${template.id}`}
>
{buttonText}
Expand Down
3 changes: 2 additions & 1 deletion frontend/src/content/content.ts
Original file line number Diff line number Diff line change
Expand Up @@ -244,7 +244,8 @@ const previewEmailTemplate = {
const previewLetterTemplate = {
pageTitle: generatePageTitle('Preview letter template'),
backLinkText: backToAllTemplates,
buttonText: 'Submit template',
submitText: 'Submit template',
requestProofText: 'Request a proof',
};

const previewNHSAppTemplate = {
Expand Down
1 change: 1 addition & 0 deletions infrastructure/terraform/components/app/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
| <a name="input_enable_cognito_built_in_idp"></a> [enable\_cognito\_built\_in\_idp](#input\_enable\_cognito\_built\_in\_idp) | Enable the use of Cognito as an IDP; CIS2 is prefered | `bool` | `false` | no |
| <a name="input_enable_event_caching"></a> [enable\_event\_caching](#input\_enable\_event\_caching) | Enable caching of events to an S3 bucket | `bool` | `true` | no |
| <a name="input_enable_letters"></a> [enable\_letters](#input\_enable\_letters) | Feature flag for letters | `string` | `false` | no |
| <a name="input_enable_proofing"></a> [enable\_proofing](#input\_enable\_proofing) | Feature flag for proofing | `string` | `false` | no |
| <a name="input_environment"></a> [environment](#input\_environment) | The name of the tfscaffold environment | `string` | n/a | yes |
| <a name="input_event_delivery_logging"></a> [event\_delivery\_logging](#input\_event\_delivery\_logging) | Enable SNS Event Delivery logging | `bool` | `true` | no |
| <a name="input_event_delivery_logging_success_sample_percentage"></a> [event\_delivery\_logging\_success\_sample\_percentage](#input\_event\_delivery\_logging\_success\_sample\_percentage) | Enable caching of events to an S3 bucket | `number` | `0` | no |
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,5 +19,6 @@ module "backend_api" {
enable_backup = var.destination_vault_arn != null ? true : false

enable_letters = var.enable_letters
enable_proofing = var.enable_proofing
letter_suppliers = var.letter_suppliers
}
6 changes: 6 additions & 0 deletions infrastructure/terraform/components/app/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -188,6 +188,12 @@ variable "enable_letters" {
default = false
}

variable "enable_proofing" {
type = string
description = "Feature flag for proofing"
default = false
}

variable "observability_account_id" {
type = string
description = "The Observability Account ID that needs access"
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ module "backend_api" {
}

enable_letters = true
enable_proofing = false
letter_suppliers = var.letter_suppliers

kms_key_arn = data.aws_kms_key.sandbox.arn
Expand Down
1 change: 1 addition & 0 deletions infrastructure/terraform/modules/backend-api/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ No requirements.
| <a name="input_dynamodb_kms_key_arn"></a> [dynamodb\_kms\_key\_arn](#input\_dynamodb\_kms\_key\_arn) | KMS Key ARN for encrypting DynamoDB data. If not given, a key will be created. | `string` | `""` | no |
| <a name="input_enable_backup"></a> [enable\_backup](#input\_enable\_backup) | Enable Backups for the DynamoDB table? | `bool` | `true` | no |
| <a name="input_enable_letters"></a> [enable\_letters](#input\_enable\_letters) | Enable letters feature flag | `bool` | n/a | yes |
| <a name="input_enable_proofing"></a> [enable\_proofing](#input\_enable\_proofing) | Enable proofing feature flag | `bool` | n/a | yes |
| <a name="input_environment"></a> [environment](#input\_environment) | The name of the tfscaffold environment | `string` | n/a | yes |
| <a name="input_group"></a> [group](#input\_group) | The group variables are being inherited from (often synonmous with account short-name) | `string` | n/a | yes |
| <a name="input_kms_key_arn"></a> [kms\_key\_arn](#input\_kms\_key\_arn) | KMS Key ARN | `string` | n/a | yes |
Expand Down
1 change: 1 addition & 0 deletions infrastructure/terraform/modules/backend-api/locals.tf
Original file line number Diff line number Diff line change
Expand Up @@ -44,6 +44,7 @@ locals {
TEMPLATES_INTERNAL_BUCKET_NAME = module.s3bucket_internal.id
TEMPLATES_QUARANTINE_BUCKET_NAME = module.s3bucket_quarantine.id
TEMPLATES_TABLE_NAME = aws_dynamodb_table.templates.name
ENABLE_PROOFING = var.enable_proofing
}

dynamodb_kms_key_arn = var.dynamodb_kms_key_arn == "" ? aws_kms_key.dynamo[0].arn : var.dynamodb_kms_key_arn
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -504,6 +504,7 @@
"DELETED",
"NOT_YET_SUBMITTED",
"PENDING_UPLOAD",
"PENDING_PROOF_REQUEST",
"PENDING_VALIDATION",
"SUBMITTED",
"VALIDATION_FAILED",
Expand Down
5 changes: 5 additions & 0 deletions infrastructure/terraform/modules/backend-api/variables.tf
Original file line number Diff line number Diff line change
Expand Up @@ -76,6 +76,11 @@ variable "enable_letters" {
description = "Enable letters feature flag"
}

variable "enable_proofing" {
type = bool
description = "Enable proofing feature flag"
}

variable "kms_key_arn" {
type = string
description = "KMS Key ARN"
Expand Down
Loading
Loading