From 2c05a3cdf4b2e925da13a4441d7453372f072f07 Mon Sep 17 00:00:00 2001 From: quality Date: Wed, 7 Oct 2026 17:46:01 -0400 Subject: [PATCH 1/2] test(bundle): drive the cron dispatcher's unknown-job arm through dist/index.js handleCronJob.ts' default arm (could not execute . May not be supported - please refer to docs) was unit-covered only. Add the two remaining cases of the cron jobs-input suite: a lone unknown name fails the run lowercased without any api call, and an unknown name beside label-sync still fails the run after the known job completes. Closes #241 Signed-off-by: quality --- __tests__/bundle/cronJobsInput.test.ts | 33 ++++++++++++++++++++++++-- 1 file changed, 31 insertions(+), 2 deletions(-) diff --git a/__tests__/bundle/cronJobsInput.test.ts b/__tests__/bundle/cronJobsInput.test.ts index 3a52e0d9..e4cc8d71 100644 --- a/__tests__/bundle/cronJobsInput.test.ts +++ b/__tests__/bundle/cronJobsInput.test.ts @@ -2,13 +2,14 @@ import type { FakeGithub } from './fakeGithub' import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from 'vitest' import { start } from './fakeGithub' -import { token } from './helpers' +import { configReads, repo, token } from './helpers' import { runBundle } from './runBundle' vi.setConfig({ testTimeout: 30_000 }) // the `jobs` input validation of the cron dispatcher, driven through dist/index.js: the push event routes to the -// cron jobs like schedule and workflow_dispatch do, and a blank list fails the run before anything talks to the api +// cron jobs like schedule and workflow_dispatch do, a blank list fails the run before anything talks to the api, +// and a name the dispatcher does not know fails the run whether or not a known job runs beside it describe('dist/index.js cron jobs input', () => { let gh: FakeGithub @@ -33,4 +34,32 @@ describe('dist/index.js cron jobs input', () => { expect(result.errors.some(e => /please provide a list of space delimited/.test(e))).toBe(true) expect(gh.requests).toEqual([]) }) + + it('an unknown job name fails the run lowercased, naming the docs, and calls no api', async () => { + const result = await runBundle({ eventName: 'workflow_dispatch', payload: {}, inputs: { ...token, jobs: 'Tide' }, apiUrl: gh.url }) + + expect(result.status, result.stdout).toBe(1) + expect(result.errors).toEqual([ + 'TypeError: error handling cron job: Error: could not execute tide. May not be supported - please refer to docs', + ]) + expect(gh.requests).toEqual([]) + }) + + it('an unknown job name still fails the run when a known job runs beside it', async () => { + gh.route('GET', `${repo}/labels`, { status: 200, body: [] }) + gh.route('POST', `${repo}/labels`, { status: 201, body: {} }) + + const result = await runBundle({ eventName: 'schedule', payload: {}, inputs: { ...token, jobs: 'bogus\nlabel-sync' }, apiUrl: gh.url }) + + expect(result.status, result.stdout).toBe(1) + expect(result.errors).toEqual([ + 'TypeError: error handling cron job: Error: could not execute bogus. May not be supported - please refer to docs', + ]) + // label-sync ran to completion beside the rejected name: it looked for a configuration and synced the built-ins + const paths = gh.requests.map(r => `${r.method} ${r.path}`) + expect(paths.filter(p => /\/contents\//.test(p)).sort()).toEqual([...configReads()].sort()) + expect(paths).toContain(`GET ${repo}/labels?per_page=100`) + expect(gh.requestsMatching('POST', /\/labels$/).length).toBeGreaterThan(0) + expect(result.stdout).toMatch(/label-sync: created \d+/) + }) }) From ca2887147ad611912b81f09460b533ec43746e9c Mon Sep 17 00:00:00 2001 From: quality Date: Thu, 8 Oct 2026 04:04:20 -0400 Subject: [PATCH 2/2] test(bundle): check the unknown-job error by fragment and drop the mixed-list case Review on #371: assert on the 'could not execute tide' fragment rather than the full error string, and drop the 'bogus\nlabel-sync' case, which reaches nothing the first case does not. Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com> Signed-off-by: quality --- __tests__/bundle/cronJobsInput.test.ts | 27 ++++---------------------- 1 file changed, 4 insertions(+), 23 deletions(-) diff --git a/__tests__/bundle/cronJobsInput.test.ts b/__tests__/bundle/cronJobsInput.test.ts index e4cc8d71..042dad6a 100644 --- a/__tests__/bundle/cronJobsInput.test.ts +++ b/__tests__/bundle/cronJobsInput.test.ts @@ -2,14 +2,14 @@ import type { FakeGithub } from './fakeGithub' import { afterAll, afterEach, beforeAll, describe, expect, it, vi } from 'vitest' import { start } from './fakeGithub' -import { configReads, repo, token } from './helpers' +import { token } from './helpers' import { runBundle } from './runBundle' vi.setConfig({ testTimeout: 30_000 }) // the `jobs` input validation of the cron dispatcher, driven through dist/index.js: the push event routes to the // cron jobs like schedule and workflow_dispatch do, a blank list fails the run before anything talks to the api, -// and a name the dispatcher does not know fails the run whether or not a known job runs beside it +// and a name the dispatcher does not know fails the run describe('dist/index.js cron jobs input', () => { let gh: FakeGithub @@ -39,27 +39,8 @@ describe('dist/index.js cron jobs input', () => { const result = await runBundle({ eventName: 'workflow_dispatch', payload: {}, inputs: { ...token, jobs: 'Tide' }, apiUrl: gh.url }) expect(result.status, result.stdout).toBe(1) - expect(result.errors).toEqual([ - 'TypeError: error handling cron job: Error: could not execute tide. May not be supported - please refer to docs', - ]) + expect(result.errors).toHaveLength(1) + expect(result.errors[0]).toContain('could not execute tide') expect(gh.requests).toEqual([]) }) - - it('an unknown job name still fails the run when a known job runs beside it', async () => { - gh.route('GET', `${repo}/labels`, { status: 200, body: [] }) - gh.route('POST', `${repo}/labels`, { status: 201, body: {} }) - - const result = await runBundle({ eventName: 'schedule', payload: {}, inputs: { ...token, jobs: 'bogus\nlabel-sync' }, apiUrl: gh.url }) - - expect(result.status, result.stdout).toBe(1) - expect(result.errors).toEqual([ - 'TypeError: error handling cron job: Error: could not execute bogus. May not be supported - please refer to docs', - ]) - // label-sync ran to completion beside the rejected name: it looked for a configuration and synced the built-ins - const paths = gh.requests.map(r => `${r.method} ${r.path}`) - expect(paths.filter(p => /\/contents\//.test(p)).sort()).toEqual([...configReads()].sort()) - expect(paths).toContain(`GET ${repo}/labels?per_page=100`) - expect(gh.requestsMatching('POST', /\/labels$/).length).toBeGreaterThan(0) - expect(result.stdout).toMatch(/label-sync: created \d+/) - }) })