174 lines
5.7 KiB
TypeScript
174 lines
5.7 KiB
TypeScript
import { describe, it, expect } from "vitest";
|
|
import { readFileSync } from "node:fs";
|
|
import { resolve } from "node:path";
|
|
|
|
describe("Mietanfrage Page", () => {
|
|
const pagePath = resolve(__dirname, "../../pages/mietanfrage.vue");
|
|
const content = readFileSync(pagePath, "utf-8");
|
|
|
|
it("should have page title Mietanfrage", () => {
|
|
expect(content).toContain("Mietanfrage");
|
|
expect(content).toContain('data-testid="mietanfrage-title"');
|
|
});
|
|
|
|
it("should use useCart composable", () => {
|
|
expect(content).toContain("useCart");
|
|
});
|
|
|
|
it("should use useApi composable", () => {
|
|
expect(content).toContain("useApi");
|
|
});
|
|
|
|
it("should have breadcrumb navigation", () => {
|
|
expect(content).toContain("Breadcrumb");
|
|
expect(content).toContain('to="/"');
|
|
expect(content).toContain('to="/warenkorb"');
|
|
});
|
|
|
|
it("should have empty cart state with redirect to mietkatalog", () => {
|
|
expect(content).toContain('data-testid="mietanfrage-empty-cart"');
|
|
expect(content).toContain('to="/mietkatalog"');
|
|
expect(content).toContain("Ihr Warenkorb ist leer");
|
|
});
|
|
|
|
it("should have cart overview section (read-only)", () => {
|
|
expect(content).toContain('data-testid="mietanfrage-cart-overview"');
|
|
expect(content).toContain('data-testid="mietanfrage-cart-item"');
|
|
});
|
|
|
|
it("should have event name field (required)", () => {
|
|
expect(content).toContain('data-testid="form-event-name"');
|
|
expect(content).toContain("Veranstaltung");
|
|
});
|
|
|
|
it("should have date start field (required)", () => {
|
|
expect(content).toContain('data-testid="form-date-start"');
|
|
expect(content).toContain("Von");
|
|
});
|
|
|
|
it("should have date end field (required)", () => {
|
|
expect(content).toContain('data-testid="form-date-end"');
|
|
expect(content).toContain("Bis");
|
|
});
|
|
|
|
it("should have location field (required)", () => {
|
|
expect(content).toContain('data-testid="form-location"');
|
|
expect(content).toContain("Veranstaltungsort");
|
|
});
|
|
|
|
it("should have person count field (required)", () => {
|
|
expect(content).toContain('data-testid="form-person-count"');
|
|
expect(content).toContain("Personenanzahl");
|
|
});
|
|
|
|
it("should have contact name field (required)", () => {
|
|
expect(content).toContain('data-testid="form-contact-name"');
|
|
expect(content).toContain("Name");
|
|
});
|
|
|
|
it("should have contact company field (optional)", () => {
|
|
expect(content).toContain('data-testid="form-contact-company"');
|
|
expect(content).toContain("Firma");
|
|
});
|
|
|
|
it("should have contact email field (required)", () => {
|
|
expect(content).toContain('data-testid="form-contact-email"');
|
|
expect(content).toContain("E-Mail");
|
|
});
|
|
|
|
it("should have contact phone field (optional)", () => {
|
|
expect(content).toContain('data-testid="form-contact-phone"');
|
|
expect(content).toContain("Telefon");
|
|
});
|
|
|
|
it("should have contact street field", () => {
|
|
expect(content).toContain('data-testid="form-contact-street"');
|
|
});
|
|
|
|
it("should have contact postal code field", () => {
|
|
expect(content).toContain('data-testid="form-contact-postalcode"');
|
|
});
|
|
|
|
it("should have contact city field", () => {
|
|
expect(content).toContain('data-testid="form-contact-city"');
|
|
});
|
|
|
|
it("should have message textarea", () => {
|
|
expect(content).toContain('data-testid="form-message"');
|
|
expect(content).toContain("Nachricht");
|
|
});
|
|
|
|
it("should have email validation with regex", () => {
|
|
expect(content).toContain("emailRegex");
|
|
expect(content).toContain("emailRegex.test");
|
|
});
|
|
|
|
it("should have validateField function", () => {
|
|
expect(content).toContain("validateField");
|
|
expect(content).toContain("validateAll");
|
|
});
|
|
|
|
it("should have error display for event_name", () => {
|
|
expect(content).toContain('data-testid="error-event-name"');
|
|
});
|
|
|
|
it("should have error display for contact_email", () => {
|
|
expect(content).toContain('data-testid="error-contact-email"');
|
|
});
|
|
|
|
it("should have submit button", () => {
|
|
expect(content).toContain('data-testid="mietanfrage-submit"');
|
|
expect(content).toContain("Anfrage senden");
|
|
});
|
|
|
|
it("should have submitting state with spinner", () => {
|
|
expect(content).toContain("submitting");
|
|
expect(content).toContain("Wird gesendet");
|
|
expect(content).toContain("animate-spin");
|
|
});
|
|
|
|
it("should have success state with reference number", () => {
|
|
expect(content).toContain('data-testid="mietanfrage-success"');
|
|
expect(content).toContain('data-testid="mietanfrage-reference-number"');
|
|
expect(content).toContain("Vielen Dank");
|
|
expect(content).toContain("reference_number");
|
|
});
|
|
|
|
it("should have error state", () => {
|
|
expect(content).toContain('data-testid="mietanfrage-error"');
|
|
expect(content).toContain("Fehler");
|
|
});
|
|
|
|
it("should POST to /api/rental-requests", () => {
|
|
expect(content).toContain("/api/rental-requests");
|
|
expect(content).toContain("post");
|
|
});
|
|
|
|
it("should clear cart after successful submit", () => {
|
|
expect(content).toContain("clearCart");
|
|
expect(content).toContain("success");
|
|
});
|
|
|
|
it("should have back link to warenkorb", () => {
|
|
expect(content).toContain('data-testid="mietanfrage-back"');
|
|
expect(content).toContain('to="/warenkorb"');
|
|
});
|
|
|
|
it("should use TypeScript with lang=ts", () => {
|
|
expect(content).toContain('<script setup lang="ts">');
|
|
});
|
|
|
|
it("should use Tailwind classes, no inline styles", () => {
|
|
expect(content).not.toContain('style="');
|
|
});
|
|
|
|
it("should use useHead for page title", () => {
|
|
expect(content).toContain("useHead");
|
|
});
|
|
|
|
it("should import RentalRequestPayload and RentalRequestResponse types", () => {
|
|
expect(content).toContain("RentalRequestPayload");
|
|
expect(content).toContain("RentalRequestResponse");
|
|
});
|
|
});
|