Skip to content

Commit

Permalink
test: added delay for taxonomy creation and updated term test case
Browse files Browse the repository at this point in the history
  • Loading branch information
harshithad0703 committed Jul 10, 2024
1 parent 971a4d9 commit e975292
Show file tree
Hide file tree
Showing 4 changed files with 22 additions and 21 deletions.
7 changes: 4 additions & 3 deletions test/sanity-check/api/organization-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { contentstackClient } from '../utility/ContentstackClient'
var user = {}
var client = {}
var organization = {}
let organizationUID = process.env.ORGANIZATION

describe('Organization api test', () => {
setup(() => {
Expand Down Expand Up @@ -50,7 +51,7 @@ describe('Organization api test', () => {
})

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

it('should get all roles in an organization', done => {
organization.roles()
client.organization(organizationUID).roles()
.then((roles) => {
for (const i in roles.items) {
jsonWrite(roles.items, 'orgRoles.json')
expect(roles.items[i].uid).to.not.equal(null, 'Role uid cannot be null')
expect(roles.items[i].name).to.not.equal(null, 'Role name cannot be null')
expect(roles.items[i].org_uid).to.be.equal(organization.uid, 'Role org_uid not match')
expect(roles.items[i].org_uid).to.be.equal(organizationUID, 'Role org_uid not match')
}
done()
})
Expand Down
2 changes: 1 addition & 1 deletion test/sanity-check/api/taxonomy-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ describe('taxonomy api Test', () => {
expect(taxonomyResponse.name).to.be.equal(taxonomy.name)
setTimeout(() => {
done()
}, 1000)
}, 10000)
})
.catch(done)
})
Expand Down
30 changes: 15 additions & 15 deletions test/sanity-check/api/team-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,25 +12,25 @@ const stackApiKey = process.env.API_KEY
let userId = ''
let teamUid1 = ''
let teamUid2 = ''
let orgRole1 = ''
let stackRole1 = ''
let stackRole2 = ''
let stackRole3 = ''
const orgAdminRole = ''
let adminRole = ''
let contentManagerRole = ''
let developerRole = ''

describe('Teams API Test', () => {
beforeEach(() => {
const user = jsonReader('loggedinuser.json')
client = contentstackClient(user.authtoken)
const orgRoles = jsonReader('orgRoles.json')
orgRole1 = orgRoles[0].uid
orgAdminRole = orgRoles.find(role => role.name === 'admin').uid;
})

it('should create new team 1 when required object is passed', async () => {
const response = await makeTeams().create({
name: 'test_team1',
users: [],
stackRoleMapping: [],
organizationRole: orgRole1 })
organizationRole: orgAdminRole })
teamUid1 = response.uid
expect(response.uid).not.to.be.equal(null)
expect(response.name).not.to.be.equal(null)
Expand All @@ -43,7 +43,7 @@ describe('Teams API Test', () => {
name: 'test_team2',
users: [],
stackRoleMapping: [],
organizationRole: orgRole1 })
organizationRole: orgAdminRole })
teamUid2 = response.uid
expect(response.uid).not.to.be.equal(null)
expect(response.name).not.to.be.equal(null)
Expand Down Expand Up @@ -76,7 +76,7 @@ describe('Teams API Test', () => {
email: process.env.EMAIL
}
],
organizationRole: orgRole1,
organizationRole: '',
stackRoleMapping: []
}
await makeTeams(teamUid1).update(updateData)
Expand All @@ -98,16 +98,16 @@ describe('Teams Stack Role Mapping API Test', () => {
const user = jsonReader('loggedinuser.json')
client = contentstackClient(user.authtoken)
const stackRoles = jsonReader('roles.json')
stackRole1 = stackRoles[0].uid
stackRole2 = stackRoles[1].uid
stackRole3 = stackRoles[2].uid
adminRole = stackRoles.find(role => role.name === 'Admin').uid;
contentManagerRole = stackRoles.find(role => role.name === 'Content Manager').uid;
developerRole = stackRoles.find(role => role.name === 'Developer').uid;
})

it('should add roles', done => {
const stackRoleMappings = {
stackApiKey: stackApiKey,
roles: [
stackRole1
adminRole
]
}
makestackRoleMappings(teamUid2).add(stackRoleMappings).then((response) => {
Expand All @@ -130,9 +130,9 @@ describe('Teams Stack Role Mapping API Test', () => {
it('should update roles', done => {
const stackRoleMappings = {
roles: [
stackRole1,
stackRole2,
stackRole3
adminRole,
contentManagerRole,
developerRole
]
}
makestackRoleMappings(teamUid2, stackApiKey).update(stackRoleMappings).then((response) => {
Expand Down
4 changes: 2 additions & 2 deletions test/sanity-check/api/terms-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ describe('Terms API Test', () => {
})
it('should create taxonomy', async () => {
await client.stack({ api_key: process.env.API_KEY }).taxonomy().create({ taxonomy })
})
}, 10000)

it('should create term', done => {
makeTerms(taxonomy.uid).create(term)
Expand Down Expand Up @@ -144,7 +144,7 @@ describe('Terms API Test', () => {
})

it('should move the term to parent uid passed', done => {
makeTerms(taxonomy.uid, childTerm2.term.uid).move({ force: true })
makeTerms(taxonomy.uid, childTerm2.term.uid).fetch()
.then(async (term) => {
term.parent_uid = null
const moveTerm = await term.move({ force: true })
Expand Down

0 comments on commit e975292

Please sign in to comment.