feat(detail): move app details into content view

This commit is contained in:
2026-05-18 23:08:29 +08:00
parent c2e8b9a1b4
commit e607e4991b
5 changed files with 533 additions and 28 deletions
+50
View File
@@ -0,0 +1,50 @@
import { fireEvent, render, screen } from "@testing-library/vue";
import { describe, expect, it } from "vitest";
import AppDetailPage from "@/components/AppDetailPage.vue";
import type { App } from "@/global/typedefinition";
const app: App = {
name: "WPS",
pkgname: "wps",
version: "1.0.0",
filename: "wps_1.0.0_amd64.deb",
torrent_address: "",
author: "",
contributor: "",
website: "",
update: "",
size: "110M",
more: "Office suite",
tags: "office",
img_urls: [],
icons: "",
category: "office",
origin: "apm",
currentStatus: "not-installed",
};
describe("AppDetailPage", () => {
it("renders as page, emits back, and gates favorite for anonymous users", async () => {
const rendered = render(AppDetailPage, {
props: {
app,
screenshots: [],
sparkInstalled: false,
apmInstalled: false,
loggedIn: false,
reviewAppKey: "apm:amd64-apm:office:wps",
reviewTags: null,
},
});
expect(screen.getByText("Office suite")).toBeTruthy();
await fireEvent.click(screen.getByRole("button", { name: "返回" }));
await fireEvent.click(screen.getByRole("button", { name: "收藏" }));
expect(rendered.emitted("back")).toHaveLength(1);
expect(rendered.emitted("request-login")?.[0]?.[0]).toBe(
"收藏应用需要登录星火账号。",
);
});
});
+60
View File
@@ -0,0 +1,60 @@
import { describe, expect, it } from "vitest";
import {
buildFavoriteAppKey,
buildReviewAppKey,
buildReviewTags,
getDisplayApp,
parsePackageArch,
} from "@/modules/appIdentity";
import type { App } from "@/global/typedefinition";
const app: App = {
name: "WPS",
pkgname: "wps",
version: "1.0.0",
filename: "wps_1.0.0_amd64.deb",
torrent_address: "",
author: "",
contributor: "",
website: "",
update: "",
size: "",
more: "",
tags: "",
img_urls: [],
icons: "",
category: "office",
origin: "apm",
currentStatus: "not-installed",
};
describe("appIdentity", () => {
it("builds favorite and review keys", () => {
expect(buildFavoriteAppKey(app)).toBe("app:office:wps");
expect(buildReviewAppKey(app, "amd64")).toBe("apm:amd64-apm:office:wps");
});
it("parses package arch and review tags", () => {
expect(parsePackageArch(app.filename)).toBe("amd64");
expect(
buildReviewTags(app, { clientArch: "amd64", distro: "deepin 25" }),
).toMatchObject({
origin: "apm",
category: "office",
pkgname: "wps",
packageArch: "amd64",
});
});
it("returns selected display app from merged apps", () => {
const merged: App = {
...app,
isMerged: true,
viewingOrigin: "spark",
sparkApp: { ...app, origin: "spark" },
apmApp: app,
};
expect(getDisplayApp(merged)?.origin).toBe("spark");
});
});