Skip to content

Commit 3be2ccc

Browse files
committed
test(workday): assert Get_Organizations element order in the XML sent to Workday
1 parent 7d3106c commit 3be2ccc

2 files changed

Lines changed: 26 additions & 12 deletions

File tree

‎apps/sim/lib/internal/workday/client.test.ts‎

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {
44
createWorkdaySoapClient,
55
extractRefId,
66
} from '@/lib/internal/workday/client'
7+
import { executeWorkdayGetOrganizations } from '@/lib/internal/workday/operations'
78

89
const SUCCESS_RESPONSE = `<?xml version="1.0" encoding="UTF-8"?>
910
<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wd="urn:com.workday/bsvc">
@@ -39,6 +40,31 @@ describe('Workday SOAP client', () => {
3940
)
4041
})
4142

43+
it('sends Get_Organizations criteria before the response filter, in schema order', async () => {
44+
fetchMock.mockResolvedValue(
45+
new Response(
46+
'<env:Envelope xmlns:env="http://schemas.xmlsoap.org/soap/envelope/" xmlns:wd="urn:com.workday/bsvc"><env:Body><wd:Get_Organizations_Response/></env:Body></env:Envelope>',
47+
{ status: 200 }
48+
)
49+
)
50+
51+
await executeWorkdayGetOrganizations({
52+
tenantUrl: 'https://wd2-impl-services1.workday.com',
53+
tenant: 'example',
54+
username: 'user',
55+
password: 'password',
56+
type: 'Supervisory',
57+
})
58+
59+
const body = String(fetchMock.mock.calls[0]?.[1]?.body)
60+
const criteria = body.indexOf('<wd:Request_Criteria>')
61+
const filter = body.indexOf('<wd:Response_Filter>')
62+
const group = body.indexOf('<wd:Response_Group>')
63+
expect(criteria).toBeGreaterThan(-1)
64+
expect(criteria).toBeLessThan(filter)
65+
expect(filter).toBeLessThan(group)
66+
})
67+
4268
it('passes cancellation to fetch, escapes XML, and parses SOAP responses', async () => {
4369
fetchMock.mockResolvedValue(new Response(SUCCESS_RESPONSE, { status: 200 }))
4470
const controller = new AbortController()

‎apps/sim/lib/internal/workday/operations.test.ts‎

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -173,18 +173,6 @@ describe('Workday operations', () => {
173173
})
174174
})
175175

176-
it('sends the organization type criteria before the response filter, in schema order', async () => {
177-
clientMocks.Get_OrganizationsAsync.mockResolvedValue([{ Response_Data: {} }])
178-
179-
await executeWorkdayGetOrganizations({ ...CREDENTIALS, type: 'Supervisory' })
180-
181-
expect(Object.keys(firstCallArgs(clientMocks.Get_OrganizationsAsync))).toEqual([
182-
'Request_Criteria',
183-
'Response_Filter',
184-
'Response_Group',
185-
])
186-
})
187-
188176
it('sends personal information changes under Change_Personal_Information_Data', async () => {
189177
await executeWorkdayUpdateWorker({
190178
...CREDENTIALS,

0 commit comments

Comments
 (0)