Skip to content

Commit 5828b96

Browse files
committed
chore(sanity): add trackedExpect across all sanity API test files
- Add trackedExpect import and key success-path assertions in: globalfield, branch, bulkOperation, entryVariants, terms, ungroupedVariants, variants, contentType, branchAlias, taxonomy, previewToken, team, webhook, variantGroup, token, environment, extension, label, role - Mochawesome report now shows specific Expected vs Actual in Assertions Verified for easier debugging - Update .talismanrc checksums for modified sanity files
1 parent 6e01b08 commit 5828b96

30 files changed

+278
-185
lines changed

.talismanrc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ fileignoreconfig:
2828
checksum: 2597efae3c1ab8cc173d5bf205f1c76932211f8e0eb2a16444e055d83481976c
2929
# Sanity check test files - use process.env for all secrets (no hardcoded values)
3030
- filename: test/sanity-check/api/environment-test.js
31-
checksum: 9557c3898d40ab061061fdce522a8f7450214de6cb5b34ef1ffb634064a2ca06
31+
checksum: e554b04ac510600c8489870a6097ee5f824f5b5e0f1a6358d8ef4ad24b3b0c12
3232
- filename: test/sanity-check/env.example.txt
3333
checksum: 3339944cd20d6d72f70a92e54af3de96736250b4b7117a29577575f9b52ed611
3434
- filename: test/sanity-check/api/token-test.js
@@ -52,7 +52,7 @@ fileignoreconfig:
5252
- filename: test/sanity-check/mock/content-types/index.js
5353
checksum: ff47f74037e22f791e2d7c6afbaccf7857b26b51dd2e2361b5b4b70d36057b7f
5454
- filename: test/sanity-check/sanity.js
55-
checksum: 94fc68fc78e00b8b268f6e86b5ed55dbfe48fbde45f780629afa1c75c968f438
55+
checksum: 523725a12c93abdc1b89a1e7ef38021184e7d710f8719290923f835f8d615693
5656
- filename: test/sanity-check/api/user-test.js
5757
checksum: 5f1284561725f99980a800c87d80d2f7b6f56e1efa618adb10bbf87312b0deec
5858
- filename: test/sanity-check/api/locale-test.js
@@ -82,7 +82,7 @@ fileignoreconfig:
8282
- filename: test/sanity-check/api/branch-test.js
8383
checksum: 49c8fd18c59d45e4335f766591711849722206bce34860efa8eced7172f44efa
8484
- filename: test/sanity-check/api/stack-test.js
85-
checksum: afefc21f2ac44e18f03e8bd12f80143f5545f2147fc6cedf8a933ff2aa3f4028
85+
checksum: abcc3b1a7a6e52a553645bd7a7a38b287402604f6b61df51a69745cd2aa8a187
8686
- filename: test/sanity-check/api/previewToken-test.js
8787
checksum: 9efe3852336f1c5f961682ca21673514b2bd1334a040c5d56983074f41c6b8e0
8888
- filename: test/sanity-check/api/role-test.js

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

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@
1414
import { expect } from 'chai'
1515
import { describe, it, before, after } from 'mocha'
1616
import { contentstackClient } from '../utility/ContentstackClient.js'
17-
import { validateAssetResponse, testData, wait } from '../utility/testHelpers.js'
17+
import { validateAssetResponse, testData, wait, trackedExpect } from '../utility/testHelpers.js'
1818
import path from 'path'
1919
import fs from 'fs'
2020

@@ -56,8 +56,8 @@ describe('Asset API Tests', () => {
5656
})
5757

5858
// SDK returns the asset object directly
59-
expect(response).to.be.an('object')
60-
expect(response.uid).to.be.a('string')
59+
trackedExpect(response, 'Asset response').toBeAn('object')
60+
trackedExpect(response.uid, 'Asset UID').toBeA('string')
6161
validateAssetResponse(response)
6262

6363
expect(response.filename).to.include('image')
@@ -81,8 +81,8 @@ describe('Asset API Tests', () => {
8181
description: 'Test HTML upload'
8282
})
8383

84-
expect(asset).to.be.an('object')
85-
expect(asset.uid).to.be.a('string')
84+
trackedExpect(asset, 'HTML asset').toBeAn('object')
85+
trackedExpect(asset.uid, 'Asset UID').toBeA('string')
8686
expect(asset.filename).to.include('upload')
8787
expect(asset.content_type).to.include('html')
8888

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

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@
1010
import { expect } from 'chai'
1111
import { describe, it, before } from 'mocha'
1212
import { contentstackClient } from '../utility/ContentstackClient.js'
13-
import { testData } from '../utility/testHelpers.js'
13+
import { testData, trackedExpect } from '../utility/testHelpers.js'
1414

1515
describe('Audit Log API Tests', () => {
1616
let client
@@ -31,8 +31,8 @@ describe('Audit Log API Tests', () => {
3131
try {
3232
const response = await stack.auditLog().fetchAll()
3333

34-
expect(response).to.be.an('object')
35-
expect(response.items || response.logs).to.be.an('array')
34+
trackedExpect(response, 'Audit log response').toBeAn('object')
35+
trackedExpect(response.items || response.logs, 'Logs list').toBeAn('array')
3636
} catch (error) {
3737
// Audit logs might require specific permissions
3838
console.log('Audit log fetch failed:', error.errorMessage)
@@ -46,7 +46,7 @@ describe('Audit Log API Tests', () => {
4646

4747
if (logs && logs.length > 0) {
4848
const log = logs[0]
49-
expect(log.uid).to.be.a('string')
49+
trackedExpect(log.uid, 'Log UID').toBeA('string')
5050

5151
if (log.created_at) {
5252
expect(new Date(log.created_at)).to.be.instanceof(Date)
@@ -66,8 +66,8 @@ describe('Audit Log API Tests', () => {
6666
const logUid = logs[0].uid
6767
const singleLog = await stack.auditLog(logUid).fetch()
6868

69-
expect(singleLog).to.be.an('object')
70-
expect(singleLog.uid).to.equal(logUid)
69+
trackedExpect(singleLog, 'Single log').toBeAn('object')
70+
trackedExpect(singleLog.uid, 'Log UID').toEqual(logUid)
7171
}
7272
} catch (error) {
7373
console.log('Single log fetch failed:', error.errorMessage)

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

Lines changed: 9 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ import {
2020
branchAlias,
2121
branchAliasUpdate
2222
} from '../mock/configurations.js'
23-
import { validateBranchResponse, testData, wait, shortId } from '../utility/testHelpers.js'
23+
import { validateBranchResponse, testData, wait, shortId, trackedExpect } from '../utility/testHelpers.js'
2424

2525
describe('Branch API Tests', () => {
2626
let client
@@ -48,19 +48,17 @@ describe('Branch API Tests', () => {
4848
it('should query all branches', async () => {
4949
const response = await stack.branch().query().find()
5050

51-
expect(response).to.be.an('object')
52-
expect(response.items || response.branches).to.be.an('array')
53-
51+
trackedExpect(response, 'Branches response').toBeAn('object')
5452
const items = response.items || response.branches
55-
// At least main branch should exist
56-
expect(items.length).to.be.at.least(1)
53+
trackedExpect(items, 'Branches list').toBeAn('array')
54+
trackedExpect(items.length, 'Branches count').toBeAtLeast(1)
5755
})
5856

5957
it('should fetch main branch', async () => {
6058
const response = await stack.branch('main').fetch()
6159

62-
expect(response).to.be.an('object')
63-
expect(response.uid).to.equal('main')
60+
trackedExpect(response, 'Main branch').toBeAn('object')
61+
trackedExpect(response.uid, 'Main branch UID').toEqual('main')
6462
})
6563

6664
it('should create a development branch from main', async function () {
@@ -77,11 +75,11 @@ describe('Branch API Tests', () => {
7775
// SDK returns the branch object directly
7876
const branch = await stack.branch().create(branchData)
7977

80-
expect(branch).to.be.an('object')
81-
expect(branch.uid).to.be.a('string')
78+
trackedExpect(branch, 'Branch').toBeAn('object')
79+
trackedExpect(branch.uid, 'Branch UID').toBeA('string')
8280
validateBranchResponse(branch)
8381

84-
expect(branch.uid).to.equal(devBranchUid)
82+
trackedExpect(branch.uid, 'Branch UID').toEqual(devBranchUid)
8583
expect(branch.source).to.equal('main')
8684

8785
createdBranch = branch

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

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
import { expect } from 'chai'
1212
import { describe, it, before, after } from 'mocha'
1313
import { contentstackClient } from '../utility/ContentstackClient.js'
14-
import { testData, wait, shortId } from '../utility/testHelpers.js'
14+
import { testData, wait, shortId, trackedExpect } from '../utility/testHelpers.js'
1515

1616
describe('Branch Alias API Tests', () => {
1717
let client
@@ -67,11 +67,11 @@ describe('Branch Alias API Tests', () => {
6767
// Create the branch alias using SDK method (same as old tests)
6868
const response = await stack.branchAlias(testAliasUid).createOrUpdate(testBranchUid)
6969

70-
expect(response).to.be.an('object')
70+
trackedExpect(response, 'Branch alias').toBeAn('object')
7171

7272
// Validate response matches old test expectations
73-
expect(response.uid).to.equal(testBranchUid)
74-
expect(response.alias).to.equal(testAliasUid)
73+
trackedExpect(response.uid, 'Branch alias uid').toEqual(testBranchUid)
74+
trackedExpect(response.alias, 'Branch alias alias').toEqual(testAliasUid)
7575
expect(response.urlPath).to.equal(`/stacks/branches/${testBranchUid}`)
7676

7777
// Store for later tests
@@ -90,10 +90,10 @@ describe('Branch Alias API Tests', () => {
9090

9191
const response = await stack.branchAlias(testAliasUid).fetch()
9292

93-
expect(response).to.be.an('object')
93+
trackedExpect(response, 'Branch alias').toBeAn('object')
9494
// Validate response matches old test expectations
95-
expect(response.uid).to.equal(testBranchUid)
96-
expect(response.alias).to.equal(testAliasUid)
95+
trackedExpect(response.uid, 'Branch alias uid').toEqual(testBranchUid)
96+
trackedExpect(response.alias, 'Branch alias alias').toEqual(testAliasUid)
9797
expect(response.urlPath).to.equal(`/stacks/branches/${testBranchUid}`)
9898
expect(response.source).to.be.a('string')
9999
// Check SDK methods exist on response

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import { expect } from 'chai'
66
import { describe, it, before, after } from 'mocha'
77
import { contentstackClient } from '../utility/ContentstackClient.js'
8-
import { wait, testData } from '../utility/testHelpers.js'
8+
import { wait, testData, trackedExpect } from '../utility/testHelpers.js'
99

1010
let client = null
1111
let stack = null
@@ -129,8 +129,9 @@ describe('Bulk Operations API Tests', () => {
129129
api_version: '3.2'
130130
})
131131

132-
expect(response.notice).to.not.equal(undefined)
133-
expect(response.job_id).to.not.equal(undefined)
132+
trackedExpect(response, 'Bulk publish response').toBeAn('object')
133+
trackedExpect(response.notice, 'Bulk publish notice').toExist()
134+
trackedExpect(response.job_id, 'Bulk publish job_id').toExist()
134135

135136
if (response.job_id) {
136137
jobIds.push(response.job_id)

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

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,8 @@ import {
2727
generateValidUid,
2828
testData,
2929
safeDeleteContentType,
30-
wait
30+
wait,
31+
trackedExpect
3132
} from '../utility/testHelpers.js'
3233

3334
// Get base path for mock files (works with both ESM and CommonJS after Babel transpilation)
@@ -59,11 +60,11 @@ describe('Content Type API Tests', () => {
5960
// SDK returns the content type object directly
6061
const ct = await stack.contentType().create(ctData)
6162

62-
expect(ct).to.be.an('object')
63-
expect(ct.uid).to.be.a('string')
63+
trackedExpect(ct, 'Content type').toBeAn('object')
64+
trackedExpect(ct.uid, 'Content type UID').toBeA('string')
6465
validateContentTypeResponse(ct, simpleCtUid)
6566

66-
expect(ct.title).to.include('Simple Test')
67+
trackedExpect(ct.title, 'Content type title').toInclude('Simple Test')
6768
expect(ct.schema).to.be.an('array')
6869
expect(ct.schema.length).to.be.at.least(1)
6970

@@ -84,9 +85,9 @@ describe('Content Type API Tests', () => {
8485
this.timeout(15000)
8586
const response = await stack.contentType(simpleCtUid).fetch()
8687

87-
expect(response).to.be.an('object')
88-
expect(response.uid).to.equal(simpleCtUid)
89-
expect(response.title).to.equal(createdCt.title)
88+
trackedExpect(response, 'Content type').toBeAn('object')
89+
trackedExpect(response.uid, 'Content type UID').toEqual(simpleCtUid)
90+
trackedExpect(response.title, 'Content type title').toEqual(createdCt.title)
9091
expect(response.schema).to.deep.equal(createdCt.schema)
9192
})
9293

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ import {
1818
mediumEntryUpdate,
1919
complexEntry
2020
} from '../mock/entries/index.js'
21-
import { testData, wait } from '../utility/testHelpers.js'
21+
import { testData, wait, trackedExpect } from '../utility/testHelpers.js'
2222

2323
describe('Entry API Tests', () => {
2424
let client
@@ -113,8 +113,8 @@ describe('Entry API Tests', () => {
113113
// SDK returns the entry object directly
114114
const entry = await stack.contentType(mediumCtUid).entry().create(entryData)
115115

116-
expect(entry).to.be.an('object')
117-
expect(entry.uid).to.be.a('string')
116+
trackedExpect(entry, 'Entry').toBeAn('object')
117+
trackedExpect(entry.uid, 'Entry UID').toBeA('string')
118118
expect(entry.title).to.include('All Fields')
119119
expect(entry.summary).to.be.a('string')
120120
expect(entry.view_count).to.equal(1250)
@@ -134,7 +134,7 @@ describe('Entry API Tests', () => {
134134

135135
const entry = await stack.contentType(mediumCtUid).entry(entryUid).fetch()
136136

137-
expect(entry.uid).to.equal(entryUid)
137+
trackedExpect(entry.uid, 'Entry UID').toEqual(entryUid)
138138
expect(entry.title).to.include('All Fields')
139139
})
140140

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

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
import { expect } from 'chai'
66
import { describe, it, before, after } from 'mocha'
77
import { contentstackClient } from '../utility/ContentstackClient.js'
8-
import { generateUniqueId, wait, testData } from '../utility/testHelpers.js'
8+
import { generateUniqueId, wait, testData, trackedExpect } from '../utility/testHelpers.js'
99

1010
let client = null
1111
let stack = null
@@ -195,9 +195,10 @@ describe('Entry Variants API Tests', () => {
195195
.variants(variantUid)
196196
.update(variantEntryData)
197197

198-
expect(response.entry).to.not.equal(undefined)
199-
expect(response.entry.title).to.not.equal(null)
200-
expect(response.notice).to.include('variant')
198+
trackedExpect(response, 'Entry variant update response').toBeAn('object')
199+
trackedExpect(response.entry, 'Entry variant entry').toExist()
200+
trackedExpect(response.entry.title, 'Entry variant title').toExist()
201+
trackedExpect(response.notice, 'Notice').toInclude('variant')
201202
} catch (error) {
202203
if (error.status === 403 || error.errorCode === 403) {
203204
console.log('Entry Variants feature not enabled')
@@ -226,8 +227,9 @@ describe('Entry Variants API Tests', () => {
226227
.variants(variantUid)
227228
.fetch()
228229

229-
expect(response.entry).to.not.equal(undefined)
230-
expect(response.entry._variant).to.not.equal(undefined)
230+
trackedExpect(response, 'Entry variant fetch response').toBeAn('object')
231+
trackedExpect(response.entry, 'Entry variant entry').toExist()
232+
trackedExpect(response.entry._variant, 'Entry variant _variant').toExist()
231233
} catch (error) {
232234
if (error.status === 403 || error.status === 404) {
233235
this.skip()

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

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ import {
1616
productionEnvironment,
1717
environmentUpdate
1818
} from '../mock/configurations.js'
19-
import { validateEnvironmentResponse, testData, wait } from '../utility/testHelpers.js'
19+
import { validateEnvironmentResponse, testData, wait, trackedExpect } from '../utility/testHelpers.js'
2020

2121
/**
2222
* Helper function to wait for environment to be available after creation
@@ -81,13 +81,13 @@ describe('Environment API Tests', () => {
8181
// SDK returns the environment object directly
8282
const env = await stack.environment().create(envData)
8383

84-
expect(env).to.be.an('object')
85-
expect(env.uid).to.be.a('string')
84+
trackedExpect(env, 'Environment').toBeAn('object')
85+
trackedExpect(env.uid, 'Environment UID').toBeA('string')
8686
validateEnvironmentResponse(env)
8787

88-
expect(env.name).to.equal(devEnvName)
89-
expect(env.urls).to.be.an('array')
90-
expect(env.urls.length).to.be.at.least(1)
88+
trackedExpect(env.name, 'Environment name').toEqual(devEnvName)
89+
trackedExpect(env.urls, 'Environment urls').toBeAn('array')
90+
trackedExpect(env.urls.length, 'Environment urls count').toBeAtLeast(1)
9191

9292
createdEnvUid = env.uid
9393
currentEnvName = env.name
@@ -107,9 +107,9 @@ describe('Environment API Tests', () => {
107107
// SDK uses environment NAME for fetch (not UID) - following old test pattern
108108
const response = await waitForEnvironment(stack, currentEnvName)
109109

110-
expect(response).to.be.an('object')
111-
expect(response.uid).to.equal(createdEnvUid)
112-
expect(response.name).to.equal(currentEnvName)
110+
trackedExpect(response, 'Environment').toBeAn('object')
111+
trackedExpect(response.uid, 'Environment UID').toEqual(createdEnvUid)
112+
trackedExpect(response.name, 'Environment name').toEqual(currentEnvName)
113113
})
114114

115115
it('should validate environment URL structure', async function () {

0 commit comments

Comments
 (0)