Skip to content

Commit

Permalink
Merge pull request #205 from contentstack/fix/add-delay-in-sanity
Browse files Browse the repository at this point in the history
add delay for branch and term creation
  • Loading branch information
harshithad0703 authored Oct 23, 2024
2 parents 01758db + d983caa commit de92d67
Show file tree
Hide file tree
Showing 3 changed files with 32 additions and 49 deletions.
22 changes: 9 additions & 13 deletions test/sanity-check/api/branch-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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()
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 @@ -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) => {
Expand Down
57 changes: 22 additions & 35 deletions test/sanity-check/api/terms-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 => {
Expand Down Expand Up @@ -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) {
Expand Down

0 comments on commit de92d67

Please sign in to comment.