From a1d2fbd96bb6713c3172198d71e94274af409aee Mon Sep 17 00:00:00 2001 From: naoNao89 <90588855+naoNao89@users.noreply.github.com> Date: Thu, 31 Jul 2025 05:29:42 +0700 Subject: [Editor] Prevent excessive project creation from invalid routes Race conditions in useEffect hook caused navigation to invalid project IDs to create multiple 'Untitled Project' entries. Users reported accumulating 885+ projects due to this bug. This change adds global invalid project ID tracking across component remounts and prevents race conditions through: - Global invalidProjectIds Set in project store with tracking functions - isInitializingRef to prevent duplicate initialization attempts - Proper useEffect cleanup with cancellation tokens - Specific error handling for 'not found' vs recoverable errors - Removed problematic activeProject?.id dependency Testing: - Add comprehensive test suite (15 tests) with Vitest + React Testing Library - Include integration tests demonstrating bug and validating fix - Update CI pipeline to run automated tests Fixes #182 --- apps/web/vitest.config.ts | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 apps/web/vitest.config.ts (limited to 'apps/web/vitest.config.ts') diff --git a/apps/web/vitest.config.ts b/apps/web/vitest.config.ts new file mode 100644 index 00000000..e546f78a --- /dev/null +++ b/apps/web/vitest.config.ts @@ -0,0 +1,30 @@ +/// +import { defineConfig } from 'vitest/config' +import react from '@vitejs/plugin-react' +import path from 'path' + +export default defineConfig({ + plugins: [react()], + test: { + environment: 'jsdom', + setupFiles: ['./src/__tests__/setup.ts'], + globals: true, + css: true, + coverage: { + provider: 'v8', + reporter: ['text', 'json', 'html'], + exclude: [ + 'node_modules/', + 'src/__tests__/', + '**/*.d.ts', + '**/*.config.*', + '**/coverage/**' + ] + } + }, + resolve: { + alias: { + '@': path.resolve(__dirname, './src'), + }, + }, +}) -- cgit v1.3.1