| 1 | import assert from "node:assert/strict"; |
| 2 | import React from "react"; |
| 3 | import { renderToStaticMarkup } from "react-dom/server"; |
| 4 | import { LocaleProvider } from "../lib/i18n"; |
| 5 | import { PresentedFiles } from "../components/PresentedFiles"; |
| 6 | import type { PresentedFileView } from "../lib/chatViewSource"; |
| 7 | |
| 8 | const files: PresentedFileView[] = Array.from({ length: 5 }, (_, index) => ({ |
| 9 | path: `output/file-${index + 1}.html`, |
| 10 | description: `Preview ${index + 1}`, |
| 11 | toolCallId: `present-${index + 1}`, |
| 12 | })); |
| 13 | |
| 14 | const markup = renderToStaticMarkup( |
| 15 | <LocaleProvider><PresentedFiles files={files} tabId="tab-1" /></LocaleProvider>, |
| 16 | ); |
| 17 | |
| 18 | assert.equal((markup.match(/class="presented-file"/g) ?? []).length, 4); |
| 19 | assert.match(markup, /file-1\.html/); |
| 20 | assert.doesNotMatch(markup, /file-5\.html/); |
| 21 | assert.match(markup, /5/); |
| 22 | console.log("presented files UI: four-card collapsed grid passed"); |
| 23 |