fix(application): resolve typecheck errors in estimate-operations tests
CI / Architecture Guardrails (push) Successful in 2m57s
CI / Typecheck (push) Failing after 5m27s
CI / Build (push) Has been skipped
CI / E2E Tests (push) Has been skipped
CI / Fresh-Linux Docker Deploy (push) Has been skipped
CI / Assistant Split Regression (push) Failing after 5m49s
CI / Lint (push) Successful in 6m55s
CI / Unit Tests (push) Failing after 4m37s
CI / Release Images (push) Has been skipped
CI / Architecture Guardrails (push) Successful in 2m57s
CI / Typecheck (push) Failing after 5m27s
CI / Build (push) Has been skipped
CI / E2E Tests (push) Has been skipped
CI / Fresh-Linux Docker Deploy (push) Has been skipped
CI / Assistant Split Regression (push) Failing after 5m49s
CI / Lint (push) Successful in 6m55s
CI / Unit Tests (push) Failing after 4m37s
CI / Release Images (push) Has been skipped
- Import EstimateStatus enum instead of using "DRAFT" string literal - Type BASE_VERSION fixture explicitly so lockedAt accepts Date | null - Add non-null assertion on mock.calls[0] to satisfy strict types - Reorder id/spread in version fixture to avoid duplicate property warning
This commit is contained in:
@@ -1,4 +1,5 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import { EstimateStatus } from "@capakraken/shared";
|
||||
import { createEstimate } from "../use-cases/estimate/create-estimate.js";
|
||||
import { cloneEstimate } from "../use-cases/estimate/clone-estimate.js";
|
||||
import { listEstimates } from "../use-cases/estimate/list-estimates.js";
|
||||
@@ -12,7 +13,24 @@ import {
|
||||
// Shared fixtures
|
||||
// ---------------------------------------------------------------------------
|
||||
|
||||
const BASE_VERSION = {
|
||||
const BASE_VERSION: {
|
||||
id: string;
|
||||
estimateId: string;
|
||||
versionNumber: number;
|
||||
label: string;
|
||||
status: string;
|
||||
lockedAt: Date | null;
|
||||
notes: string | null;
|
||||
projectSnapshot: Record<string, unknown>;
|
||||
createdAt: Date;
|
||||
updatedAt: Date;
|
||||
assumptions: never[];
|
||||
scopeItems: never[];
|
||||
demandLines: never[];
|
||||
resourceSnapshots: never[];
|
||||
metrics: never[];
|
||||
exports: never[];
|
||||
} = {
|
||||
id: "ver_1",
|
||||
estimateId: "est_1",
|
||||
versionNumber: 1,
|
||||
@@ -84,7 +102,7 @@ describe("createEstimate", () => {
|
||||
projectId: "proj_1",
|
||||
name: "My Estimate",
|
||||
baseCurrency: "USD",
|
||||
status: "DRAFT" as const,
|
||||
status: EstimateStatus.DRAFT,
|
||||
assumptions: [],
|
||||
scopeItems: [],
|
||||
demandLines: [],
|
||||
@@ -105,7 +123,7 @@ describe("createEstimate", () => {
|
||||
const db = makeDb();
|
||||
await createEstimate(db as never, minimalInput);
|
||||
|
||||
const createData = db.estimate.create.mock.calls[0][0].data;
|
||||
const createData = db.estimate.create.mock.calls[0]![0].data;
|
||||
expect(createData.projectId).toBe("proj_1");
|
||||
});
|
||||
|
||||
@@ -175,7 +193,7 @@ describe("cloneEstimate", () => {
|
||||
const result = await cloneEstimate(db as never, { sourceEstimateId: "est_src" });
|
||||
|
||||
expect(db.estimate.create).toHaveBeenCalledOnce();
|
||||
const createData = db.estimate.create.mock.calls[0][0].data;
|
||||
const createData = db.estimate.create.mock.calls[0]![0].data;
|
||||
expect(createData.name).toBe("Copy of Original");
|
||||
expect(result.id).toBe("est_clone");
|
||||
});
|
||||
@@ -184,7 +202,7 @@ describe("cloneEstimate", () => {
|
||||
const db = makeDb();
|
||||
await cloneEstimate(db as never, { sourceEstimateId: "est_src", name: "Custom Clone" });
|
||||
|
||||
const createData = db.estimate.create.mock.calls[0][0].data;
|
||||
const createData = db.estimate.create.mock.calls[0]![0].data;
|
||||
expect(createData.name).toBe("Custom Clone");
|
||||
});
|
||||
|
||||
@@ -245,7 +263,7 @@ describe("listEstimates", () => {
|
||||
const db = makeDb();
|
||||
await listEstimates(db as never, { projectId: "proj_1" });
|
||||
|
||||
const where = db.estimate.findMany.mock.calls[0][0].where;
|
||||
const where = db.estimate.findMany.mock.calls[0]![0].where;
|
||||
expect(where.projectId).toBe("proj_1");
|
||||
});
|
||||
|
||||
@@ -253,7 +271,7 @@ describe("listEstimates", () => {
|
||||
const db = makeDb([]);
|
||||
await listEstimates(db as never, { status: "APPROVED" as never });
|
||||
|
||||
const where = db.estimate.findMany.mock.calls[0][0].where;
|
||||
const where = db.estimate.findMany.mock.calls[0]![0].where;
|
||||
expect(where.status).toBe("APPROVED");
|
||||
});
|
||||
|
||||
@@ -261,7 +279,7 @@ describe("listEstimates", () => {
|
||||
const db = makeDb();
|
||||
await listEstimates(db as never, { query: "alpha" });
|
||||
|
||||
const where = db.estimate.findMany.mock.calls[0][0].where;
|
||||
const where = db.estimate.findMany.mock.calls[0]![0].where;
|
||||
expect(where.OR).toBeDefined();
|
||||
expect(where.OR).toHaveLength(2);
|
||||
});
|
||||
@@ -431,11 +449,9 @@ describe("createEstimateRevision", () => {
|
||||
) {
|
||||
const txMock = {
|
||||
estimateVersion: {
|
||||
create: vi
|
||||
.fn()
|
||||
.mockResolvedValue({
|
||||
id: "ver_new",
|
||||
create: vi.fn().mockResolvedValue({
|
||||
...BASE_VERSION,
|
||||
id: "ver_new",
|
||||
versionNumber: 2,
|
||||
status: "WORKING",
|
||||
}),
|
||||
|
||||
Reference in New Issue
Block a user