mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-10-25 17:22:27 +08:00
fix(mcode): refresh provider state after removal (#7578)
Co-authored-by: thisTom <19346741+thisTom@users.noreply.github.com>
This commit is contained in:
1 parent
6f6087cdba
commit
09c5d39d8c
2 files changed
+59
No files matched your search
@@ -777,6 +777,10 @@ function App() {
|
|||||||
await queryClient.invalidateQueries({
|
await queryClient.invalidateQueries({
|
||||||
queryKey: hermesKeys.liveProviderIds,
|
queryKey: hermesKeys.liveProviderIds,
|
||||||
});
|
});
|
||||||
|
} else if (activeApp === "mcode") {
|
||||||
|
await queryClient.invalidateQueries({
|
||||||
|
queryKey: ["providers", "mcode"],
|
||||||
|
});
|
||||||
}
|
}
|
||||||
toast.success(
|
toast.success(
|
||||||
activeApp === "pi"
|
activeApp === "pi"
|
||||||
|
|||||||
@@ -390,6 +390,61 @@ describe("App integration with MSW", () => {
|
|||||||
);
|
);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it("refreshes MiniMax Code provider membership after removing it from live config", async () => {
|
||||||
|
localStorage.setItem("cc-switch-last-app", "mcode");
|
||||||
|
let liveConfigManaged = true;
|
||||||
|
let providerRequests = 0;
|
||||||
|
server.use(
|
||||||
|
http.post("http://tauri.local/get_providers", async ({ request }) => {
|
||||||
|
const { app } = (await request.json()) as { app: string };
|
||||||
|
if (app !== "mcode") return;
|
||||||
|
providerRequests += 1;
|
||||||
|
return HttpResponse.json({
|
||||||
|
custom: {
|
||||||
|
id: "custom",
|
||||||
|
name: "Custom MiniMax Code",
|
||||||
|
settingsConfig: {},
|
||||||
|
meta: { liveConfigManaged },
|
||||||
|
},
|
||||||
|
});
|
||||||
|
}),
|
||||||
|
http.post(
|
||||||
|
"http://tauri.local/remove_provider_from_live_config",
|
||||||
|
async ({ request }) => {
|
||||||
|
expect(await request.json()).toEqual({ id: "custom", app: "mcode" });
|
||||||
|
liveConfigManaged = false;
|
||||||
|
return HttpResponse.json(true);
|
||||||
|
},
|
||||||
|
),
|
||||||
|
);
|
||||||
|
|
||||||
|
const { default: App } = await import("@/App");
|
||||||
|
renderApp(App);
|
||||||
|
|
||||||
|
await waitFor(() =>
|
||||||
|
expect(screen.getByTestId("provider-list")).toHaveTextContent(
|
||||||
|
'"liveConfigManaged":true',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
const requestsBeforeRemoval = providerRequests;
|
||||||
|
fireEvent.click(screen.getByText("remove"));
|
||||||
|
fireEvent.click(screen.getByText("confirm-delete"));
|
||||||
|
|
||||||
|
await waitFor(() =>
|
||||||
|
expect(screen.queryByTestId("confirm-dialog")).not.toBeInTheDocument(),
|
||||||
|
);
|
||||||
|
expect(liveConfigManaged).toBe(false);
|
||||||
|
await waitFor(() =>
|
||||||
|
expect(screen.getByTestId("provider-list")).toHaveTextContent(
|
||||||
|
'"liveConfigManaged":false',
|
||||||
|
),
|
||||||
|
);
|
||||||
|
expect(providerRequests).toBeGreaterThan(requestsBeforeRemoval);
|
||||||
|
expect(screen.getByTestId("provider-list")).toHaveTextContent(
|
||||||
|
"Custom MiniMax Code",
|
||||||
|
);
|
||||||
|
});
|
||||||
|
|
||||||
it("warns without blocking when removing Pi's global default provider", async () => {
|
it("warns without blocking when removing Pi's global default provider", async () => {
|
||||||
localStorage.setItem("cc-switch-last-app", "pi");
|
localStorage.setItem("cc-switch-last-app", "pi");
|
||||||
setProviders("pi", {
|
setProviders("pi", {
|
||||||
|
|||||||
Reference in new issue
Block a user