From ce306a7642e5d0865db81620b33aad17454cc772 Mon Sep 17 00:00:00 2001 From: spark Date: Wed, 21 Oct 2026 21:37:38 +0100 Subject: [PATCH 1/2] Fix the app tests that keep main red since the offline sync landed 54c40bd made useLocalFtp read the signed-in client with useAuth() and made useOfflineSync (mounted by App) subscribe through onSocketLive() from library/realtime. The tests were not updated: - LocalFtp.test.tsx renders the hook with no AuthProvider, so every case threw "useAuth outside AuthProvider". It now mocks ../auth.js with a bare client, the same way FacesQueuePage.test.tsx does. The target has no organization, so the offline flush and local autopilot never call it. - App.test.tsx mocks ./library/realtime.js without onSocketLive. The sync effect threw, unmounted the tree and the sign-in and editor panel cases could not find their text. The mock now returns a no-op subscription. No test is skipped and no product code changes. --- apps/app/src/App.test.tsx | 2 +- apps/app/src/library/LocalFtp.test.tsx | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/apps/app/src/App.test.tsx b/apps/app/src/App.test.tsx index fd43411..796e981 100644 --- a/apps/app/src/App.test.tsx +++ b/apps/app/src/App.test.tsx @@ -5,7 +5,7 @@ import userEvent from "@testing-library/user-event"; import { describe, expect, it, vi } from "vitest"; import { App } from "./App.js"; -vi.mock("./library/realtime.js", () => ({ useLibraryLive: () => "live" })); +vi.mock("./library/realtime.js", () => ({ useLibraryLive: () => "live", onSocketLive: () => () => {} })); const ME: Me = { user: { id: "u1", email: "ana@photoreport.pt", name: "Ana", locale: "pt-PT" }, diff --git a/apps/app/src/library/LocalFtp.test.tsx b/apps/app/src/library/LocalFtp.test.tsx index 68413cc..cd362ba 100644 --- a/apps/app/src/library/LocalFtp.test.tsx +++ b/apps/app/src/library/LocalFtp.test.tsx @@ -5,6 +5,10 @@ import { type FtpStatus, type IncomingFile, type Invoke, useLocalFtp } from "./L import type { UploadStatus } from "./uploads.js"; import { localPhotos } from "../offline/local.js"; +// The feed sends through the signed-in client (offline queue flush, local autopilot). Nothing here signs in, and +// the target has no organization, so a bare client is enough. +vi.mock("../auth.js", () => ({ useAuth: () => ({ api: {} }) })); + const status = (running: boolean): FtpStatus => ({ running, settings: { port: 2121, users: [{ name: "1dx", password: "1dx" }], ingest: "~/Desktop/ingest", workFolder: "~/Desktop/{year}/{date} - {event}", autoStart: false, uploadOriginals: false }, -- 2.47.3 From 2c77135e7a184b3102db4e27b148614ad2e03dff Mon Sep 17 00:00:00 2001 From: spark Date: Wed, 21 Oct 2026 22:42:56 +0100 Subject: [PATCH 2/2] Let the sports test answer the EHF pages that refreshDue now reads 899b45f (#111) added the six EHF club competitions to the catalog and to refreshDue. The fake sites in test/sports.test.ts did not know *.eurohandball.com, so every EHF season page answered 404, refreshDue returned six errors and "reads the Liga and FPA, and only again after six hours" failed on main. The fake now serves an EHF season page with its ids and empty match lists, and the expected competitions include the six EHF ones (no fixtures yet). --- apps/api/test/sports.test.ts | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/apps/api/test/sports.test.ts b/apps/api/test/sports.test.ts index ad7be37..22c69c3 100644 --- a/apps/api/test/sports.test.ts +++ b/apps/api/test/sports.test.ts @@ -308,6 +308,11 @@ const fakeSites = (state: { benfica: { shirtNumber: number; name: string; photos }, ]); if (u.pathname.includes("/calendar/")) return json([]); + // EHF club competitions: the season pages exist but list no matches yet. + if (u.host.endsWith(".eurohandball.com")) { + if (u.pathname.endsWith("/matches/")) return bytes(Buffer.from(`
`, "utf8")); + if (u.pathname.startsWith("/umbraco/api/competitionmatchesapi/")) return json({ matches: [], hasPastMatches: false, hasFutureMatches: false }); + } if (u.host === "www.ligaportugal.pt" && u.pathname.endsWith(".png")) return { ok: true, status: 200, json: async () => ({}), text: async () => "", arrayBuffer: async () => state.png.buffer.slice(state.png.byteOffset, state.png.byteOffset + state.png.byteLength) as ArrayBuffer }; return { ok: false, status: 404, json: async () => ({}), text: async () => "", arrayBuffer: async () => new ArrayBuffer(0) }; @@ -352,6 +357,12 @@ describe("sports data service", () => { expect(comps.map((c) => [c.provider, c.externalId, c.season])).toEqual([ ["LIGA", "allianzcup", "20262027"], ["FPA", "PO09", "20262027"], + ["EHF", "cl-men", "20262027"], + ["EHF", "cl-women", "20262027"], + ["EHF", "ec-men", "20262027"], + ["EHF", "ec-women", "20262027"], + ["EHF", "el-men", "20262027"], + ["EHF", "el-women", "20262027"], ["LIGA", "ligaportugalbetclic", "20262027"], ["LIGA", "ligaportugalmeusuper", "20262027"], ["UEFA", "1", "20262027"], -- 2.47.3