Skip to content

The open alternative to Salesforce, designed for AI.

Make flaky Storybook stories deterministic for Argos (animations + lazy-load) (#21609)

Raphaël Bosi03f9ace0bc35
diff --git a/packages/twenty-front/.storybook/vitest.setup.ts b/packages/twenty-front/.storybook/vitest.setup.ts
index c3d0fa7c70e..de1f68906dd 100644
--- a/packages/twenty-front/.storybook/vitest.setup.ts
+++ b/packages/twenty-front/.storybook/vitest.setup.ts
@@ -1,12 +1,30 @@
+import { Globals } from '@react-spring/web';
import { setProjectAnnotations } from '@storybook/react-vite';
import { MotionGlobalConfig } from 'framer-motion';
import * as projectAnnotations from './preview';
MotionGlobalConfig.skipAnimations = true;
+Globals.assign({ skipAnimation: true });
-// Pre-warm the dynamic import used by WorkflowStepDecorator so the
-// module is cached before any test runs (avoids flaky timeouts in CI).
+const disableCssAnimationsStyle = document.createElement('style');
+disableCssAnimationsStyle.innerHTML = `*, *::before, *::after {
+ animation-duration: 0s !important;
+ animation-delay: 0s !important;
+ transition-duration: 0s !important;
+ transition-delay: 0s !important;
+}`;
+document.head.appendChild(disableCssAnimationsStyle);
+
+// Pre-warm the dynamic imports used by lazy() story components so the
+// modules are cached before any test runs (avoids flaky timeouts and Argos
+// screenshots that capture a Suspense skeleton instead of the loaded content).
import('~/testing/utils/getTestEnrichedObjectMetadataItemsMock');
+import('react-markdown');
+import('remark-gfm');
+import('@/activities/components/ActivityRichTextEditor');
+import('@/object-record/record-field/ui/meta-types/input/components/RichTextFieldEditor');
+import('@/navigation-menu-item/display/sections/favorites/components/FavoritesSectionDispatcher');
+import('@/navigation-menu-item/display/sections/workspace/components/WorkspaceSectionDispatcher');
// This is an important step to apply the right configuration when testing your stories.
// More info at: https://storybook.js.org/docs/api/portable-stories/portable-stories-vitest#setprojectannotations
diff --git a/packages/twenty-front/vite.config.ts b/packages/twenty-front/vite.config.ts
index 33d02e124b4..5424e5c6194 100644
--- a/packages/twenty-front/vite.config.ts
+++ b/packages/twenty-front/vite.config.ts
@@ -154,6 +154,7 @@ export default defineConfig(({ mode }) => {
'@nivo/pie',
'@nivo/line',
'@nivo/arcs',
+ '@react-spring/web',
'd3-shape',
],
},