From 5126b8bcdfe6d56b844ac0af02c205c9b412cdd3 Mon Sep 17 00:00:00 2001 From: "harshitha.d" Date: Tue, 22 Oct 2024 19:26:51 +0530 Subject: [PATCH 1/2] add delay for branch and term creation --- test/sanity-check/api/branch-test.js | 22 ++++------ test/sanity-check/api/taxonomy-test.js | 3 +- test/sanity-check/api/terms-test.js | 57 ++++++++++---------------- 3 files changed, 33 insertions(+), 49 deletions(-) diff --git a/test/sanity-check/api/branch-test.js b/test/sanity-check/api/branch-test.js index 57491802..147fcd0d 100644 --- a/test/sanity-check/api/branch-test.js +++ b/test/sanity-check/api/branch-test.js @@ -12,19 +12,15 @@ describe('Branch api Test', () => { client = contentstackClient(user.authtoken) }) - it('should create a dev branch from stage branch', done => { - makeBranch() - .create({ branch: devBranch }) - .then((response) => { - expect(response.uid).to.be.equal(devBranch.uid) - expect(response.source).to.be.equal(devBranch.source) - expect(response.alias).to.not.equal(undefined) - expect(response.delete).to.not.equal(undefined) - expect(response.fetch).to.not.equal(undefined) - done() - }) - .catch(done) - }) + it('should create a dev branch from stage branch',async () => { + const response = await makeBranch().create({ branch: devBranch }); + expect(response.uid).to.be.equal(devBranch.uid); + expect(response.source).to.be.equal(devBranch.source); + expect(response.alias).to.not.equal(undefined); + expect(response.delete).to.not.equal(undefined); + expect(response.fetch).to.not.equal(undefined); + await new Promise(resolve => setTimeout(resolve, 15000)); + }); it('should return main branch when query is called', done => { makeBranch() diff --git a/test/sanity-check/api/taxonomy-test.js b/test/sanity-check/api/taxonomy-test.js index 7493c27f..cce95eb4 100644 --- a/test/sanity-check/api/taxonomy-test.js +++ b/test/sanity-check/api/taxonomy-test.js @@ -32,7 +32,7 @@ describe('taxonomy api Test', () => { .catch(done) }) - it('should fetch taxonomy of the uid passe', done => { + it('should fetch taxonomy of the uid passed', done => { makeTaxonomy(taxonomyUID) .fetch() .then((taxonomyResponse) => { @@ -51,6 +51,7 @@ describe('taxonomy api Test', () => { return taxonomyResponse.update() }) .then((taxonomyResponse) => { + console.log("🚀 ~ .then ~ taxonomyResponse:", taxonomyResponse) expect(taxonomyResponse.uid).to.be.equal(taxonomyUID) expect(taxonomyResponse.name).to.be.equal('Updated Name') done() diff --git a/test/sanity-check/api/terms-test.js b/test/sanity-check/api/terms-test.js index 16e782e7..097ab370 100644 --- a/test/sanity-check/api/terms-test.js +++ b/test/sanity-check/api/terms-test.js @@ -44,31 +44,22 @@ describe('Terms API Test', () => { await client.stack({ api_key: process.env.API_KEY }).taxonomy().create({ taxonomy }) }, 10000) - it('should create term', done => { - makeTerms(taxonomy.uid).create(term) - .then((response) => { - expect(response.uid).to.be.equal(term.term.uid) - done() - }) - .catch(done) + it('should create term', async () => { + const response = await makeTerms(taxonomy.uid).create(term) + expect(response.uid).to.be.equal(term.term.uid) + await new Promise(resolve => setTimeout(resolve, 15000)); }) - it('should create child term 1', done => { - makeTerms(taxonomy.uid).create(childTerm1) - .then((response) => { - expect(response.uid).to.be.equal(childTerm1.term.uid) - done() - }) - .catch(done) + it('should create child term 1', async () => { + const response = await makeTerms(taxonomy.uid).create(childTerm1) + expect(response.uid).to.be.equal(childTerm1.term.uid) + await new Promise(resolve => setTimeout(resolve, 15000)); }) - it('should create child term 2', done => { - makeTerms(taxonomy.uid).create(childTerm2) - .then((response) => { - expect(response.uid).to.be.equal(childTerm2.term.uid) - done() - }) - .catch(done) + it('should create child term 2', async () => { + const response = await makeTerms(taxonomy.uid).create(childTerm2) + expect(response.uid).to.be.equal(childTerm2.term.uid) + await new Promise(resolve => setTimeout(resolve, 15000)); }) it('should query and get all terms', done => { @@ -180,20 +171,16 @@ describe('Branch creation api Test', () => { client = contentstackClient(user.authtoken) }) - it('should create staging branch', done => { - makeBranch() - .create({ branch: stageBranch }) - .then((response) => { - expect(response.uid).to.be.equal(stageBranch.uid) - expect(response.urlPath).to.be.equal(`/stacks/branches/${stageBranch.uid}`) - expect(response.source).to.be.equal(stageBranch.source) - expect(response.alias).to.not.equal(undefined) - expect(response.delete).to.not.equal(undefined) - expect(response.fetch).to.not.equal(undefined) - done() - }) - .catch(done) - }) + it('should create staging branch', async () => { + const response = await makeBranch().create({ branch: stageBranch }); + expect(response.uid).to.be.equal(stageBranch.uid); + expect(response.urlPath).to.be.equal(`/stacks/branches/${stageBranch.uid}`); + expect(response.source).to.be.equal(stageBranch.source); + expect(response.alias).to.not.equal(undefined); + expect(response.fetch).to.not.equal(undefined); + expect(response.delete).to.not.equal(undefined); + await new Promise(resolve => setTimeout(resolve, 15000)); + }); }) function makeBranch (uid = null) { From 044f4d5a77d7425be12c7b9d1d67722010d972dc Mon Sep 17 00:00:00 2001 From: "harshitha.d" Date: Wed, 23 Oct 2024 10:29:23 +0530 Subject: [PATCH 2/2] removed console.log --- test/sanity-check/api/taxonomy-test.js | 1 - 1 file changed, 1 deletion(-) diff --git a/test/sanity-check/api/taxonomy-test.js b/test/sanity-check/api/taxonomy-test.js index cce95eb4..4ce676a0 100644 --- a/test/sanity-check/api/taxonomy-test.js +++ b/test/sanity-check/api/taxonomy-test.js @@ -51,7 +51,6 @@ describe('taxonomy api Test', () => { return taxonomyResponse.update() }) .then((taxonomyResponse) => { - console.log("🚀 ~ .then ~ taxonomyResponse:", taxonomyResponse) expect(taxonomyResponse.uid).to.be.equal(taxonomyUID) expect(taxonomyResponse.name).to.be.equal('Updated Name') done()