Skip to content

Commit 40f42d1

Browse files
authored
CCM-9923: add download bucket assertion to letter e2e test (#547)
1 parent 7eda0d2 commit 40f42d1

File tree

1 file changed

+26
-1
lines changed

1 file changed

+26
-1
lines changed

tests/test-team/template-mgmt-e2e-tests/template-mgmt-letter-full.e2e.spec.ts

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -182,7 +182,32 @@ test.describe('letter complete e2e journey', () => {
182182

183183
expect(pdfHrefs.length).toBeGreaterThan(0);
184184

185-
for (const href of pdfHrefs) expect(href).toContain(templateId);
185+
const downloadBucketMetadata = await Promise.all(
186+
pdfHrefs.map((href) => {
187+
const [, downloadBucketPath] =
188+
(href as string).match(
189+
// eslint-disable-next-line security/detect-non-literal-regexp
190+
new RegExp(
191+
`/templates/files/(${user.userId}/proofs/${templateId}/[^/]+)/?$`
192+
)
193+
) ?? [];
194+
195+
if (!downloadBucketPath) {
196+
throw new Error(
197+
`Could not determine bucket path based on URL: ${href}`
198+
);
199+
}
200+
201+
return templateStorageHelper.getS3Metadata(
202+
process.env.TEMPLATES_DOWNLOAD_BUCKET_NAME,
203+
downloadBucketPath
204+
);
205+
})
206+
);
207+
208+
for (const [i, entry] of downloadBucketMetadata.entries()) {
209+
expect(entry, JSON.stringify(pdfHrefs[i])).not.toBeNull();
210+
}
186211

187212
await previewTemplatePage.clickContinueButton();
188213
}).toPass({ timeout: 60_000 });

0 commit comments

Comments
 (0)