Apply repository-wide ESLint auto-fix formatting pass

Co-Authored-By: Codex <codex@openai.com>
This commit is contained in:
2026-03-08 12:11:57 +08:00
parent 7c48faaa3d
commit 847904c49b
172 changed files with 13629 additions and 9154 deletions

View File

@@ -3,41 +3,41 @@
// Authors:
// imacat.yang@dsp.im (imacat), 2026/03/06
import { describe, it, expect, beforeEach, vi } from 'vitest';
import { setActivePinia, createPinia } from 'pinia';
import { describe, it, expect, beforeEach, vi } from "vitest";
import { setActivePinia, createPinia } from "pinia";
// Mock all heavy imports that MainContainer.vue pulls in
vi.mock('@/stores/loading', () => ({
vi.mock("@/stores/loading", () => ({
useLoadingStore: () => ({ isLoading: false }),
}));
vi.mock('@/stores/allMapData', () => ({
vi.mock("@/stores/allMapData", () => ({
useAllMapDataStore: () => ({}),
}));
vi.mock('@/stores/conformance', () => ({
vi.mock("@/stores/conformance", () => ({
useConformanceStore: () => ({}),
}));
vi.mock('@/stores/pageAdmin', () => ({
vi.mock("@/stores/pageAdmin", () => ({
usePageAdminStore: () => ({}),
}));
vi.mock('@/module/alertModal.js', () => ({
vi.mock("@/module/alertModal.js", () => ({
leaveFilter: vi.fn(),
leaveConformance: vi.fn(),
}));
vi.mock('@/module/apiError.js', () => ({
vi.mock("@/module/apiError.js", () => ({
default: vi.fn(),
}));
vi.mock('@/router/index.ts', () => ({
default: { push: vi.fn(), currentRoute: { value: { path: '/' } } },
vi.mock("@/router/index.ts", () => ({
default: { push: vi.fn(), currentRoute: { value: { path: "/" } } },
}));
vi.mock('@/module/cytoscapeMap.js', () => ({}));
vi.mock("@/module/cytoscapeMap.js", () => ({}));
import { useLoginStore } from '@/stores/login';
import * as cookieUtil from '@/utils/cookieUtil.js';
import { useLoginStore } from "@/stores/login";
import * as cookieUtil from "@/utils/cookieUtil.js";
// Import the component definition to access beforeRouteEnter
import MainContainer from '@/views/MainContainer.vue';
import MainContainer from "@/views/MainContainer.vue";
describe('MainContainer beforeRouteEnter', () => {
describe("MainContainer beforeRouteEnter", () => {
let loginStore;
let next;
@@ -48,10 +48,10 @@ describe('MainContainer beforeRouteEnter', () => {
next = vi.fn();
vi.clearAllMocks();
// Clear cookies
document.cookie.split(';').forEach((c) => {
const name = c.split('=')[0].trim();
document.cookie.split(";").forEach((c) => {
const name = c.split("=")[0].trim();
if (name) {
document.cookie = name + '=; Max-Age=-99999999; path=/';
document.cookie = name + "=; Max-Age=-99999999; path=/";
}
});
});
@@ -61,10 +61,10 @@ describe('MainContainer beforeRouteEnter', () => {
return guard({}, {}, next);
};
it('calls next() after successful refreshToken', async () => {
it("calls next() after successful refreshToken", async () => {
// Not logged in, but has refresh token
document.cookie = 'luciaRefreshToken=some-token';
vi.spyOn(loginStore, 'refreshToken').mockResolvedValue();
document.cookie = "luciaRefreshToken=some-token";
vi.spyOn(loginStore, "refreshToken").mockResolvedValue();
await callGuard();
@@ -72,34 +72,38 @@ describe('MainContainer beforeRouteEnter', () => {
expect(next).toHaveBeenCalled();
});
it('redirects to login when refreshToken fails', async () => {
it("redirects to login when refreshToken fails", async () => {
// Not logged in, has refresh token, but refresh fails
document.cookie = 'luciaRefreshToken=some-token';
vi.spyOn(loginStore, 'refreshToken').mockRejectedValue(new Error('401'));
document.cookie = "luciaRefreshToken=some-token";
vi.spyOn(loginStore, "refreshToken").mockRejectedValue(new Error("401"));
await callGuard();
expect(next).toHaveBeenCalledWith(
expect.objectContaining({ path: '/login' }),
expect.objectContaining({ path: "/login" }),
);
});
it('calls next() when already logged in', async () => {
document.cookie = 'isLuciaLoggedIn=true';
it("calls next() when already logged in", async () => {
document.cookie = "isLuciaLoggedIn=true";
await callGuard();
expect(next).toHaveBeenCalled();
});
it('stores a relative return-to path when redirecting to login', async () => {
window.history.replaceState({}, '', '/discover/log/1/map?view=summary#node-2');
it("stores a relative return-to path when redirecting to login", async () => {
window.history.replaceState(
{},
"",
"/discover/log/1/map?view=summary#node-2",
);
await callGuard();
const redirectArg = next.mock.calls[0][0];
const returnTo = redirectArg.query['return-to'];
const returnTo = redirectArg.query["return-to"];
expect(atob(returnTo)).toBe('/discover/log/1/map?view=summary#node-2');
expect(atob(returnTo)).toBe("/discover/log/1/map?view=summary#node-2");
});
});