Remove randomness from flaky twenty-front Storybook stories (#21594)

Several twenty-front Storybook stories were flagged flaky by Argos
because they render different pixels across runs. This removes the
non-determinism behind them.

**What changed**
- **Images** — replaced random `picsum.photos` URLs in the Logo and
TabList stories with the existing `AVATAR_URL_MOCK`, and added global
MSW handlers in `.storybook/preview.tsx` that serve a deterministic
image for every remote host (picsum, twenty-icons.com,
twentyhq.github.io, etc.) so no story depends on a network image load.
- **Numbers** — the line-chart story built its data with
`Math.random()`; now uses a deterministic formula.
- **Dates** — the terminal "long output" story stamped its lines with
`new Date()`; now uses a fixed base timestamp. The calendar-channel
date/time format previews and example event used render-time
`Date.now()`/`new Date()` in shared components; they now use a fixed
reference date (`DateTimeSettingsPreviewDate`).
- **Lazy-load timing** — the date-picker story now waits for the
lazily-loaded calendar before the snapshot.

<!-- This is an auto-generated description by cubic. -->
<a
href="https://cubic.dev/pr/twentyhq/twenty/pull/21594?utm_source=github"
target="_blank" rel="noopener noreferrer"
data-no-image-dialog="true"><picture><source
media="(prefers-color-scheme: dark)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"><source
media="(prefers-color-scheme: light)"
srcset="https://www.cubic.dev/buttons/review-in-cubic-light.svg"><img
alt="Review in cubic"
src="https://www.cubic.dev/buttons/review-in-cubic-dark.svg"></picture></a>
<!-- End of auto-generated description by cubic. -->
This commit is contained in:
Raphaël Bosi
2026-06-15 13:37:19 +02:00
committed by GitHub
parent c848ac34fd
commit ecc7b38b75
10 changed files with 88 additions and 40 deletions
@@ -31,7 +31,16 @@ const meta: Meta<typeof DateTimePicker> = {
export default meta;
type Story = StoryObj<typeof DateTimePicker>;
export const Default: Story = {};
export const Default: Story = {
play: async ({ canvasElement }) => {
const canvas = within(canvasElement);
await canvas.findByRole(
'button',
{ name: 'Select month and year' },
{ timeout: 10000 },
);
},
};
export const WithOpenMonthSelect: Story = {
play: async ({ canvasElement }) => {
@@ -10,10 +10,13 @@ import {
IconPhone,
IconUser,
} from 'twenty-ui-deprecated/display';
import { ComponentWithRouterDecorator } from 'twenty-ui-deprecated/testing';
import {
AVATAR_URL_MOCK,
ComponentWithRouterDecorator,
} from 'twenty-ui-deprecated/testing';
const tabs = [
{ id: 'general', title: 'General', logo: 'https://picsum.photos/200' },
{ id: 'general', title: 'General', logo: AVATAR_URL_MOCK },
{ id: 'contacts', title: 'Contacts', Icon: IconUser },
{ id: 'messages', title: 'Messages', Icon: IconMail },
{ id: 'calls', title: 'Calls', Icon: IconPhone },
@@ -23,7 +26,7 @@ const tabs = [
{
id: 'time',
title: 'Time Tracking',
logo: 'https://picsum.photos/192/192',
logo: AVATAR_URL_MOCK,
},
{
id: 'activity',