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-140345-Fix issues in media QR block variant #1658

Merged
merged 13 commits into from
Jan 5, 2024
6 changes: 4 additions & 2 deletions libs/blocks/media/media.css
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,7 @@ div[class*="-up"] .media .foreground > .media-row {
padding-bottom: 0;
padding-top: 0;
display: inline-flex;
margin-top: var(--spacing-xxs);
}

.media.qr-code .google-play {
Expand Down Expand Up @@ -341,8 +342,9 @@ div[class*="-up"] .media .foreground > .media-row {

.media.qr-code img.qr-code-img {
Copy link
Contributor

Choose a reason for hiding this comment

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

Is the added tag specificity actually needed? Would .media.qr-code .qr-code-img not achieve the same result?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I believe it will. However as it was not required to update for the changes requested in the ticket, I didn't touched it. I can follow up with original contributor to check the reason and may be address this in a separate PR.

display: flex;
width: 150px;
height: 170px;
width: 140px;
height: 140px;
margin-top: var(--spacing-s);
}

.media.qr-code .qr-button-container {
Expand Down
2 changes: 1 addition & 1 deletion libs/blocks/media/media.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ export default function init(el) {

// qr code
if (row.closest('.qr-code')) {
const imgQRCode = row.querySelector('.text > p.body-s > picture > img');
const imgQRCode = row.querySelector('.text img');
if (imgQRCode) {
imgQRCode.classList.add('qr-code-img');
}
Expand Down
30 changes: 29 additions & 1 deletion test/blocks/media/media.test.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import { readFile } from '@web/test-runner-commands';
import { readFile, setViewport } from '@web/test-runner-commands';
import { expect } from '@esm-bundle/chai';

document.head.innerHTML = "<link rel='stylesheet' href='../../../libs/blocks/media/media.css'>";
document.body.innerHTML = await readFile({ path: './mocks/body.html' });
const { default: init } = await import('../../../libs/blocks/media/media.js');
describe('media', () => {
Expand Down Expand Up @@ -67,6 +68,33 @@ describe('media', () => {
const appStoreCta = medias[5].querySelector('a.app-store');
expect(appStoreCta).to.exist;
});
it('desktop view has visibile qr code image and no google-play and app-store CTA', async () => {
await setViewport({ width: 1200, height: 100 });
const qrCodeImg = medias[5].querySelector('img.qr-code-img');
const qrCTA = medias[5].querySelectorAll('.qr-button-container');
expect(window.getComputedStyle(qrCodeImg).getPropertyValue('display')).not.to.be.equal('none');
qrCTA.forEach(async (cta) => {
Ruchika4 marked this conversation as resolved.
Show resolved Hide resolved
expect(window.getComputedStyle(cta).getPropertyValue('display')).to.be.equal('none');
Ruchika4 marked this conversation as resolved.
Show resolved Hide resolved
});
});
it('mobile view has visibile google-play and app-store CTA and no qr code image', async () => {
await setViewport({ width: 600, height: 100 });
const qrCodeImg = medias[5].querySelector('img.qr-code-img');
const qrCTA = medias[5].querySelectorAll('.qr-button-container');
expect(window.getComputedStyle(qrCodeImg).getPropertyValue('display')).to.be.equal('none');
qrCTA.forEach(async (cta) => {
expect(window.getComputedStyle(cta).getPropertyValue('display')).not.to.be.equal('none');
});
});
it('tablet view has visibile google-play and app-store CTA and no qr code image', async () => {
await setViewport({ width: 1199, height: 100 });
const qrCodeImg = medias[5].querySelector('img.qr-code-img');
const qrCTA = medias[5].querySelectorAll('.qr-button-container');
expect(window.getComputedStyle(qrCodeImg).getPropertyValue('display')).to.be.equal('none');
qrCTA.forEach(async (cta) => {
expect(window.getComputedStyle(cta).getPropertyValue('display')).not.to.be.equal('none');
});
});
});
describe('with bio variant', () => {
it('has a bio avatar and icon-stack area', () => {
Expand Down
Loading