diff --git a/CHANGELOG.md b/CHANGELOG.md index 919e210e..7138fa22 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Changelog +## [v1.15.4](https://github.com/contentstack/contentstack-management-javascript/tree/v1.15.4) (2024-03-26) + - Fixes + - sanity test and dependency upgrades ## [v1.15.3](https://github.com/contentstack/contentstack-management-javascript/tree/v1.15.3) (2024-02-16) - Fix - Fix for updating entry diff --git a/package-lock.json b/package-lock.json index 02d5b32d..c3662261 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,16 +1,16 @@ { "name": "@contentstack/management", - "version": "1.15.3", + "version": "1.15.4", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "@contentstack/management", - "version": "1.15.3", + "version": "1.15.4", "license": "MIT", "dependencies": { "@slack/bolt": "^3.17.1", - "axios": "^1.6.6", + "axios": "^1.6.8", "form-data": "^3.0.1", "lodash": "^4.17.21", "qs": "^6.11.2" @@ -3974,11 +3974,11 @@ } }, "node_modules/axios": { - "version": "1.6.6", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.6.tgz", - "integrity": "sha512-XZLZDFfXKM9U/Y/B4nNynfCRUqNyVZ4sBC/n9GDRCkq9vd2mIvKjKKsbIh1WPmHmNbg6ND7cTBY3Y2+u1G3/2Q==", + "version": "1.6.8", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.8.tgz", + "integrity": "sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ==", "dependencies": { - "follow-redirects": "^1.15.4", + "follow-redirects": "^1.15.6", "form-data": "^4.0.0", "proxy-from-env": "^1.1.0" } @@ -6489,9 +6489,9 @@ "dev": true }, "node_modules/follow-redirects": { - "version": "1.15.4", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.4.tgz", - "integrity": "sha512-Cr4D/5wlrb0z9dgERpUL3LrmPKVDsETIJhaCMeDfuFYcqa5bldGV6wBsAN6X/vxlXQtFBMrXdXxdL8CbDTGniw==", + "version": "1.15.6", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", + "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==", "funding": [ { "type": "individual", @@ -16685,11 +16685,11 @@ "integrity": "sha512-DMD0KiN46eipeziST1LPP/STfDU0sufISXmjSgvVsoU2tqxctQeASejWcfNtxYKqETM1UxQ8sp2OrSBWpHY6sw==" }, "axios": { - "version": "1.6.6", - "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.6.tgz", - "integrity": "sha512-XZLZDFfXKM9U/Y/B4nNynfCRUqNyVZ4sBC/n9GDRCkq9vd2mIvKjKKsbIh1WPmHmNbg6ND7cTBY3Y2+u1G3/2Q==", + "version": "1.6.8", + "resolved": "https://registry.npmjs.org/axios/-/axios-1.6.8.tgz", + "integrity": "sha512-v/ZHtJDU39mDpyBoFVkETcd/uNdxrWRrg3bKpOKzXFA6Bvqopts6ALSMU3y6ijYxbw2B+wPrIv46egTzJXCLGQ==", "requires": { - "follow-redirects": "^1.15.4", + "follow-redirects": "^1.15.6", "form-data": "^4.0.0", "proxy-from-env": "^1.1.0" }, @@ -18614,9 +18614,9 @@ "dev": true }, "follow-redirects": { - "version": "1.15.4", - "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.4.tgz", - "integrity": "sha512-Cr4D/5wlrb0z9dgERpUL3LrmPKVDsETIJhaCMeDfuFYcqa5bldGV6wBsAN6X/vxlXQtFBMrXdXxdL8CbDTGniw==" + "version": "1.15.6", + "resolved": "https://registry.npmjs.org/follow-redirects/-/follow-redirects-1.15.6.tgz", + "integrity": "sha512-wWN62YITEaOpSK584EZXJafH1AGpO8RVgElfkuXbTOrPX4fIfOyEpW/CsiNd8JdYrAoOvafRTOEnvsO++qCqFA==" }, "for-each": { "version": "0.3.3", diff --git a/package.json b/package.json index f04fc96c..c8ed9ca8 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "@contentstack/management", - "version": "1.15.3", + "version": "1.15.4", "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", @@ -53,7 +53,7 @@ "license": "MIT", "dependencies": { "@slack/bolt": "^3.17.1", - "axios": "^1.6.6", + "axios": "^1.6.8", "form-data": "^3.0.1", "lodash": "^4.17.21", "qs": "^6.11.2" diff --git a/sanity-report.mjs b/sanity-report.mjs index 2014ae87..6a2fe583 100644 --- a/sanity-report.mjs +++ b/sanity-report.mjs @@ -25,7 +25,7 @@ console.log(`Pending Tests: ${pendingTests}`) console.log(`Total Duration: ${durationInMinutes}m ${durationInSeconds.toFixed(2)}s`) const slackMessage = ` -*Test Summary* +*JavaScript CMA Report* • Total Suites: *${totalSuites}* • Total Tests: *${totalTests}* • Passed Tests: *${passedTests}* diff --git a/test/sanity-check/api/asset-test.js b/test/sanity-check/api/asset-test.js index 70d7fbe0..db3e68b4 100644 --- a/test/sanity-check/api/asset-test.js +++ b/test/sanity-check/api/asset-test.js @@ -1,7 +1,7 @@ import path from 'path' import { expect } from 'chai' import { describe, it, setup } from 'mocha' -import { jsonReader, writeDownloadedFile } from '../utility/fileOperations/readwrite' +import { jsonReader, jsonWrite, writeDownloadedFile } from '../utility/fileOperations/readwrite' import { contentstackClient } from '../utility/ContentstackClient.js' var client = {} @@ -25,6 +25,7 @@ describe('Assets api Test', () => { } makeAsset().create(asset) .then((asset) => { + jsonWrite(asset, 'publishAsset2.json') assetUID = asset.uid assetURL = asset.url expect(asset.uid).to.be.not.equal(null) @@ -76,6 +77,7 @@ describe('Assets api Test', () => { } makeAsset().create(asset) .then((asset) => { + jsonWrite(asset, 'publishAsset1.json') publishAssetUID = asset.uid expect(asset.uid).to.be.not.equal(null) expect(asset.url).to.be.not.equal(null) diff --git a/test/sanity-check/api/bulkOperation-test.js b/test/sanity-check/api/bulkOperation-test.js new file mode 100644 index 00000000..afa79406 --- /dev/null +++ b/test/sanity-check/api/bulkOperation-test.js @@ -0,0 +1,121 @@ +import { expect } from 'chai' +import { describe, it, setup } from 'mocha' +import { jsonReader } from '../../sanity-check/utility/fileOperations/readwrite' +import { contentstackClient } from '../../sanity-check/utility/ContentstackClient' +import { singlepageCT, multiPageCT } from '../mock/content-type.js' +import dotenv from 'dotenv' +dotenv.config() + +let client = {} +let entryUid1 = '' +let assetUid1 = '' +let entryUid2 = '' +let assetUid2 = '' + +describe('BulkOperation api test', () => { + setup(() => { + const user = jsonReader('loggedinuser.json') + const entryRead1 = jsonReader('publishEntry1.json') + const assetRead1 = jsonReader('publishAsset1.json') + entryUid1 = entryRead1.uid + assetUid1 = assetRead1.uid + const entryRead2 = jsonReader('publishEntry2.json') + const assetRead2 = jsonReader('publishAsset2.json') + entryUid2 = entryRead2.uid + assetUid2 = assetRead2.uid + client = contentstackClient(user.authtoken) + }) + + it('should publish one entry when publishDetails of an entry is passed', done => { + const publishDetails = { + entries: [ + { + uid: entryUid1, + content_type: multiPageCT.content_type.title, + locale: 'en-us' + } + ], + locales: [ + 'en-us' + ], + environments: [ + 'development' + ] + } + doBulkOperation() + .publish({ details: publishDetails, api_version: '3.2' }) + .then((response) => { + expect(response.notice).to.not.equal(undefined) + expect(response.job_id).to.not.equal(undefined) + done() + }) + .catch(done) + }) + + it('should publish one asset when publishDetails of an asset is passed', done => { + const publishDetails = { + assets: [ + { + uid: assetUid1 + } + ], + locales: [ + 'en-us' + ], + environments: [ + 'development' + ] + } + doBulkOperation() + .publish({ details: publishDetails, api_version: '3.2' }) + .then((response) => { + expect(response.notice).to.not.equal(undefined) + expect(response.job_id).to.not.equal(undefined) + done() + }) + .catch(done) + }) + + it('should publish multiple entries assets when publishDetails of entries and assets are passed', done => { + const publishDetails = { + entries: [ + { + uid: entryUid1, + content_type: multiPageCT.content_type.uid, + locale: 'en-us' + }, + { + uid: entryUid2, + content_type: singlepageCT.content_type.uid, + locale: 'en-us' + } + ], + assets: [ + { + uid: assetUid1 + }, + { + uid: assetUid2 + } + ], + locales: [ + 'en-us' + ], + environments: [ + 'development' + ] + } + doBulkOperation() + .publish({ details: publishDetails, api_version: '3.2' }) + .then((response) => { + expect(response.notice).to.not.equal(undefined) + expect(response.job_id).to.not.equal(undefined) + done() + }) + .catch(done) + }) +}) + +function doBulkOperation (uid = null) { + return client.stack({ api_key: process.env.API_KEY }).bulkOperation() +} diff --git a/test/sanity-check/api/entry-test.js b/test/sanity-check/api/entry-test.js index fc2f02bd..e22da61b 100644 --- a/test/sanity-check/api/entry-test.js +++ b/test/sanity-check/api/entry-test.js @@ -50,6 +50,7 @@ describe('Entry api Test', () => { return entry.update({ locale: 'en-at' }) }) .then((entryResponse) => { + jsonWrite(entryResponse, 'publishEntry2.json') entryUTD = entryResponse.uid expect(entryResponse.title).to.be.equal('Sample Entry in en-at') expect(entryResponse.uid).to.be.not.equal(null) @@ -182,6 +183,7 @@ describe('Entry api Test', () => { entry: path.join(__dirname, '../mock/entry.json') }) .then((response) => { + jsonWrite(response, 'publishEntry1.json') expect(response.uid).to.be.not.equal(null) done() }) diff --git a/test/sanity-check/api/user-test.js b/test/sanity-check/api/user-test.js index aa7e21f2..838828cf 100644 --- a/test/sanity-check/api/user-test.js +++ b/test/sanity-check/api/user-test.js @@ -1,7 +1,7 @@ import { expect } from 'chai' import { describe, it } from 'mocha' -import { contentstackClient } from '../../utility/ContentstackClient' -import { jsonWrite } from '../../utility/fileOperations/readwrite' +import { contentstackClient } from '../../sanity-check/utility/ContentstackClient' +import { jsonWrite } from '../../sanity-check/utility/fileOperations/readwrite' import axios from 'axios' import dotenv from 'dotenv' diff --git a/test/sanity-check/sanity.js b/test/sanity-check/sanity.js index bb69aafd..169a91d2 100644 --- a/test/sanity-check/sanity.js +++ b/test/sanity-check/sanity.js @@ -13,6 +13,7 @@ require('./api/contentType-test') require('./api/asset-test') require('./api/extension-test') require('./api/entry-test') +require('./api/bulkOperation-test') require('./api/webhook-test') require('./api/workflow-test') require('./api/globalfield-test') diff --git a/test/sanity-check/utility/fileOperations/readwrite.js b/test/sanity-check/utility/fileOperations/readwrite.js index c06fe895..b5ae4900 100644 --- a/test/sanity-check/utility/fileOperations/readwrite.js +++ b/test/sanity-check/utility/fileOperations/readwrite.js @@ -1,6 +1,6 @@ import fs from 'fs' import path from 'path' -const dataFiles = './test/utility/dataFiles/' +const dataFiles = './test/sanity-check/utility/dataFiles/' export function jsonReader (fileName) { if (!fs.existsSync(`${dataFiles}${fileName}`)) { return