import { readFileSync } from "node:fs"; import { resolve } from "node:path"; import { runInNewContext } from "node:vm"; import { act, render, screen, waitFor } from "@testing-library/react"; import userEvent from "@testing-library/user-event"; import { describe, expect, it, vi } from "vitest"; import { LanguageSwitcher } from "@/components/LanguageSwitcher"; import { ThreadComposer } from "@/components/thread/ThreadComposer"; import { resources } from "@/i18n"; import { LOCALE_STORAGE_KEY, resolveInitialLocale, supportedLocales, } from "@/i18n/config"; const QUICK_ACTION_KEYS = ["plan", "analyze", "brainstorm", "code", "summarize", "more"]; const IMAGE_QUICK_ACTION_KEYS = ["icon", "sticker", "poster", "product", "portrait", "edit"]; const HERO_GREETING_KEYS = ["workOn", "start", "build", "tackle"]; const SLASH_COMMAND_KEYS = [ "new", "stop", "restart", "status", "model", "history", "dream", "dream_log", "dream_restore", "dream_prompt", "goal", "trigger", "help", "pairing", ]; const SETTINGS_NAV_KEYS = [ "overview", "appearance", "models", "image", "browser", "apps", "automations", "runtime", "advanced", ]; const LOCALIZED_SETTINGS_COPY_KEYS = [ "settings.backToChat", "settings.sidebar.title", "settings.sidebar.ariaLabel", "settings.nav.overview", "settings.nav.appearance", "settings.nav.models", "settings.nav.providers", "settings.nav.apps", "settings.nav.automations", "settings.nav.runtime", "settings.nav.advanced", "sidebar.automations", "settings.automations.filters.active", "settings.automations.queue", "settings.automations.empty", "settings.automations.systemTask", "settings.automations.labels.schedule", "settings.automations.status.active", "settings.automations.deleteTitle", "settings.sections.interface", "settings.sections.localPreferences", "settings.sections.webSearch", "settings.sections.webBehavior", "settings.sections.webuiSafety", "settings.sections.capabilities", "settings.sections.apps", "settings.apps.description", "settings.apps.caption", "settings.apps.restartRequired", "settings.nanobotFeatures.disable", "settings.nanobotFeatures.ready", "settings.nanobotFeatures.missingDependency", "settings.nanobotFeatures.installConfirmTitle", "settings.nanobotFeatures.installConfirmDescription", "settings.nanobotFeatures.installConfirmAction", "settings.nanobotFeatures.channelDisabled", "settings.nanobotFeatures.notEnabled", "settings.sections.about", "settings.rows.theme", "settings.rows.language", "settings.rows.density", "settings.rows.activityMode", "settings.rows.fileEditDisplay", "settings.rows.codeWrap", "settings.rows.brandLogos", "settings.rows.currentModel", "settings.rows.localServiceAccess", "settings.rows.webuiDefaultAccess", "settings.rows.contextWindow", "settings.help.theme", "settings.help.language", "settings.help.density", "settings.help.activityMode", "settings.help.fileEditDisplay", "settings.help.codeWrap", "settings.help.brandLogos", "settings.help.currentModel", "settings.help.localServiceAccess", "settings.help.webuiDefaultAccess", "settings.values.light", "settings.values.dark", "settings.values.comfortable", "settings.values.compact", "settings.values.expanded", "settings.values.enabled", "settings.values.disabled", "settings.values.defaultPermission", "settings.values.fullAccess", "settings.values.configured", "settings.values.notConfigured", "settings.status.loading", "settings.status.unsaved", "settings.status.upToDate", "settings.actions.save", "settings.actions.saving", "settings.about.checking", "settings.about.checkForUpdates", "settings.about.upToDate", "settings.about.updateAvailable", ]; const LOCALIZED_WORKSPACE_COPY_KEYS = [ "thread.composer.workspace.accessAria", "thread.composer.workspace.default", "thread.composer.workspace.full", "errors.workspaceScopeRejected.title", "errors.workspaceScopeRejected.body", "workspace.dialog.defaultProject", "workspace.dialog.usePath", "workspace.dialog.absolutePathRequired", ]; const INDEX_HTML = readFileSync(resolve(process.cwd(), "index.html"), "utf8"); const PREBOOT_SCRIPT = INDEX_HTML.match( /