Projektordner in der Nextcloud anlegen und je nach Status verschieben (P10)
Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01AmyPfuNc4sCRfaF3oURXZz
This commit is contained in:
@@ -1,5 +1,6 @@
|
||||
// Prüft Server und Datenbank zusammen. Läuft nur mit TEST_DATABASE_URL (lokal und in der CI).
|
||||
import { describe, it, expect, beforeAll, afterAll } from "vitest";
|
||||
import { falscheNextcloud } from "./falsche-nextcloud.js";
|
||||
import type { FastifyInstance } from "fastify";
|
||||
import { erstellePool, type Pool } from "../src/server/db.js";
|
||||
import { migriere } from "../src/server/migrate.js";
|
||||
@@ -231,3 +232,38 @@ describe.skipIf(!url)("Übernahme aus V70 über die API", () => {
|
||||
expect((await app.inject(`/kalender/${kalenderToken.slice(0, -1)}${kalenderToken.endsWith("x") ? "y" : "x"}/baustellen.ics`)).statusCode).toBe(404);
|
||||
});
|
||||
});
|
||||
|
||||
describe.skipIf(!url)("Projektordner in der Nextcloud über die API", () => {
|
||||
let pool: Pool;
|
||||
let app: FastifyInstance;
|
||||
const f = falscheNextcloud();
|
||||
|
||||
beforeAll(async () => {
|
||||
pool = erstellePool(url!);
|
||||
await pool.query("drop schema public cascade; create schema public;");
|
||||
await migriere(pool);
|
||||
app = await baueApp({ pool, webOrdner: "/gibt-es-nicht", nextcloud: f.nc });
|
||||
});
|
||||
afterAll(async () => {
|
||||
await app?.close();
|
||||
await pool?.end();
|
||||
});
|
||||
|
||||
it("neues Projekt bekommt einen Ordner, Statuswechsel verschiebt ihn", async () => {
|
||||
const p = (await app.inject({ method: "POST", url: "/api/projekte", payload: { nummer: "A-26-130", bezeichnung: "Carport Most", status: "angebot" } })).json();
|
||||
expect(p.nextcloud_link).toBe("01 Angebot/A-26-130 Carport Most");
|
||||
const q = (await app.inject({ method: "PATCH", url: `/api/projekte/${p.id}`, payload: { nummer: "P-26-021", status: "auftrag" } })).json();
|
||||
expect(q.nextcloud_link).toBe("02 laufende Projekte/P-26-021 Carport Most");
|
||||
expect(f.relativ()).toContain("02 laufende Projekte/P-26-021 Carport Most/02 Umsetzung");
|
||||
});
|
||||
|
||||
it("Fehler der Nextcloud verhindert das Speichern nicht", async () => {
|
||||
f.ordner.clear(); // Wurzel fehlt: jede Anlage schlägt fehl
|
||||
const r = await app.inject({ method: "POST", url: "/api/projekte", payload: { nummer: "A-26-131", bezeichnung: "Gaube", status: "angebot" } });
|
||||
expect(r.statusCode).toBe(201);
|
||||
expect(r.json().ordner_fehler).toMatch(/Nextcloud/);
|
||||
f.ordner.add(f.wurzel);
|
||||
const nochmal = (await app.inject({ method: "POST", url: `/api/projekte/${r.json().id}/ordner` })).json();
|
||||
expect(nochmal.nextcloud_link).toBe("01 Angebot/A-26-131 Gaube");
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user