From 0fe5a58f20a8c37cdc820a59d96210e1e76959c3 Mon Sep 17 00:00:00 2001 From: hitesh-shetty-cstk Date: Mon, 24 Aug 2026 17:08:19 +0530 Subject: [PATCH] chore(tests): standardize api key placeholder values in specs Spec fixtures used ad hoc api key strings that read like real stack keys (bltanything, bltapikey, livePreviewApiKey123, test-key), so sample data was hard to tell apart from meaningful values. Replace them all with YOUR_API_KEY. The one exception is the test asserting that a user-config api key takes precedence over an SDK header api key, where the header keeps a distinct YOUR_HEADER_API_KEY so the assertion still proves precedence rather than passing trivially. Co-Authored-By: Claude --- .../__test__/handleUserConfig.test.ts | 26 +++++++++---------- src/livePreview/__test__/live-preview.test.ts | 6 ++--- .../contentstack-live-preview-HOC.test.ts | 8 +++--- 3 files changed, 20 insertions(+), 20 deletions(-) diff --git a/src/configManager/__test__/handleUserConfig.test.ts b/src/configManager/__test__/handleUserConfig.test.ts index b4cda152..011190b8 100644 --- a/src/configManager/__test__/handleUserConfig.test.ts +++ b/src/configManager/__test__/handleUserConfig.test.ts @@ -53,7 +53,7 @@ describe("handleInitData()", () => { const initData: Partial = { enable: true, stackDetails: { - apiKey: "bltanything", + apiKey: "YOUR_API_KEY", environment: "", }, }; @@ -64,7 +64,7 @@ describe("handleInitData()", () => { enable: true, cleanCslpOnProduction: true, stackDetails: { - apiKey: "bltanything", + apiKey: "YOUR_API_KEY", environment: "", contentTypeUid: "", entryUid: "", @@ -90,7 +90,7 @@ describe("handleInitData()", () => { const initData: Partial = { enable: true, stackDetails: { - apiKey: "bltanything", + apiKey: "YOUR_API_KEY", environment: "", }, }; @@ -103,7 +103,7 @@ describe("handleInitData()", () => { const initData: Partial = { enable: true, stackDetails: { - apiKey: "bltanything", + apiKey: "YOUR_API_KEY", environment: "", }, stackSdk: { @@ -111,7 +111,7 @@ describe("handleInitData()", () => { enable: true, }, headers: { - api_key: "bltanything", + api_key: "YOUR_API_KEY", }, environment: "", cachePolicy: 1, @@ -138,7 +138,7 @@ describe("handleInitData()", () => { mode: "builder", stackDetails: { environment: "main", - apiKey: "bltanything", + apiKey: "YOUR_API_KEY", }, }; @@ -176,23 +176,23 @@ describe("handleInitData()", () => { const initData: Partial = { enable: true, stackDetails: { - apiKey: "bltuserapikey", + apiKey: "YOUR_API_KEY", }, }; handleInitData(initData); - expect(config.stackDetails.apiKey).toBe("bltuserapikey"); + expect(config.stackDetails.apiKey).toBe("YOUR_API_KEY"); initData.stackSdk = { live_preview: {}, headers: { - api_key: "bltheaderapikey", + api_key: "YOUR_HEADER_API_KEY", }, environment: "dev", }; handleInitData(initData); - expect(config.stackDetails.apiKey).toBe("bltuserapikey"); + expect(config.stackDetails.apiKey).toBe("YOUR_API_KEY"); }); test("should reset api key if it is not passed", () => { @@ -270,7 +270,7 @@ describe("handleInitData()", () => { const initData: Partial = { enable: true, stackDetails: { - apiKey: "bltapikey", + apiKey: "YOUR_API_KEY", }, mode: "builder", }; @@ -294,7 +294,7 @@ describe("handleInitData()", () => { initData.stackSdk = { live_preview: {}, headers: { - api_key: "bltapikey", + api_key: "YOUR_API_KEY", branch: "sdkbranch", }, environment: "dev", @@ -311,7 +311,7 @@ describe("handleInitData()", () => { stackSdk: { live_preview: {}, headers: { - api_key: "sdkbranch", + api_key: "YOUR_API_KEY", branch: "sdkbranch", }, environment: "dev", diff --git a/src/livePreview/__test__/live-preview.test.ts b/src/livePreview/__test__/live-preview.test.ts index c4ef5398..05bd4df4 100644 --- a/src/livePreview/__test__/live-preview.test.ts +++ b/src/livePreview/__test__/live-preview.test.ts @@ -607,7 +607,7 @@ describe("enable=false early return", () => { Config.replace({ enable: false, mode: "builder", - stackDetails: { environment: "preview", apiKey: "test-key" }, + stackDetails: { environment: "preview", apiKey: "YOUR_API_KEY" }, }); new LivePreview(); @@ -656,7 +656,7 @@ describe("LivePreview edit button condition", () => { enable: true, editButton: { enable: false }, mode: "builder", - stackDetails: { environment: "preview", apiKey: "test-key" }, + stackDetails: { environment: "preview", apiKey: "YOUR_API_KEY" }, }); new LivePreview(); @@ -745,7 +745,7 @@ describe("LivePreview init with partial stackDetails", () => { Config.replace({ enable: true, stackDetails: { - apiKey: "partial-key", + apiKey: "YOUR_API_KEY", } as any, }); diff --git a/src/preview/__test__/contentstack-live-preview-HOC.test.ts b/src/preview/__test__/contentstack-live-preview-HOC.test.ts index 0dafa3e8..c13745ab 100644 --- a/src/preview/__test__/contentstack-live-preview-HOC.test.ts +++ b/src/preview/__test__/contentstack-live-preview-HOC.test.ts @@ -98,7 +98,7 @@ describe("Live Preview HOC init", () => { mode: "builder", stackDetails: { environment: "development", - apiKey: "livePreviewApiKey123", + apiKey: "YOUR_API_KEY", }, }); @@ -171,13 +171,13 @@ describe("Live Preview HOC config", () => { const userConfig: Partial = { enable: true, stackDetails: { - apiKey: "livePreviewApiKey123", + apiKey: "YOUR_API_KEY", }, }; ContentstackLivePreview.init(userConfig); - expect(Config.get().stackDetails.apiKey).toBe("livePreviewApiKey123"); + expect(Config.get().stackDetails.apiKey).toBe("YOUR_API_KEY"); }); test("should set the hash from the URL", async () => { @@ -225,7 +225,7 @@ describe("Live Preview HOC config", () => { const userConfig: Partial = { enable: true, stackDetails: { - apiKey: "livePreviewApiKey123", + apiKey: "YOUR_API_KEY", }, };