Skip to content

Commit

Permalink
MWPW-140345-Fix issues in media QR block variant (#1658)
Browse files Browse the repository at this point in the history
* MWPW-140345

* MWPW-140345

* MWPW-140345

* Update media.js

* Update media.css

* Update unit test

* Update qr block css

* Update media.css

* Update media.test.js

* Update media.test.js
  • Loading branch information
Ruchika4 authored Jan 5, 2024
1 parent 38723f9 commit 66f6042
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 4 deletions.
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 {
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.equal('none');
qrCTA.forEach((cta) => {
expect(window.getComputedStyle(cta).getPropertyValue('display')).to.equal('none');
});
});
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.equal('none');
qrCTA.forEach((cta) => {
expect(window.getComputedStyle(cta).getPropertyValue('display')).not.to.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.equal('none');
qrCTA.forEach((cta) => {
expect(window.getComputedStyle(cta).getPropertyValue('display')).not.to.equal('none');
});
});
});
describe('with bio variant', () => {
it('has a bio avatar and icon-stack area', () => {
Expand Down

0 comments on commit 66f6042

Please sign in to comment.