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-169416 [MEP] stop treating remove action differently in preview #3789

Open
wants to merge 2 commits into
base: stage
Choose a base branch
from
Open
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
15 changes: 3 additions & 12 deletions libs/features/personalization/personalization.js
Original file line number Diff line number Diff line change
Expand Up @@ -214,13 +214,8 @@ export const createContent = (el, { content, manifestId, targetManifestId, actio
};

const COMMANDS = {
[COMMANDS_KEYS.remove]: (el, { content, manifestId }) => {
if (content === 'false') return;
if (manifestId && !el.href?.includes('/tools/ost')) {
el.dataset.removedManifestId = manifestId;
return;
}
el.classList.add(CLASS_EL_DELETE);
[COMMANDS_KEYS.remove]: (el, { content }) => {
if (content !== 'false') el.classList.add(CLASS_EL_DELETE);
},
[COMMANDS_KEYS.replace]: (el, cmd) => {
if (!el || el.classList.contains(CLASS_EL_REPLACE)) return;
Expand Down Expand Up @@ -1093,11 +1088,7 @@ export function handleFragmentCommand(command, a) {
return fragment;
}
if (action === COMMANDS_KEYS.remove) {
if (manifestId) {
a.parentElement.dataset.removedManifestId = manifestId;
} else {
a.parentElement.remove();
}
a.parentElement.remove();
}
return false;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -235,7 +235,7 @@ describe('Merch Cards', async () => {
const merchCards = await init(el);
expect(merchCards.filter).to.equal('all');
await delay(500);
expect(merchCards.querySelectorAll('h3[data-removed-manifest-id]').length).to.equal(4);
expect(merchCards.querySelectorAll('h3').length).to.equal(0);
});

it('should localize the query-index url', async () => {
Expand Down
27 changes: 0 additions & 27 deletions test/features/personalization/actions.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -244,33 +244,6 @@ describe('remove action', () => {
await initFragments(removeMeFrag);
expect(document.querySelector('a[href="/fragments/removeme"]')).to.be.null;
});

it('removeContent should tag but not remove content in preview', async () => {
document.body.innerHTML = await readFile({ path: './mocks/personalization.html' });

let manifestJson = await readFile({ path: './mocks/actions/manifestRemove.json' });
manifestJson = JSON.parse(manifestJson);
setFetchResponse(manifestJson);
delete config.mep;

expect(document.querySelector('.z-pattern')).to.not.be.null;
await init({
mepParam: '',
mepHighlight: false,
mepButton: false,
pzn: '/path/to/manifest.json',
promo: false,
target: false,
});

expect(document.querySelector('.z-pattern')).to.not.be.null;
expect(document.querySelector('.z-pattern').dataset.removedManifestId).to.equal('manifest.json');

const removeMeFrag = document.querySelector('a[href="/fragments/removeme"]');
await initFragments(removeMeFrag);
expect(document.querySelector('a[href="/fragments/removeme"]')).to.not.be.null;
expect(document.querySelector('a[href="/fragments/removeme"]').dataset.removedManifestId).to.not.be.null;
});
});

describe('useBlockCode action', async () => {
Expand Down
Loading