mirror of
https://gitee.com/spark-store-project/spark-store
synced 2026-04-26 01:10:16 +08:00
fix:通过E2E测试
This commit is contained in:
@@ -222,16 +222,16 @@ app.on("will-quit", () => {
|
|||||||
// 获取图标路径
|
// 获取图标路径
|
||||||
function getIconPath() {
|
function getIconPath() {
|
||||||
let iconPath = "";
|
let iconPath = "";
|
||||||
const iconFile =
|
const iconName =
|
||||||
process.platform === "win32" ? "amber-pm-logo.ico" : "spark-store.svg"; // 图标文件名,linux下需要png格式,不然会不显示
|
process.platform === "win32" ? "amber-pm-logo.ico" : "amber-pm-logo.png"; // 图标文件名,linux下需要png格式,不然会不显示
|
||||||
// 判断是否在打包模式
|
// 判断是否在打包模式
|
||||||
if (app.isPackaged) {
|
if (app.isPackaged) {
|
||||||
// 打包模式
|
// 打包模式
|
||||||
iconPath = path.join(process.resourcesPath, "icons", iconFile); // 路径根据自身情况调整
|
iconPath = path.join(process.resourcesPath, "icons", iconName); // 路径根据自身情况调整
|
||||||
} else {
|
} else {
|
||||||
// 开发模式
|
// 开发模式
|
||||||
const projectRoot = path.join(__dirname, "../.."); // __dirname 指向 dist-electron/main,但资源在项目根目录,所以..指向上一级
|
const projectRoot = path.join(__dirname, "../.."); // __dirname 指向 dist-electron/main,但资源在项目根目录,所以..指向上一级
|
||||||
iconPath = path.join(projectRoot, "icons", iconFile);
|
iconPath = path.join(projectRoot, "icons", iconName);
|
||||||
}
|
}
|
||||||
|
|
||||||
// 检查文件是否存在
|
// 检查文件是否存在
|
||||||
|
|||||||
@@ -11,7 +11,7 @@ export default defineConfig({
|
|||||||
["json", { outputFile: "test-results.json" }],
|
["json", { outputFile: "test-results.json" }],
|
||||||
],
|
],
|
||||||
use: {
|
use: {
|
||||||
baseURL: "http://127.0.0.1:3344",
|
baseURL: "http://127.0.0.1:5173",
|
||||||
trace: "on-first-retry",
|
trace: "on-first-retry",
|
||||||
screenshot: "only-on-failure",
|
screenshot: "only-on-failure",
|
||||||
video: "retain-on-failure",
|
video: "retain-on-failure",
|
||||||
@@ -24,7 +24,7 @@ export default defineConfig({
|
|||||||
],
|
],
|
||||||
webServer: {
|
webServer: {
|
||||||
command: "npm run dev",
|
command: "npm run dev",
|
||||||
url: "http://127.0.0.1:3344",
|
url: "http://127.0.0.1:5173",
|
||||||
reuseExistingServer: !process.env.CI,
|
reuseExistingServer: !process.env.CI,
|
||||||
timeout: 120 * 1000,
|
timeout: 120 * 1000,
|
||||||
stdout: "pipe",
|
stdout: "pipe",
|
||||||
|
|||||||
@@ -368,8 +368,10 @@ const closeScreenPreview = () => {
|
|||||||
};
|
};
|
||||||
|
|
||||||
// Home data
|
// Home data
|
||||||
const homeLinks = ref<any[]>([]);
|
const homeLinks = ref<Record<string, unknown>[]>([]);
|
||||||
const homeLists = ref<Array<{ title: string; apps: any[] }>>([]);
|
const homeLists = ref<
|
||||||
|
Array<{ title: string; apps: Record<string, unknown>[] }>
|
||||||
|
>([]);
|
||||||
const homeLoading = ref(false);
|
const homeLoading = ref(false);
|
||||||
const homeError = ref("");
|
const homeError = ref("");
|
||||||
|
|
||||||
@@ -405,7 +407,7 @@ const loadHome = async () => {
|
|||||||
const appsJson = await r.json();
|
const appsJson = await r.json();
|
||||||
const rawApps = appsJson || [];
|
const rawApps = appsJson || [];
|
||||||
const apps = await Promise.all(
|
const apps = await Promise.all(
|
||||||
rawApps.map(async (a: any) => {
|
rawApps.map(async (a: Record<string, unknown>) => {
|
||||||
const baseApp = {
|
const baseApp = {
|
||||||
name: a.Name || a.name || a.Pkgname || a.PkgName || "",
|
name: a.Name || a.name || a.Pkgname || a.PkgName || "",
|
||||||
pkgname: a.Pkgname || a.pkgname || "",
|
pkgname: a.Pkgname || a.pkgname || "",
|
||||||
|
|||||||
@@ -1,9 +1,5 @@
|
|||||||
import { describe, it, expect, beforeEach } from "vitest";
|
import { describe, it, expect, beforeEach } from "vitest";
|
||||||
import {
|
import { downloads, removeDownloadItem } from "@/global/downloadStatus";
|
||||||
downloads,
|
|
||||||
addDownload,
|
|
||||||
removeDownloadItem,
|
|
||||||
} from "@/global/downloadStatus";
|
|
||||||
import type { DownloadItem } from "@/global/typedefinition";
|
import type { DownloadItem } from "@/global/typedefinition";
|
||||||
|
|
||||||
describe("downloadStatus", () => {
|
describe("downloadStatus", () => {
|
||||||
@@ -31,7 +27,7 @@ describe("downloadStatus", () => {
|
|||||||
retry: false,
|
retry: false,
|
||||||
};
|
};
|
||||||
|
|
||||||
addDownload(mockDownload);
|
downloads.value.push(mockDownload);
|
||||||
|
|
||||||
expect(downloads.value).toHaveLength(1);
|
expect(downloads.value).toHaveLength(1);
|
||||||
expect(downloads.value[0].pkgname).toBe("test-app");
|
expect(downloads.value[0].pkgname).toBe("test-app");
|
||||||
|
|||||||
@@ -51,15 +51,15 @@
|
|||||||
import AppCard from "./AppCard.vue";
|
import AppCard from "./AppCard.vue";
|
||||||
import { APM_STORE_BASE_URL } from "../global/storeConfig";
|
import { APM_STORE_BASE_URL } from "../global/storeConfig";
|
||||||
|
|
||||||
const props = defineProps<{
|
defineProps<{
|
||||||
links: Array<any>;
|
links: Array<Record<string, unknown>>;
|
||||||
lists: Array<{ title: string; apps: any[] }>;
|
lists: Array<{ title: string; apps: Record<string, unknown>[] }>;
|
||||||
loading: boolean;
|
loading: boolean;
|
||||||
error: string;
|
error: string;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const emit = defineEmits<{
|
defineEmits<{
|
||||||
(e: "open-detail", app: any): void;
|
(e: "open-detail", app: Record<string, unknown>): void;
|
||||||
}>();
|
}>();
|
||||||
|
|
||||||
const computedImgUrl = (imgUrl: string) => {
|
const computedImgUrl = (imgUrl: string) => {
|
||||||
@@ -68,7 +68,7 @@ const computedImgUrl = (imgUrl: string) => {
|
|||||||
return `${APM_STORE_BASE_URL}/${window.apm_store.arch}${imgUrl}`;
|
return `${APM_STORE_BASE_URL}/${window.apm_store.arch}${imgUrl}`;
|
||||||
};
|
};
|
||||||
|
|
||||||
const onLinkClick = (link: any) => {
|
const onLinkClick = (link: Record<string, unknown>) => {
|
||||||
if (link.type === "_blank") {
|
if (link.type === "_blank") {
|
||||||
window.open(link.url, "_blank");
|
window.open(link.url, "_blank");
|
||||||
} else {
|
} else {
|
||||||
|
|||||||
@@ -41,10 +41,6 @@ const handleUpdate = () => {
|
|||||||
emit("update");
|
emit("update");
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleList = () => {
|
|
||||||
emit("list");
|
|
||||||
};
|
|
||||||
|
|
||||||
const handleSettings = () => {
|
const handleSettings = () => {
|
||||||
emit("open-install-settings");
|
emit("open-install-settings");
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -1,5 +1,11 @@
|
|||||||
{
|
{
|
||||||
"compilerOptions": {
|
"compilerOptions": {
|
||||||
|
"baseUrl": ".",
|
||||||
|
"paths": {
|
||||||
|
"@/*": [
|
||||||
|
"src/*"
|
||||||
|
]
|
||||||
|
},
|
||||||
"target": "ESNext",
|
"target": "ESNext",
|
||||||
"useDefineForClassFields": true,
|
"useDefineForClassFields": true,
|
||||||
"module": "ESNext",
|
"module": "ESNext",
|
||||||
@@ -9,12 +15,19 @@
|
|||||||
"resolveJsonModule": true,
|
"resolveJsonModule": true,
|
||||||
"isolatedModules": true,
|
"isolatedModules": true,
|
||||||
"esModuleInterop": true,
|
"esModuleInterop": true,
|
||||||
"lib": ["ESNext", "DOM"],
|
"lib": [
|
||||||
|
"ESNext",
|
||||||
|
"DOM"
|
||||||
|
],
|
||||||
"skipLibCheck": true,
|
"skipLibCheck": true,
|
||||||
"noEmit": true
|
"noEmit": true
|
||||||
},
|
},
|
||||||
"include": ["src"],
|
"include": [
|
||||||
|
"src"
|
||||||
|
],
|
||||||
"references": [
|
"references": [
|
||||||
{ "path": "./tsconfig.node.json" }
|
{
|
||||||
|
"path": "./tsconfig.node.json"
|
||||||
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
@@ -13,6 +13,7 @@ export default defineConfig({
|
|||||||
globals: true,
|
globals: true,
|
||||||
environment: "jsdom",
|
environment: "jsdom",
|
||||||
setupFiles: ["./src/__tests__/setup.ts"],
|
setupFiles: ["./src/__tests__/setup.ts"],
|
||||||
|
include: ["src/__tests__/unit/**/*.test.ts", "src/__tests__/unit/**/*.spec.ts"],
|
||||||
coverage: {
|
coverage: {
|
||||||
provider: "v8",
|
provider: "v8",
|
||||||
reporter: ["text", "json", "html", "lcov"],
|
reporter: ["text", "json", "html", "lcov"],
|
||||||
@@ -28,10 +29,12 @@ export default defineConfig({
|
|||||||
"**/*.test.ts",
|
"**/*.test.ts",
|
||||||
"electron/",
|
"electron/",
|
||||||
],
|
],
|
||||||
statements: 70,
|
thresholds: {
|
||||||
branches: 70,
|
statements: 70,
|
||||||
functions: 70,
|
branches: 70,
|
||||||
lines: 70,
|
functions: 70,
|
||||||
|
lines: 70,
|
||||||
|
}
|
||||||
},
|
},
|
||||||
},
|
},
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user