mirror of
https://github.com/anomalyco/opencode.git
synced 2026-11-18 15:28:48 +03:00
test(app): stop partial settings mocks leaking across browser tests (#55276)
This commit is contained in:
committed by
GitHub
Unverified
parent
6dc4d4e758
commit
52ba7d630f
@@ -19,9 +19,9 @@
|
||||
"build": "vite build",
|
||||
"serve": "vite preview",
|
||||
"test": "bun run test:unit && bun run test:browser",
|
||||
"test:unit": "bun test --conditions=solid --only-failures --preload ./happydom.ts ./src",
|
||||
"test:browser": "bun test --conditions=browser --preload ./happydom.ts ./test-browser",
|
||||
"test:unit:watch": "bun test --conditions=solid --watch --preload ./happydom.ts ./src",
|
||||
"test:unit": "bun test --conditions=solid --only-failures --isolate --preload ./happydom.ts ./src",
|
||||
"test:browser": "bun test --conditions=browser --isolate --preload ./happydom.ts ./test-browser",
|
||||
"test:unit:watch": "bun test --conditions=solid --watch --isolate --preload ./happydom.ts ./src",
|
||||
"test:e2e": "playwright test",
|
||||
"test:e2e:built": "PLAYWRIGHT_BUILD=1 playwright test",
|
||||
"test:e2e:local": "playwright test",
|
||||
|
||||
@@ -1,19 +1,6 @@
|
||||
import { beforeAll, describe, expect, mock, test } from "bun:test"
|
||||
import { describe, expect, test } from "bun:test"
|
||||
import { createRoot } from "solid-js"
|
||||
import type { LineComment } from "./comments"
|
||||
|
||||
let createCommentSessionForTest: typeof import("./comments").createCommentSessionForTest
|
||||
|
||||
beforeAll(async () => {
|
||||
mock.module("@solidjs/router", () => ({
|
||||
useNavigate: () => () => undefined,
|
||||
useParams: () => ({}),
|
||||
useLocation: () => ({}),
|
||||
useSearchParams: () => [{}, () => undefined],
|
||||
}))
|
||||
const mod = await import("./comments")
|
||||
createCommentSessionForTest = mod.createCommentSessionForTest
|
||||
})
|
||||
import { createCommentSessionForTest, type LineComment } from "./comments"
|
||||
|
||||
function line(file: string, id: string, time: number): LineComment {
|
||||
return {
|
||||
|
||||
@@ -23,8 +23,17 @@ const createState = (input: { sdk: object; data: object; coordinator: object })
|
||||
createServerNotificationState({ key: server, ...input } as never)
|
||||
|
||||
beforeAll(async () => {
|
||||
const { sessionIDHasOpenTab } = await import("@/shell/tabs/tabs")
|
||||
// Fakes replace only the hooks this test controls. Spreading the real module keeps every other export, such as
|
||||
// projectSettingsKey, for the modules the notification state imports.
|
||||
const real = {
|
||||
platform: await import("@/runtime/platform/platform"),
|
||||
settings: await import("@/settings/model"),
|
||||
language: await import("@/runtime/i18n/language"),
|
||||
tabs: await import("@/shell/tabs/tabs"),
|
||||
}
|
||||
|
||||
mock.module("@/runtime/platform/platform", () => ({
|
||||
...real.platform,
|
||||
usePlatform: () => ({
|
||||
platform: "web",
|
||||
notify: async (title: string) => {
|
||||
@@ -33,16 +42,17 @@ beforeAll(async () => {
|
||||
}),
|
||||
}))
|
||||
mock.module("@/settings/model", () => ({
|
||||
...real.settings,
|
||||
useSettings: () => ({
|
||||
sounds: { agentEnabled: () => false, errorsEnabled: () => false },
|
||||
notifications: { agent: () => true, errors: () => true },
|
||||
}),
|
||||
}))
|
||||
mock.module("@/runtime/i18n/language", () => ({ useLanguage: () => ({ t: (key: string) => key }) }))
|
||||
mock.module("@/shell/tabs/tabs", () => ({
|
||||
useTabs: () => tabs,
|
||||
sessionIDHasOpenTab,
|
||||
mock.module("@/runtime/i18n/language", () => ({
|
||||
...real.language,
|
||||
useLanguage: () => ({ t: (key: string) => key }),
|
||||
}))
|
||||
mock.module("@/shell/tabs/tabs", () => ({ ...real.tabs, useTabs: () => tabs }))
|
||||
createServerNotificationState = (await import("@/shell/notifications/notification")).createServerNotificationState
|
||||
})
|
||||
|
||||
|
||||
Reference in New Issue
Block a user