Apply repository-wide ESLint auto-fix formatting pass
Co-Authored-By: Codex <codex@openai.com>
This commit is contained in:
@@ -3,24 +3,26 @@
|
||||
// Authors:
|
||||
// imacat.yang@dsp.im (imacat), 2026/03/05
|
||||
|
||||
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";
|
||||
|
||||
vi.mock('@/module/apiError.js', () => ({
|
||||
vi.mock("@/module/apiError.js", () => ({
|
||||
default: vi.fn(),
|
||||
}));
|
||||
|
||||
const { mockGet, mockPost, mockPut } = vi.hoisted(() => ({
|
||||
mockGet: vi.fn(), mockPost: vi.fn(), mockPut: vi.fn(),
|
||||
mockGet: vi.fn(),
|
||||
mockPost: vi.fn(),
|
||||
mockPut: vi.fn(),
|
||||
}));
|
||||
vi.mock('@/api/client.js', () => ({
|
||||
vi.mock("@/api/client.js", () => ({
|
||||
default: { get: mockGet, post: mockPost, put: mockPut },
|
||||
}));
|
||||
|
||||
import apiError from '@/module/apiError.js';
|
||||
import { useConformanceStore } from '@/stores/conformance';
|
||||
import apiError from "@/module/apiError.js";
|
||||
import { useConformanceStore } from "@/stores/conformance";
|
||||
|
||||
describe('conformanceStore', () => {
|
||||
describe("conformanceStore", () => {
|
||||
let store;
|
||||
|
||||
beforeEach(() => {
|
||||
@@ -29,21 +31,21 @@ describe('conformanceStore', () => {
|
||||
vi.clearAllMocks();
|
||||
});
|
||||
|
||||
it('has correct default state', () => {
|
||||
it("has correct default state", () => {
|
||||
expect(store.conformanceLogId).toBeNull();
|
||||
expect(store.conformanceFilterId).toBeNull();
|
||||
expect(store.allConformanceTask).toEqual([]);
|
||||
expect(store.selectedRuleType).toBe('Have activity');
|
||||
expect(store.selectedRuleType).toBe("Have activity");
|
||||
});
|
||||
|
||||
describe('getConformanceParams', () => {
|
||||
it('fetches log check params when no filter', async () => {
|
||||
describe("getConformanceParams", () => {
|
||||
it("fetches log check params when no filter", async () => {
|
||||
store.conformanceLogId = 1;
|
||||
store.conformanceFilterId = null;
|
||||
const mockData = {
|
||||
tasks: [{ label: 'A' }],
|
||||
sources: ['A'],
|
||||
sinks: ['B'],
|
||||
tasks: [{ label: "A" }],
|
||||
sources: ["A"],
|
||||
sinks: ["B"],
|
||||
processing_time: {},
|
||||
waiting_time: {},
|
||||
cycle_time: {},
|
||||
@@ -52,14 +54,12 @@ describe('conformanceStore', () => {
|
||||
|
||||
await store.getConformanceParams();
|
||||
|
||||
expect(mockGet).toHaveBeenCalledWith(
|
||||
'/api/log-checks/params?log_id=1',
|
||||
);
|
||||
expect(store.allConformanceTask).toEqual([{ label: 'A' }]);
|
||||
expect(store.allCfmSeqStart).toEqual(['A']);
|
||||
expect(mockGet).toHaveBeenCalledWith("/api/log-checks/params?log_id=1");
|
||||
expect(store.allConformanceTask).toEqual([{ label: "A" }]);
|
||||
expect(store.allCfmSeqStart).toEqual(["A"]);
|
||||
});
|
||||
|
||||
it('fetches filter check params when filter set', async () => {
|
||||
it("fetches filter check params when filter set", async () => {
|
||||
store.conformanceFilterId = 5;
|
||||
const mockData = {
|
||||
tasks: [],
|
||||
@@ -74,137 +74,137 @@ describe('conformanceStore', () => {
|
||||
await store.getConformanceParams();
|
||||
|
||||
expect(mockGet).toHaveBeenCalledWith(
|
||||
'/api/filter-checks/params?filter_id=5',
|
||||
"/api/filter-checks/params?filter_id=5",
|
||||
);
|
||||
});
|
||||
});
|
||||
|
||||
describe('addConformanceCheckId', () => {
|
||||
it('posts to log temp-check and stores id', async () => {
|
||||
describe("addConformanceCheckId", () => {
|
||||
it("posts to log temp-check and stores id", async () => {
|
||||
store.conformanceLogId = 1;
|
||||
store.conformanceFilterId = null;
|
||||
mockPost.mockResolvedValue({ data: { id: 42 } });
|
||||
|
||||
await store.addConformanceCheckId({ rule: 'test' });
|
||||
await store.addConformanceCheckId({ rule: "test" });
|
||||
|
||||
expect(mockPost).toHaveBeenCalledWith(
|
||||
'/api/temp-log-checks?log_id=1',
|
||||
{ rule: 'test' },
|
||||
);
|
||||
expect(mockPost).toHaveBeenCalledWith("/api/temp-log-checks?log_id=1", {
|
||||
rule: "test",
|
||||
});
|
||||
expect(store.conformanceLogTempCheckId).toBe(42);
|
||||
});
|
||||
|
||||
it('posts to filter temp-check when filter set', async () => {
|
||||
it("posts to filter temp-check when filter set", async () => {
|
||||
store.conformanceFilterId = 3;
|
||||
mockPost.mockResolvedValue({ data: { id: 99 } });
|
||||
|
||||
await store.addConformanceCheckId({ rule: 'test' });
|
||||
await store.addConformanceCheckId({ rule: "test" });
|
||||
|
||||
expect(mockPost).toHaveBeenCalledWith(
|
||||
'/api/temp-filter-checks?filter_id=3',
|
||||
{ rule: 'test' },
|
||||
"/api/temp-filter-checks?filter_id=3",
|
||||
{ rule: "test" },
|
||||
);
|
||||
expect(store.conformanceFilterTempCheckId).toBe(99);
|
||||
});
|
||||
});
|
||||
|
||||
describe('getConformanceReport', () => {
|
||||
it('fetches temp log check report', async () => {
|
||||
describe("getConformanceReport", () => {
|
||||
it("fetches temp log check report", async () => {
|
||||
store.conformanceLogTempCheckId = 10;
|
||||
const mockData = { file: {}, charts: {} };
|
||||
mockGet.mockResolvedValue({ data: mockData });
|
||||
|
||||
await store.getConformanceReport();
|
||||
|
||||
expect(mockGet).toHaveBeenCalledWith(
|
||||
'/api/temp-log-checks/10',
|
||||
);
|
||||
expect(mockGet).toHaveBeenCalledWith("/api/temp-log-checks/10");
|
||||
expect(store.allConformanceTempReportData).toEqual(mockData);
|
||||
});
|
||||
|
||||
it('stores routeFile when getRouteFile=true', async () => {
|
||||
it("stores routeFile when getRouteFile=true", async () => {
|
||||
store.conformanceLogTempCheckId = 10;
|
||||
const mockData = { file: { name: 'test.csv' } };
|
||||
const mockData = { file: { name: "test.csv" } };
|
||||
mockGet.mockResolvedValue({ data: mockData });
|
||||
|
||||
await store.getConformanceReport(true);
|
||||
|
||||
expect(store.allRouteFile).toEqual({ name: 'test.csv' });
|
||||
expect(store.allRouteFile).toEqual({ name: "test.csv" });
|
||||
expect(store.allConformanceTempReportData).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('addConformanceCreateCheckId', () => {
|
||||
it('creates log check and clears temp id', async () => {
|
||||
describe("addConformanceCreateCheckId", () => {
|
||||
it("creates log check and clears temp id", async () => {
|
||||
store.conformanceLogId = 1;
|
||||
store.conformanceFilterId = null;
|
||||
store.conformanceLogTempCheckId = 10;
|
||||
store.conformanceRuleData = { type: 'test' };
|
||||
store.conformanceRuleData = { type: "test" };
|
||||
mockPost.mockResolvedValue({ data: { id: 100 } });
|
||||
|
||||
await store.addConformanceCreateCheckId('myRule');
|
||||
await store.addConformanceCreateCheckId("myRule");
|
||||
|
||||
expect(mockPost).toHaveBeenCalledWith(
|
||||
'/api/log-checks?log_id=1',
|
||||
{ name: 'myRule', rule: { type: 'test' } },
|
||||
);
|
||||
expect(mockPost).toHaveBeenCalledWith("/api/log-checks?log_id=1", {
|
||||
name: "myRule",
|
||||
rule: { type: "test" },
|
||||
});
|
||||
expect(store.conformanceLogCreateCheckId).toBe(100);
|
||||
expect(store.conformanceLogTempCheckId).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe('updateConformance', () => {
|
||||
it('updates existing log check', async () => {
|
||||
describe("updateConformance", () => {
|
||||
it("updates existing log check", async () => {
|
||||
store.conformanceLogCreateCheckId = 50;
|
||||
store.conformanceRuleData = { type: 'updated' };
|
||||
store.conformanceRuleData = { type: "updated" };
|
||||
mockPut.mockResolvedValue({ status: 200 });
|
||||
|
||||
await store.updateConformance();
|
||||
|
||||
expect(mockPut).toHaveBeenCalledWith(
|
||||
'/api/log-checks/50',
|
||||
{ type: 'updated' },
|
||||
);
|
||||
expect(mockPut).toHaveBeenCalledWith("/api/log-checks/50", {
|
||||
type: "updated",
|
||||
});
|
||||
expect(store.isUpdateConformance).toBe(true);
|
||||
});
|
||||
});
|
||||
|
||||
it('setConformanceLogCreateCheckId sets value', () => {
|
||||
store.setConformanceLogCreateCheckId('abc');
|
||||
expect(store.conformanceLogCreateCheckId).toBe('abc');
|
||||
it("setConformanceLogCreateCheckId sets value", () => {
|
||||
store.setConformanceLogCreateCheckId("abc");
|
||||
expect(store.conformanceLogCreateCheckId).toBe("abc");
|
||||
});
|
||||
|
||||
describe('getters', () => {
|
||||
it('conformanceTask returns labels', () => {
|
||||
store.allConformanceTask = [
|
||||
{ label: 'A' }, { label: 'B' },
|
||||
];
|
||||
expect(store.conformanceTask).toEqual(['A', 'B']);
|
||||
describe("getters", () => {
|
||||
it("conformanceTask returns labels", () => {
|
||||
store.allConformanceTask = [{ label: "A" }, { label: "B" }];
|
||||
expect(store.conformanceTask).toEqual(["A", "B"]);
|
||||
});
|
||||
|
||||
it('cases getter formats date attributes with correct minute token', () => {
|
||||
store.allCases = [{
|
||||
started_at: '2023-06-15T10:30:00Z',
|
||||
completed_at: '2023-06-15T11:45:00Z',
|
||||
facets: [],
|
||||
attributes: [{
|
||||
type: 'date',
|
||||
value: '2023-06-15T14:30:00Z',
|
||||
}],
|
||||
}];
|
||||
it("cases getter formats date attributes with correct minute token", () => {
|
||||
store.allCases = [
|
||||
{
|
||||
started_at: "2023-06-15T10:30:00Z",
|
||||
completed_at: "2023-06-15T11:45:00Z",
|
||||
facets: [],
|
||||
attributes: [
|
||||
{
|
||||
type: "date",
|
||||
value: "2023-06-15T14:30:00Z",
|
||||
},
|
||||
],
|
||||
},
|
||||
];
|
||||
const result = store.cases;
|
||||
// The date attribute should show minutes (30), not month (06)
|
||||
expect(result[0].attributes[0].value).toMatch(/:30:/);
|
||||
});
|
||||
|
||||
it('cases getter does not corrupt original state on repeated access', () => {
|
||||
const originalDate = '2023-06-15T10:30:00Z';
|
||||
store.allCases = [{
|
||||
started_at: originalDate,
|
||||
completed_at: '2023-06-15T11:45:00Z',
|
||||
facets: [],
|
||||
attributes: [],
|
||||
}];
|
||||
it("cases getter does not corrupt original state on repeated access", () => {
|
||||
const originalDate = "2023-06-15T10:30:00Z";
|
||||
store.allCases = [
|
||||
{
|
||||
started_at: originalDate,
|
||||
completed_at: "2023-06-15T11:45:00Z",
|
||||
facets: [],
|
||||
attributes: [],
|
||||
},
|
||||
];
|
||||
store.cases;
|
||||
// Original state should still contain the ISO date
|
||||
expect(store.allCases[0].started_at).toBe(originalDate);
|
||||
|
||||
Reference in New Issue
Block a user