mirror of
https://gitee.com/spark-store-project/spark-store
synced 2026-06-22 14:13:49 +08:00
fix(favorites): refresh installed apps across origins
This commit is contained in:
@@ -1,4 +1,4 @@
|
||||
import { fireEvent, render, screen } from "@testing-library/vue";
|
||||
import { fireEvent, render, screen, waitFor } from "@testing-library/vue";
|
||||
import { beforeEach, describe, expect, it, vi } from "vitest";
|
||||
|
||||
import App from "@/App.vue";
|
||||
@@ -197,6 +197,10 @@ describe("App account placeholders", () => {
|
||||
});
|
||||
render(App);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText("2")).toBeTruthy();
|
||||
});
|
||||
|
||||
await fireEvent.click(await screen.findByRole("button", { name: /Momen/ }));
|
||||
await fireEvent.click(screen.getByText("我的收藏"));
|
||||
|
||||
@@ -209,4 +213,50 @@ describe("App account placeholders", () => {
|
||||
pkgnameList: undefined,
|
||||
});
|
||||
});
|
||||
|
||||
it("refreshes Spark installed state for favorites in both mode", async () => {
|
||||
invoke.mockImplementation(async (channel: string, payload?: unknown) => {
|
||||
if (channel === "get-store-filter") return "both";
|
||||
if (channel === "check-spark-available") return true;
|
||||
if (channel === "check-apm-available") return true;
|
||||
if (channel === "get-app-version") return "5.0.0";
|
||||
if (channel === "list-installed") {
|
||||
const request = payload as { origin?: string };
|
||||
if (request.origin === "spark") {
|
||||
return {
|
||||
success: true,
|
||||
apps: [
|
||||
{
|
||||
pkgname: "wps",
|
||||
name: "WPS",
|
||||
version: "1.0.0",
|
||||
arch: "amd64",
|
||||
flags: "installed",
|
||||
origin: "spark",
|
||||
},
|
||||
],
|
||||
};
|
||||
}
|
||||
return { success: true, apps: [] };
|
||||
}
|
||||
return [];
|
||||
});
|
||||
render(App);
|
||||
|
||||
await waitFor(() => {
|
||||
expect(screen.getByText("2")).toBeTruthy();
|
||||
});
|
||||
|
||||
await fireEvent.click(await screen.findByRole("button", { name: /Momen/ }));
|
||||
await fireEvent.click(screen.getByText("我的收藏"));
|
||||
|
||||
expect(
|
||||
await screen.findByRole("heading", { name: "我的收藏" }),
|
||||
).toBeTruthy();
|
||||
expect(await screen.findByText("已安装")).toBeTruthy();
|
||||
expect(invoke).toHaveBeenCalledWith("list-installed", {
|
||||
origin: "spark",
|
||||
pkgnameList: ["wps"],
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
@@ -112,4 +112,15 @@ describe("favoriteAvailability", () => {
|
||||
)[0];
|
||||
expect(resolved.status).toBe("installed");
|
||||
});
|
||||
|
||||
it("marks installed favorites from all-category catalog matches", () => {
|
||||
const resolved = resolveFavoriteItems(
|
||||
[favorite],
|
||||
[app("spark")],
|
||||
[app("spark", { category: "all", currentStatus: "installed" })],
|
||||
{ spark: true, apm: true },
|
||||
"both",
|
||||
)[0];
|
||||
expect(resolved.status).toBe("installed");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user