Skip to content

Commit 45795c8

Browse files
test(webview): drop the three duplicated top-level cases, name the second describe
The review thread measured true against bf7a9e9. Three cases appeared twice, identical apart from indentation - "should merge concurrent persisted updates from separate provider instances without lost viewStates", "should remove the buffered apiConfiguration when it is cleared" and "should increment instance count for each new instance" each sat once inside a describe and once as a direct child of describe("ClineProvider") - and describe("view state persistence edge cases") appeared twice, so reports showed two groups under one name. Deleted the three top-level copies; the in-describe copies stay byte-for-byte unchanged. Renamed the second block to "view-local buffer: loading, setValue mutations and rollback", which names what its four cases actually do: load the persisted mode, profile name and resolved profile into viewLocalState; apply setValue mutations to global state and keep or clear the buffered fields; drop the buffered apiConfiguration when it is cleared; roll back the shared write when per-view persistence fails. The first block keeps the old title - its eleven cases are all persisted-viewStates edge cases, which is what it says. Survivor check before pushing: 349 test titles in the file before, 346 after; each of the three names still appears exactly once and no title dropped to zero. Three other same-title pairs exist ("handles case when no current task exists", "loads saved API config when switching modes", "saves current config when switching to mode without config") and are left alone: their bodies differ, so they are not duplicates of each other. prettier --check, tsc --noEmit -p . and eslint --max-warnings=0 are clean, and vitest core/webview is 34 files / 982 tests green. No production file is touched, so the scope measure still reports the same 810 extension-package executable lines.
1 parent bf7a9e9 commit 45795c8

1 file changed

Lines changed: 1 addition & 80 deletions

File tree

‎src/core/webview/__tests__/ClineProvider.spec.ts‎

Lines changed: 1 addition & 80 deletions
Original file line numberDiff line numberDiff line change
@@ -6799,41 +6799,7 @@ describe("ClineProvider", () => {
67996799
})
68006800
})
68016801

6802-
it("should merge concurrent persisted updates from separate provider instances without lost viewStates", async () => {
6803-
const provider1 = new ClineProvider(
6804-
mockContext,
6805-
mockOutputChannel,
6806-
"sidebar",
6807-
new ContextProxy(mockContext),
6808-
6809-
new WebviewFocusTracker(),
6810-
)
6811-
const provider2 = new ClineProvider(
6812-
mockContext,
6813-
mockOutputChannel,
6814-
"editor",
6815-
new ContextProxy(mockContext),
6816-
new WebviewFocusTracker(),
6817-
)
6818-
6819-
await provider1["setViewStateId"]("stable-sidebar-view")
6820-
await provider2["setViewStateId"]("stable-editor-view")
6821-
6822-
await Promise.all([
6823-
provider1.saveViewState("mode", "architect"),
6824-
provider2.saveViewState("currentApiConfigName", "editor-profile"),
6825-
])
6826-
6827-
expect(mockContext.globalState.get("viewStates")).toMatchObject({
6828-
"stable-sidebar-view": { mode: "architect" },
6829-
"stable-editor-view": { currentApiConfigName: "editor-profile" },
6830-
})
6831-
6832-
await provider1.dispose()
6833-
await provider2.dispose()
6834-
})
6835-
6836-
describe("view state persistence edge cases", () => {
6802+
describe("view-local buffer: loading, setValue mutations and rollback", () => {
68376803
it("should load persisted mode, profile name and resolved profile into viewLocalState", async () => {
68386804
const writer = new ClineProvider(
68396805
mockContext,
@@ -7012,24 +6978,6 @@ describe("ClineProvider", () => {
70126978
await provider.dispose()
70136979
})
70146980

7015-
it("should remove the buffered apiConfiguration when it is cleared", async () => {
7016-
const provider = new ClineProvider(
7017-
mockContext,
7018-
mockOutputChannel,
7019-
"sidebar",
7020-
new ContextProxy(mockContext),
7021-
new WebviewFocusTracker(),
7022-
)
7023-
const save = provider.saveViewState.bind(provider) as (key: string, value: unknown) => Promise<void>
7024-
await provider.saveViewState("apiConfiguration", { apiProvider: providerIdentifiers.openrouter })
7025-
await provider.saveViewState("apiConfiguration", undefined)
7026-
expect(provider["viewLocalState"]).not.toHaveProperty("apiConfiguration")
7027-
await provider.saveViewState("apiConfiguration", { apiProvider: providerIdentifiers.openrouter })
7028-
await save("apiConfiguration", null)
7029-
expect(provider["viewLocalState"]).not.toHaveProperty("apiConfiguration")
7030-
await provider.dispose()
7031-
})
7032-
70336981
it("should clear viewLocalState and the persisted entry when resetting state", async () => {
70346982
const provider = new ClineProvider(
70356983
mockContext,
@@ -7279,33 +7227,6 @@ describe("ClineProvider", () => {
72797227
})
72807228
})
72817229

7282-
it("should increment instance count for each new instance", async () => {
7283-
const provider1 = new ClineProvider(
7284-
mockContext,
7285-
mockOutputChannel,
7286-
"editor",
7287-
new ContextProxy(mockContext),
7288-
new WebviewFocusTracker(),
7289-
)
7290-
const provider2 = new ClineProvider(
7291-
mockContext,
7292-
mockOutputChannel,
7293-
"editor",
7294-
new ContextProxy(mockContext),
7295-
new WebviewFocusTracker(),
7296-
)
7297-
7298-
// First editor instance should be "editor-0" (or next available)
7299-
// Second editor instance should have a different number
7300-
const num1 = parseInt(provider1.viewId.split("-")[1]!)
7301-
const num2 = parseInt(provider2.viewId.split("-")[1]!)
7302-
7303-
expect(num2).toBeGreaterThan(num1)
7304-
7305-
await provider1.dispose()
7306-
await provider2.dispose()
7307-
})
7308-
73097230
it("should reapply an independently mutated profile name when the load settles", async () => {
73107231
const provider = new ClineProvider(
73117232
mockContext,

0 commit comments

Comments
 (0)