fieldlens-deploy/apps/web/src/sync.test.ts
Admin c858f4e252
Some checks failed
CI / verify (push) Has been cancelled
fix: sync scans immediately and mark acknowledgements
2026-09-23 09:44:08 +00:00

22 lines
940 B
TypeScript

import { readFile } from 'node:fs/promises'
import { fileURLToPath } from 'node:url'
import { describe, expect, it } from 'vitest'
describe('sync contract', () => {
it('does not treat browser connectivity state as proof that the API is reachable', async () => {
const source = await readFile(fileURLToPath(new URL('./sync.ts', import.meta.url)), 'utf8')
expect(source).not.toContain('navigator.onLine')
expect(source).toContain("window.addEventListener('online'")
expect(source).toContain("document.addEventListener('visibilitychange'")
})
it('reacts immediately to local capture events and coalesces concurrent sync requests', async () => {
const source = await readFile(fileURLToPath(new URL('./sync.ts', import.meta.url)), 'utf8')
expect(source).toContain('FIELDLENS_SYNC_REQUEST_EVENT')
expect(source).toContain('syncRequested = true')
expect(source).toContain('while (syncRequested)')
})
})