Skip to content

Commit

Permalink
MWPW-160015: M@S: support for mnemonic multifield (#3075)
Browse files Browse the repository at this point in the history
* MWPW-160015: M@S: support for mnemonic multifield

during card hydration.

* updated deps
  • Loading branch information
yesil authored Oct 30, 2024
1 parent 7255d63 commit fa39a05
Show file tree
Hide file tree
Showing 4 changed files with 157 additions and 158 deletions.
132 changes: 66 additions & 66 deletions libs/deps/mas/mas.js

Large diffs are not rendered by default.

132 changes: 66 additions & 66 deletions libs/features/mas/mas/dist/mas.js

Large diffs are not rendered by default.

13 changes: 7 additions & 6 deletions libs/features/mas/web-components/src/aem-fragment.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export class AemFragment extends HTMLElement {
/**
* Internal promise to track the readiness of the web-component to render.
*/
_readyPromise;
#readyPromise;

static get observedAttributes() {
return [ATTRIBUTE_FRAGMENT];
Expand Down Expand Up @@ -113,17 +113,17 @@ export class AemFragment extends HTMLElement {
}

async refresh(flushCache = true) {
if (this._readyPromise) {
if (this.#readyPromise) {
const ready = await Promise.race([
this._readyPromise,
this.#readyPromise,
Promise.resolve(false),
]);
if (!ready) return; // already fetching data
}
if (flushCache) {
cache.remove(this.fragmentId);
}
this._readyPromise = this.fetchData()
this.#readyPromise = this.fetchData()
.then(() => {
this.dispatchEvent(
new CustomEvent(EVENT_AEM_LOAD, {
Expand All @@ -137,9 +137,10 @@ export class AemFragment extends HTMLElement {
.catch(() => {
/* c8 ignore next 3 */
this.#fail('Network error: failed to load fragment');
this._readyPromise = null;
this.#readyPromise = null;
return false;
});
this.#readyPromise;
}

#fail(error) {
Expand Down Expand Up @@ -168,7 +169,7 @@ export class AemFragment extends HTMLElement {

get updateComplete() {
return (
this._readyPromise ??
this.#readyPromise ??
Promise.reject(new Error('AEM fragment cannot be loaded'))
);
}
Expand Down
38 changes: 18 additions & 20 deletions libs/features/mas/web-components/test/aem-fragment.test.html.js
Original file line number Diff line number Diff line change
Expand Up @@ -95,15 +95,15 @@ runTests(async () => {
});

it('merch-card fails when aem-fragment contains incorrect merch data', async () => {
const [, , , , , cardWithWrongOsis] = getTemplateContent('cards');

let masErrorTriggered = false;
cardWithWrongOsis.addEventListener(EVENT_MAS_ERROR, () => {
masErrorTriggered = true;
});
spTheme.append(cardWithWrongOsis);
await delay(100);
expect(masErrorTriggered).to.true;
const [, , , , , cardWithWrongOsis] = getTemplateContent('cards');

let masErrorTriggered = false;
cardWithWrongOsis.addEventListener(EVENT_MAS_ERROR, () => {
masErrorTriggered = true;
});
spTheme.append(cardWithWrongOsis);
await delay(100);
expect(masErrorTriggered).to.true;
});

it('uses ims token to retrieve a fragment', async () => {
Expand All @@ -115,18 +115,16 @@ runTests(async () => {
sinon.assert.calledOnce(window.adobeid.authorize);
});


it('renders ccd slice card', async () => {
const [, , , , , , sliceCard] = getTemplateContent('cards');
spTheme.append(sliceCard);
await delay(100);
expect(sliceCard.querySelector('merch-icon')).to.exist;
expect(sliceCard.querySelector('div[slot="image"]')).to.exist;
expect(sliceCard.querySelector('div[slot="body-s"]')).to.exist;
expect(sliceCard.querySelector('div[slot="footer"]')).to.exist;
const badge = sliceCard.shadowRoot?.querySelector('div#badge');
expect(badge).to.exist;

const [, , , , , , sliceCard] = getTemplateContent('cards');
spTheme.append(sliceCard);
await delay(100);
expect(sliceCard.querySelector('merch-icon')).to.exist;
expect(sliceCard.querySelector('div[slot="image"]')).to.exist;
expect(sliceCard.querySelector('div[slot="body-s"]')).to.exist;
expect(sliceCard.querySelector('div[slot="footer"]')).to.exist;
const badge = sliceCard.shadowRoot?.querySelector('div#badge');
expect(badge).to.exist;
});
});
});

0 comments on commit fa39a05

Please sign in to comment.