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,11 +3,11 @@
// Authors:
// imacat.yang@dsp.im (imacat), 2026/03/05
import { describe, it, expect, beforeEach, vi } from 'vitest';
import { mount } from '@vue/test-utils';
import { setActivePinia, createPinia } from 'pinia';
import { describe, it, expect, beforeEach, vi } from "vitest";
import { mount } from "@vue/test-utils";
import { setActivePinia, createPinia } from "pinia";
vi.mock('@/module/apiError.js', () => ({
vi.mock("@/module/apiError.js", () => ({
default: vi.fn(),
}));
@@ -15,14 +15,14 @@ const mockRoute = vi.hoisted(() => ({
query: {},
}));
vi.mock('vue-router', () => ({
vi.mock("vue-router", () => ({
useRoute: () => mockRoute,
}));
import Login from '@/views/Login/Login.vue';
import { useLoginStore } from '@/stores/login';
import Login from "@/views/Login/Login.vue";
import { useLoginStore } from "@/stores/login";
describe('Login', () => {
describe("Login", () => {
let pinia;
beforeEach(() => {
@@ -42,62 +42,62 @@ describe('Login', () => {
});
};
it('renders login form', () => {
it("renders login form", () => {
const wrapper = mountLogin();
expect(wrapper.find('h2').text()).toBe('LOGIN');
expect(wrapper.find('#account').exists()).toBe(true);
expect(wrapper.find('#password').exists()).toBe(true);
expect(wrapper.find("h2").text()).toBe("LOGIN");
expect(wrapper.find("#account").exists()).toBe(true);
expect(wrapper.find("#password").exists()).toBe(true);
});
it('has disabled login button when fields are empty', () => {
it("has disabled login button when fields are empty", () => {
const wrapper = mountLogin();
const btn = wrapper.find('#login_btn_main_btn');
expect(btn.attributes('disabled')).toBeDefined();
const btn = wrapper.find("#login_btn_main_btn");
expect(btn.attributes("disabled")).toBeDefined();
});
it('enables login button when both fields have values', async () => {
it("enables login button when both fields have values", async () => {
const wrapper = mountLogin();
const store = useLoginStore();
store.auth.username = 'user';
store.auth.password = 'pass';
store.auth.username = "user";
store.auth.password = "pass";
await wrapper.vm.$nextTick();
const btn = wrapper.find('#login_btn_main_btn');
expect(btn.attributes('disabled')).toBeUndefined();
const btn = wrapper.find("#login_btn_main_btn");
expect(btn.attributes("disabled")).toBeUndefined();
});
it('shows error message when isInvalid', async () => {
it("shows error message when isInvalid", async () => {
const wrapper = mountLogin();
const store = useLoginStore();
store.isInvalid = true;
await wrapper.vm.$nextTick();
expect(wrapper.text()).toContain('Incorrect account or password');
expect(wrapper.text()).toContain("Incorrect account or password");
});
it('toggles password visibility', async () => {
it("toggles password visibility", async () => {
const wrapper = mountLogin();
const store = useLoginStore();
store.auth.password = 'secret';
store.auth.password = "secret";
await wrapper.vm.$nextTick();
const pwdInput = wrapper.find('#password');
expect(pwdInput.attributes('type')).toBe('password');
const pwdInput = wrapper.find("#password");
expect(pwdInput.attributes("type")).toBe("password");
// Click the eye icon to toggle
const eyeToggle = wrapper.find(
'label[for="passwordt"] span.cursor-pointer',
);
if (eyeToggle.exists()) {
await eyeToggle.trigger('click');
await eyeToggle.trigger("click");
await wrapper.vm.$nextTick();
expect(pwdInput.attributes('type')).toBe('text');
expect(pwdInput.attributes("type")).toBe("text");
}
});
it('stores return-to URL from route query', () => {
it("stores return-to URL from route query", () => {
const wrapper = mountLogin({
route: { query: { 'return-to': 'encodedUrl' } },
route: { query: { "return-to": "encodedUrl" } },
});
const store = useLoginStore();
expect(store.rememberedReturnToUrl).toBe('encodedUrl');
expect(store.rememberedReturnToUrl).toBe("encodedUrl");
});
});