From 204b8d4b125e3762ab7a48e926e07617a3eecb85 Mon Sep 17 00:00:00 2001 From: Akansha Arora <> Date: Mon, 23 Sep 2024 16:49:47 +0530 Subject: [PATCH 1/7] Jarvis stage for acom stage env --- libs/features/jarvis-chat.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/libs/features/jarvis-chat.js b/libs/features/jarvis-chat.js index fc5c313ee5..03e516ba21 100644 --- a/libs/features/jarvis-chat.js +++ b/libs/features/jarvis-chat.js @@ -204,7 +204,7 @@ const openChat = (event) => { }; const startInitialization = async (config, event, onDemand) => { - const asset = 'https://client.messaging.adobe.com/latest/AdobeMessagingClient'; + const asset = `https://${config.env.name !== 'prod' ? 'stage-' : ''}client.messaging.adobe.com/latest/AdobeMessagingClient`; await Promise.all([ loadStyle(`${asset}.css`), loadScript(`${asset}.js`), From 7bb775c2c19a64588141f02110e932e82788957a Mon Sep 17 00:00:00 2001 From: Akansha Arora <> Date: Wed, 25 Sep 2024 10:39:46 +0530 Subject: [PATCH 2/7] Added test cases for asset URL verification --- test/features/jarvis-chat/jarvis-chat.test.js | 31 +++++++++++++++++++ 1 file changed, 31 insertions(+) diff --git a/test/features/jarvis-chat/jarvis-chat.test.js b/test/features/jarvis-chat/jarvis-chat.test.js index ee6e6fe273..a94ae533f0 100644 --- a/test/features/jarvis-chat/jarvis-chat.test.js +++ b/test/features/jarvis-chat/jarvis-chat.test.js @@ -262,4 +262,35 @@ describe('Jarvis Chat', () => { params.callbacks.onReadyCallback(); expect(openMessagingWindowSpy.called).to.be.true; }); + it('should use stage asset URL in non-prod environment', async () => { + setConfig(defaultConfig); + const config = getConfig(); + config.jarvis.onDemand = false; + + const loadScriptSpy = sinon.spy(); + const loadStyleSpy = sinon.spy(); + + await initJarvisChat(config, loadScriptSpy, loadStyleSpy, sinon.stub()); + + const expectedAsset = 'https://stage-client.messaging.adobe.com/latest/AdobeMessagingClient'; + expect(loadScriptSpy.calledWithExactly(`${expectedAsset}.js`)).to.be.true; + expect(loadStyleSpy.calledWithExactly(`${expectedAsset}.css`)).to.be.true; + }); + + it('should use prod asset URL in prod environment', async () => { + setConfig(defaultConfig); + const config = getConfig(); + config.jarvis.onDemand = false; + config.env.name = 'prod'; + + const loadScriptSpy = sinon.spy(); + const loadStyleSpy = sinon.spy(); + + await initJarvisChat(config, loadScriptSpy, loadStyleSpy, sinon.stub()); + + const expectedAsset = 'https://client.messaging.adobe.com/latest/AdobeMessagingClient'; + expect(loadScriptSpy.calledWithExactly(`${expectedAsset}.js`)).to.be.true; + expect(loadStyleSpy.calledWithExactly(`${expectedAsset}.css`)).to.be.true; + }); + }); From 324e62c5ead8b7c37ac6f882daa92a1bf72e9671 Mon Sep 17 00:00:00 2001 From: Akansha Arora <> Date: Wed, 25 Sep 2024 10:58:12 +0530 Subject: [PATCH 3/7] Added test cases for asset URL verification --- test/features/jarvis-chat/jarvis-chat.test.js | 104 +++++++++++++----- 1 file changed, 75 insertions(+), 29 deletions(-) diff --git a/test/features/jarvis-chat/jarvis-chat.test.js b/test/features/jarvis-chat/jarvis-chat.test.js index a94ae533f0..c2aee96f59 100644 --- a/test/features/jarvis-chat/jarvis-chat.test.js +++ b/test/features/jarvis-chat/jarvis-chat.test.js @@ -2,7 +2,10 @@ import sinon from 'sinon'; import { expect } from '@esm-bundle/chai'; import { readFile } from '@web/test-runner-commands'; -import { initJarvisChat, openChat } from '../../../libs/features/jarvis-chat.js'; +import { + initJarvisChat, + openChat, +} from '../../../libs/features/jarvis-chat.js'; import { setConfig, getConfig } from '../../../libs/utils/utils.js'; const defaultConfig = { @@ -18,17 +21,33 @@ describe('Jarvis Chat', () => { let isAdobeMessagingClientInitializedStub; let getMessagingExperienceStateStub; beforeEach(() => { - window.AdobeMessagingExperienceClient = window.AdobeMessagingExperienceClient - || { + window.AdobeMessagingExperienceClient = + window.AdobeMessagingExperienceClient || { initialize: () => {}, openMessagingWindow: () => {}, isAdobeMessagingClientInitialized: () => {}, getMessagingExperienceState: () => {}, }; - initializeSpy = sinon.spy(window.AdobeMessagingExperienceClient, 'initialize'); - openMessagingWindowSpy = sinon.spy(window.AdobeMessagingExperienceClient, 'openMessagingWindow'); - isAdobeMessagingClientInitializedStub = sinon.stub(window.AdobeMessagingExperienceClient, 'isAdobeMessagingClientInitialized').returns(true); - getMessagingExperienceStateStub = sinon.stub(window.AdobeMessagingExperienceClient, 'getMessagingExperienceState').returns({ windowState: 'hidden' }); + initializeSpy = sinon.spy( + window.AdobeMessagingExperienceClient, + 'initialize' + ); + openMessagingWindowSpy = sinon.spy( + window.AdobeMessagingExperienceClient, + 'openMessagingWindow' + ); + isAdobeMessagingClientInitializedStub = sinon + .stub( + window.AdobeMessagingExperienceClient, + 'isAdobeMessagingClientInitialized' + ) + .returns(true); + getMessagingExperienceStateStub = sinon + .stub( + window.AdobeMessagingExperienceClient, + 'getMessagingExperienceState' + ) + .returns({ windowState: 'hidden' }); }); afterEach(() => { @@ -168,12 +187,16 @@ describe('Jarvis Chat', () => { }); it('should open a chat session upon click', async () => { - document.body.innerHTML = await readFile({ path: './mocks/jarvis-chat.html' }); + document.body.innerHTML = await readFile({ + path: './mocks/jarvis-chat.html', + }); setConfig(defaultConfig); const config = getConfig(); await initJarvisChat(config, sinon.stub(), sinon.stub(), sinon.stub()); const args = initializeSpy.getCall(0).args[0]; - args.callbacks.initCallback({ releaseControl: { showAdobeMessaging: true } }); + args.callbacks.initCallback({ + releaseControl: { showAdobeMessaging: true }, + }); openMessagingWindowSpy.resetHistory(); document.body.querySelector('a').click(); expect(openMessagingWindowSpy.called).to.be.true; @@ -189,35 +212,51 @@ describe('Jarvis Chat', () => { await initJarvisChat(config, sinon.stub(), sinon.stub(), sinon.stub()); const args = initializeSpy.getCall(0).args[0]; - const iconRender = await readFile({ path: './mocks/sendChatIconRenderEvent.json' }); + const iconRender = await readFile({ + path: './mocks/sendChatIconRenderEvent.json', + }); window.digitalData = window.digitalData || {}; window.alloy_all = window.digitalData || {}; window._satellite = window._satellite || { track: sinon.spy() }; window._satellite.track.resetHistory(); args.callbacks.analyticsCallback(JSON.parse(iconRender)); - expect(window.digitalData.primaryEvent.eventInfo.eventName).to.equal('chat:init:launch:event.subtype:icon:render'); + expect(window.digitalData.primaryEvent.eventInfo.eventName).to.equal( + 'chat:init:launch:event.subtype:icon:render' + ); expect(window.digitalData.chat.chatInfo.chatType).to.equal('render'); expect(window._satellite.track.called).to.be.true; - const iconClick = await readFile({ path: './mocks/sendChatIconClickEvent.json' }); + const iconClick = await readFile({ + path: './mocks/sendChatIconClickEvent.json', + }); window._satellite.track.resetHistory(); args.callbacks.analyticsCallback(JSON.parse(iconClick)); - expect(window.digitalData.primaryEvent.eventInfo.eventName).to.equal('chat:init:launch:event.subtype:icon:click'); + expect(window.digitalData.primaryEvent.eventInfo.eventName).to.equal( + 'chat:init:launch:event.subtype:icon:click' + ); expect(window.digitalData.chat.chatInfo.chatType).to.equal('click'); expect(window._satellite.track.called).to.be.true; const product = await readFile({ path: './mocks/sendProductEvent.json' }); window._satellite.track.resetHistory(); args.callbacks.analyticsCallback(JSON.parse(product)); - expect(window.digitalData.primaryEvent.eventInfo.eventName).to.equal('chat:product:auth-subproduct:sub:type'); - expect(window.digitalData.chat.chatInfo.primaryProduct.productName).to.equal('sub'); + expect(window.digitalData.primaryEvent.eventInfo.eventName).to.equal( + 'chat:product:auth-subproduct:sub:type' + ); + expect( + window.digitalData.chat.chatInfo.primaryProduct.productName + ).to.equal('sub'); expect(window._satellite.track.called).to.be.true; window.digitalData = { sophiaResponse: { fromPage: 'test2' } }; - const survey = await readFile({ path: './mocks/sendSurveyFeedbackEvent.json' }); + const survey = await readFile({ + path: './mocks/sendSurveyFeedbackEvent.json', + }); window._satellite.track.resetHistory(); args.callbacks.analyticsCallback(JSON.parse(survey)); - expect(window.digitalData.primaryEvent.eventInfo.eventName).to.equal('chat:survey:5-star-survey:test:type:id'); + expect(window.digitalData.primaryEvent.eventInfo.eventName).to.equal( + 'chat:survey:5-star-survey:test:type:id' + ); expect(window._satellite.track.called).to.be.true; const error = await readFile({ path: './mocks/sendChatErrorEvent.json' }); @@ -227,7 +266,9 @@ describe('Jarvis Chat', () => { expect(window.digitalData.chat.chatInfo.chatErrorType).to.equal('init'); expect(window._satellite.track.called).to.be.true; - window.digitalData = { sophiaResponse: { fromPage: [{ variationId: '2', campaignId: '3' }] } }; + window.digitalData = { + sophiaResponse: { fromPage: [{ variationId: '2', campaignId: '3' }] }, + }; const def = await readFile({ path: './mocks/sendPrimaryEvent.json' }); window._satellite.track.resetHistory(); args.callbacks.analyticsCallback(JSON.parse(def)); @@ -245,11 +286,15 @@ describe('Jarvis Chat', () => { await initJarvisChat(config, sinon.stub(), sinon.stub(), sinon.stub()); const args = initializeSpy.getCall(0).args[0]; // Set uninitialized state - args.callbacks.initCallback({ releaseControl: { showAdobeMessaging: false } }); + args.callbacks.initCallback({ + releaseControl: { showAdobeMessaging: false }, + }); initializeSpy.resetHistory(); config.jarvis.onDemand = true; - document.body.innerHTML = await readFile({ path: './mocks/jarvis-chat.html' }); + document.body.innerHTML = await readFile({ + path: './mocks/jarvis-chat.html', + }); await initJarvisChat(config, sinon.stub(), sinon.stub(), sinon.stub()); expect(initializeSpy.called).to.be.false; document.querySelector('a').click(); @@ -258,7 +303,9 @@ describe('Jarvis Chat', () => { }); expect(initializeSpy.called).to.be.true; const params = initializeSpy.getCall(0).args[0]; - params.callbacks.initCallback({ releaseControl: { showAdobeMessaging: true } }); + params.callbacks.initCallback({ + releaseControl: { showAdobeMessaging: true }, + }); params.callbacks.onReadyCallback(); expect(openMessagingWindowSpy.called).to.be.true; }); @@ -266,31 +313,30 @@ describe('Jarvis Chat', () => { setConfig(defaultConfig); const config = getConfig(); config.jarvis.onDemand = false; - + const loadScriptSpy = sinon.spy(); const loadStyleSpy = sinon.spy(); - + await initJarvisChat(config, loadScriptSpy, loadStyleSpy, sinon.stub()); - + const expectedAsset = 'https://stage-client.messaging.adobe.com/latest/AdobeMessagingClient'; expect(loadScriptSpy.calledWithExactly(`${expectedAsset}.js`)).to.be.true; expect(loadStyleSpy.calledWithExactly(`${expectedAsset}.css`)).to.be.true; }); - + it('should use prod asset URL in prod environment', async () => { setConfig(defaultConfig); const config = getConfig(); config.jarvis.onDemand = false; config.env.name = 'prod'; - + const loadScriptSpy = sinon.spy(); const loadStyleSpy = sinon.spy(); - + await initJarvisChat(config, loadScriptSpy, loadStyleSpy, sinon.stub()); - + const expectedAsset = 'https://client.messaging.adobe.com/latest/AdobeMessagingClient'; expect(loadScriptSpy.calledWithExactly(`${expectedAsset}.js`)).to.be.true; expect(loadStyleSpy.calledWithExactly(`${expectedAsset}.css`)).to.be.true; }); - }); From acd908de8f74e527815eb344bd3b651426c0db55 Mon Sep 17 00:00:00 2001 From: Akansha Arora <> Date: Wed, 25 Sep 2024 11:06:05 +0530 Subject: [PATCH 4/7] Revert "Added test cases for asset URL verification" This reverts commit 324e62c5ead8b7c37ac6f882daa92a1bf72e9671. :wq# --- test/features/jarvis-chat/jarvis-chat.test.js | 104 +++++------------- 1 file changed, 29 insertions(+), 75 deletions(-) diff --git a/test/features/jarvis-chat/jarvis-chat.test.js b/test/features/jarvis-chat/jarvis-chat.test.js index c2aee96f59..a94ae533f0 100644 --- a/test/features/jarvis-chat/jarvis-chat.test.js +++ b/test/features/jarvis-chat/jarvis-chat.test.js @@ -2,10 +2,7 @@ import sinon from 'sinon'; import { expect } from '@esm-bundle/chai'; import { readFile } from '@web/test-runner-commands'; -import { - initJarvisChat, - openChat, -} from '../../../libs/features/jarvis-chat.js'; +import { initJarvisChat, openChat } from '../../../libs/features/jarvis-chat.js'; import { setConfig, getConfig } from '../../../libs/utils/utils.js'; const defaultConfig = { @@ -21,33 +18,17 @@ describe('Jarvis Chat', () => { let isAdobeMessagingClientInitializedStub; let getMessagingExperienceStateStub; beforeEach(() => { - window.AdobeMessagingExperienceClient = - window.AdobeMessagingExperienceClient || { + window.AdobeMessagingExperienceClient = window.AdobeMessagingExperienceClient + || { initialize: () => {}, openMessagingWindow: () => {}, isAdobeMessagingClientInitialized: () => {}, getMessagingExperienceState: () => {}, }; - initializeSpy = sinon.spy( - window.AdobeMessagingExperienceClient, - 'initialize' - ); - openMessagingWindowSpy = sinon.spy( - window.AdobeMessagingExperienceClient, - 'openMessagingWindow' - ); - isAdobeMessagingClientInitializedStub = sinon - .stub( - window.AdobeMessagingExperienceClient, - 'isAdobeMessagingClientInitialized' - ) - .returns(true); - getMessagingExperienceStateStub = sinon - .stub( - window.AdobeMessagingExperienceClient, - 'getMessagingExperienceState' - ) - .returns({ windowState: 'hidden' }); + initializeSpy = sinon.spy(window.AdobeMessagingExperienceClient, 'initialize'); + openMessagingWindowSpy = sinon.spy(window.AdobeMessagingExperienceClient, 'openMessagingWindow'); + isAdobeMessagingClientInitializedStub = sinon.stub(window.AdobeMessagingExperienceClient, 'isAdobeMessagingClientInitialized').returns(true); + getMessagingExperienceStateStub = sinon.stub(window.AdobeMessagingExperienceClient, 'getMessagingExperienceState').returns({ windowState: 'hidden' }); }); afterEach(() => { @@ -187,16 +168,12 @@ describe('Jarvis Chat', () => { }); it('should open a chat session upon click', async () => { - document.body.innerHTML = await readFile({ - path: './mocks/jarvis-chat.html', - }); + document.body.innerHTML = await readFile({ path: './mocks/jarvis-chat.html' }); setConfig(defaultConfig); const config = getConfig(); await initJarvisChat(config, sinon.stub(), sinon.stub(), sinon.stub()); const args = initializeSpy.getCall(0).args[0]; - args.callbacks.initCallback({ - releaseControl: { showAdobeMessaging: true }, - }); + args.callbacks.initCallback({ releaseControl: { showAdobeMessaging: true } }); openMessagingWindowSpy.resetHistory(); document.body.querySelector('a').click(); expect(openMessagingWindowSpy.called).to.be.true; @@ -212,51 +189,35 @@ describe('Jarvis Chat', () => { await initJarvisChat(config, sinon.stub(), sinon.stub(), sinon.stub()); const args = initializeSpy.getCall(0).args[0]; - const iconRender = await readFile({ - path: './mocks/sendChatIconRenderEvent.json', - }); + const iconRender = await readFile({ path: './mocks/sendChatIconRenderEvent.json' }); window.digitalData = window.digitalData || {}; window.alloy_all = window.digitalData || {}; window._satellite = window._satellite || { track: sinon.spy() }; window._satellite.track.resetHistory(); args.callbacks.analyticsCallback(JSON.parse(iconRender)); - expect(window.digitalData.primaryEvent.eventInfo.eventName).to.equal( - 'chat:init:launch:event.subtype:icon:render' - ); + expect(window.digitalData.primaryEvent.eventInfo.eventName).to.equal('chat:init:launch:event.subtype:icon:render'); expect(window.digitalData.chat.chatInfo.chatType).to.equal('render'); expect(window._satellite.track.called).to.be.true; - const iconClick = await readFile({ - path: './mocks/sendChatIconClickEvent.json', - }); + const iconClick = await readFile({ path: './mocks/sendChatIconClickEvent.json' }); window._satellite.track.resetHistory(); args.callbacks.analyticsCallback(JSON.parse(iconClick)); - expect(window.digitalData.primaryEvent.eventInfo.eventName).to.equal( - 'chat:init:launch:event.subtype:icon:click' - ); + expect(window.digitalData.primaryEvent.eventInfo.eventName).to.equal('chat:init:launch:event.subtype:icon:click'); expect(window.digitalData.chat.chatInfo.chatType).to.equal('click'); expect(window._satellite.track.called).to.be.true; const product = await readFile({ path: './mocks/sendProductEvent.json' }); window._satellite.track.resetHistory(); args.callbacks.analyticsCallback(JSON.parse(product)); - expect(window.digitalData.primaryEvent.eventInfo.eventName).to.equal( - 'chat:product:auth-subproduct:sub:type' - ); - expect( - window.digitalData.chat.chatInfo.primaryProduct.productName - ).to.equal('sub'); + expect(window.digitalData.primaryEvent.eventInfo.eventName).to.equal('chat:product:auth-subproduct:sub:type'); + expect(window.digitalData.chat.chatInfo.primaryProduct.productName).to.equal('sub'); expect(window._satellite.track.called).to.be.true; window.digitalData = { sophiaResponse: { fromPage: 'test2' } }; - const survey = await readFile({ - path: './mocks/sendSurveyFeedbackEvent.json', - }); + const survey = await readFile({ path: './mocks/sendSurveyFeedbackEvent.json' }); window._satellite.track.resetHistory(); args.callbacks.analyticsCallback(JSON.parse(survey)); - expect(window.digitalData.primaryEvent.eventInfo.eventName).to.equal( - 'chat:survey:5-star-survey:test:type:id' - ); + expect(window.digitalData.primaryEvent.eventInfo.eventName).to.equal('chat:survey:5-star-survey:test:type:id'); expect(window._satellite.track.called).to.be.true; const error = await readFile({ path: './mocks/sendChatErrorEvent.json' }); @@ -266,9 +227,7 @@ describe('Jarvis Chat', () => { expect(window.digitalData.chat.chatInfo.chatErrorType).to.equal('init'); expect(window._satellite.track.called).to.be.true; - window.digitalData = { - sophiaResponse: { fromPage: [{ variationId: '2', campaignId: '3' }] }, - }; + window.digitalData = { sophiaResponse: { fromPage: [{ variationId: '2', campaignId: '3' }] } }; const def = await readFile({ path: './mocks/sendPrimaryEvent.json' }); window._satellite.track.resetHistory(); args.callbacks.analyticsCallback(JSON.parse(def)); @@ -286,15 +245,11 @@ describe('Jarvis Chat', () => { await initJarvisChat(config, sinon.stub(), sinon.stub(), sinon.stub()); const args = initializeSpy.getCall(0).args[0]; // Set uninitialized state - args.callbacks.initCallback({ - releaseControl: { showAdobeMessaging: false }, - }); + args.callbacks.initCallback({ releaseControl: { showAdobeMessaging: false } }); initializeSpy.resetHistory(); config.jarvis.onDemand = true; - document.body.innerHTML = await readFile({ - path: './mocks/jarvis-chat.html', - }); + document.body.innerHTML = await readFile({ path: './mocks/jarvis-chat.html' }); await initJarvisChat(config, sinon.stub(), sinon.stub(), sinon.stub()); expect(initializeSpy.called).to.be.false; document.querySelector('a').click(); @@ -303,9 +258,7 @@ describe('Jarvis Chat', () => { }); expect(initializeSpy.called).to.be.true; const params = initializeSpy.getCall(0).args[0]; - params.callbacks.initCallback({ - releaseControl: { showAdobeMessaging: true }, - }); + params.callbacks.initCallback({ releaseControl: { showAdobeMessaging: true } }); params.callbacks.onReadyCallback(); expect(openMessagingWindowSpy.called).to.be.true; }); @@ -313,30 +266,31 @@ describe('Jarvis Chat', () => { setConfig(defaultConfig); const config = getConfig(); config.jarvis.onDemand = false; - + const loadScriptSpy = sinon.spy(); const loadStyleSpy = sinon.spy(); - + await initJarvisChat(config, loadScriptSpy, loadStyleSpy, sinon.stub()); - + const expectedAsset = 'https://stage-client.messaging.adobe.com/latest/AdobeMessagingClient'; expect(loadScriptSpy.calledWithExactly(`${expectedAsset}.js`)).to.be.true; expect(loadStyleSpy.calledWithExactly(`${expectedAsset}.css`)).to.be.true; }); - + it('should use prod asset URL in prod environment', async () => { setConfig(defaultConfig); const config = getConfig(); config.jarvis.onDemand = false; config.env.name = 'prod'; - + const loadScriptSpy = sinon.spy(); const loadStyleSpy = sinon.spy(); - + await initJarvisChat(config, loadScriptSpy, loadStyleSpy, sinon.stub()); - + const expectedAsset = 'https://client.messaging.adobe.com/latest/AdobeMessagingClient'; expect(loadScriptSpy.calledWithExactly(`${expectedAsset}.js`)).to.be.true; expect(loadStyleSpy.calledWithExactly(`${expectedAsset}.css`)).to.be.true; }); + }); From ae4dadc3a5275b411f54b588f495a2712ea0e61f Mon Sep 17 00:00:00 2001 From: Akansha Arora <> Date: Wed, 25 Sep 2024 11:16:14 +0530 Subject: [PATCH 5/7] Clean up code by removing lint errors --- test/features/jarvis-chat/jarvis-chat.test.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/test/features/jarvis-chat/jarvis-chat.test.js b/test/features/jarvis-chat/jarvis-chat.test.js index a94ae533f0..ba3e260b2f 100644 --- a/test/features/jarvis-chat/jarvis-chat.test.js +++ b/test/features/jarvis-chat/jarvis-chat.test.js @@ -262,35 +262,29 @@ describe('Jarvis Chat', () => { params.callbacks.onReadyCallback(); expect(openMessagingWindowSpy.called).to.be.true; }); + it('should use stage asset URL in non-prod environment', async () => { setConfig(defaultConfig); const config = getConfig(); config.jarvis.onDemand = false; - const loadScriptSpy = sinon.spy(); const loadStyleSpy = sinon.spy(); - await initJarvisChat(config, loadScriptSpy, loadStyleSpy, sinon.stub()); - const expectedAsset = 'https://stage-client.messaging.adobe.com/latest/AdobeMessagingClient'; expect(loadScriptSpy.calledWithExactly(`${expectedAsset}.js`)).to.be.true; expect(loadStyleSpy.calledWithExactly(`${expectedAsset}.css`)).to.be.true; }); - + it('should use prod asset URL in prod environment', async () => { setConfig(defaultConfig); const config = getConfig(); config.jarvis.onDemand = false; config.env.name = 'prod'; - const loadScriptSpy = sinon.spy(); const loadStyleSpy = sinon.spy(); - await initJarvisChat(config, loadScriptSpy, loadStyleSpy, sinon.stub()); - const expectedAsset = 'https://client.messaging.adobe.com/latest/AdobeMessagingClient'; expect(loadScriptSpy.calledWithExactly(`${expectedAsset}.js`)).to.be.true; expect(loadStyleSpy.calledWithExactly(`${expectedAsset}.css`)).to.be.true; }); - }); From 469683433545ee28437bfc3d0ec45d7adde5643e Mon Sep 17 00:00:00 2001 From: Akansha Arora <> Date: Wed, 25 Sep 2024 11:25:05 +0530 Subject: [PATCH 6/7] Revert "Clean up code by removing lint errors" This reverts commit ae4dadc3a5275b411f54b588f495a2712ea0e61f. --- test/features/jarvis-chat/jarvis-chat.test.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/test/features/jarvis-chat/jarvis-chat.test.js b/test/features/jarvis-chat/jarvis-chat.test.js index ba3e260b2f..a94ae533f0 100644 --- a/test/features/jarvis-chat/jarvis-chat.test.js +++ b/test/features/jarvis-chat/jarvis-chat.test.js @@ -262,29 +262,35 @@ describe('Jarvis Chat', () => { params.callbacks.onReadyCallback(); expect(openMessagingWindowSpy.called).to.be.true; }); - it('should use stage asset URL in non-prod environment', async () => { setConfig(defaultConfig); const config = getConfig(); config.jarvis.onDemand = false; + const loadScriptSpy = sinon.spy(); const loadStyleSpy = sinon.spy(); + await initJarvisChat(config, loadScriptSpy, loadStyleSpy, sinon.stub()); + const expectedAsset = 'https://stage-client.messaging.adobe.com/latest/AdobeMessagingClient'; expect(loadScriptSpy.calledWithExactly(`${expectedAsset}.js`)).to.be.true; expect(loadStyleSpy.calledWithExactly(`${expectedAsset}.css`)).to.be.true; }); - + it('should use prod asset URL in prod environment', async () => { setConfig(defaultConfig); const config = getConfig(); config.jarvis.onDemand = false; config.env.name = 'prod'; + const loadScriptSpy = sinon.spy(); const loadStyleSpy = sinon.spy(); + await initJarvisChat(config, loadScriptSpy, loadStyleSpy, sinon.stub()); + const expectedAsset = 'https://client.messaging.adobe.com/latest/AdobeMessagingClient'; expect(loadScriptSpy.calledWithExactly(`${expectedAsset}.js`)).to.be.true; expect(loadStyleSpy.calledWithExactly(`${expectedAsset}.css`)).to.be.true; }); + }); From 361168f55934dec002c0d91aceb2581a25690bc3 Mon Sep 17 00:00:00 2001 From: Akansha Arora <> Date: Wed, 25 Sep 2024 11:30:26 +0530 Subject: [PATCH 7/7] Clean up code by removing lint errors --- test/features/jarvis-chat/jarvis-chat.test.js | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/test/features/jarvis-chat/jarvis-chat.test.js b/test/features/jarvis-chat/jarvis-chat.test.js index a94ae533f0..ba3e260b2f 100644 --- a/test/features/jarvis-chat/jarvis-chat.test.js +++ b/test/features/jarvis-chat/jarvis-chat.test.js @@ -262,35 +262,29 @@ describe('Jarvis Chat', () => { params.callbacks.onReadyCallback(); expect(openMessagingWindowSpy.called).to.be.true; }); + it('should use stage asset URL in non-prod environment', async () => { setConfig(defaultConfig); const config = getConfig(); config.jarvis.onDemand = false; - const loadScriptSpy = sinon.spy(); const loadStyleSpy = sinon.spy(); - await initJarvisChat(config, loadScriptSpy, loadStyleSpy, sinon.stub()); - const expectedAsset = 'https://stage-client.messaging.adobe.com/latest/AdobeMessagingClient'; expect(loadScriptSpy.calledWithExactly(`${expectedAsset}.js`)).to.be.true; expect(loadStyleSpy.calledWithExactly(`${expectedAsset}.css`)).to.be.true; }); - + it('should use prod asset URL in prod environment', async () => { setConfig(defaultConfig); const config = getConfig(); config.jarvis.onDemand = false; config.env.name = 'prod'; - const loadScriptSpy = sinon.spy(); const loadStyleSpy = sinon.spy(); - await initJarvisChat(config, loadScriptSpy, loadStyleSpy, sinon.stub()); - const expectedAsset = 'https://client.messaging.adobe.com/latest/AdobeMessagingClient'; expect(loadScriptSpy.calledWithExactly(`${expectedAsset}.js`)).to.be.true; expect(loadStyleSpy.calledWithExactly(`${expectedAsset}.css`)).to.be.true; }); - });