|
|
@@ -102,6 +102,29 @@ describe("ContextProxy", () => {
|
|
|
const result = proxy.getGlobalState("apiProvider", "default-value")
|
|
|
expect(result).toBe("default-value")
|
|
|
})
|
|
|
+
|
|
|
+ it("should bypass cache for pass-through state keys", async () => {
|
|
|
+ // Setup mock return value
|
|
|
+ mockGlobalState.get.mockReturnValue("pass-through-value")
|
|
|
+
|
|
|
+ // Use a pass-through key (taskHistory)
|
|
|
+ const result = proxy.getGlobalState("taskHistory" as GlobalStateKey)
|
|
|
+
|
|
|
+ // Should get value directly from original context
|
|
|
+ expect(result).toBe("pass-through-value")
|
|
|
+ expect(mockGlobalState.get).toHaveBeenCalledWith("taskHistory")
|
|
|
+ })
|
|
|
+
|
|
|
+ it("should respect default values for pass-through state keys", async () => {
|
|
|
+ // Setup mock to return undefined
|
|
|
+ mockGlobalState.get.mockReturnValue(undefined)
|
|
|
+
|
|
|
+ // Use a pass-through key with default value
|
|
|
+ const result = proxy.getGlobalState("taskHistory" as GlobalStateKey, "default-value")
|
|
|
+
|
|
|
+ // Should return default value when original context returns undefined
|
|
|
+ expect(result).toBe("default-value")
|
|
|
+ })
|
|
|
})
|
|
|
|
|
|
describe("updateGlobalState", () => {
|
|
|
@@ -115,6 +138,21 @@ describe("ContextProxy", () => {
|
|
|
const storedValue = await proxy.getGlobalState("apiProvider")
|
|
|
expect(storedValue).toBe("new-value")
|
|
|
})
|
|
|
+
|
|
|
+ it("should bypass cache for pass-through state keys", async () => {
|
|
|
+ await proxy.updateGlobalState("taskHistory" as GlobalStateKey, "new-value")
|
|
|
+
|
|
|
+ // Should update original context
|
|
|
+ expect(mockGlobalState.update).toHaveBeenCalledWith("taskHistory", "new-value")
|
|
|
+
|
|
|
+ // Setup mock for subsequent get
|
|
|
+ mockGlobalState.get.mockReturnValue("new-value")
|
|
|
+
|
|
|
+ // Should get fresh value from original context
|
|
|
+ const storedValue = proxy.getGlobalState("taskHistory" as GlobalStateKey)
|
|
|
+ expect(storedValue).toBe("new-value")
|
|
|
+ expect(mockGlobalState.get).toHaveBeenCalledWith("taskHistory")
|
|
|
+ })
|
|
|
})
|
|
|
|
|
|
describe("getSecret", () => {
|