Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -9,12 +9,6 @@ vi.mock('../../utils/export-visualization', () => ({
copyResult: vi.fn(),
}));

declare global {
// eslint-disable-next-line no-var
var IS_REACT_ACT_ENVIRONMENT: boolean;
}
globalThis.IS_REACT_ACT_ENVIRONMENT = true;

async function click(button: HTMLButtonElement) {
await act(async () => {
button.dispatchEvent(new MouseEvent('click', { bubbles: true }));
Expand Down
7 changes: 7 additions & 0 deletions apps/ai-studio/types.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
declare global {
// React reads this flag to know the test environment wraps updates in act(); vitest.setup.ts sets it.
// eslint-disable-next-line no-var
var IS_REACT_ACT_ENVIRONMENT: boolean;
}

export {};
1 change: 1 addition & 0 deletions apps/ai-studio/vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ export default defineConfig(() => {
test: {
globals: true,
environment: 'jsdom',
setupFiles: ['./vitest.setup.ts'],
},
};
});
1 change: 1 addition & 0 deletions apps/ai-studio/vitest.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
globalThis.IS_REACT_ACT_ENVIRONMENT = true;
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { type Root, createRoot } from 'react-dom/client';

import { NavButton } from './nav-button';

(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;

let container: HTMLDivElement;
let root: Root;

Expand Down
2 changes: 0 additions & 2 deletions packages/ui/src/components/menu/menu.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { afterEach, beforeEach, describe, expect, it } from 'vitest';

import { Menu } from './menu';

(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;

let container: HTMLDivElement;
let root: Root;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { type Root, createRoot } from 'react-dom/client';

import { NodeDescription } from './node-description';

(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;

let container: HTMLDivElement;
let root: Root;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@ import { afterEach, beforeEach, describe, expect, it } from 'vitest';

import { NodePanel } from './node-panel';

(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;

let container: HTMLDivElement;
let root: Root;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,6 @@ import { type Root, createRoot } from 'react-dom/client';

import { SegmentPicker } from './segment-picker';

(globalThis as typeof globalThis & { IS_REACT_ACT_ENVIRONMENT: boolean }).IS_REACT_ACT_ENVIRONMENT = true;

let container: HTMLDivElement;
let root: Root;

Expand Down
6 changes: 0 additions & 6 deletions packages/ui/src/shared/components/field/field.spec.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,6 @@ import { Input } from '../../../components/input/input';
import { TextArea } from '../../../components/text-area/text-area';
import { Field } from './field';

declare global {
// eslint-disable-next-line no-var
var IS_REACT_ACT_ENVIRONMENT: boolean;
}
globalThis.IS_REACT_ACT_ENVIRONMENT = true;

describe('Field', () => {
let container: HTMLDivElement;
let root: ReturnType<typeof createRoot>;
Expand Down
2 changes: 1 addition & 1 deletion packages/ui/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,6 @@
"@ui/*": ["./src/*"]
}
},
"include": ["src", "types.d.ts"],
"include": ["src", "types.d.ts", "vitest.setup.ts"],
"exclude": ["node_modules", "dist"]
}
8 changes: 8 additions & 0 deletions packages/ui/types.d.ts
Original file line number Diff line number Diff line change
@@ -1 +1,9 @@
/// <reference types="vite/client" />

declare global {
// React reads this flag to know the test environment wraps updates in act(); vitest.setup.ts sets it.
// eslint-disable-next-line no-var
var IS_REACT_ACT_ENVIRONMENT: boolean;
}

export {};
2 changes: 1 addition & 1 deletion packages/ui/vite.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export default defineConfig({
libInjectCss(),
// A stray *.spec.mts in the ts program stalls this build for 15+ minutes
// with no output - keep every spec shape excluded.
dts({ entryRoot: 'src', exclude: ['**/*.spec.{ts,tsx,mts}'] }),
dts({ entryRoot: 'src', exclude: ['**/*.spec.{ts,tsx,mts}', 'vitest.setup.ts'] }),
copyTokenStyles(),
combineCssBundle(rootDirectory),
...(process.env.BUNDLE_STATS ? bundleStatsPlugins() : []),
Expand Down
1 change: 1 addition & 0 deletions packages/ui/vitest.config.mts
Original file line number Diff line number Diff line change
Expand Up @@ -14,5 +14,6 @@ export default defineConfig({
test: {
globals: true,
environment: 'jsdom',
setupFiles: ['./vitest.setup.ts'],
},
});
1 change: 1 addition & 0 deletions packages/ui/vitest.setup.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
globalThis.IS_REACT_ACT_ENVIRONMENT = true;
Loading