From a54c816eaf57b9f0abfafb139f7fec99a45ef4a1 Mon Sep 17 00:00:00 2001 From: harshithad0703 Date: Wed, 10 Jul 2024 15:50:34 +0530 Subject: [PATCH] test: added delay for taxonomy creation and updated term test case --- test/sanity-check/api/organization-test.js | 7 ++--- test/sanity-check/api/taxonomy-test.js | 2 +- test/sanity-check/api/team-test.js | 30 +++++++++++----------- test/sanity-check/api/terms-test.js | 4 +-- 4 files changed, 22 insertions(+), 21 deletions(-) diff --git a/test/sanity-check/api/organization-test.js b/test/sanity-check/api/organization-test.js index 11866ed9..f1beb65d 100644 --- a/test/sanity-check/api/organization-test.js +++ b/test/sanity-check/api/organization-test.js @@ -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(() => { @@ -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] @@ -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() }) diff --git a/test/sanity-check/api/taxonomy-test.js b/test/sanity-check/api/taxonomy-test.js index 6a898f22..7493c27f 100644 --- a/test/sanity-check/api/taxonomy-test.js +++ b/test/sanity-check/api/taxonomy-test.js @@ -27,7 +27,7 @@ describe('taxonomy api Test', () => { expect(taxonomyResponse.name).to.be.equal(taxonomy.name) setTimeout(() => { done() - }, 1000) + }, 10000) }) .catch(done) }) diff --git a/test/sanity-check/api/team-test.js b/test/sanity-check/api/team-test.js index 0a103b29..2f9de0b9 100644 --- a/test/sanity-check/api/team-test.js +++ b/test/sanity-check/api/team-test.js @@ -12,17 +12,17 @@ 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 () => { @@ -30,7 +30,7 @@ describe('Teams API Test', () => { 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) @@ -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) @@ -76,7 +76,7 @@ describe('Teams API Test', () => { email: process.env.EMAIL } ], - organizationRole: orgRole1, + organizationRole: '', stackRoleMapping: [] } await makeTeams(teamUid1).update(updateData) @@ -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) => { @@ -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) => { diff --git a/test/sanity-check/api/terms-test.js b/test/sanity-check/api/terms-test.js index 3280023b..16e782e7 100644 --- a/test/sanity-check/api/terms-test.js +++ b/test/sanity-check/api/terms-test.js @@ -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) @@ -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 })