Skip to content

Commit

Permalink
MWPW-137777 Show Article Header Dates in Production (adobecom#1458)
Browse files Browse the repository at this point in the history
* MWPW-137777 Show Article Header Dates in Production
  • Loading branch information
Brandon32 authored Oct 30, 2023
1 parent fc395b4 commit f5003e4
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 0 deletions.
2 changes: 2 additions & 0 deletions libs/blocks/article-header/article-header.js
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ async function buildSharing() {
}

async function validateDate(date) {
const { env } = getConfig();
if (env?.name === 'prod') return;
if (date && !/^[0-1]\d{1}-[0-3]\d{1}-[2]\d{3}$/.test(date.textContent.trim())) {
// match publication date to MM-DD-YYYY format
date.classList.add('article-date-invalid');
Expand Down
9 changes: 9 additions & 0 deletions test/blocks/article-header/article-header.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -97,4 +97,13 @@ describe('test the invalid article header', () => {
const date = await waitForElement('.article-date-invalid');
expect(date).to.exist;
});

it('does not add invalid-date on prod', async () => {
setConfig({ ...conf, env: { name: 'prod' } });
await init(document.body.querySelector('.article-header'));

const date = await waitForElement('.article-date');
expect(date).to.exist;
expect(date.classList.contains('article-date-invalid')).to.be.false;
});
});

0 comments on commit f5003e4

Please sign in to comment.