Files
Nick SzaunigandClaude Opus 5.5 5c2878875b
Docker-Images bauen und veroeffentlichen / build-and-push (push) Successful in 2m54s
feat: Buchung sofort möglich, sobald alle Freigaben erteilt sind
Vor dem 01.11.2026 gilt dann der Early-Bird-Preis. Fehlt eine Freigabe, bleibt die Vorschau.

Co-Authored-By: Claude Opus 5.5 (1M context) <[email protected]>
2026-10-06 23:07:39 +02:00

117 lines
4.0 KiB
TypeScript

import { describe, expect, test } from "vitest";
import { evaluateSales, type CampGateFields } from "@/lib/sales-gate";
const unreleased: CampGateFields = {
salesEnabled: false,
capacityConfirmed: false,
stammmodelQuotaConfirmed: false,
campStartDate: null,
dateConfirmed: false,
locationName: null,
locationConfirmed: false,
accommodationText: null,
accommodationConfirmed: false,
servicesConfirmed: false,
organizerName: null,
organizerAddress: null,
organizerEmail: null,
organizerConfirmed: false,
taxNote: null,
taxConfirmed: false,
termsVersion: null,
termsApproved: false,
withdrawalText: null,
withdrawalApproved: false,
travelLawChecked: false,
installmentsApproved: false,
installmentRuleApproved: false,
testPhaseOverride: null,
};
const released: CampGateFields = {
...unreleased,
salesEnabled: true,
capacityConfirmed: true,
stammmodelQuotaConfirmed: true,
campStartDate: "2027-06-05",
dateConfirmed: true,
locationName: "Villa",
locationConfirmed: true,
accommodationText: "Beschreibung",
accommodationConfirmed: true,
servicesConfirmed: true,
organizerName: "Veranstalter",
organizerAddress: "Adresse",
organizerEmail: "[email protected]",
organizerConfirmed: true,
taxNote: "Hinweis",
taxConfirmed: true,
termsVersion: "1",
termsApproved: true,
withdrawalText: "Belehrung",
withdrawalApproved: true,
travelLawChecked: true,
};
const earlyBird = new Date("2026-11-10T12:00:00Z");
describe("Verkaufsfreigabe", () => {
test("Livemodus ohne Freigaben: Checkout gesperrt, alle Blocker benannt", () => {
const state = evaluateSales(earlyBird, unreleased, "live");
expect(state.checkoutOpen).toBe(false);
expect(state.closedReason).toBe("NOT_RELEASED");
expect(state.releaseBlockers).toHaveLength(12);
});
test("Livemodus: eine einzige fehlende Freigabe sperrt den Verkauf", () => {
const state = evaluateSales(earlyBird, { ...released, travelLawChecked: false }, "live");
expect(state.checkoutOpen).toBe(false);
expect(state.releaseBlockers).toEqual(["TRAVEL_LAW"]);
});
test("Livemodus mit allen Freigaben in der Early-Bird-Phase: offen", () => {
expect(evaluateSales(earlyBird, released, "live").checkoutOpen).toBe(true);
});
test("Livemodus vor dem 01.11.2026 mit allen Freigaben: offen zum Early-Bird-Preis", () => {
const state = evaluateSales(new Date("2026-10-01T12:00:00Z"), released, "live");
expect(state.checkoutOpen).toBe(true);
expect(state.effectivePhase).toBe("EARLY_BIRD");
expect(state.phaseSimulated).toBe(false);
});
test("Livemodus vor dem 01.11.2026 mit fehlender Freigabe: Vorschau, Override wirkungslos", () => {
const state = evaluateSales(
new Date("2026-10-01T12:00:00Z"),
{ ...released, travelLawChecked: false, testPhaseOverride: "REGULAR" },
"live",
);
expect(state.checkoutOpen).toBe(false);
expect(state.closedReason).toBe("PREVIEW");
});
test("Testmodus ohne Freigaben: Checkout offen, Preisphase simulierbar", () => {
const state = evaluateSales(new Date("2026-10-01T12:00:00Z"), { ...unreleased, testPhaseOverride: "REGULAR" }, "test");
expect(state.checkoutOpen).toBe(true);
expect(state.effectivePhase).toBe("REGULAR");
expect(state.phaseSimulated).toBe(true);
});
test("Testmodus ohne Override vor Verkaufsstart bleibt Vorschau", () => {
expect(evaluateSales(new Date("2026-10-01T12:00:00Z"), unreleased, "test").checkoutOpen).toBe(false);
});
test("Ratenzahlung live erst nach ausdruecklicher Freigabe", () => {
expect(evaluateSales(earlyBird, released, "live").installmentsAllowed).toBe(false);
expect(
evaluateSales(earlyBird, { ...released, installmentsApproved: true, installmentRuleApproved: true }, "live")
.installmentsAllowed,
).toBe(true);
});
test("ab Anreisetag ist der Verkauf geschlossen", () => {
const state = evaluateSales(new Date("2027-06-05T08:00:00Z"), released, "live");
expect(state.closedReason).toBe("CAMP_STARTED");
});
});