Skip to content

Commit c1ad34f

Browse files
authored
CCM-10387: client ownership (#620)
1 parent e8524fc commit c1ad34f

File tree

76 files changed

+1965
-813
lines changed

Some content is hidden

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

76 files changed

+1965
-813
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@ node_modules
2525

2626
# testing
2727
/coverage
28+
acceptance-test-report
2829

2930
# next.js
3031
/.next/

frontend/src/__tests__/components/molecules/PreviewTemplateDetails.test.tsx

Lines changed: 1 addition & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -132,7 +132,7 @@ describe('PreviewTemplateDetailsLetter', () => {
132132
<PreviewTemplateDetailsLetter
133133
template={{
134134
id: 'template-id',
135-
owner: 'owner',
135+
clientId: 'client-id',
136136
name: 'Example letter',
137137
templateStatus: 'PROOF_AVAILABLE',
138138
templateType: 'LETTER',
@@ -201,42 +201,4 @@ describe('PreviewTemplateDetailsLetter', () => {
201201

202202
expect(container.asFragment()).toMatchSnapshot();
203203
});
204-
205-
it('If the template is client-owned, the clientId is used to construct download link', () => {
206-
const { getByTestId } = render(
207-
<PreviewTemplateDetailsLetter
208-
template={{
209-
createdAt: '2025-01-13T10:19:25.579Z',
210-
files: {
211-
pdfTemplate: {
212-
fileName: 'file.pdf',
213-
currentVersion: '4C728B7D-A028-4BA2-B180-A63CDD2AE1E9',
214-
virusScanStatus: 'PASSED',
215-
},
216-
proofs: {
217-
'a.pdf': {
218-
fileName: 'a.pdf',
219-
virusScanStatus: 'PASSED',
220-
supplier: 'MBA',
221-
},
222-
},
223-
},
224-
id: 'template-id',
225-
language: 'en',
226-
letterType: 'x0',
227-
name: 'Example letter',
228-
owner: 'CLIENT#client',
229-
templateStatus: 'PROOF_AVAILABLE',
230-
templateType: 'LETTER',
231-
updatedAt: '2025-01-13T10:19:25.579Z',
232-
}}
233-
/>
234-
);
235-
236-
const link = getByTestId('proof-link_a.pdf');
237-
expect(link).toHaveAttribute(
238-
'href',
239-
'/templates/files/client/proofs/template-id/a.pdf'
240-
);
241-
});
242204
});

frontend/src/__tests__/components/molecules/ViewLetterTemplate.test.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ describe('ViewLetterTemplate component', () => {
1010
{
1111
templateType: 'LETTER',
1212
id: 'template-id',
13-
owner: 'owner',
13+
clientId: 'client-id',
1414
name: 'Example template',
1515
templateStatus: 'SUBMITTED',
1616
createdAt: '2025-03-28T12:30:54.684Z',

frontend/src/__tests__/components/molecules/__snapshots__/PreviewTemplateDetails.test.tsx.snap

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -376,7 +376,7 @@ exports[`PreviewTemplateDetailsLetter matches snapshot when proofs are present,
376376
<li>
377377
<a
378378
data-testid="proof-link_a.pdf"
379-
href="/templates/files/owner/proofs/template-id/a.pdf"
379+
href="/templates/files/client-id/proofs/template-id/a.pdf"
380380
rel="noopener noreferrer"
381381
target="_blank"
382382
>
@@ -408,7 +408,7 @@ exports[`PreviewTemplateDetailsLetter matches snapshot when proofs are present,
408408
<li>
409409
<a
410410
data-testid="proof-link_b.pdf"
411-
href="/templates/files/owner/proofs/template-id/b.pdf"
411+
href="/templates/files/client-id/proofs/template-id/b.pdf"
412412
rel="noopener noreferrer"
413413
target="_blank"
414414
>

frontend/src/__tests__/components/molecules/__snapshots__/ViewLetterTemplate.test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@ exports[`ViewLetterTemplate component matches submitted snapshot 1`] = `
152152
<li>
153153
<a
154154
data-testid="proof-link_supplier-proof.pdf"
155-
href="/templates/files/owner/proofs/template-id/supplier-proof.pdf"
155+
href="/templates/files/client-id/proofs/template-id/supplier-proof.pdf"
156156
rel="noopener noreferrer"
157157
target="_blank"
158158
>

frontend/src/__tests__/components/organisms/PreviewLetterTemplate.test.tsx

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ describe('PreviewLetterTemplate component', () => {
9999
<PreviewLetterTemplate
100100
template={{
101101
id: '2C56C5F6-B3AD-4FF8-A8A2-52E4FA8AF2BE',
102-
owner: 'owner',
102+
clientId: 'client-id',
103103
name: 'letter',
104104
templateType: 'LETTER',
105105
templateStatus: 'PROOF_AVAILABLE',
@@ -134,7 +134,6 @@ describe('PreviewLetterTemplate component', () => {
134134
<PreviewLetterTemplate
135135
template={{
136136
id: '0A097DCD-35F9-4DAD-A37E-AC358B71B74D',
137-
owner: 'owner',
138137
name: 'letter',
139138
templateType: 'LETTER',
140139
templateStatus: 'NOT_YET_SUBMITTED',
@@ -259,7 +258,6 @@ describe('PreviewLetterTemplate component', () => {
259258
<PreviewLetterTemplate
260259
template={{
261260
id: '0A097DCD-35F9-4DAD-A37E-AC358B71B74D',
262-
owner: 'owner',
263261
name: 'letter',
264262
templateType: 'LETTER',
265263
templateStatus: 'NOT_YET_SUBMITTED',

frontend/src/__tests__/components/organisms/__snapshots__/PreviewLetterTemplate.test.tsx.snap

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -938,7 +938,7 @@ exports[`PreviewLetterTemplate component matches snapshot when template status i
938938
<li>
939939
<a
940940
data-testid="proof-link_your-proof.pdf"
941-
href="/templates/files/owner/proofs/2C56C5F6-B3AD-4FF8-A8A2-52E4FA8AF2BE/your-proof.pdf"
941+
href="/templates/files/client-id/proofs/2C56C5F6-B3AD-4FF8-A8A2-52E4FA8AF2BE/your-proof.pdf"
942942
rel="noopener noreferrer"
943943
target="_blank"
944944
>

frontend/src/components/molecules/PreviewTemplateDetails/PreviewTemplateDetailsLetter.tsx

Lines changed: 2 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,6 @@ import concatClassNames from '@utils/concat-class-names';
1212

1313
const { rowHeadings } = content.components.previewTemplateDetails;
1414

15-
const clientOwnerPrefix = 'CLIENT#';
16-
1715
export default function PreviewTemplateDetailsLetter({
1816
template,
1917
}: {
@@ -27,12 +25,7 @@ export default function PreviewTemplateDetailsLetter({
2725
proofFilenames.length > 0 &&
2826
(template.templateStatus === 'PROOF_AVAILABLE' ||
2927
template.templateStatus === 'SUBMITTED') &&
30-
template.owner;
31-
32-
const proofOwner =
33-
template.owner && template.owner.startsWith(clientOwnerPrefix)
34-
? template.owner.slice(clientOwnerPrefix.length)
35-
: template.owner;
28+
template.clientId;
3629

3730
return (
3831
<>
@@ -77,7 +70,7 @@ export default function PreviewTemplateDetailsLetter({
7770
{proofFilenames.map((file) => (
7871
<li key={file}>
7972
<a
80-
href={`${getBasePath()}/files/${proofOwner}/proofs/${template.id}/${file}`}
73+
href={`${getBasePath()}/files/${template.clientId}/proofs/${template.id}/${file}`}
8174
target='_blank'
8275
rel='noopener noreferrer'
8376
data-testid={`proof-link_${file}`}

infrastructure/terraform/modules/backend-api/module_delete_template_lambda.tf

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,19 @@ data "aws_iam_policy_document" "delete_template_lambda_policy" {
4848
]
4949
}
5050

51+
statement {
52+
sid = "AllowDynamoGSIAccess"
53+
effect = "Allow"
54+
55+
actions = [
56+
"dynamodb:Query",
57+
]
58+
59+
resources = [
60+
"${aws_dynamodb_table.templates.arn}/index/QueryById",
61+
]
62+
}
63+
5164
statement {
5265
sid = "AllowKMSAccess"
5366
effect = "Allow"

infrastructure/terraform/modules/backend-api/module_lambda_process_proof.tf

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ data "aws_iam_policy_document" "process_proof" {
5050
aws_dynamodb_table.templates.arn,
5151
]
5252
}
53+
5354
statement {
5455
sid = "AllowDynamoGSIAccess"
5556
effect = "Allow"

0 commit comments

Comments
 (0)