diff --git a/scripts/collect-i18n-general.ts b/scripts/collect-i18n-general.ts index 1bbcb2060..5165e89be 100644 --- a/scripts/collect-i18n-general.ts +++ b/scripts/collect-i18n-general.ts @@ -1,5 +1,8 @@ import * as fs from 'fs' +// Import Vite define shim to make __DISTRIBUTION__ and other define variables available +import './vite-define-shim' + import { DESKTOP_DIALOGS } from '../apps/desktop-ui/src/constants/desktopDialogs' import { comfyPageFixture as test } from '../browser_tests/fixtures/ComfyPage' import { diff --git a/scripts/vite-define-shim.ts b/scripts/vite-define-shim.ts new file mode 100644 index 000000000..e12b126f3 --- /dev/null +++ b/scripts/vite-define-shim.ts @@ -0,0 +1,46 @@ +/** + * Shim for Vite define variables to make them available during Playwright test execution + * This file should be imported before any code that uses Vite define variables + */ + +// Define global constants that Vite would normally replace at build time +declare global { + const __COMFYUI_FRONTEND_VERSION__: string + const __SENTRY_ENABLED__: boolean + const __SENTRY_DSN__: string + const __ALGOLIA_APP_ID__: string + const __ALGOLIA_API_KEY__: string + const __USE_PROD_CONFIG__: boolean + const __DISTRIBUTION__: 'desktop' | 'localhost' | 'cloud' +} + +type GlobalWithDefines = typeof globalThis & { + __COMFYUI_FRONTEND_VERSION__: string + __SENTRY_ENABLED__: boolean + __SENTRY_DSN__: string + __ALGOLIA_APP_ID__: string + __ALGOLIA_API_KEY__: string + __USE_PROD_CONFIG__: boolean + __DISTRIBUTION__: 'desktop' | 'localhost' | 'cloud' + window?: Record +} + +const globalWithDefines = globalThis as GlobalWithDefines + +// Set default values for Playwright test environment +globalWithDefines.__COMFYUI_FRONTEND_VERSION__ = + process.env.npm_package_version || '1.0.0' +globalWithDefines.__SENTRY_ENABLED__ = false +globalWithDefines.__SENTRY_DSN__ = '' +globalWithDefines.__ALGOLIA_APP_ID__ = '' +globalWithDefines.__ALGOLIA_API_KEY__ = '' +globalWithDefines.__USE_PROD_CONFIG__ = false +globalWithDefines.__DISTRIBUTION__ = 'localhost' + +// Provide a minimal window shim for Node environment +// This is needed for code that checks window existence during imports +if (typeof window === 'undefined') { + globalWithDefines.window = {} +} + +export {} diff --git a/src/locales/en/main.json b/src/locales/en/main.json index 1205517f4..1d2e14365 100644 --- a/src/locales/en/main.json +++ b/src/locales/en/main.json @@ -2254,4 +2254,4 @@ "replacementInstruction": "Install these nodes to run this workflow, or replace them with installed alternatives. Missing nodes are highlighted in red on the canvas." } } -} +} \ No newline at end of file