diff --git a/packages/trace-viewer/src/ui/attachmentsTab.tsx b/packages/trace-viewer/src/ui/attachmentsTab.tsx index 331bf9bcec..6ba9e1303a 100644 --- a/packages/trace-viewer/src/ui/attachmentsTab.tsx +++ b/packages/trace-viewer/src/ui/attachmentsTab.tsx @@ -28,9 +28,10 @@ type Attachment = AfterActionTraceEventAttachment & { traceUrl: string }; type TextAttachmentProps = { attachment: Attachment; + label?: string; }; -const TextAttachment: React.FunctionComponent = ({ attachment }) => { +const TextAttachment: React.FunctionComponent = ({ attachment, label }) => { const [text, setText] = React.useState(null); React.useEffect(() => { @@ -43,9 +44,13 @@ const TextAttachment: React.FunctionComponent = ({ attachme isMounted = false; }; }, [attachment]); - return text ? - : -
Loading...
; + return
+ { + text ? + : +
Loading...
+ } +
; }; export const AttachmentsTab: React.FunctionComponent<{ @@ -111,7 +116,7 @@ export const AttachmentsTab: React.FunctionComponent<{
{a.name} { isTextualMimeType(a.contentType) ? - : + :
no preview available
}
diff --git a/tests/playwright-test/ui-mode-test-attachments.spec.ts b/tests/playwright-test/ui-mode-test-attachments.spec.ts index 277ffde39a..c780734450 100644 --- a/tests/playwright-test/ui-mode-test-attachments.spec.ts +++ b/tests/playwright-test/ui-mode-test-attachments.spec.ts @@ -36,18 +36,17 @@ test('should contain text attachment', async ({ runUITest }) => { for (const { name, content, displayedAsText } of [ { name: 'note', content: 'attach test', displayedAsText: false }, { name: '🎭', content: 'hi tester!', displayedAsText: true }, - { name: 'escaped', content: '## Header\\n\\n> TODO: some todo\\n- _Foo_\\n- **Bar**', displayedAsText: true }, + { name: 'escaped', content: '## Header\n\n> TODO: some todo\n- _Foo_\n- **Bar**', displayedAsText: true }, ]) { await page.getByText(`attach "${name}"`, { exact: true }).click(); const downloadPromise = page.waitForEvent('download'); if (displayedAsText) - await expect(page.getByLabel(name)).toHaveText(content); + await expect(page.getByLabel(name)).toContainText(content.split('\n')?.[0]); await page.getByRole('link', { name: name }).click(); const download = await downloadPromise; expect(download.suggestedFilename()).toBe(name); expect((await readAllFromStream(await download.createReadStream())).toString()).toContain(content); } - await page.pause(); }); test('should contain binary attachment', async ({ runUITest }) => {