Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 27 additions & 3 deletions apps/sim/tools/ashby/ashby.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'
Expand All @@ -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<never, never>, params: unknown): Record<string, unknown> {
function requestBody(
tool: { request?: { body?: unknown } },
params: unknown
): Record<string, unknown> {
const build = tool.request?.body as (p: unknown) => Record<string, unknown>
return build(params)
}

async function transform(tool: ToolConfig<never, never>, body: unknown) {
async function transform(tool: { transformResponse?: unknown }, body: unknown) {
const run = tool.transformResponse as (r: Response) => Promise<{ output: Record<string, never> }>
return run(respond(body))
}
Expand Down Expand Up @@ -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.
Expand Down
4 changes: 2 additions & 2 deletions apps/sim/tools/ashby/get_job.ts
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,8 @@ export const getJobTool: ToolConfig<AshbyGetJobParams, AshbyGetJobResponse> = {
body: (params) => ({
id: params.jobId.trim(),
expand: ['openings', 'location', 'compensation'],
...(params.includeUnpublishedJobPostingIds !== undefined
? { includeUnpublishedJobPostingIds: params.includeUnpublishedJobPostingIds }
...(typeof params.includeUnpublishedJobPostingIds === 'boolean'
? { includeUnpublishedJobPostingsIds: params.includeUnpublishedJobPostingIds }
: {}),
}),
},
Expand Down
3 changes: 1 addition & 2 deletions scripts/check-test-types.baseline.json
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Loading