diff --git a/.storybook/preview.ts b/.storybook/preview.ts index 807e49cd90..b574746898 100644 --- a/.storybook/preview.ts +++ b/.storybook/preview.ts @@ -5,6 +5,11 @@ import * as locales from '@sl-design-system/locales'; import { type Preview } from '@storybook/web-components-vite'; import { INITIAL_VIEWPORTS } from 'storybook/viewport'; import { updateTheme, themes } from './themes.js'; +import MockDate from 'mockdate'; + +if (!import.meta.env?.DEV) { + MockDate.set('2025-06-01T00:00:00Z'); +} const { setLocale } = configureLocalization({ sourceLocale: locales.sourceLocale, diff --git a/chromatic/.storybook/preview.ts b/chromatic/.storybook/preview.ts index 6eab81db67..c61470e9c2 100644 --- a/chromatic/.storybook/preview.ts +++ b/chromatic/.storybook/preview.ts @@ -3,6 +3,7 @@ import { type Preview } from '@storybook/web-components'; import '@webcomponents/scoped-custom-element-registry/scoped-custom-element-registry.min.js'; import { html } from 'lit'; import { themes, updateTheme } from '../../.storybook/themes'; +import MockDate from 'mockdate'; // Id's of components that only need to be rendered once, not in all mock states. const singleState = [ @@ -18,6 +19,10 @@ const singleState = [ 'all--tooltip' ]; +if (!import.meta.env?.DEV) { + MockDate.set('2025-06-01T00:00:00Z'); +} + const preview: Preview = { decorators: [ (story, { globals: { mode = 'light', theme = 'sanoma-learning' } }) => { diff --git a/package.json b/package.json index 05bafbb880..0d8e3ebf95 100644 --- a/package.json +++ b/package.json @@ -476,6 +476,7 @@ "husky": "^9.1.7", "lint-staged": "^16.2.5", "lit": "^3.3.1", + "mockdate": "^3.0.5", "playwright": "^1.56.1", "sinon": "^21.0.0", "sinon-chai": "^4.0.1", diff --git a/yarn.lock b/yarn.lock index fd79a96083..0d0a2d3828 100644 --- a/yarn.lock +++ b/yarn.lock @@ -5093,6 +5093,7 @@ __metadata: husky: "npm:^9.1.7" lint-staged: "npm:^16.2.5" lit: "npm:^3.3.1" + mockdate: "npm:^3.0.5" playwright: "npm:^1.56.1" sinon: "npm:^21.0.0" sinon-chai: "npm:^4.0.1" @@ -16526,6 +16527,13 @@ __metadata: languageName: node linkType: hard +"mockdate@npm:^3.0.5": + version: 3.0.5 + resolution: "mockdate@npm:3.0.5" + checksum: 10c0/36ab00c4b94d3e3cc8b9ecec27730dcf396d47d2ba046ad96635e7f9bc4bba0fff6125dedaba7313b1cadc0cefc0eb3f3ac0d5c3655707afd3b82fa4550aae92 + languageName: node + linkType: hard + "moo@npm:^0.5.2": version: 0.5.2 resolution: "moo@npm:0.5.2"