Add projects
This commit is contained in:
parent
2d3a9ad623
commit
8b607dd700
1802 changed files with 503346 additions and 2 deletions
40
frontend/tests/sponsorMutationRecovery.test.ts
Normal file
40
frontend/tests/sponsorMutationRecovery.test.ts
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
import { describe, expect, test, vi } from 'vitest';
|
||||
import {
|
||||
isSponsorPartialMutationError,
|
||||
runSponsorMutationWithRecovery,
|
||||
} from '../src/features/providers/sponsorMutationRecovery';
|
||||
|
||||
describe('sponsor mutation recovery', () => {
|
||||
test('refreshes after a failed multi-endpoint mutation and preserves the original failure', async () => {
|
||||
const originalError = new Error('Claude update failed');
|
||||
const refresh = vi.fn(async () => {});
|
||||
|
||||
let caught: unknown;
|
||||
try {
|
||||
await runSponsorMutationWithRecovery(async () => {
|
||||
throw originalError;
|
||||
}, refresh);
|
||||
} catch (error) {
|
||||
caught = error;
|
||||
}
|
||||
|
||||
expect(refresh).toHaveBeenCalledTimes(1);
|
||||
expect(isSponsorPartialMutationError(caught)).toBe(true);
|
||||
expect((caught as Error & { cause?: unknown }).cause).toBe(originalError);
|
||||
});
|
||||
|
||||
test('does not let a refresh failure replace the original mutation failure', async () => {
|
||||
const originalError = new Error('OpenAI update failed');
|
||||
|
||||
await expect(
|
||||
runSponsorMutationWithRecovery(
|
||||
async () => {
|
||||
throw originalError;
|
||||
},
|
||||
async () => {
|
||||
throw new Error('refresh failed');
|
||||
}
|
||||
)
|
||||
).rejects.toMatchObject({ cause: originalError });
|
||||
});
|
||||
});
|
||||
Loading…
Reference in a new issue