handle duplicate attachment names

This commit is contained in:
Simon Knott 2024-10-10 12:19:14 +02:00
parent 03082bdb0e
commit 2cb9c525de
No known key found for this signature in database
GPG key ID: 8CEDC00028084AEC
2 changed files with 9 additions and 2 deletions

View file

@ -163,9 +163,11 @@ const StepTreeItem: React.FC<{
}> = ({ step, depth, attachments }) => {
if (step.category === 'attach') {
const attachmentName = step.title.match(/^attach "(.*)"$/)?.[1];
const attachment = attachments.find(a => a.name === attachmentName);
if (attachment)
const matchingAttachments = attachments.filter(a => a.name === attachmentName);
if (matchingAttachments.length === 1) {
const [attachment] = matchingAttachments;
return <AttachmentLink attachment={attachment} depth={depth} openInNewTab={getAttachmentCategory(attachment) === 'html'} />;
}
}
return <TreeItem title={<span>

View file

@ -892,6 +892,9 @@ for (const useIntermediateMergeReport of [false] as const) {
contentType: 'text/html',
body: Buffer.from('<h1>step attachment</h1>'),
});
await testInfo.attach('foo', { body: 'a' });
await testInfo.attach('foo', { body: 'b' });
});
});
`,
@ -908,6 +911,8 @@ for (const useIntermediateMergeReport of [false] as const) {
await testSteps.getByText('step with attachment').click();
await expect(testSteps.getByText('attach "foo"'), 'uses normal rendering when it cannot correlate by name').toHaveCount(2);
const [newTab] = await Promise.all([
page.waitForEvent('popup'),
testSteps.getByText('step-attachment.html').click(),