From 6329d3ae52f44d58fecdfcd8986d2aef8c63cd71 Mon Sep 17 00:00:00 2001 From: yudshj Date: Thu, 19 Nov 2026 16:51:52 +0800 Subject: [PATCH] Cover compaction summary content, fallback and tab title --- .../tests/summary-preview.client.spec.tsx | 27 +++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 packages/client/ui-sidebar-documentpreview/tests/summary-preview.client.spec.tsx diff --git a/packages/client/ui-sidebar-documentpreview/tests/summary-preview.client.spec.tsx b/packages/client/ui-sidebar-documentpreview/tests/summary-preview.client.spec.tsx new file mode 100644 index 0000000000..c77cc119d7 --- /dev/null +++ b/packages/client/ui-sidebar-documentpreview/tests/summary-preview.client.spec.tsx @@ -0,0 +1,27 @@ +// @vitest-environment jsdom +/** Summary tabs display only the Markdown supplied by the current navigation. */ +import { cleanup, render, screen } from '@testing-library/react' +import { afterEach, expect, it } from 'vitest' +import { SummaryPreview, SummaryTitle } from '../src/client/SummaryPreview.tsx' +import { harness, t } from './fixtures.client.ts' + +afterEach(cleanup) + +it('shows the recorded Markdown and names the region after the summary tab', () => { + const props = harness().props({ revision: 1, params: { summaryMarkdown: '## Recorded summary' } }) + render() + expect(screen.getByRole('region', { name: 'summary.title' }).contains( + screen.getByRole('heading', { name: 'Recorded summary', level: 2 }), + )).toBe(true) +}) + +it.each([undefined, { line: 1 }])('shows the expired state without summary content', (params) => { + render() + expect(screen.getByRole('status').textContent).toBe('summary.expired') +}) + +it('uses the localized title and Markdown glyph in the tab strip', () => { + const { container } = render() + expect(container.textContent).toBe('summary.title') + expect(container.querySelector('svg[width="16"] [data-file-type-mark]')).toBeTruthy() +})