Skip to content

Commit

Permalink
Fix test
Browse files Browse the repository at this point in the history
  • Loading branch information
timfish committed Dec 18, 2024
1 parent 5e5fe04 commit 47a8b0b
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 54 deletions.

This file was deleted.

This file was deleted.

29 changes: 29 additions & 0 deletions packages/browser/test/transports/offline.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ describe('makeOfflineTransport', () => {
await deleteDatabase('sentry');
(global as any).TextEncoder = TextEncoder;
(global as any).TextDecoder = TextDecoder;
(global as any).addEventListener = () => {};
});

it('indexedDb wrappers push, unshift and pop', async () => {
Expand Down Expand Up @@ -115,4 +116,32 @@ describe('makeOfflineTransport', () => {
expect(queuedCount).toEqual(1);
expect(getSendCount()).toEqual(2);
});

it('flush forces retry', async () => {
const { getSendCount, baseTransport } = createTestTransport(new Error(), { statusCode: 200 }, { statusCode: 200 });
let queuedCount = 0;
const transport = makeBrowserOfflineTransport(baseTransport)({
...transportOptions,
shouldStore: () => {
queuedCount += 1;
return true;
},
url: 'http://localhost',
});
const result = await transport.send(ERROR_ENVELOPE);

expect(result).toEqual({});

await delay(MIN_DELAY * 2);

expect(getSendCount()).toEqual(0);
expect(queuedCount).toEqual(1);

await transport.flush();

await delay(MIN_DELAY * 2);

expect(queuedCount).toEqual(1);
expect(getSendCount()).toEqual(1);
});
});

0 comments on commit 47a8b0b

Please sign in to comment.