Skip to content

Commit 14c1394

Browse files
committed
fix: ESLint in branch-test.js and auditlog-test.js
- branch-test: remove unused mock imports and createdBranch; fix trailing spaces, padded-blocks - auditlog-test: remove unused testData; fix trailing spaces, padded-blocks, no-unused-expressions
1 parent 1ce0d64 commit 14c1394

File tree

2 files changed

+14
-29
lines changed

2 files changed

+14
-29
lines changed

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

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* Audit Log API Tests
3-
*
3+
*
44
* Comprehensive test suite for:
55
* - Audit log fetch
66
* - Audit log filtering
@@ -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, trackedExpect } from '../utility/testHelpers.js'
13+
import { trackedExpect } from '../utility/testHelpers.js'
1414

1515
describe('Audit Log API Tests', () => {
1616
let client
@@ -26,7 +26,6 @@ describe('Audit Log API Tests', () => {
2626
// ==========================================================================
2727

2828
describe('Audit Log Fetch', () => {
29-
3029
it('should fetch audit logs', async () => {
3130
try {
3231
const response = await stack.auditLog().fetchAll()
@@ -80,7 +79,6 @@ describe('Audit Log API Tests', () => {
8079
// ==========================================================================
8180

8281
describe('Audit Log Filtering', () => {
83-
8482
it('should fetch logs with pagination', async () => {
8583
try {
8684
const response = await stack.auditLog().query({
@@ -117,7 +115,6 @@ describe('Audit Log API Tests', () => {
117115
// ==========================================================================
118116

119117
describe('Error Handling', () => {
120-
121118
it('should fail to fetch non-existent audit log', async () => {
122119
try {
123120
await stack.auditLog('nonexistent_log_12345').fetch()
@@ -139,6 +136,7 @@ describe('Audit Log API Tests', () => {
139136
console.log('Audit log accessible without auth token - skipping test')
140137
} catch (error) {
141138
// Accept any error - could be 401, 403, or other auth-related errors
139+
// eslint-disable-next-line no-unused-expressions
142140
expect(error).to.exist
143141
if (error.status) {
144142
expect(error.status).to.be.oneOf([401, 403, 422])

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

Lines changed: 11 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
/**
22
* Branch API Tests
3-
*
3+
*
44
* Comprehensive test suite for:
55
* - Branch CRUD operations
66
* - Branch compare
@@ -12,14 +12,6 @@
1212
import { expect } from 'chai'
1313
import { describe, it, before, after } from 'mocha'
1414
import { contentstackClient } from '../utility/ContentstackClient.js'
15-
import {
16-
developmentBranch,
17-
featureBranch,
18-
branchCompare,
19-
branchMerge,
20-
branchAlias,
21-
branchAliasUpdate
22-
} from '../mock/configurations.js'
2315
import { validateBranchResponse, testData, wait, shortId, trackedExpect } from '../utility/testHelpers.js'
2416

2517
describe('Branch API Tests', () => {
@@ -37,8 +29,7 @@ describe('Branch API Tests', () => {
3729

3830
describe('Branch CRUD Operations', () => {
3931
// Branch UID must be max 15 chars, only lowercase and numbers
40-
let devBranchUid = `dev${shortId()}`
41-
let createdBranch
32+
const devBranchUid = `dev${shortId()}`
4233
let branchCreated = false
4334

4435
after(async () => {
@@ -63,7 +54,7 @@ describe('Branch API Tests', () => {
6354

6455
it('should create a development branch from main', async function () {
6556
this.timeout(30000)
66-
57+
6758
const branchData = {
6859
branch: {
6960
uid: devBranchUid,
@@ -82,18 +73,16 @@ describe('Branch API Tests', () => {
8273
trackedExpect(branch.uid, 'Branch UID').toEqual(devBranchUid)
8374
expect(branch.source).to.equal('main')
8475

85-
createdBranch = branch
8676
branchCreated = true
8777
testData.branches.development = branch
88-
78+
8979
// Wait for branch to be fully ready
9080
await wait(3000)
9181
} catch (error) {
9282
// If branch already exists (409), try to fetch it
9383
if (error.status === 409 || (error.errorMessage && error.errorMessage.includes('already exists'))) {
9484
console.log(` Branch ${devBranchUid} already exists, fetching it`)
9585
const existing = await stack.branch(devBranchUid).fetch()
96-
createdBranch = existing
9786
branchCreated = true
9887
testData.branches.development = existing
9988
} else {
@@ -105,13 +94,13 @@ describe('Branch API Tests', () => {
10594

10695
it('should fetch the created branch', async function () {
10796
this.timeout(15000)
108-
97+
10998
if (!branchCreated) {
11099
console.log(' Skipping - branch was not created')
111100
this.skip()
112101
return
113102
}
114-
103+
115104
const response = await stack.branch(devBranchUid).fetch()
116105

117106
expect(response).to.be.an('object')
@@ -124,7 +113,7 @@ describe('Branch API Tests', () => {
124113
this.skip()
125114
return
126115
}
127-
116+
128117
const branch = await stack.branch(devBranchUid).fetch()
129118

130119
expect(branch.uid).to.be.a('string')
@@ -274,7 +263,6 @@ describe('Branch API Tests', () => {
274263
// ==========================================================================
275264

276265
describe('Error Handling', () => {
277-
278266
it('should fail to create branch with duplicate UID', async () => {
279267
// Main branch always exists
280268
try {
@@ -329,9 +317,8 @@ describe('Branch API Tests', () => {
329317
// ==========================================================================
330318

331319
describe('Delete Branch', () => {
332-
333320
// Helper to wait for branch to be ready (with polling)
334-
async function waitForBranchReady(branchUid, maxAttempts = 10) {
321+
async function waitForBranchReady (branchUid, maxAttempts = 10) {
335322
for (let i = 0; i < maxAttempts; i++) {
336323
try {
337324
const branch = await stack.branch(branchUid).fetch()
@@ -357,7 +344,7 @@ describe('Branch API Tests', () => {
357344
source: 'main'
358345
}
359346
})
360-
347+
361348
// Wait for branch to be fully created (15 seconds like old tests)
362349
await wait(15000)
363350

@@ -380,14 +367,14 @@ describe('Branch API Tests', () => {
380367
source: 'main'
381368
}
382369
})
383-
370+
384371
// Wait for branch to be fully created (15 seconds like old tests)
385372
await wait(15000)
386373

387374
// Poll until branch is ready
388375
const branch = await waitForBranchReady(tempBranchUid, 5)
389376
await branch.delete()
390-
377+
391378
// Wait for deletion to propagate
392379
await wait(5000)
393380

0 commit comments

Comments
 (0)