Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

MWPW-157555: Remove useless logic and putting import commerce.js top. #2906

Merged
merged 6 commits into from
Sep 30, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 1 addition & 9 deletions libs/blocks/merch/merch.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@ import {
createTag, getConfig, loadArea, loadScript, loadStyle, localizeLink,
} from '../../utils/utils.js';
import { replaceKey } from '../../features/placeholders.js';
import * as commerceLib from '../../deps/mas/commerce.js';

export const CHECKOUT_LINK_CONFIG_PATH = '/commerce/checkout-link.json'; // relative to libs.

Expand Down Expand Up @@ -422,15 +423,6 @@ export async function initService(force = false) {
}
const { env, commerce = {}, locale } = getConfig();
initService.promise = initService.promise ?? polyfills().then(async () => {
const { hostname, searchParams } = new URL(window.location.href);
let commerceLibPath = '../../deps/mas/commerce.js';
if (/hlx\.(page|live)$|localhost$|www\.stage\.adobe\.com$/.test(hostname)) {
const maslibs = searchParams.get('maslibs');
if (maslibs) {
commerceLibPath = `${getMasBase(hostname, maslibs)}/libs/commerce.js`;
}
}
const commerceLib = await import(commerceLibPath);
const service = await commerceLib.init(() => ({
env,
commerce,
Expand Down
10 changes: 0 additions & 10 deletions test/blocks/merch/merch.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -798,16 +798,6 @@ describe('Merch Block', () => {
updateSearch({});
});

it('should load commerce.js via maslibs', async () => {
initService.promise = undefined;
getMasBase.baseUrl = 'http://localhost:2000/test/blocks/merch/mas';
updateSearch({ maslibs: 'test' });
setConfig(config);
await mockIms();
const commerce = await initService(true);
expect(commerce.mock).to.be.true;
});

it('should return the default Adobe URL if no maslibs parameter is present', () => {
expect(getMasBase()).to.equal('https://www.adobe.com/mas');
});
Expand Down
Loading