diff --git a/apps/sim/tools/ashby/ashby.test.ts b/apps/sim/tools/ashby/ashby.test.ts index e46da7cc0cc..ac16621988f 100644 --- a/apps/sim/tools/ashby/ashby.test.ts +++ b/apps/sim/tools/ashby/ashby.test.ts @@ -6,6 +6,7 @@ import { changeApplicationStageTool } from '@/tools/ashby/change_application_sta import { deleteApplicationTool } from '@/tools/ashby/delete_application' import { getApplicationTool } from '@/tools/ashby/get_application' import { getCandidateTool } from '@/tools/ashby/get_candidate' +import { getJobTool } from '@/tools/ashby/get_job' import { getJobPostingTool } from '@/tools/ashby/get_job_posting' import { listApplicationsTool } from '@/tools/ashby/list_applications' import { listCandidatesTool } from '@/tools/ashby/list_candidates' @@ -21,16 +22,18 @@ import { setCustomFieldValuesTool } from '@/tools/ashby/set_custom_field_values' import { transferApplicationTool } from '@/tools/ashby/transfer_application' import { updateCandidateTool } from '@/tools/ashby/update_candidate' import { ashbyAuthHeaders } from '@/tools/ashby/utils' -import type { ToolConfig } from '@/tools/types' const respond = (body: unknown) => new Response(JSON.stringify(body), { status: 200 }) -function requestBody(tool: ToolConfig, params: unknown): Record { +function requestBody( + tool: { request?: { body?: unknown } }, + params: unknown +): Record { const build = tool.request?.body as (p: unknown) => Record return build(params) } -async function transform(tool: ToolConfig, body: unknown) { +async function transform(tool: { transformResponse?: unknown }, body: unknown) { const run = tool.transformResponse as (r: Response) => Promise<{ output: Record }> return run(respond(body)) } @@ -263,6 +266,27 @@ describe('ashby request bodies', () => { expect(body).not.toHaveProperty('includeUnpublishedJobPostingsIds') }) + it('get_job sends the job.info spelling of the unpublished posting IDs flag', () => { + // job.info rejects unknown keys (additionalProperties: false), so the + // singular `includeUnpublishedJobPostingIds` never reached Ashby as intended. + const body = requestBody(getJobTool, { + apiKey: 'k', + jobId: ' j ', + includeUnpublishedJobPostingIds: true, + }) + expect(body).toMatchObject({ id: 'j', includeUnpublishedJobPostingsIds: true }) + expect(body).not.toHaveProperty('includeUnpublishedJobPostingIds') + for (const untouched of [null, '']) { + expect( + requestBody(getJobTool, { + apiKey: 'k', + jobId: 'j', + includeUnpublishedJobPostingIds: untouched, + }) + ).toEqual({ id: 'j', expand: ['openings', 'location', 'compensation'] }) + } + }) + it('change_application_source sends sourceId when one is provided', () => { // Ashby requires the key to be present; omitting it is a 400 rather than // the intended write. diff --git a/apps/sim/tools/ashby/get_job.ts b/apps/sim/tools/ashby/get_job.ts index 3a0454c1931..b30bc21d236 100644 --- a/apps/sim/tools/ashby/get_job.ts +++ b/apps/sim/tools/ashby/get_job.ts @@ -38,8 +38,8 @@ export const getJobTool: ToolConfig = { body: (params) => ({ id: params.jobId.trim(), expand: ['openings', 'location', 'compensation'], - ...(params.includeUnpublishedJobPostingIds !== undefined - ? { includeUnpublishedJobPostingIds: params.includeUnpublishedJobPostingIds } + ...(typeof params.includeUnpublishedJobPostingIds === 'boolean' + ? { includeUnpublishedJobPostingsIds: params.includeUnpublishedJobPostingIds } : {}), }), }, diff --git a/scripts/check-test-types.baseline.json b/scripts/check-test-types.baseline.json index 1cb383e238b..da9f1aff787 100644 --- a/scripts/check-test-types.baseline.json +++ b/scripts/check-test-types.baseline.json @@ -2574,8 +2574,7 @@ "TS2345": 25 }, "apps/sim/tools/ashby/ashby.test.ts": { - "TS2339": 3, - "TS2345": 50 + "TS2339": 3 }, "apps/sim/tools/assistant-execution.test.ts": { "TS2554": 2