Skip to content
Merged

Next #119

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
19 commits
Select commit Hold shift + click to select a range
010f950
test: Added locale test suit and delete test suit to sanity folder
harshithad0703 Jan 19, 2024
0c4641c
chore: updated package-lock file
harshithad0703 Jan 19, 2024
4699571
Merge pull request #113 from contentstack/test/cs-43465-environment-d…
harshithad0703 Jan 22, 2024
bf8d05f
Added taxonomy import/export support (#112)
sunil-lakshman Jan 22, 2024
7b4bb83
Validating the object when update the entries with assets (#114)
sunil-lakshman Jan 22, 2024
786fa6d
test: added delivery token test sanity folder
harshithad0703 Jan 23, 2024
08e79f6
test: added extension test suit to sanity
harshithad0703 Jan 24, 2024
a1f1866
test: updated test msg
harshithad0703 Jan 24, 2024
f4a52d6
Merge pull request #116 from contentstack/test/cs-43491-sanity-test-d…
harshithad0703 Jan 24, 2024
9427708
cleared assertion error
harshithad0703 Jan 24, 2024
9098484
test: added assertions for failing tests
harshithad0703 Jan 25, 2024
2802b79
Merge pull request #117 from contentstack/test/cs-43492-sanity-test-e…
harshithad0703 Jan 25, 2024
6938c0d
Feat/cs 43619 taxonomy import export testcases (#118)
sunil-lakshman Jan 25, 2024
4d20885
Merge branch 'master' into next
sunil-lakshman Jan 25, 2024
3489d88
test: added global field test suit to sanity
harshithad0703 Jan 25, 2024
ff8dd65
Merge branch 'next' into test/cs-43493-sanity-test-global-fields
harshithad0703 Jan 25, 2024
3f57256
Merge pull request #120 from contentstack/test/cs-43493-sanity-test-g…
harshithad0703 Jan 25, 2024
4a07c8a
test: add sanity test for label
harshithad0703 Jan 29, 2024
c01d3a0
Merge pull request #121 from contentstack/test/cs-43494-sanity-test-f…
harshithad0703 Jan 29, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,8 @@
# Changelog

## [v1.15.1](https://github.com/contentstack/contentstack-management-javascript/tree/v1.15.1) (2024-01-29)
- Feature
- Taxonomy Import/Export test cases are added
## [v1.15.0](https://github.com/contentstack/contentstack-management-javascript/tree/v1.15.0) (2024-01-23)
- Feature
- Taxonomy Import/Export feature added
Expand Down
5 changes: 3 additions & 2 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "@contentstack/management",
"version": "1.15.0",
"version": "1.15.1",
"description": "The Content Management API is used to manage the content of your Contentstack account",
"main": "./dist/node/contentstack-management.js",
"browser": "./dist/web/contentstack-management.js",
Expand Down Expand Up @@ -30,7 +30,8 @@
"buildnativescript": "webpack --config webpack/webpack.nativescript.js --mode production",
"buildweb": "webpack --config webpack/webpack.web.js --mode production",
"test": "npm run test:api && npm run test:unit",
"test:sanity": "BABEL_ENV=test nyc --reporter=html mocha --require @babel/register ./test/sanity-check/sanity.js -t 30000 --reporter mochawesome --require babel-polyfill --reporter-options reportDir=mochawesome-report,reportFilename=mochawesome.json && marge mochawesome-report/mochawesome.json -f sanity-report.html --inline",
"test:sanity-test": "BABEL_ENV=test nyc --reporter=html mocha --require @babel/register ./test/sanity-check/sanity.js -t 30000 --reporter mochawesome --require babel-polyfill --reporter-options reportDir=mochawesome-report,reportFilename=mochawesome.json && marge mochawesome-report/mochawesome.json -f sanity-report.html --inline",
"test:sanity": "npm run test:sanity-test || true",
"test:sanity-report": "marge mochawesome-report/mochawesome.json -f sanity-report.html --inline && node sanity-report.mjs",
"test:api": "BABEL_ENV=test nyc --reporter=html --reporter=text mocha --require @babel/register ./test/test.js -t 30000 --reporter mochawesome --require babel-polyfill",
"test:unit": "BABEL_ENV=test nyc --reporter=html --reporter=text mocha --require @babel/register ./test/unit/index.js -t 30000 --reporter mochawesome --require babel-polyfill",
Expand Down
8 changes: 8 additions & 0 deletions test/api/mock/taxonomy.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"taxonomy": {
"uid": "UID",
"name": "name",
"description": "test"
},
"terms": []
}
25 changes: 25 additions & 0 deletions test/api/taxonomy-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { expect } from 'chai'
import path from 'path'
import { describe, it, setup } from 'mocha'
import { jsonReader } from '../utility/fileOperations/readwrite'
import { contentstackClient } from '../utility/ContentstackClient.js'
Expand All @@ -12,6 +13,8 @@ const taxonomy = {
description: 'Description for Taxonomy testing'
}

const importTaxonomy = { taxonomy: path.join(__dirname, './mock/taxonomy.json') }

var taxonomyUID = ''
var taxonomyDelUID = 'taxonomy_testing'

Expand All @@ -32,6 +35,28 @@ describe('taxonomy api Test', () => {
.catch(done)
})

it('Import taxonomy', done => {
makeTaxonomy()
.import(importTaxonomy)
.then((taxonomyResponse) => {
expect(taxonomyResponse.name).to.be.equal("name")
done()
})
.catch(done)
})

it('Export taxonomy', done => {
makeTaxonomy(taxonomyUID)
.export()
.then((taxonomyResponse) => {
expect(taxonomyResponse.uid).to.be.equal(taxonomyUID)
expect(taxonomyResponse.name).to.be.not.equal(null)
done()
})
.catch(done)
})


it('Fetch taxonomy from uid', done => {
makeTaxonomy(taxonomyUID)
.fetch()
Expand Down
23 changes: 0 additions & 23 deletions test/sanity-check/api/branchAlias-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -55,29 +55,6 @@ describe('Branch Alias api Test', () => {
})
.catch(done)
})

it('Should delete Branch Alias', done => {
try {
makeBranchAlias(`${stageBranch.uid}_alias`)
.delete()
.then((response) => {
expect(response.notice).to.be.equal('Branch alias deleted successfully.')
done()
})
.catch(done)
} catch (e) {
done()
}
})
it('Should delete stage branch from uid', done => {
client.stack({ api_key: process.env.API_KEY }).branch(stageBranch.uid)
.delete()
.then((response) => {
expect(response.notice).to.be.equal('Your request to delete branch is in progress. Please check organization bulk task queue for more details.')
done()
})
.catch(done)
})
})

function makeBranchAlias (uid = null) {
Expand Down
10 changes: 10 additions & 0 deletions test/sanity-check/api/contentType-delete-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,6 +21,16 @@ describe('Content Type delete api Test', () => {
makeContentType(singlepageCT.content_type.uid).delete()
.catch(done)
})

it('should delete ContentTypes', done => {
makeContentType('multi_page_from_json')
.delete()
.then((contentType) => {
expect(contentType.notice).to.be.equal('Content Type deleted successfully.')
done()
})
.catch(done)
})
})

function makeContentType (uid = null) {
Expand Down
12 changes: 0 additions & 12 deletions test/sanity-check/api/contentType-test.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@ import { contentstackClient } from '../utility/ContentstackClient.js'

let client = {}
let multiPageCTUid = ''
let importCTUid = ''

describe('Content Type api Test', () => {
setup(() => {
Expand Down Expand Up @@ -100,22 +99,11 @@ describe('Content Type api Test', () => {
content_type: path.join(__dirname, '../mock/contentType.json')
})
.then((response) => {
importCTUid = response.uid
expect(response.uid).to.be.not.equal(null)
done()
})
.catch(done)
})

it('should delete ContentTypes', done => {
makeContentType(importCTUid)
.delete()
.then((contentType) => {
expect(contentType.notice).to.be.equal('Content Type deleted successfully.')
done()
})
.catch(done)
})
})

function makeContentType (uid = null) {
Expand Down
74 changes: 73 additions & 1 deletion test/sanity-check/api/delete-test.js
Original file line number Diff line number Diff line change
@@ -1,8 +1,13 @@
import { expect } from 'chai'
import { describe, it, setup } from 'mocha'
import { jsonReader } from '../utility/fileOperations/readwrite'
import { environmentCreate, environmentProdCreate } from '../mock/environment.js'
import { contentstackClient } from '../utility/ContentstackClient.js'
import { environmentCreate, environmentProdCreate } from '../mock/environment.js'
import { stageBranch } from '../mock/branch.js'
import { createDeliveryToken } from '../mock/deliveryToken.js'
import dotenv from 'dotenv'

dotenv.config()

let client = {}

Expand Down Expand Up @@ -59,10 +64,77 @@ describe('Delete Locale api Test', () => {
})
})

describe('Delivery Token delete api Test', () => {
let tokenUID = ''
setup(() => {
const user = jsonReader('loggedinuser.json')
client = contentstackClient(user.authtoken)
})

it('should get token uid by name for deleting that token', done => {
makeDeliveryToken()
.query({ query: { name: createDeliveryToken.token.name } })
.find()
.then((tokens) => {
tokens.items.forEach((token) => {
tokenUID = token.uid
})
done()
})
.catch(done)
})
it('should delete Delivery token from uid', done => {
makeDeliveryToken(tokenUID)
.delete()
.then((data) => {
expect(data.notice).to.be.equal('Delivery Token deleted successfully.')
done()
})
.catch(done)
})
})

describe('Branch Alias delete api Test', () => {
setup(() => {
const user = jsonReader('loggedinuser.json')
client = contentstackClient(user.authtoken)
})
it('Should delete Branch Alias', done => {
try {
makeBranchAlias(`${stageBranch.uid}_alias`)
.delete()
.then((response) => {
expect(response.notice).to.be.equal('Branch alias deleted successfully.')
done()
})
.catch(done)
} catch (e) {
done()
}
})
it('Should delete stage branch from uid', done => {
client.stack({ api_key: process.env.API_KEY }).branch(stageBranch.uid)
.delete()
.then((response) => {
expect(response.notice).to.be.equal('Your request to delete branch is in progress. Please check organization bulk task queue for more details.')
done()
})
.catch(done)
})
})

function makeEnvironment (uid = null) {
return client.stack({ api_key: process.env.API_KEY }).environment(uid)
}

function makeLocale (uid = null) {
return client.stack({ api_key: process.env.API_KEY }).locale(uid)
}

function makeDeliveryToken (uid = null) {
return client.stack({ api_key: process.env.API_KEY }).deliveryToken(uid)
}

function makeBranchAlias (uid = null) {
return client.stack({ api_key: process.env.API_KEY }).branchAlias(uid)
}
143 changes: 143 additions & 0 deletions test/sanity-check/api/deliveryToken-test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,143 @@
import { expect } from 'chai'
import { describe, it, setup } from 'mocha'
import { jsonReader } from '../utility/fileOperations/readwrite'
import { createDeliveryToken, createDeliveryToken2 } from '../mock/deliveryToken.js'
import { contentstackClient } from '../utility/ContentstackClient.js'
import dotenv from 'dotenv'

dotenv.config()
let client = {}

let tokenUID = ''
describe('Delivery Token api Test', () => {
setup(() => {
const user = jsonReader('loggedinuser.json')
client = contentstackClient(user.authtoken)
})

it('should add a Delivery Token for development', done => {
makeDeliveryToken()
.create(createDeliveryToken)
.then((token) => {
expect(token.name).to.be.equal(createDeliveryToken.token.name)
expect(token.description).to.be.equal(createDeliveryToken.token.description)
expect(token.scope[0].environments[0].name).to.be.equal(createDeliveryToken.token.scope[0].environments[0])
expect(token.scope[0].module).to.be.equal(createDeliveryToken.token.scope[0].module)
expect(token.uid).to.be.not.equal(null)
done()
})
.catch(done)
})

it('should add a Delivery Token for production', done => {
makeDeliveryToken()
.create(createDeliveryToken2)
.then((token) => {
tokenUID = token.uid
expect(token.name).to.be.equal(createDeliveryToken2.token.name)
expect(token.description).to.be.equal(createDeliveryToken2.token.description)
expect(token.scope[0].environments[0].name).to.be.equal(createDeliveryToken2.token.scope[0].environments[0])
expect(token.scope[0].module).to.be.equal(createDeliveryToken2.token.scope[0].module)
expect(token.uid).to.be.not.equal(null)
done()
})
.catch(done)
})

it('should get a Delivery Token from uid', done => {
makeDeliveryToken(tokenUID)
.fetch()
.then((token) => {
expect(token.name).to.be.equal(createDeliveryToken2.token.name)
expect(token.description).to.be.equal(createDeliveryToken2.token.description)
expect(token.scope[0].environments[0].name).to.be.equal(createDeliveryToken2.token.scope[0].environments[0])
expect(token.scope[0].module).to.be.equal(createDeliveryToken2.token.scope[0].module)
expect(token.uid).to.be.not.equal(null)
done()
})
.catch(done)
})

it('should query to get all Delivery Token', done => {
makeDeliveryToken()
.query()
.find()
.then((tokens) => {
tokens.items.forEach((token) => {
expect(token.name).to.be.not.equal(null)
expect(token.description).to.be.not.equal(null)
expect(token.scope[0].environments[0].name).to.be.not.equal(null)
expect(token.scope[0].module).to.be.not.equal(null)
expect(token.uid).to.be.not.equal(null)
})
done()
})
.catch(done)
})

it('should query to get a Delivery Token from name', done => {
makeDeliveryToken()
.query({ query: { name: createDeliveryToken.token.name } })
.find()
.then((tokens) => {
tokens.items.forEach((token) => {
expect(token.name).to.be.equal(createDeliveryToken.token.name)
expect(token.description).to.be.equal(createDeliveryToken.token.description)
expect(token.scope[0].environments[0].name).to.be.equal(createDeliveryToken.token.scope[0].environments[0])
expect(token.scope[0].module).to.be.equal(createDeliveryToken.token.scope[0].module)
expect(token.uid).to.be.not.equal(null)
})
done()
})
.catch(done)
})

it('should fetch and update a Delivery Token from uid', done => {
makeDeliveryToken(tokenUID)
.fetch()
.then((token) => {
token.name = 'Update Production Name'
token.description = 'Update Production description'
token.scope = createDeliveryToken2.token.scope
return token.update()
})
.then((token) => {
expect(token.name).to.be.equal('Update Production Name')
expect(token.description).to.be.equal('Update Production description')
expect(token.scope[0].environments[0].name).to.be.equal(createDeliveryToken2.token.scope[0].environments[0])
expect(token.scope[0].module).to.be.equal(createDeliveryToken2.token.scope[0].module)
expect(token.uid).to.be.not.equal(null)
done()
})
.catch(done)
})

it('should update a Delivery Token from uid', done => {
const token = makeDeliveryToken(tokenUID)
Object.assign(token, createDeliveryToken2.token)
token.update()
.then((token) => {
expect(token.name).to.be.equal(createDeliveryToken2.token.name)
expect(token.description).to.be.equal(createDeliveryToken2.token.description)
expect(token.scope[0].environments[0].name).to.be.equal(createDeliveryToken2.token.scope[0].environments[0])
expect(token.scope[0].module).to.be.equal(createDeliveryToken2.token.scope[0].module)
expect(token.uid).to.be.not.equal(null)
done()
})
.catch(done)
})

it('should delete a Delivery Token from uid', done => {
makeDeliveryToken(tokenUID)
.delete()
.then((data) => {
expect(data.notice).to.be.equal('Delivery Token deleted successfully.')
done()
})
.catch(done)
})
})

function makeDeliveryToken (uid = null) {
return client.stack({ api_key: process.env.API_KEY }).deliveryToken(uid)
}
Loading