Import normalizer: offline tool to normalize the raw archive spreadsheets #663
@@ -394,51 +394,6 @@ describe('home page load — reader branch (isReader = !canWrite && !canAnnotate
|
|||||||
expect(result.isReader).toBe(false);
|
expect(result.isReader).toBe(false);
|
||||||
});
|
});
|
||||||
|
|
||||||
it('maps search result items directly to recentDocs without wrapping in a .document property', async () => {
|
|
||||||
const searchItem = {
|
|
||||||
id: 'd1',
|
|
||||||
title: 'Liebesbrief',
|
|
||||||
originalFilename: 'letter.pdf',
|
|
||||||
completionPercentage: 80,
|
|
||||||
receivers: [],
|
|
||||||
tags: [],
|
|
||||||
contributors: [],
|
|
||||||
matchData: { titleOffsets: [], senderMatched: false }
|
|
||||||
};
|
|
||||||
const mockGet = vi
|
|
||||||
.fn()
|
|
||||||
.mockResolvedValueOnce({ response: { ok: true, status: 200 }, data: [] }) // initial persons
|
|
||||||
.mockResolvedValueOnce({
|
|
||||||
response: { ok: true },
|
|
||||||
data: { totalDocuments: 1, totalPersons: 1 }
|
|
||||||
}) // stats
|
|
||||||
.mockResolvedValueOnce({ response: { ok: true }, data: [] }) // topPersons
|
|
||||||
.mockResolvedValueOnce({
|
|
||||||
response: { ok: true },
|
|
||||||
data: { items: [searchItem], totalElements: 1, pageNumber: 0, pageSize: 5, totalPages: 1 }
|
|
||||||
}) // search
|
|
||||||
.mockResolvedValueOnce({ response: { ok: true }, data: [] }); // stories
|
|
||||||
vi.mocked(createApiClient).mockReturnValue({ GET: mockGet } as ReturnType<
|
|
||||||
typeof createApiClient
|
|
||||||
>);
|
|
||||||
|
|
||||||
const result = await load({
|
|
||||||
url: makeUrl(),
|
|
||||||
request: new Request('http://localhost/'),
|
|
||||||
fetch: vi.fn() as unknown as typeof fetch,
|
|
||||||
parent: vi
|
|
||||||
.fn()
|
|
||||||
.mockResolvedValue({ canWrite: false, canAnnotate: false, canBlogWrite: false })
|
|
||||||
} as Parameters<typeof load>[0]);
|
|
||||||
|
|
||||||
expect(result.isReader).toBe(true);
|
|
||||||
if (result.isReader) {
|
|
||||||
expect(result.recentDocs).toHaveLength(1);
|
|
||||||
expect(result.recentDocs[0]).toBeDefined();
|
|
||||||
expect(result.recentDocs[0].id).toBe('d1');
|
|
||||||
}
|
|
||||||
});
|
|
||||||
|
|
||||||
it('returns topPersons=[] when topPersons fetch fails, rest of data still loads', async () => {
|
it('returns topPersons=[] when topPersons fetch fails, rest of data still loads', async () => {
|
||||||
const okStats = {
|
const okStats = {
|
||||||
response: { ok: true, status: 200 },
|
response: { ok: true, status: 200 },
|
||||||
|
|||||||
Reference in New Issue
Block a user