Skip to content

Commit ae2bdae

Browse files
Merge pull request #166 from contentstack/fix/DX-869-sanity-test-failures
DX | 869 | sanity test failures
2 parents fb5260f + fdcb3a0 commit ae2bdae

File tree

4 files changed

+22
-21
lines changed

4 files changed

+22
-21
lines changed

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

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ import { contentstackClient } from '../utility/ContentstackClient'
66
var user = {}
77
var client = {}
88
var organization = {}
9+
let organizationUID = process.env.ORGANIZATION
910

1011
describe('Organization api test', () => {
1112
setup(() => {
@@ -50,7 +51,7 @@ describe('Organization api test', () => {
5051
})
5152

5253
it('should get all stacks in an Organization', done => {
53-
organization.stacks()
54+
client.organization(organizationUID).stacks()
5455
.then((response) => {
5556
for (const index in response.items) {
5657
const stack = response.items[index]
@@ -76,13 +77,13 @@ describe('Organization api test', () => {
7677
// })
7778

7879
it('should get all roles in an organization', done => {
79-
organization.roles()
80+
client.organization(organizationUID).roles()
8081
.then((roles) => {
8182
for (const i in roles.items) {
8283
jsonWrite(roles.items, 'orgRoles.json')
8384
expect(roles.items[i].uid).to.not.equal(null, 'Role uid cannot be null')
8485
expect(roles.items[i].name).to.not.equal(null, 'Role name cannot be null')
85-
expect(roles.items[i].org_uid).to.be.equal(organization.uid, 'Role org_uid not match')
86+
expect(roles.items[i].org_uid).to.be.equal(organizationUID, 'Role org_uid not match')
8687
}
8788
done()
8889
})

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ describe('taxonomy api Test', () => {
2727
expect(taxonomyResponse.name).to.be.equal(taxonomy.name)
2828
setTimeout(() => {
2929
done()
30-
}, 1000)
30+
}, 10000)
3131
})
3232
.catch(done)
3333
})

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

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,25 @@ const stackApiKey = process.env.API_KEY
1212
let userId = ''
1313
let teamUid1 = ''
1414
let teamUid2 = ''
15-
let orgRole1 = ''
16-
let stackRole1 = ''
17-
let stackRole2 = ''
18-
let stackRole3 = ''
15+
const orgAdminRole = ''
16+
let adminRole = ''
17+
let contentManagerRole = ''
18+
let developerRole = ''
1919

2020
describe('Teams API Test', () => {
2121
beforeEach(() => {
2222
const user = jsonReader('loggedinuser.json')
2323
client = contentstackClient(user.authtoken)
2424
const orgRoles = jsonReader('orgRoles.json')
25-
orgRole1 = orgRoles[0].uid
25+
orgAdminRole = orgRoles.find(role => role.name === 'admin').uid;
2626
})
2727

2828
it('should create new team 1 when required object is passed', async () => {
2929
const response = await makeTeams().create({
3030
name: 'test_team1',
3131
users: [],
3232
stackRoleMapping: [],
33-
organizationRole: orgRole1 })
33+
organizationRole: orgAdminRole })
3434
teamUid1 = response.uid
3535
expect(response.uid).not.to.be.equal(null)
3636
expect(response.name).not.to.be.equal(null)
@@ -43,7 +43,7 @@ describe('Teams API Test', () => {
4343
name: 'test_team2',
4444
users: [],
4545
stackRoleMapping: [],
46-
organizationRole: orgRole1 })
46+
organizationRole: orgAdminRole })
4747
teamUid2 = response.uid
4848
expect(response.uid).not.to.be.equal(null)
4949
expect(response.name).not.to.be.equal(null)
@@ -76,7 +76,7 @@ describe('Teams API Test', () => {
7676
email: process.env.EMAIL
7777
}
7878
],
79-
organizationRole: orgRole1,
79+
organizationRole: '',
8080
stackRoleMapping: []
8181
}
8282
await makeTeams(teamUid1).update(updateData)
@@ -98,16 +98,16 @@ describe('Teams Stack Role Mapping API Test', () => {
9898
const user = jsonReader('loggedinuser.json')
9999
client = contentstackClient(user.authtoken)
100100
const stackRoles = jsonReader('roles.json')
101-
stackRole1 = stackRoles[0].uid
102-
stackRole2 = stackRoles[1].uid
103-
stackRole3 = stackRoles[2].uid
101+
adminRole = stackRoles.find(role => role.name === 'Admin').uid;
102+
contentManagerRole = stackRoles.find(role => role.name === 'Content Manager').uid;
103+
developerRole = stackRoles.find(role => role.name === 'Developer').uid;
104104
})
105105

106106
it('should add roles', done => {
107107
const stackRoleMappings = {
108108
stackApiKey: stackApiKey,
109109
roles: [
110-
stackRole1
110+
adminRole
111111
]
112112
}
113113
makestackRoleMappings(teamUid2).add(stackRoleMappings).then((response) => {
@@ -130,9 +130,9 @@ describe('Teams Stack Role Mapping API Test', () => {
130130
it('should update roles', done => {
131131
const stackRoleMappings = {
132132
roles: [
133-
stackRole1,
134-
stackRole2,
135-
stackRole3
133+
adminRole,
134+
contentManagerRole,
135+
developerRole
136136
]
137137
}
138138
makestackRoleMappings(teamUid2, stackApiKey).update(stackRoleMappings).then((response) => {

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -42,7 +42,7 @@ describe('Terms API Test', () => {
4242
})
4343
it('should create taxonomy', async () => {
4444
await client.stack({ api_key: process.env.API_KEY }).taxonomy().create({ taxonomy })
45-
})
45+
}, 10000)
4646

4747
it('should create term', done => {
4848
makeTerms(taxonomy.uid).create(term)
@@ -144,7 +144,7 @@ describe('Terms API Test', () => {
144144
})
145145

146146
it('should move the term to parent uid passed', done => {
147-
makeTerms(taxonomy.uid, childTerm2.term.uid).move({ force: true })
147+
makeTerms(taxonomy.uid, childTerm2.term.uid).fetch()
148148
.then(async (term) => {
149149
term.parent_uid = null
150150
const moveTerm = await term.move({ force: true })

0 commit comments

Comments
 (0)