mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-12 22:13:05 +00:00
queueMicrotask under req.transactionID raced withPayloadTransaction commit. Register after-commit callbacks, soft-fail missing notification rows on send, and pin the schedule with a convention unit spec.
28 lines
1.2 KiB
TypeScript
28 lines
1.2 KiB
TypeScript
import { readFileSync } from 'node:fs'
|
|
import { resolve } from 'node:path'
|
|
import { describe, expect, it } from 'vitest'
|
|
|
|
// Pass 5 P1: notification push must not be scheduled with `queueMicrotask` while
|
|
// the create still rides `req.transactionID` — microtasks flush before
|
|
// `withPayloadTransaction` commits. The create module must route txn-bound
|
|
// sends through `onPayloadTransactionCommit`.
|
|
describe('notification push schedule (Pass 5 P1)', () => {
|
|
const source = readFileSync(
|
|
resolve(process.cwd(), 'src/utilities/notification/createCampaignNotification.ts'),
|
|
'utf8',
|
|
)
|
|
|
|
it('registers push on withPayloadTransaction commit when a transactionID is present', () => {
|
|
expect(source).toMatch(/onPayloadTransactionCommit\s*\(/)
|
|
expect(source).toMatch(/req\?\.transactionID/)
|
|
})
|
|
|
|
it('does not schedule sendCampaignPush via queueMicrotask unconditionally', () => {
|
|
// Unconditional microtask around send was the P1 bug. A microtask only on
|
|
// the no-transaction branch remains allowed; the send call must not appear
|
|
// as the sole queueMicrotask body without a transactionID guard above it.
|
|
expect(source).not.toMatch(
|
|
/queueMicrotask\s*\(\s*\(\)\s*=>\s*\{\s*void sendCampaignPushForNotification/,
|
|
)
|
|
})
|
|
})
|