ci: trigga på master + formatfix inför Gitea Actions
CI / Typecheck, test & build (push) Failing after 2s
CI / Typecheck, test & build (push) Failing after 2s
This commit is contained in:
@@ -44,8 +44,22 @@ describe("updateCookingAssumptionProfile", () => {
|
||||
});
|
||||
|
||||
it("keeps a rolling history of last 10 sessions", () => {
|
||||
type Profile = { averageEatenPortions: number | null; averageLeftoverPortions: number | null; observationCount: number; lastSessionAnswers?: Array<{ sessionId: string; eaten: number; leftovers: number; date: string }> | null };
|
||||
let existing: Profile = { averageEatenPortions: null, averageLeftoverPortions: null, observationCount: 0 };
|
||||
type Profile = {
|
||||
averageEatenPortions: number | null;
|
||||
averageLeftoverPortions: number | null;
|
||||
observationCount: number;
|
||||
lastSessionAnswers?: Array<{
|
||||
sessionId: string;
|
||||
eaten: number;
|
||||
leftovers: number;
|
||||
date: string;
|
||||
}> | null;
|
||||
};
|
||||
let existing: Profile = {
|
||||
averageEatenPortions: null,
|
||||
averageLeftoverPortions: null,
|
||||
observationCount: 0,
|
||||
};
|
||||
for (let i = 0; i < 12; i++) {
|
||||
existing = updateCookingAssumptionProfile(
|
||||
{
|
||||
@@ -91,7 +105,12 @@ describe("rollbackCookingAssumptionProfile", () => {
|
||||
averageEatenPortions: number | null;
|
||||
averageLeftoverPortions: number | null;
|
||||
observationCount: number;
|
||||
lastSessionAnswers?: Array<{ sessionId: string; eaten: number; leftovers: number; date: string }> | null;
|
||||
lastSessionAnswers?: Array<{
|
||||
sessionId: string;
|
||||
eaten: number;
|
||||
leftovers: number;
|
||||
date: string;
|
||||
}> | null;
|
||||
} = { averageEatenPortions: null, averageLeftoverPortions: null, observationCount: 0 };
|
||||
|
||||
// Three chronological observations.
|
||||
@@ -134,7 +153,12 @@ describe("rollbackCookingAssumptionProfile", () => {
|
||||
averageEatenPortions: number | null;
|
||||
averageLeftoverPortions: number | null;
|
||||
observationCount: number;
|
||||
lastSessionAnswers?: Array<{ sessionId: string; eaten: number; leftovers: number; date: string }> | null;
|
||||
lastSessionAnswers?: Array<{
|
||||
sessionId: string;
|
||||
eaten: number;
|
||||
leftovers: number;
|
||||
date: string;
|
||||
}> | null;
|
||||
} = { averageEatenPortions: null, averageLeftoverPortions: null, observationCount: 0 };
|
||||
existing = updateCookingAssumptionProfile(
|
||||
{
|
||||
|
||||
@@ -3,7 +3,9 @@ import { buildReconciliationCandidates } from "../src/reconciliation.js";
|
||||
|
||||
const PINNED = new Date("2026-08-07T00:00:00.000Z");
|
||||
|
||||
function baseItem(overrides: Partial<Parameters<typeof buildReconciliationCandidates>[0][number]> = {}) {
|
||||
function baseItem(
|
||||
overrides: Partial<Parameters<typeof buildReconciliationCandidates>[0][number]> = {},
|
||||
) {
|
||||
return {
|
||||
id: "itm-1",
|
||||
displayName: "Mjölk",
|
||||
@@ -22,7 +24,12 @@ describe("buildReconciliationCandidates", () => {
|
||||
it("returns empty when no items match", () => {
|
||||
const result = buildReconciliationCandidates(
|
||||
[baseItem({ quantity: 0, depletedAt: PINNED })],
|
||||
{ plannedRecipeIngredientIds: new Map(), daysLeftByItemId: new Map(), dailyConsumptionRate: new Map(), priceMinorByItemId: new Map() },
|
||||
{
|
||||
plannedRecipeIngredientIds: new Map(),
|
||||
daysLeftByItemId: new Map(),
|
||||
dailyConsumptionRate: new Map(),
|
||||
priceMinorByItemId: new Map(),
|
||||
},
|
||||
PINNED,
|
||||
);
|
||||
expect(result).toEqual([]);
|
||||
@@ -69,7 +76,12 @@ describe("buildReconciliationCandidates", () => {
|
||||
const item = baseItem({ confidence: 0.3, verifiedByUser: false });
|
||||
const result = buildReconciliationCandidates(
|
||||
[item],
|
||||
{ plannedRecipeIngredientIds: new Map(), daysLeftByItemId: new Map(), dailyConsumptionRate: new Map(), priceMinorByItemId: new Map() },
|
||||
{
|
||||
plannedRecipeIngredientIds: new Map(),
|
||||
daysLeftByItemId: new Map(),
|
||||
dailyConsumptionRate: new Map(),
|
||||
priceMinorByItemId: new Map(),
|
||||
},
|
||||
PINNED,
|
||||
);
|
||||
expect(result[0]?.reasons).toContainEqual({ kind: "low_confidence", confidence: 0.3 });
|
||||
@@ -92,11 +104,20 @@ describe("buildReconciliationCandidates", () => {
|
||||
|
||||
it("caps results at maxItems", () => {
|
||||
const items = Array.from({ length: 20 }, (_, i) =>
|
||||
baseItem({ id: `itm-${i}`, displayName: `Vara ${String(i).padStart(2, "0")}`, confidence: 0.1 }),
|
||||
baseItem({
|
||||
id: `itm-${i}`,
|
||||
displayName: `Vara ${String(i).padStart(2, "0")}`,
|
||||
confidence: 0.1,
|
||||
}),
|
||||
);
|
||||
const result = buildReconciliationCandidates(
|
||||
items,
|
||||
{ plannedRecipeIngredientIds: new Map(), daysLeftByItemId: new Map(), dailyConsumptionRate: new Map(), priceMinorByItemId: new Map() },
|
||||
{
|
||||
plannedRecipeIngredientIds: new Map(),
|
||||
daysLeftByItemId: new Map(),
|
||||
dailyConsumptionRate: new Map(),
|
||||
priceMinorByItemId: new Map(),
|
||||
},
|
||||
PINNED,
|
||||
5,
|
||||
);
|
||||
|
||||
@@ -98,7 +98,10 @@ describe("computeTrust", () => {
|
||||
|
||||
describe("householdTrustScore", () => {
|
||||
it("returns 100 / up_to_date for empty inventory", () => {
|
||||
const result = householdTrustScore({ items: [], correctionCount30d: 0, transactionCount30d: 0 }, PINNED);
|
||||
const result = householdTrustScore(
|
||||
{ items: [], correctionCount30d: 0, transactionCount30d: 0 },
|
||||
PINNED,
|
||||
);
|
||||
expect(result.score).toBe(100);
|
||||
expect(result.status).toBe("up_to_date");
|
||||
});
|
||||
@@ -107,8 +110,20 @@ describe("householdTrustScore", () => {
|
||||
const result = householdTrustScore(
|
||||
{
|
||||
items: [
|
||||
{ confidence: 1, verifiedByUser: true, lastVerifiedAt: PINNED, quantity: 2, updatedAt: PINNED },
|
||||
{ confidence: 1, verifiedByUser: true, lastVerifiedAt: PINNED, quantity: 3, updatedAt: PINNED },
|
||||
{
|
||||
confidence: 1,
|
||||
verifiedByUser: true,
|
||||
lastVerifiedAt: PINNED,
|
||||
quantity: 2,
|
||||
updatedAt: PINNED,
|
||||
},
|
||||
{
|
||||
confidence: 1,
|
||||
verifiedByUser: true,
|
||||
lastVerifiedAt: PINNED,
|
||||
quantity: 3,
|
||||
updatedAt: PINNED,
|
||||
},
|
||||
],
|
||||
correctionCount30d: 0,
|
||||
transactionCount30d: 0,
|
||||
@@ -124,7 +139,13 @@ describe("householdTrustScore", () => {
|
||||
const result = householdTrustScore(
|
||||
{
|
||||
items: [
|
||||
{ confidence: 0.3, verifiedByUser: false, lastVerifiedAt: null, quantity: 0.1, updatedAt: old },
|
||||
{
|
||||
confidence: 0.3,
|
||||
verifiedByUser: false,
|
||||
lastVerifiedAt: null,
|
||||
quantity: 0.1,
|
||||
updatedAt: old,
|
||||
},
|
||||
],
|
||||
correctionCount30d: 5,
|
||||
transactionCount30d: 10,
|
||||
@@ -140,8 +161,20 @@ describe("householdTrustScore", () => {
|
||||
const result = householdTrustScore(
|
||||
{
|
||||
items: [
|
||||
{ confidence: 0.8, verifiedByUser: true, lastVerifiedAt: weekAgo, quantity: 1, updatedAt: weekAgo },
|
||||
{ confidence: 0.5, verifiedByUser: false, lastVerifiedAt: null, quantity: 1, updatedAt: weekAgo },
|
||||
{
|
||||
confidence: 0.8,
|
||||
verifiedByUser: true,
|
||||
lastVerifiedAt: weekAgo,
|
||||
quantity: 1,
|
||||
updatedAt: weekAgo,
|
||||
},
|
||||
{
|
||||
confidence: 0.5,
|
||||
verifiedByUser: false,
|
||||
lastVerifiedAt: null,
|
||||
quantity: 1,
|
||||
updatedAt: weekAgo,
|
||||
},
|
||||
],
|
||||
correctionCount30d: 1,
|
||||
transactionCount30d: 5,
|
||||
|
||||
Reference in New Issue
Block a user