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-142935 [Project PEP] PEP <> Geo Routing Modal Interactions #2403

Merged
merged 12 commits into from
Jun 17, 2024
11 changes: 9 additions & 2 deletions libs/features/webapp-prompt/webapp-prompt.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ const getIcon = (content) => {
return icons.company;
};

const geoRoutingActive = () => !!document.querySelector('.locale-modal-v2')
|| !!document.querySelector('.locale-modal');

const waitForClosedGRMThen = (loadPEP) => {
document.addEventListener('milo:modal:closed', loadPEP);
};

class AppPrompt {
constructor({ promptPath, entName, parent, getAnchorState } = {}) {
this.promptPath = promptPath;
Expand All @@ -43,8 +50,8 @@ class AppPrompt {
this.getAnchorState = getAnchorState;
this.id = this.promptPath.split('/').pop();
this.elements = {};

this.init();
if (geoRoutingActive()) waitForClosedGRMThen(this.init);
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Suggested change
if (geoRoutingActive()) waitForClosedGRMThen(this.init);
if (geoRoutingActive()) document.addEventListener('milo:modal:closed', loadPEP);

else this.init();
}

init = async () => {
Expand Down
19 changes: 19 additions & 0 deletions test/features/webapp-prompt/webapp-prompt.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,25 @@ describe('PEP', () => {
await clock.runAllAsync();
expect(document.querySelector(allSelectors.pepWrapper)).to.not.exist;
});

it('should not render PEP when the GRM is open', async () => {
document.body.insertAdjacentHTML('afterbegin', '<div class="locale-modal-v2"></div>');
document.body.insertAdjacentHTML('afterbegin', '<div class="locale-modal"></div>');

await initPep({});

try {
clock.runAll();
} catch (e) {
expect(document.querySelector(allSelectors.pepWrapper)).to.not.exist;
}

document.querySelector('.locale-modal-v2')?.remove();
document.querySelector('.locale-modal')?.remove();

await clock.runAllAsync();
expect(document.querySelector(allSelectors.pepWrapper)).to.exist;
});
});

describe('PEP configuration tests', () => {
Expand Down
Loading