Skip to content

Commit

Permalink
Jarvis stage URL for Acom stage env (#2948)
Browse files Browse the repository at this point in the history
* Jarvis stage for acom stage env

* Added test cases for asset URL verification

* Added test cases for asset URL verification

* Revert "Added test cases for asset URL verification"

This reverts commit 324e62c.

:wq#

* Clean up code by removing lint errors

* Revert "Clean up code by removing lint errors"

This reverts commit ae4dadc.

* Clean up code by removing lint errors

---------

Co-authored-by: Akansha Arora <>
  • Loading branch information
akanshaa-18 authored Sep 26, 2024
1 parent 96edd14 commit e6e12c8
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion libs/features/jarvis-chat.js
Original file line number Diff line number Diff line change
Expand Up @@ -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`),
Expand Down
25 changes: 25 additions & 0 deletions test/features/jarvis-chat/jarvis-chat.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -262,4 +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;
});
});

0 comments on commit e6e12c8

Please sign in to comment.