// FE-ATLAS2-DATA-080 to FE-ATLAS2-DATA-082: the replay rules both write queues share. import { describe, expect, it } from 'vitest'; import { BUILD_VERSION, isRetryableStatus, MAX_SERVER_ERROR_ATTEMPTS, SERVER_ERROR_BACKOFF_MS, STUCK_SYNCING_MS, } from './queuePolicy'; describe('queuePolicy', () => { it('FE-ATLAS2-DATA-080: only an expired login, a timeout, too-early and rate limiting are worth waiting out', () => { for (const status of [401, 408, 425, 429]) expect(isRetryableStatus(status)).toBe(true); for (const status of [undefined, 200, 400, 403, 404, 409, 422, 500, 503]) expect(isRetryableStatus(status)).toBe(false); }); it('FE-ATLAS2-DATA-081: the gap doubles from 30 s up to 32 minutes before the last server-error try', () => { expect(MAX_SERVER_ERROR_ATTEMPTS).toBe(8); expect(SERVER_ERROR_BACKOFF_MS).toBe(30_000); const lastGap = SERVER_ERROR_BACKOFF_MS * 2 ** (MAX_SERVER_ERROR_ATTEMPTS - 2); expect(lastGap).toBe(32 * 60_000); expect(STUCK_SYNCING_MS).toBe(60_000); }); it('FE-ATLAS2-DATA-082: the build stamp is a string, empty where the bundler defined none', () => { expect(typeof BUILD_VERSION).toBe('string'); }); });