mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-10-25 17:22:27 +08:00
The usage page now reopens on the tab, preset range and trend/heatmap metrics picked last time. These are kept in localStorage as local UI preferences, not in settings.json. A custom date range does not replace the remembered preset, and the app/provider/model filters are not kept. The request log column picker moves from the table header into the Display section of the settings tab, and the sidebar Today label becomes the same kind of checklist (cost and tokens; stored values unchanged). Currency, sidebar Today and log columns now sit on one row.
43 lines
1.1 KiB
TypeScript
43 lines
1.1 KiB
TypeScript
import "@testing-library/jest-dom";
|
|
import { afterAll, afterEach, beforeAll, vi } from "vitest";
|
|
import { cleanup } from "@testing-library/react";
|
|
import i18n from "i18next";
|
|
import { initReactI18next } from "react-i18next";
|
|
import { server } from "./msw/server";
|
|
import { resetProviderState } from "./msw/state";
|
|
import "./msw/tauriMocks";
|
|
|
|
beforeAll(async () => {
|
|
server.listen({ onUnhandledRequest: "warn" });
|
|
await i18n.use(initReactI18next).init({
|
|
lng: "zh",
|
|
fallbackLng: "zh",
|
|
resources: {
|
|
zh: { translation: {} },
|
|
en: { translation: {} },
|
|
},
|
|
interpolation: {
|
|
escapeValue: false,
|
|
},
|
|
});
|
|
});
|
|
|
|
afterEach(() => {
|
|
cleanup();
|
|
// 页面数据的本地缓存(src/lib/localCache.ts)和用量页记住的选择不能从一个用例带到下一个
|
|
for (const key of Object.keys(localStorage)) {
|
|
if (
|
|
key.startsWith("cc-switch-cache:") ||
|
|
key.startsWith("cc-switch.usage.")
|
|
)
|
|
localStorage.removeItem(key);
|
|
}
|
|
resetProviderState();
|
|
server.resetHandlers();
|
|
vi.clearAllMocks();
|
|
});
|
|
|
|
afterAll(() => {
|
|
server.close();
|
|
});
|