Skip to content

Commit 64d940b

Browse files
committed
test: ✅ added compare and merge api tests [CS-36688]
1 parent 74c1550 commit 64d940b

File tree

3 files changed

+80
-2
lines changed

3 files changed

+80
-2
lines changed

lib/entity.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -275,7 +275,7 @@ export async function get (http, url, params, data) {
275275
...cloneDeep(params)
276276
},
277277
headers: {
278-
...cloneDeep(this.stackHeaders)
278+
...cloneDeep(data.stackHeaders)
279279
}
280280
} || {}
281281
try {

test/api/branch-test.js

Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -116,6 +116,84 @@ describe('Branch api Test', () => {
116116
})
117117
.catch(done)
118118
})
119+
120+
it('Should provide list of content types and global fields that exist in only one branch or are different between the two branches', done => {
121+
makeBranch(branch.uid)
122+
.compare(devBranch.uid)
123+
.all()
124+
.then((response) => {
125+
expect(response.branches.base_branch).to.be.equal(branch.uid)
126+
expect(response.branches.compare_branch).to.be.equal(devBranch.uid)
127+
done()
128+
})
129+
.catch(done)
130+
})
131+
132+
it('Should list differences for a single content type between two branches', done => {
133+
makeBranch(branch.uid)
134+
.compare(devBranch.uid)
135+
.contentTypes()
136+
.then((response) => {
137+
expect(response.branches.base_branch).to.be.equal(branch.uid)
138+
expect(response.branches.compare_branch).to.be.equal(devBranch.uid)
139+
done()
140+
})
141+
.catch(done)
142+
})
143+
144+
it('Should list differences for a single global field between two branches', done => {
145+
makeBranch(branch.uid)
146+
.compare(devBranch.uid)
147+
.globalFields()
148+
.then((response) => {
149+
expect(response.branches.base_branch).to.be.equal(branch.uid)
150+
expect(response.branches.compare_branch).to.be.equal(devBranch.uid)
151+
done()
152+
})
153+
.catch(done)
154+
})
155+
156+
it('Should provide list of global fields that exist in only one branch or are different between the two branches', done => {
157+
const mergeObj = {
158+
base_branch: branch.uid,
159+
compare_branch: devBranch.uid,
160+
default_merge_strategy: "ignore",
161+
merge_comment: "Merging dev into main",
162+
no_revert: true
163+
}
164+
makeBranch()
165+
.merge(mergeObj)
166+
.then((response) => {
167+
expect(response.branches.base_branch).to.be.equal(branch.uid)
168+
expect(response.branches.compare_branch).to.be.equal(devBranch.uid)
169+
done()
170+
})
171+
.catch(done)
172+
})
173+
174+
it('Should list all recent merge jobs', done => {
175+
makeBranch()
176+
.mergeQueue()
177+
.find()
178+
.then((response) => {
179+
expect(response.branches.base_branch).to.be.equal(branch.uid)
180+
expect(response.branches.compare_branch).to.be.equal(devBranch.uid)
181+
done()
182+
})
183+
.catch(done)
184+
})
185+
186+
it('Should list all recent merge jobs', done => {
187+
makeBranch()
188+
.mergeQueue(branch.uid)
189+
.fetch()
190+
.then((response) => {
191+
expect(response.branches.base_branch).to.be.equal(branch.uid)
192+
expect(response.branches.compare_branch).to.be.equal(devBranch.uid)
193+
done()
194+
})
195+
.catch(done)
196+
})
119197
})
120198

121199
function makeBranch (uid = null) {

test/utility/ContentstackClient.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import * as contentstack from '../../lib/contentstack.js'
22
import dotenv from 'dotenv'
33
dotenv.config()
44
function contentstackClient (authtoken = null) {
5-
var params = { host: process.env.HOST }
5+
var params = { host: process.env.HOST, version: process.env.VERSION || 'v3', defaultHostName: process.env.DEFAULTHOST }
66
if (authtoken) {
77
params.authtoken = authtoken
88
}

0 commit comments

Comments
 (0)