diff --git a/tests/int/campaignInvite.int.spec.ts b/tests/int/campaignInvite.int.spec.ts index d408efb2..a3a9b74a 100644 --- a/tests/int/campaignInvite.int.spec.ts +++ b/tests/int/campaignInvite.int.spec.ts @@ -611,10 +611,12 @@ describe('campaign invite domain', () => { const actions = await import('@/app/(campaign)/campanha/actions/invite').catch(() => null) expect(actions).not.toBeNull() - await payload.delete({ - collection: 'consent', - where: { key: { equals: 'lideranca-autopreenchimento' } }, - }) + // Harness purge (Onda0-provision / lease precedent): raw SQL so the + // admin-path beforeDelete guard and access checks never apply to this + // lifecycle setup — the window lease already guarantees isolation. + await payload.db.drizzle.execute( + sql`DELETE FROM "consent" WHERE "key" = ${'lideranca-autopreenchimento'}`, + ) const coordinator = await campaignFixtures().createCampaignUser('coordinator') const municipality = await campaignFixtures().getMunicipality() const { leadership } = await createInviteLeadershipGraph(coordinator, municipality.id) diff --git a/tests/int/campaignSupporter.int.spec.ts b/tests/int/campaignSupporter.int.spec.ts index 3ba7ee4a..96432978 100644 --- a/tests/int/campaignSupporter.int.spec.ts +++ b/tests/int/campaignSupporter.int.spec.ts @@ -212,6 +212,17 @@ describe('campaign supporter domain', () => { limit: 1, }) if (existingVoteConsent.docs[0]) { + // S9+: Consent.beforeDelete refuses deleting an in-use legal text. The + // minimal seed links seeded supporters to this canonical consent, so + // detach the live voteIntentionConsent references FIRST — the explicit, + // ordered version of the FK `ON DELETE SET NULL` this purge relied on + // silently before the guard existed. + await payload.update({ + collection: 'supporter', + where: { voteIntentionConsent: { equals: existingVoteConsent.docs[0].id } }, + data: { voteIntentionConsent: null }, + overrideAccess: true, + }) await payload.delete({ collection: 'consent', id: existingVoteConsent.docs[0].id,