handle duplicate attachment names
This commit is contained in:
parent
03082bdb0e
commit
2cb9c525de
|
|
@ -163,10 +163,12 @@ 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>
|
||||
<span style={{ float: 'right' }}>{msToString(step.duration)}</span>
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
|
|
|
|||
Loading…
Reference in a new issue