diff --git a/CHANGELOG.md b/CHANGELOG.md index 2c11ea9d..1b2bd660 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,10 @@ ## Change log +### Version: 3.25.3 +#### Date: April-21-2025 +##### Fix: + - Handle the sanity tests when ENVs are not provided + ### Version: 3.25.2 #### Date: April-02-2025 ##### Fix: diff --git a/README.md b/README.md index 5dffec71..3471eda5 100755 --- a/README.md +++ b/README.md @@ -19,11 +19,11 @@ For browsers, we recommend to download the library via npm or yarn to ensure 100 If you'd like to use a standalone built file you can use the following script tag or download it from [jsDelivr](https://www.jsdelivr.com/package/npm/contentstack), under the `dist` directory: ```html - + ``` You can also specify a specific version number. ```html - + ``` To initialize the SDK, you will need to specify the API Key, Delivery Token, and Environment Name of your stack. diff --git a/package-lock.json b/package-lock.json index b9fd17b6..5f81ba35 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "contentstack", - "version": "3.25.2", + "version": "3.25.3", "lockfileVersion": 3, "requires": true, "packages": { "": { "name": "contentstack", - "version": "3.25.2", + "version": "3.25.3", "license": "MIT", "dependencies": { "@contentstack/utils": "^1.3.18", diff --git a/package.json b/package.json index a3427ed2..4a5b1dd2 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "contentstack", - "version": "3.25.2", + "version": "3.25.3", "description": "Contentstack Javascript SDK", "homepage": "https://www.contentstack.com/", "author": { diff --git a/test/config.js b/test/config.js index 69c45db8..6f5088f2 100755 --- a/test/config.js +++ b/test/config.js @@ -1,5 +1,15 @@ 'use strict'; -require('dotenv').config() +require('dotenv').config(); + +const requiredVars = ['HOST', 'EMAIL', 'PASSWORD', 'ORGANIZATION', 'API_KEY']; +const missingVars = requiredVars.filter((key) => !process.env[key]); + +if (missingVars.length > 0) { + const errorMessage = `\x1b[31mError: Missing environment variables - ${missingVars.join(', ')}`; + const error = new Error(errorMessage); + error.stack = error.message; + throw error; +} module.exports = { stack: { 'api_key': process.env.API_KEY, 'delivery_token': process.env.DELIVERY_TOKEN, 'environment': process.env.ENVIRONMENT, }, diff --git a/test/live-preview/live-preview-test.js b/test/live-preview/live-preview-test.js index 4ffc93e2..6685e8cb 100644 --- a/test/live-preview/live-preview-test.js +++ b/test/live-preview/live-preview-test.js @@ -1,11 +1,13 @@ 'use strict'; +const init = require("../config.js"); const Contentstack = require('../../dist/node/contentstack.js'); describe('Contentstack Live Preview Tests', () => { test('should check for values initialized', () => { + const stack1 = Contentstack.Stack(init.stack) const stack = Contentstack.Stack({ - 'api_key': process.env.region_API_KEY, + 'api_key': process.env.API_KEY, 'delivery_token': process.env.DELIVERY_TOKEN, 'environment': process.env.ENVIRONMENT }); @@ -16,15 +18,9 @@ describe('Contentstack Live Preview Tests', () => { }); test('should check host when live preview is enabled and management token is provided', () => { - const stack = Contentstack.Stack({ - 'api_key': process.env.API_KEY, - 'delivery_token': process.env.DELIVERY_TOKEN, - 'environment': process.env.ENVIRONMENT, - live_preview: { - enable: true, - management_token: 'management_token' - } - }); + init.stack.live_preview.enable = true; + init.stack.live_preview.management_token = 'management_token'; + const stack = Contentstack.Stack(init.stack); const livePreviewObject = stack.config.live_preview; expect(livePreviewObject).not.toBe('undefined'); @@ -34,15 +30,9 @@ describe('Contentstack Live Preview Tests', () => { }); test('should check host when live preview is disabled and management token is provided', () => { - const stack = Contentstack.Stack({ - 'api_key': process.env.API_KEY, - 'delivery_token': process.env.DELIVERY_TOKEN, - 'environment': process.env.ENVIRONMENT, - live_preview: { - enable: false, - management_token: 'management_token' - } - }); + init.stack.live_preview.enable = false; + init.stack.live_preview.management_token = 'management_token'; + const stack = Contentstack.Stack(init.stack); const livePreviewObject = stack.config.live_preview; expect(livePreviewObject).not.toBe('undefined'); @@ -51,15 +41,9 @@ describe('Contentstack Live Preview Tests', () => { }); test('should check host when live preview is enabled and preview token is provided', () => { - const stack = Contentstack.Stack({ - 'api_key': process.env.API_KEY, - 'delivery_token': process.env.DELIVERY_TOKEN, - 'environment': process.env.ENVIRONMENT, - live_preview: { - enable: true, - preview_token: 'preview_token' - } - }); + init.stack.live_preview.enable = true; + init.stack.live_preview.preview_token = 'preview_token'; + const stack = Contentstack.Stack(init.stack); const livePreviewObject = stack.config.live_preview; expect(livePreviewObject).not.toBe('undefined'); @@ -70,15 +54,9 @@ describe('Contentstack Live Preview Tests', () => { }); test('should check host when live preview is disabled and preview token is provided', () => { - const stack = Contentstack.Stack({ - 'api_key': process.env.API_KEY, - 'delivery_token': process.env.DELIVERY_TOKEN, - 'environment': process.env.ENVIRONMENT, - live_preview: { - enable: false, - preview_token: 'preview_token' - } - }); + init.stack.live_preview.enable = false; + init.stack.live_preview.preview_token = 'preview_token'; + const stack = Contentstack.Stack(init.stack); const livePreviewObject = stack.config.live_preview; expect(livePreviewObject).not.toBe('undefined');