-
Notifications
You must be signed in to change notification settings - Fork 419
[bugfix] Add vite-define shim for Playwright i18n collection #6906
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
Fixes the ReferenceError for __DISTRIBUTION__ when running i18n collection tests. Previously, Playwright's test runner would fail when importing code that uses Vite define variables (like __DISTRIBUTION__) because these variables are only replaced during Vite's build/dev process. Solution: - Created scripts/vite-define-shim.ts that defines all Vite define variables as global constants before tests run - Import the shim at the top of collect-i18n-general.ts - Also provides a minimal window shim for Node environment This allows the i18n collection process to import and evaluate coreMenuCommands which uses isCloud (which depends on __DISTRIBUTION__). Related to PR #6879 which added conditional menu commands based on distribution. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
|
Important Review skippedDraft detected. Please check the settings in the CodeRabbit UI or the You can disable this status message by setting the ✨ Finishing touches🧪 Generate unit tests (beta)
Comment |
🎨 Storybook Build Status✅ Build completed successfully! ⏰ Completed at: 11/25/2025, 06:19:30 AM UTC 🔗 Links🎉 Your Storybook is ready for review! |
🎭 Playwright Test Results⏰ Completed at: 11/25/2025, 06:27:54 AM UTC 📈 Summary
📊 Test Reports by Browser
🎉 Click on the links above to view detailed test results for each browser configuration. |
Bundle Size ReportSummary
Category Glance Per-category breakdownApp Entry Points — 3.18 MB (baseline 3.18 MB) • ⚪ 0 BMain entry bundles and manifests
Graph Workspace — 940 kB (baseline 940 kB) • ⚪ 0 BGraph editor runtime, canvas, workflow orchestration
Views & Navigation — 6.54 kB (baseline 6.54 kB) • ⚪ 0 BTop-level views, pages, and routed surfaces
Panels & Settings — 297 kB (baseline 297 kB) • ⚪ 0 BConfiguration panels, inspectors, and settings screens
UI Components — 139 kB (baseline 139 kB) • ⚪ 0 BReusable component library chunks
Data & Services — 12.5 kB (baseline 12.5 kB) • ⚪ 0 BStores, services, APIs, and repositories
Utilities & Hooks — 2.94 kB (baseline 2.94 kB) • ⚪ 0 BHelpers, composables, and utility bundles
Vendor & Third-Party — 8.56 MB (baseline 8.56 MB) • ⚪ 0 BExternal libraries and shared vendor chunks
Other — 3.84 MB (baseline 3.84 MB) • ⚪ 0 BBundles that do not match a named category
|
Summary
Fixes the
ReferenceError: __DISTRIBUTION__ is not definederror when running i18n collection tests.Problem
PR #6879 added conditional menu commands based on distribution (hiding memory unload commands in cloud). This introduced a dependency on
isCloudwhich uses the__DISTRIBUTION__Vite define variable incoreMenuCommands.ts.When Playwright's test runner imports this file during i18n collection, it fails because Vite define variables are only replaced during Vite's build/dev process, not during Playwright's TypeScript compilation.
Solution
Created a simple shim (
scripts/vite-define-shim.ts) that:windowshim for Node environmentcollect-i18n-general.tsbefore any code that uses these variablesThis approach is simpler than:
ctViteConfig(only works for component testing, not regular Playwright tests)Test Plan
Run
pnpm collect-i18nand verify:ReferenceError: __DISTRIBUTION__ is not definedReferenceError: window is not definedRelated
🤖 Generated with Claude Code
┆Issue is synchronized with this Notion page by Unito