test+fix(docs): correct fallbackLabel when sort prop is omitted
Add failing test for DATE-sort + undated doc showing "Undatiert" fallback label, then fix DocumentList by null-coalescing sort before comparison ((sort ?? 'DATE') === 'DATE'). Test uses one dated + one undated doc to produce two groups and trigger GroupDivider rendering. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -30,7 +30,9 @@ let {
|
|||||||
sort?: string;
|
sort?: string;
|
||||||
} = $props();
|
} = $props();
|
||||||
|
|
||||||
const fallbackLabel = $derived(sort === 'DATE' ? m.docs_group_undated() : m.docs_group_unknown());
|
const fallbackLabel = $derived(
|
||||||
|
(sort ?? 'DATE') === 'DATE' ? m.docs_group_undated() : m.docs_group_unknown()
|
||||||
|
);
|
||||||
const groupedDocuments = $derived.by(() =>
|
const groupedDocuments = $derived.by(() =>
|
||||||
groupDocuments(documents, sort ?? 'DATE', fallbackLabel)
|
groupDocuments(documents, sort ?? 'DATE', fallbackLabel)
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -90,6 +90,15 @@ describe('DocumentList – group headers', () => {
|
|||||||
await expect.element(page.getByTestId('group-divider')).not.toBeInTheDocument();
|
await expect.element(page.getByTestId('group-divider')).not.toBeInTheDocument();
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('shows Undatiert fallback label when sort is undefined and doc has no date', async () => {
|
||||||
|
const documents = [
|
||||||
|
makeDoc({ id: '1', documentDate: '1938-01-01' }),
|
||||||
|
makeDoc({ id: '2', documentDate: null })
|
||||||
|
];
|
||||||
|
render(DocumentList, { ...baseProps, documents, total: 2 }); // sort omitted — defaults to DATE grouping
|
||||||
|
await expect.element(page.getByText(/UNDATIERT/i)).toBeInTheDocument();
|
||||||
|
});
|
||||||
|
|
||||||
it('a doc with two receivers appears in both receiver groups', async () => {
|
it('a doc with two receivers appears in both receiver groups', async () => {
|
||||||
const documents = [
|
const documents = [
|
||||||
makeDoc({
|
makeDoc({
|
||||||
|
|||||||
Reference in New Issue
Block a user