Skip to content

The open alternative to Salesforce, designed for AI.

fix(front): stop GraphQLPlayground story failing on Monaco worker load errors (#27139)

Thomas Trompette6dd7a7473a79
diff --git a/packages/twenty-front/src/modules/settings/mcp-and-apis/components/__stories__/GraphQLPlayground.stories.tsx b/packages/twenty-front/src/modules/settings/mcp-and-apis/components/__stories__/GraphQLPlayground.stories.tsx
index fc8ae6cd848..4b7e143f28f 100644
--- a/packages/twenty-front/src/modules/settings/mcp-and-apis/components/__stories__/GraphQLPlayground.stories.tsx
+++ b/packages/twenty-front/src/modules/settings/mcp-and-apis/components/__stories__/GraphQLPlayground.stories.tsx
@@ -2,6 +2,7 @@ import { GraphQLPlayground } from '@/settings/mcp-and-apis/components/GraphQLPla
import { playgroundApiKeyState } from '@/settings/mcp-and-apis/states/playgroundApiKeyState';
import { useSetAtomState } from '@/ui/utilities/state/jotai/hooks/useSetAtomState';
import { type Meta, type StoryObj } from '@storybook/react-vite';
+import { type Environment } from 'monaco-editor';
import { useEffect } from 'react';
import { action } from 'storybook/actions';
import { ComponentDecorator } from 'twenty-ui/testing';
@@ -21,10 +22,27 @@ const PlaygroundApiKeySetterEffect = () => {
return null;
};
+const inertWorkerUrl = URL.createObjectURL(
+ new Blob([], { type: 'text/javascript' }),
+);
+
+const inertMonacoEnvironment: Environment = {
+ getWorker: () => new Worker(inertWorkerUrl),
+};
+
const meta: Meta<typeof GraphQLPlayground> = {
title: 'Modules/Settings/Playground/GraphQLPlayground',
component: GraphQLPlayground,
decorators: [ComponentDecorator, ComponentWithRouterDecorator],
+ beforeEach: () => {
+ const appMonacoEnvironment = window.MonacoEnvironment;
+
+ window.MonacoEnvironment = inertMonacoEnvironment;
+
+ return () => {
+ window.MonacoEnvironment = appMonacoEnvironment;
+ };
+ },
parameters: {
docs: {
description: {