Skip to content

Evenfire is an intelligence layer platform for running LLM agents that take real actions, on your infrastructure

TypeScript

fix(markdown): integrate stashed preview polish on top of GFM tables work

Med0cc738ad30
diff --git a/desktop-app/ui/src/components/GfsMarkdownPreview/GfsMarkdownPreview.test.tsx b/desktop-app/ui/src/components/GfsMarkdownPreview/GfsMarkdownPreview.test.tsx
new file mode 100644
index 000000000..3d06916df
--- /dev/null
+++ b/desktop-app/ui/src/components/GfsMarkdownPreview/GfsMarkdownPreview.test.tsx
@@ -0,0 +1,53 @@
+// @vitest-environment jsdom
+import { afterEach, describe, expect, it, vi } from 'vitest'
+import { cleanup, render, screen, within } from '@testing-library/react'
+import { GfsMarkdownPreviewBody } from '@components/GfsMarkdownPreview'
+
+function stubDownload(text: string) {
+ const downloadPreview = vi.fn(async () => ({ bytes: new TextEncoder().encode(text).buffer }))
+ Object.defineProperty(window, 'clerum', {
+ configurable: true,
+ value: { gfs: { downloadPreview } },
+ })
+ return downloadPreview
+}
+
+describe('GfsMarkdownPreview public barrel', () => {
+ afterEach(() => {
+ cleanup()
+ vi.restoreAllMocks()
+ })
+
+ it('renders GFM tables through the public import surface', async () => {
+ const markdown = [
+ '# Inventory',
+ '',
+ '| Item | Count |',
+ '| --- | ---: |',
+ '| **GFS files** | 12 |',
+ '',
+ '[Documentation](https://example.com/docs)',
+ '[Unsafe link](javascript:alert(1))',
+ ].join('\n')
+ const downloadPreview = stubDownload(markdown)
+
+ render(
+ <GfsMarkdownPreviewBody
+ byteLength={new TextEncoder().encode(markdown).byteLength}
+ fileName="inventory.md"
+ gfsUri="gfs://main/inventory"
+ />
+ )
+
+ const article = await screen.findByRole('article', {
+ name: 'Markdown preview of inventory.md',
+ })
+ const table = within(article).getByRole('table')
+ expect(within(table).getByRole('columnheader', { name: 'Item' }).getAttribute('scope')).toBe(
+ 'col'
+ )
+ expect(within(table).getByRole('cell', { name: 'GFS files' })).toBeTruthy()
+ expect(within(article).queryByRole('link', { name: 'Unsafe link' })).toBeNull()
+ expect(downloadPreview).toHaveBeenCalledWith('gfs://main/inventory', expect.any(Number))
+ })
+})