mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-27 06:13:06 +00:00
Add CAS opt-in on vote pledge estimates: without baseEstimatedAt keep last-write-wins; with a stale base refuse the write and stamp the server estimatedAt for the outbox conflict toast. Co-authored-by: Francisco Solla <fsolla@users.noreply.github.com>
29 lines
1.1 KiB
TypeScript
29 lines
1.1 KiB
TypeScript
import { describe, expect, it } from 'vitest'
|
|
|
|
import {
|
|
isOpsEstimateConflictMessage,
|
|
OPS_ESTIMATE_CONFLICT_MESSAGE,
|
|
opsEstimateConflictError,
|
|
parseOpsEstimateConflictServerEstimatedAt,
|
|
} from '@/lib/schemas/votePledge'
|
|
|
|
describe('opsEstimateConflict helpers (OH6)', () => {
|
|
it('round-trips a stamped server estimatedAt through the error message', () => {
|
|
const stamped = opsEstimateConflictError('2026-08-01T12:00:00.000Z')
|
|
expect(isOpsEstimateConflictMessage(stamped.message)).toBe(true)
|
|
expect(parseOpsEstimateConflictServerEstimatedAt(stamped.message)).toBe(
|
|
'2026-08-01T12:00:00.000Z',
|
|
)
|
|
})
|
|
|
|
it('keeps the bare conflict message exact for safeMessages matching', () => {
|
|
const bare = opsEstimateConflictError(null)
|
|
expect(bare.message).toBe(OPS_ESTIMATE_CONFLICT_MESSAGE)
|
|
expect(parseOpsEstimateConflictServerEstimatedAt(bare.message)).toBeNull()
|
|
})
|
|
|
|
it('rejects unrelated messages', () => {
|
|
expect(isOpsEstimateConflictMessage('outro erro')).toBe(false)
|
|
expect(parseOpsEstimateConflictServerEstimatedAt('outro erro')).toBeNull()
|
|
})
|
|
})
|