mirror of
https://github.com/fsolla/teqo.git
synced 2026-11-26 21:53:06 +00:00
test: pin campaignOps contract exports for knip
This commit is contained in:
parent
322d593758
commit
7fd1133843
1 changed files with 82 additions and 1 deletions
|
|
@ -5,14 +5,25 @@ import {
|
||||||
opsOutboxKey,
|
opsOutboxKey,
|
||||||
parseOpsSnapshot,
|
parseOpsSnapshot,
|
||||||
serializeOpsSnapshot,
|
serializeOpsSnapshot,
|
||||||
|
type OpsActivity,
|
||||||
|
type OpsCollectionKey,
|
||||||
|
type OpsDemand,
|
||||||
|
type OpsGoals,
|
||||||
|
type OpsLeadership,
|
||||||
|
type OpsLeadershipContact,
|
||||||
type OpsMunicipality,
|
type OpsMunicipality,
|
||||||
|
type OpsMunicipalityUpdate,
|
||||||
|
type OpsOrganization,
|
||||||
type OpsSnapshot,
|
type OpsSnapshot,
|
||||||
|
type OpsStateDeputy,
|
||||||
|
type OpsVoteEstimateScenarioFields,
|
||||||
type OpsVotePledge,
|
type OpsVotePledge,
|
||||||
type OpsVotePledgeLeaderView,
|
type OpsVotePledgeLeaderView,
|
||||||
} from '@/lib/campaignOps/opsContract'
|
} from '@/lib/campaignOps/opsContract'
|
||||||
import { resolveOpsHybridEnabled } from '@/lib/campaignOps/opsHybridFlag'
|
import { resolveOpsHybridEnabled } from '@/lib/campaignOps/opsHybridFlag'
|
||||||
import { diffOpsIds, mergeOpsSnapshot } from '@/lib/campaignOps/opsMerge'
|
import { diffOpsIds, mergeOpsSnapshot, type OpsCollectionIdDiff } from '@/lib/campaignOps/opsMerge'
|
||||||
import { OPS_MIRROR_SCHEMA_VERSION } from '@/lib/campaignOps/opsMirrorVersion'
|
import { OPS_MIRROR_SCHEMA_VERSION } from '@/lib/campaignOps/opsMirrorVersion'
|
||||||
|
import type { OpsSyncState, OpsSyncStatus } from '@/lib/campaignOps/opsSyncMeta'
|
||||||
|
|
||||||
const municipality = (
|
const municipality = (
|
||||||
partial: Partial<OpsMunicipality> & Pick<OpsMunicipality, 'id' | 'slug'>,
|
partial: Partial<OpsMunicipality> & Pick<OpsMunicipality, 'id' | 'slug'>,
|
||||||
|
|
@ -45,6 +56,76 @@ describe('OPS_MIRROR_SCHEMA_VERSION', () => {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
describe('contract surface (knip + OH4 consumers)', () => {
|
||||||
|
it('exports DTO and sync meta types for downstream issues', () => {
|
||||||
|
const collectionKey: OpsCollectionKey = 'municipalities'
|
||||||
|
const estimate: OpsVoteEstimateScenarioFields = { central: 1 }
|
||||||
|
const contact: OpsLeadershipContact = { id: 1, name: 'Test' }
|
||||||
|
const leadership: OpsLeadership = {
|
||||||
|
id: 1,
|
||||||
|
contact,
|
||||||
|
municipalities: [1],
|
||||||
|
supportStatus: 'engajado',
|
||||||
|
updatedAt: '2026-08-01T12:00:00.000Z',
|
||||||
|
}
|
||||||
|
const activity: OpsActivity = {
|
||||||
|
id: 1,
|
||||||
|
title: 'A',
|
||||||
|
slug: 'a',
|
||||||
|
kind: 'caminhada',
|
||||||
|
status: 'planejado',
|
||||||
|
municipality: 1,
|
||||||
|
updatedAt: '2026-08-01T12:00:00.000Z',
|
||||||
|
}
|
||||||
|
const stateDeputy: OpsStateDeputy = {
|
||||||
|
id: 1,
|
||||||
|
name: 'D',
|
||||||
|
slug: 'd',
|
||||||
|
updatedAt: '2026-08-01T12:00:00.000Z',
|
||||||
|
}
|
||||||
|
const organization: OpsOrganization = {
|
||||||
|
id: 1,
|
||||||
|
name: 'O',
|
||||||
|
slug: 'o',
|
||||||
|
kind: 'sindicato',
|
||||||
|
updatedAt: '2026-08-01T12:00:00.000Z',
|
||||||
|
}
|
||||||
|
const demand: OpsDemand = {
|
||||||
|
id: 1,
|
||||||
|
title: 'D',
|
||||||
|
slug: 'd',
|
||||||
|
kind: 'material',
|
||||||
|
municipality: 1,
|
||||||
|
status: 'aberta',
|
||||||
|
updatedAt: '2026-08-01T12:00:00.000Z',
|
||||||
|
}
|
||||||
|
const update: OpsMunicipalityUpdate = {
|
||||||
|
id: 1,
|
||||||
|
municipality: 1,
|
||||||
|
author: 1,
|
||||||
|
kind: 'nota',
|
||||||
|
updatedAt: '2026-08-01T12:00:00.000Z',
|
||||||
|
createdAt: '2026-08-01T12:00:00.000Z',
|
||||||
|
}
|
||||||
|
const goals: OpsGoals = { stateGoal: 100_000 }
|
||||||
|
const idDiff: OpsCollectionIdDiff = { added: [], removed: [] }
|
||||||
|
const syncStatus: OpsSyncStatus = 'idle'
|
||||||
|
const syncState: OpsSyncState = { status: syncStatus, lastSyncedAt: null }
|
||||||
|
|
||||||
|
expect(collectionKey).toBe('municipalities')
|
||||||
|
expect(estimate.central).toBe(1)
|
||||||
|
expect(leadership.contact.name).toBe('Test')
|
||||||
|
expect(activity.slug).toBe('a')
|
||||||
|
expect(stateDeputy.slug).toBe('d')
|
||||||
|
expect(organization.kind).toBe('sindicato')
|
||||||
|
expect(demand.status).toBe('aberta')
|
||||||
|
expect(update.kind).toBe('nota')
|
||||||
|
expect(goals.stateGoal).toBe(100_000)
|
||||||
|
expect(idDiff.added).toEqual([])
|
||||||
|
expect(syncState.status).toBe('idle')
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
describe('resolveOpsHybridEnabled', () => {
|
describe('resolveOpsHybridEnabled', () => {
|
||||||
it.each([
|
it.each([
|
||||||
['1', true],
|
['1', true],
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue