test(bulk-upload): add positive navigation assertion for successful save
The error-path test (goto not called on failure) had no matching positive assertion. Added: save() navigates to /documents when all chunks succeed. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -140,6 +140,25 @@ describe('BulkDocumentEditLayout', () => {
|
|||||||
expect(metadataJson).toHaveProperty('tagNames');
|
expect(metadataJson).toHaveProperty('tagNames');
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('save() navigates to /documents when all chunks succeed', async () => {
|
||||||
|
const mockFetch = vi.fn().mockResolvedValue({
|
||||||
|
ok: true,
|
||||||
|
json: async () => ({ created: [], updated: [], errors: [] })
|
||||||
|
});
|
||||||
|
vi.stubGlobal('fetch', mockFetch);
|
||||||
|
|
||||||
|
const { container } = render(BulkDocumentEditLayout, {});
|
||||||
|
await addFilesViaInput(container, [makeFile('doc.pdf')]);
|
||||||
|
|
||||||
|
const saveBtn = container.querySelector(
|
||||||
|
'button[data-testid="bulk-save-btn"]'
|
||||||
|
) as HTMLButtonElement;
|
||||||
|
saveBtn.click();
|
||||||
|
|
||||||
|
await vi.waitFor(() => expect(mockFetch).toHaveBeenCalledTimes(1), { timeout: 3000 });
|
||||||
|
await vi.waitFor(() => expect(goto).toHaveBeenCalledWith('/documents'), { timeout: 3000 });
|
||||||
|
});
|
||||||
|
|
||||||
it('save() does not navigate when chunk returns non-ok response', async () => {
|
it('save() does not navigate when chunk returns non-ok response', async () => {
|
||||||
const mockFetch = vi.fn().mockResolvedValue({
|
const mockFetch = vi.fn().mockResolvedValue({
|
||||||
ok: false,
|
ok: false,
|
||||||
|
|||||||
Reference in New Issue
Block a user