Skip to content

Commit

Permalink
[Release] Stage to Main (#2489)
Browse files Browse the repository at this point in the history
  • Loading branch information
milo-pr-merge[bot] authored Jun 20, 2024
2 parents 02bf1a6 + 75fe20d commit f6fc4bf
Show file tree
Hide file tree
Showing 7 changed files with 70 additions and 14 deletions.
14 changes: 6 additions & 8 deletions libs/blocks/modal/modal.js
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
/* eslint-disable no-underscore-dangle */
/* eslint-disable import/no-cycle */
import { createTag, getMetadata, localizeLink, loadStyle, getConfig } from '../../utils/utils.js';

Expand All @@ -20,18 +21,15 @@ export function findDetails(hash, el) {
}

function fireAnalyticsEvent(event) {
// eslint-disable-next-line no-underscore-dangle
window._satellite?.track('event', {
const data = {
xdm: {},
data: {
web: { webInteraction: { name: event?.type } },
_adobe_corpnew: { digitalData: event?.data },
},
});
data: { web: { webInteraction: { name: event?.type } } },
};
if (event?.data) data.data._adobe_corpnew = { digitalData: event.data };
window._satellite?.track('event', data);
}

export function sendAnalytics(event) {
// eslint-disable-next-line no-underscore-dangle
if (window._satellite?.track) {
fireAnalyticsEvent(event);
} else {
Expand Down
4 changes: 2 additions & 2 deletions libs/blocks/path-finder/path-finder.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ import { getReqOptions } from '../../tools/sharepoint/msal.js';
import { createTag } from '../../utils/utils.js';

const SCOPES = ['files.readwrite', 'sites.readwrite.all'];
const TELEMETRY = { application: { appName: 'Milo - Where am I' } };
const TELEMETRY = { application: { appName: 'Milo - Path Finder' } };

const getSharePointDetails = (() => {
let site;
Expand All @@ -16,7 +16,7 @@ const getSharePointDetails = (() => {
if (site && driveId && reqOpts) return { site, driveId, reqOpts };

// Fetching SharePoint details
const { sharepoint } = await getServiceConfig(origin);
const { sharepoint } = await getServiceConfig();
({ site } = sharepoint);
driveId = sharepoint.driveId ? `drives/${sharepoint.driveId}` : 'drive';
reqOpts = getReqOptions();
Expand Down
11 changes: 9 additions & 2 deletions libs/blocks/text/text.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { decorateBlockBg, decorateBlockText, getBlockSize, decorateTextOverrides } from '../../utils/decorate.js';
import { createTag, loadStyle, getConfig } from '../../utils/utils.js';
import { createTag, loadStyle, getConfig, loadBlock } from '../../utils/utils.js';

// size: [heading, body, ...detail]
const blockTypeSizes = {
Expand Down Expand Up @@ -76,7 +76,7 @@ function decorateLinkFarms(el) {
});
}

export default function init(el) {
export default async function init(el) {
el.classList.add('text-block', 'con-block');
let rows = el.querySelectorAll(':scope > div');
if (rows.length > 1) {
Expand Down Expand Up @@ -117,4 +117,11 @@ export default function init(el) {
lastActionArea.insertAdjacentElement('afterend', div);
div.append(lastActionArea);
}

const mnemonicList = el.querySelector('.mnemonic-list');
const foreground = mnemonicList?.closest('.foreground');
if (foreground) {
mnemonicList.querySelectorAll('p').forEach((product) => product.removeAttribute('class'));
await loadBlock(mnemonicList);
}
}
2 changes: 1 addition & 1 deletion libs/tools/sharepoint/msal.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ export async function getMSALConfig(telemetry) {
const { base } = getConfig();
await loadScript(`${base}/deps/msal-browser-2.34.0.js`);

const { sharepoint } = await getServiceConfig(window.location.origin);
const { sharepoint } = await getServiceConfig();

const auth = {
clientId: sharepoint.clientId,
Expand Down
11 changes: 10 additions & 1 deletion libs/utils/service-config.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,14 +8,23 @@ const DOT_MILO = '/.milo/config.json';

let config;

/* c8 ignore next 6 */
function getSiteOrigin() {
const search = new URLSearchParams(window.location.search);
const repo = search.get('repo');
const owner = search.get('owner');
return repo && owner ? `https://main--${repo}--${owner}.hlx.live` : window.location.origin;
}

/**
* Get Service Config
* @param {*} origin The origin of the site to pull the config from.
* @param {*} envName The name of the environment to pull configs for.
* @returns the config
*/
export default async function getServiceConfig(origin, envName) {
export default async function getServiceConfig(suppliedOrigin, envName) {
if (config) return config;
const origin = suppliedOrigin || getSiteOrigin();
const utilsConfig = getConfig();
const queryEnv = new URLSearchParams(window.location.search).get('env');
const env = queryEnv || envName || utilsConfig.env.name;
Expand Down
23 changes: 23 additions & 0 deletions test/blocks/text/mocks/body.html
Original file line number Diff line number Diff line change
Expand Up @@ -197,3 +197,26 @@ <h3 id="text">Text</h3>
</div>
</div>
</div>

<div id="mnemonics" class="text quiet medium light center xxl-spacing mnemonic-list text-block con-block has-bg">
<div class="background"></div>
<div class="foreground">
<div data-valign="middle">
<h2 id="get-20-creative-cloud-for-less-than-the-price-of-3-apps" class="heading-l">Get 20+ creative cloud for less than the price of 3 apps.</h2>
<p class="body-m">The All Apps plan includes 20+ apps and services plus 20,000 fonts, storage, templates, and tutorials for less than the price of acrobat, photoshop, and premiere pro sold separately.</p>
<div class="mnemonic-list" data-path="/fragments/mirafedas/includes">
<div>
<div data-valign="middle">
<p class="body-m"><strong>Includes:</strong></p>
<p class="body-m"><strong>Acrobat</strong></p>
<p class="body-m"><strong>Photoshop</strong></p>
<p class="body-m"><strong>Premiere Pro</strong></p>
<p class="body-m"><strong>Illustrator</strong></p>
<p class="body-m"><strong>Adobe Express</strong></p>
<p class="body-m"><strong>Lightroom</strong></p>
</div>
</div>
</div>
</div>
</div>
</div>
19 changes: 19 additions & 0 deletions test/blocks/text/text.test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,12 @@
import { readFile } from '@web/test-runner-commands';
import { expect } from '@esm-bundle/chai';
import { setConfig } from '../../../libs/utils/utils.js';

const conf = {
codeRoot: '/libs',
contentRoot: `${window.location.origin}`,
};
setConfig(conf);

document.body.innerHTML = await readFile({ path: './mocks/body.html' });
const { default: init } = await import('../../../libs/blocks/text/text.js');
Expand Down Expand Up @@ -78,4 +85,16 @@ describe('text block', () => {
expect(actionArea.parentElement.className.includes('cta-container')).to.be.false;
});
});
describe('text block with mnemonics list', () => {
it('renders mnemonics list', async () => {
const textBlockWithMnemonics = document.querySelector('#mnemonics');
await init(textBlockWithMnemonics);
const mnemonicsList = textBlockWithMnemonics.querySelector('.mnemonic-list');
const productList = mnemonicsList?.querySelector('.product-list');
const productItems = productList?.querySelectorAll('.product-item');
expect(mnemonicsList).to.exist;
expect(productList).to.exist;
expect(productItems.length).to.equal(7);
});
});
});

0 comments on commit f6fc4bf

Please sign in to comment.