Skip to content

Commit 2a04f4a

Browse files
test(sanity): add tests for taxonomy.publish() and branch.updateSettings() new SDK methods
New SDK methods added in development branch merge: - taxonomy.publish(data, api_version, params) - publish taxonomy/terms to environments - branch.updateSettings(payload) - update branch AM v2 linked workspace settings Tests are wrapped in try/catch to gracefully handle environments where these features are not enabled (accepts 4xx errors). Taxonomy publish tests skip if no taxonomy UID is available from prior test run.
1 parent eb63272 commit 2a04f4a

File tree

2 files changed

+107
-0
lines changed

2 files changed

+107
-0
lines changed

test/sanity-check/api/branch-test.js

Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -399,4 +399,43 @@ describe('Branch API Tests', () => {
399399
}
400400
})
401401
})
402+
403+
// ==========================================================================
404+
// BRANCH SETTINGS (AM v2)
405+
// ==========================================================================
406+
407+
describe('Branch Settings', () => {
408+
it('should call updateSettings on main branch', async function () {
409+
this.timeout(15000)
410+
const branchUid = testData.branches?.dev?.uid || 'main'
411+
412+
const payload = {
413+
branch: {
414+
settings: {
415+
am_v2: {
416+
linked_workspaces: []
417+
}
418+
}
419+
}
420+
}
421+
422+
try {
423+
const response = await stack.branch(branchUid).updateSettings(payload)
424+
expect(response).to.be.an('object')
425+
} catch (e) {
426+
// updateSettings may require AM v2 entitlement; accept 4xx errors gracefully
427+
expect(e.status).to.be.oneOf([400, 403, 404, 422])
428+
}
429+
})
430+
431+
it('should fail updateSettings with invalid payload', async function () {
432+
this.timeout(15000)
433+
try {
434+
await stack.branch('main').updateSettings({})
435+
// Empty payload may be accepted on some envs
436+
} catch (e) {
437+
expect(e.status).to.be.oneOf([400, 422])
438+
}
439+
})
440+
})
402441
})

test/sanity-check/api/taxonomy-test.js

Lines changed: 68 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,4 +244,72 @@ describe('Taxonomy API Tests', () => {
244244
}
245245
})
246246
})
247+
248+
// ==========================================================================
249+
// TAXONOMY PUBLISHING
250+
// ==========================================================================
251+
252+
describe('Taxonomy Publishing', () => {
253+
it('should publish taxonomy items to an environment', async function () {
254+
this.timeout(30000)
255+
const taxonomyUid = testData.taxonomies?.category?.uid
256+
if (!taxonomyUid) {
257+
this.skip()
258+
return
259+
}
260+
261+
const envName = testData.environments?.development?.name || 'development'
262+
const publishData = {
263+
locales: ['en-us'],
264+
environments: [envName],
265+
items: [
266+
{ uid: taxonomyUid }
267+
]
268+
}
269+
270+
try {
271+
const response = await stack.taxonomy().publish(publishData)
272+
expect(response).to.be.an('object')
273+
} catch (e) {
274+
// Feature may not be available on all environments; accept 4xx errors gracefully
275+
expect(e.status).to.be.oneOf([400, 403, 404, 422])
276+
}
277+
})
278+
279+
it('should publish taxonomy with api_version parameter', async function () {
280+
this.timeout(30000)
281+
const taxonomyUid = testData.taxonomies?.category?.uid
282+
if (!taxonomyUid) {
283+
this.skip()
284+
return
285+
}
286+
287+
const envName = testData.environments?.development?.name || 'development'
288+
const publishData = {
289+
locales: ['en-us'],
290+
environments: [envName],
291+
items: [
292+
{ uid: taxonomyUid }
293+
]
294+
}
295+
296+
try {
297+
const response = await stack.taxonomy().publish(publishData, '3.2')
298+
expect(response).to.be.an('object')
299+
} catch (e) {
300+
// Feature may not be available on all environments; accept 4xx errors gracefully
301+
expect(e.status).to.be.oneOf([400, 403, 404, 422])
302+
}
303+
})
304+
305+
it('should fail publish with empty items', async function () {
306+
this.timeout(15000)
307+
try {
308+
await stack.taxonomy().publish({ locales: ['en-us'], environments: ['development'], items: [] })
309+
// Some environments may accept empty arrays, just check it returns something
310+
} catch (e) {
311+
expect(e.status).to.be.oneOf([400, 422])
312+
}
313+
})
314+
})
247315
})

0 commit comments

Comments
 (0)