diff --git a/.github/actions/install-dependencies/action.yml b/.github/actions/install-dependencies/action.yml index f838c8a4..62683e20 100644 --- a/.github/actions/install-dependencies/action.yml +++ b/.github/actions/install-dependencies/action.yml @@ -8,7 +8,7 @@ runs: - uses: oven-sh/setup-bun@v2 name: Install Bun with: - bun-version: "1.3.6" + bun-version: "1.3.11" - name: Install dependencies shell: bash diff --git a/Dockerfile b/Dockerfile index ed3051e6..c3d21010 100644 --- a/Dockerfile +++ b/Dockerfile @@ -1,4 +1,4 @@ -ARG BUN_VERSION="1.3.6" +ARG BUN_VERSION="1.3.11" FROM oven/bun:${BUN_VERSION}-alpine AS base diff --git a/app/client/modules/backups/components/__tests__/snapshot-file-browser.test.tsx b/app/client/modules/backups/components/__tests__/snapshot-file-browser.test.tsx index 7940a2fc..e3491854 100644 --- a/app/client/modules/backups/components/__tests__/snapshot-file-browser.test.tsx +++ b/app/client/modules/backups/components/__tests__/snapshot-file-browser.test.tsx @@ -1,18 +1,13 @@ import type { ReactNode } from "react"; import { afterEach, describe, expect, mock, test } from "bun:test"; -import { cleanup, render, screen } from "@testing-library/react"; +import { HttpResponse, http, server } from "~/test/msw/server"; +import { cleanup, render, screen, waitFor } from "~/test/test-utils"; import { fromAny } from "@total-typescript/shoehorn"; await mock.module("@tanstack/react-router", () => ({ Link: ({ children }: { children?: ReactNode }) => {children}, })); -await mock.module("~/client/components/file-browsers/snapshot-tree-browser", () => ({ - SnapshotTreeBrowser: ({ queryBasePath, displayBasePath }: { queryBasePath?: string; displayBasePath?: string }) => ( -
{`query:${queryBasePath ?? "missing"} display:${displayBasePath ?? "missing"}`}
- ), -})); - await mock.module("~/client/lib/datetime", () => ({ useTimeFormat: () => ({ formatDateTime: () => "2026-03-26 00:00", @@ -23,11 +18,26 @@ import { SnapshotFileBrowser } from "../snapshot-file-browser"; afterEach(() => { cleanup(); - mock.restore(); }); describe("SnapshotFileBrowser", () => { - test("uses the snapshot common ancestor as query root while keeping a broader display root", () => { + test("uses the snapshot common ancestor as query root while keeping a broader display root", async () => { + const requests: string[] = []; + + server.use( + http.get("/api/v1/repositories/:shortId/snapshots/:snapshotId/files", ({ request }) => { + const url = new URL(request.url); + requests.push(url.searchParams.get("path") ?? ""); + + return HttpResponse.json({ + files: [ + { name: "subdir", path: "/mnt/project/subdir", type: "dir" }, + { name: "a.txt", path: "/mnt/project/subdir/a.txt", type: "file" }, + ], + }); + }), + ); + render( { />, ); - expect(screen.getByText("query:/mnt/project/subdir display:/mnt")).toBeTruthy(); + await waitFor(() => { + expect(requests[0]).toBe("/mnt/project/subdir"); + }); + + expect(await screen.findByRole("button", { name: "project" })).toBeTruthy(); }); }); diff --git a/app/client/modules/backups/routes/__tests__/backup-details.test.tsx b/app/client/modules/backups/routes/__tests__/backup-details.test.tsx index 97d8c6f6..16a555d8 100644 --- a/app/client/modules/backups/routes/__tests__/backup-details.test.tsx +++ b/app/client/modules/backups/routes/__tests__/backup-details.test.tsx @@ -1,8 +1,43 @@ +import type { ReactNode } from "react"; import { afterEach, describe, expect, mock, test } from "bun:test"; import { fromAny } from "@total-typescript/shoehorn"; import { HttpResponse, http, server } from "~/test/msw/server"; import { cleanup, render, screen } from "~/test/test-utils"; +await mock.module("@tanstack/react-router", () => ({ + Link: ({ children }: { children?: ReactNode }) => {children}, + useNavigate: () => mock(() => {}), + useSearch: () => ({}), +})); + +await mock.module("~/client/components/backup-summary-card", () => ({ + BackupSummaryCard: () => null, +})); + +await mock.module("~/client/modules/backups/components/schedule-summary", () => ({ + ScheduleSummary: () => null, +})); + +await mock.module("~/client/modules/backups/components/snapshot-timeline", () => ({ + SnapshotTimeline: () => null, +})); + +await mock.module("~/client/modules/backups/components/schedule-notifications-config", () => ({ + ScheduleNotificationsConfig: () => null, +})); + +await mock.module("~/client/modules/backups/components/schedule-mirrors-config", () => ({ + ScheduleMirrorsConfig: () => null, +})); + +await mock.module("~/client/lib/datetime", () => ({ + useTimeFormat: () => ({ + formatDateTime: () => "2026-03-26 00:00", + }), +})); + +import { ScheduleDetailsPage } from "../backup-details"; + const schedule = { shortId: "backup-1", name: "Backup 1", @@ -32,39 +67,6 @@ const snapshot = { summary: {}, }; -await mock.module("@tanstack/react-router", () => ({ - useNavigate: () => mock(() => {}), - useSearch: () => ({}), -})); - -await mock.module("~/client/components/backup-summary-card", () => ({ - BackupSummaryCard: () => null, -})); - -await mock.module("~/client/modules/backups/components/schedule-summary", () => ({ - ScheduleSummary: () => null, -})); - -await mock.module("~/client/modules/backups/components/snapshot-file-browser", () => ({ - SnapshotFileBrowser: ({ displayBasePath }: { displayBasePath?: string }) => ( -
{displayBasePath ? `display-base-path:${displayBasePath}` : "display-base-path:missing"}
- ), -})); - -await mock.module("~/client/modules/backups/components/snapshot-timeline", () => ({ - SnapshotTimeline: () => null, -})); - -await mock.module("~/client/modules/backups/components/schedule-notifications-config", () => ({ - ScheduleNotificationsConfig: () => null, -})); - -await mock.module("~/client/modules/backups/components/schedule-mirrors-config", () => ({ - ScheduleMirrorsConfig: () => null, -})); - -import { ScheduleDetailsPage } from "../backup-details"; - const mockScheduleDetailsRequests = () => { server.use( http.get("/api/v1/backups/:shortId", () => { @@ -73,12 +75,19 @@ const mockScheduleDetailsRequests = () => { http.get("/api/v1/repositories/:shortId/snapshots", () => { return HttpResponse.json([snapshot]); }), + http.get("/api/v1/repositories/:shortId/snapshots/:snapshotId/files", () => { + return HttpResponse.json({ + files: [ + { name: "project", path: "/mnt/project", type: "dir" }, + { name: "a.txt", path: "/mnt/project/a.txt", type: "file" }, + ], + }); + }), ); }; afterEach(() => { cleanup(); - mock.restore(); }); describe("ScheduleDetailsPage", () => { @@ -103,6 +112,6 @@ describe("ScheduleDetailsPage", () => { { withSuspense: true }, ); - expect(await screen.findByText("display-base-path:/mnt")).toBeTruthy(); + expect(await screen.findByRole("button", { name: "project" })).toBeTruthy(); }); }); diff --git a/package.json b/package.json index 3167ac51..f3a913f2 100644 --- a/package.json +++ b/package.json @@ -140,5 +140,5 @@ "overrides": { "esbuild": "^0.27.2" }, - "packageManager": "bun@1.3.6" + "packageManager": "bun@1.3.11" }