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

fix(notifications-panel, page-header): dynamic timestamps will not affect percy builds #6828

Open
wants to merge 2 commits into
base: main
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
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,25 @@
import { action } from '@storybook/addon-actions';
import uuidv4 from '../../global/js/utils/uuidv4';

const currentDate = new Date();
let yesterdayDate = new Date();
yesterdayDate.setDate(yesterdayDate.getDate() - 1);
let dayBeforeYesterday = new Date();
dayBeforeYesterday.setDate(dayBeforeYesterday.getDate() - 2);
/**
Currently setting this to Jan 1st of the current year so notifications aren't too far back. I set it to current year for this case.
The reason we changed this to hardcode is because percy was showing the change in timestamp as a design change. So technically it will
only trigger a percy check once a year.
*/
const currentYear = new Date().getFullYear();
const currentDate = new Date(currentYear, 0, 1); // Month is 0-based, 4 = May

// Static yesterday date (May 3, 2024)
let yesterdayDate = new Date(currentDate);
yesterdayDate.setDate(currentDate.getDate() - 1);

// Static day before yesterday date (May 2, 2024)
let dayBeforeYesterday = new Date(currentDate);
dayBeforeYesterday.setDate(currentDate.getDate() - 2);

// Constant for milliseconds in one minute
const msInOneMinute = 60000;

const data = [
{
id: uuidv4(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,16 +91,7 @@ const makeBreadcrumb = (item, title) => ({
key: `Breadcrumb ${item}`,
label: typeof title === 'string' ? title : `Breadcrumb ${item}`,
});
const now = new Date();
const m = now.getMonth();
if (m === 0) {
now.setFullYear(now.getFullYear() - 1);
now.setMonth(11);
} else {
now.setMonth(m - 1);
}
const ms = now.toLocaleString('default', { month: 'long' });
const ys = now.toLocaleString('default', { year: 'numeric' });

const breadcrumbs = {
'No breadcrumb': null,
'A single breadcrumb': [makeBreadcrumb(1, 'Home page')],
Expand All @@ -116,7 +107,7 @@ const breadcrumbs = {
'Demo breadcrumbs': [
makeBreadcrumb(1, 'Home page', '../../../homepage'),
makeBreadcrumb(2, 'Reports', '../../Reports'),
makeBreadcrumb(3, `${ms} ${ys}`, `../${ms}{ys}`),
makeBreadcrumb(3, `January 2025`, `../January 2025`),
],
};

Expand Down
Loading