Skip to content

Commit

Permalink
docs(storybook): use static dates for EuiDataGrid story
Browse files Browse the repository at this point in the history
- faker.date updated periodically to match the same time distance to a reference date which updated the data
  • Loading branch information
mgadewoll committed May 15, 2024
1 parent 6d1aea2 commit 5e29f85
Showing 1 changed file with 21 additions and 2 deletions.
23 changes: 21 additions & 2 deletions packages/eui/src/components/datagrid/data_grid.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,24 @@ import { EuiDataGrid } from './data_grid';

faker.seed(42);

// NOTE: using faker.date.past() is not fully stable for VRT as the date is
// based on a years time distance (default 1 year) which updates with progressing time
// faker.seed() ensures the same date is output in the same time frame
// but after some time the time distance will generate a newer, closer date
// which then invalidates the VRT
const staticDates = [
new Date('Tue Mar 19 2024 18:54:51 GMT+0100'),
new Date('Mon Mar 25 2024 19:27:35 GMT+0100'),
new Date('Sat Sep 09 2023 00:32:42 GMT+0200'),
new Date('Wed Jun 14 2023 06:48:29 GMT+0200'),
new Date('Mon Mar 04 2024 04:40:36 GMT+0100'),
new Date('Mon Feb 05 2024 10:51:48 GMT+0100'),
new Date('Mon Jun 19 2023 12:08:38 GMT+0200'),
new Date('Wed Jul 26 2023 01:15:02 GMT+0200'),
new Date('Wed Nov 08 2023 08:49:13 GMT+0100'),
new Date('Sun Nov 19 2023 01:49:12 GMT+0100'),
];

const dataKeys = [
'name',
'email',
Expand All @@ -35,10 +53,11 @@ const dataKeys = [
'date',
'version',
] as const;
const raw_data = Array.from({ length: 10 }).map(() => {

const raw_data = Array.from({ length: 10 }).map((_, i) => {
const email = faker.internet.email();
const name = `${faker.person.lastName()}, ${faker.person.firstName()}`;
const date = faker.date.past().toDateString();
const date = staticDates[i].toDateString();
const suffix = faker.person.suffix();
return {
name: {
Expand Down

0 comments on commit 5e29f85

Please sign in to comment.