Phase 3: Appointment model & booking API with timezone fix

This commit is contained in:
counterweight 2025-12-21 00:03:34 +01:00
parent f6cf093cb1
commit 06817875f7
Signed by: counterweight
GPG key ID: 883EDBAA726BD96C
9 changed files with 946 additions and 9 deletions

View file

@ -45,6 +45,20 @@ function getTomorrowDisplay(): string {
return tomorrow.toLocaleDateString("en-US", { weekday: "short", month: "short", day: "numeric" });
}
// Helper to get a date string in YYYY-MM-DD format using local timezone
function formatDateLocal(d: Date): string {
const year = d.getFullYear();
const month = String(d.getMonth() + 1).padStart(2, "0");
const day = String(d.getDate()).padStart(2, "0");
return `${year}-${month}-${day}`;
}
function getTomorrowDateStr(): string {
const tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate() + 1);
return formatDateLocal(tomorrow);
}
test.describe("Availability Page - Admin Access", () => {
test.beforeEach(async ({ page }) => {
await clearAuth(page);
@ -204,9 +218,7 @@ test.describe("Availability API", () => {
const authCookie = cookies.find(c => c.name === "auth_token");
if (authCookie) {
const tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate() + 1);
const dateStr = tomorrow.toISOString().split("T")[0];
const dateStr = getTomorrowDateStr();
const response = await request.put(`${API_URL}/api/admin/availability`, {
headers: {
@ -234,9 +246,7 @@ test.describe("Availability API", () => {
const authCookie = cookies.find(c => c.name === "auth_token");
if (authCookie) {
const tomorrow = new Date();
tomorrow.setDate(tomorrow.getDate() + 1);
const dateStr = tomorrow.toISOString().split("T")[0];
const dateStr = getTomorrowDateStr();
const response = await request.get(
`${API_URL}/api/admin/availability?from=${dateStr}&to=${dateStr}`,