Free, Open Source, Self-Hosted WhatsApp API Gateway
TypeScript apibotgatewayself-hostedwhatsappwhatsapp-apiwhatsapp-automationwhatsapp-botwhatsapp-gatewaywhatsapp-gateway-apiwhatsapp-webwhatsapp-web-api
test(ci): pin the non-pg specs of the test-postgres job
Yudhi Armyndharisdb57474ff1ad
diff --git a/src/common/test-lane-partition.spec.ts b/src/common/test-lane-partition.spec.tsindex 62a6fd62d..2d2283c15 100644--- a/src/common/test-lane-partition.spec.ts+++ b/src/common/test-lane-partition.spec.ts@@ -117,17 +117,22 @@ describe('Test lane partition', () => {* matches nothing and still exits 0, and a new spec left off the list runs nowhere. Diff each* workflow's list against the files on disk.*/+ /** Every `*.spec.ts` path the workflow's `test-postgres` job names on a run line. */+ const postgresJobSpecs = (file: string): string[] => {+ const workflow = yaml.load(readFileSync(join(repoRoot, '.github', 'workflows', file), 'utf8')) as {+ jobs?: Record<string, { steps?: { run?: string }[] }>;+ };+ return (workflow.jobs?.['test-postgres']?.steps ?? [])+ .flatMap(step => (step.run ?? '').split(/\s+/))+ .filter(token => token.endsWith('.spec.ts'));+ };+it.each(['ci.yml', 'release.yml'])('runs every *.pg.spec.ts in the %s test-postgres job', file => {const isPgSpec = (path: string): boolean => path.endsWith('.pg.spec.ts');const onDisk = (readdirSync(join(repoRoot, 'src'), { recursive: true }) as string[]).filter(isPgSpec).map(path => `src/${path.split('\\').join('/')}`);- const workflow = yaml.load(readFileSync(join(repoRoot, '.github', 'workflows', file), 'utf8')) as {- jobs?: Record<string, { steps?: { run?: string }[] }>;- };- const named = (workflow.jobs?.['test-postgres']?.steps ?? [])- .flatMap(step => (step.run ?? '').split(/\s+/))- .filter(isPgSpec);+ const named = postgresJobSpecs(file).filter(isPgSpec);// Vacuity guard: a scan or a parse that found nothing would pass the diff below.expect(onDisk.length).toBeGreaterThanOrEqual(5);@@ -139,6 +144,24 @@ describe('Test lane partition', () => {}).toEqual({ neverRun: [], namedButAbsent: [] });});+ /**+ * A spec that picks its dialect from DATABASE_TYPE is not a `*.pg.spec.ts`, so the scan above never+ * sees it, yet its PostgreSQL half runs only in this job. Dropping it from both workflows at once+ * leaves release-gate-parity green (the two still agree) and the scenarios silently SQLite-only.+ * Listed by hand for that reason, and a plain spec this job gains must be listed too.+ */+ const dialectSwitchedSpecs = ['src/modules/session/session-content-lifetime.spec.ts'];++ it.each(['ci.yml', 'release.yml'])('runs the dialect-switched specs in the %s test-postgres job', file => {+ const named = postgresJobSpecs(file).filter(path => !path.endsWith('.pg.spec.ts'));++ expect(dialectSwitchedSpecs.filter(path => !existsSync(join(repoRoot, path)))).toEqual([]);+ expect({+ neverRun: dialectSwitchedSpecs.filter(path => !named.includes(path)),+ unlisted: named.filter(path => !dialectSwitchedSpecs.includes(path)),+ }).toEqual({ neverRun: [], unlisted: [] });+ });+it('names suites that exist on disk', () => {const paths = [...new Set([...docLane(), ...unitLaneExcludes().map(asPath)])];expect(paths.length).toBeGreaterThan(20);