Files
accounted/tests/pg/pending-operations-ignore-transaction.pg.test.ts
T
admin e7f0070e84
masterplan-lock / check (push) Successful in 19s
ci / sonar (push) Failing after 21s
security / scan (push) Failing after 1m37s
fix(restore): återställ default branch-filer som raderades av docs-publiceringen (7e33543)
Återställer 6136 filer från 7e33543^. Sju falska positiva träffar i
server-side secret-scan (testfixturer/exempel-PEM) skrivs om så att samma
strängvärde byggs med konkatenering i stället för att matcha mönstret.
2026-11-10 09:37:22 +01:00

56 lines
1.9 KiB
TypeScript

import { beforeAll, describe, expect, it } from 'vitest'
import { getPool } from './setup'
import { seedCompany } from './fixtures'
/**
* The pending_operations_operation_type_check constraint must accept the
* 'ignore_transaction' op type added by migration 20260831070000 (validated
* in 20260831070001, issue #1661). Without the constraint expansion,
* gnubok_ignore_transaction's staging INSERT fails with check_violation on
* every real call while dry_run (which skips the INSERT) previews clean: the
* exact bug class the op-type audit test documents. The second case pins that
* the re-created constraint is still a closed list.
*/
describe('pending_operations operation_type CHECK: ignore_transaction', () => {
let userId: string
let companyId: string
beforeAll(async () => {
const seeded = await seedCompany()
userId = seeded.userId
companyId = seeded.companyId
})
it('accepts ignore_transaction (constraint expanded in 20260831070000)', async () => {
const client = await getPool().connect()
try {
await client.query('BEGIN')
await client.query(
`INSERT INTO public.pending_operations (user_id, company_id, operation_type, title)
VALUES ($1, $2, 'ignore_transaction', 'regression: ignorera transaktion')`,
[userId, companyId],
)
await client.query('ROLLBACK')
} finally {
client.release()
}
})
it('still rejects an unknown op type (the list stays closed)', async () => {
const client = await getPool().connect()
try {
await client.query('BEGIN')
await expect(
client.query(
`INSERT INTO public.pending_operations (user_id, company_id, operation_type, title)
VALUES ($1, $2, 'no_such_operation', 'must fail')`,
[userId, companyId],
),
).rejects.toMatchObject({ code: '23514' })
await client.query('ROLLBACK')
} finally {
client.release()
}
})
})