From bf1e42a4988446c96b302ba8870e17997bfdd36d Mon Sep 17 00:00:00 2001 From: counterweight Date: Sun, 21 Dec 2025 19:04:38 +0100 Subject: [PATCH] fixes --- .gitignore | 1 + frontend/e2e/booking.spec.ts | 74 +++++++++++++++++++++------- frontend/test-results/.last-run.json | 6 ++- 3 files changed, 60 insertions(+), 21 deletions(-) diff --git a/.gitignore b/.gitignore index 8da6201..e11478a 100644 --- a/.gitignore +++ b/.gitignore @@ -9,6 +9,7 @@ uv.lock node_modules/ .next/ .turbo/ +test-results/ # Env .env diff --git a/frontend/e2e/booking.spec.ts b/frontend/e2e/booking.spec.ts index 1234af2..58d697c 100644 --- a/frontend/e2e/booking.spec.ts +++ b/frontend/e2e/booking.spec.ts @@ -81,11 +81,34 @@ test.describe("Booking Page - Regular User Access", () => { }); test("selecting date shows slots section", async ({ page }) => { + // First set up availability for tomorrow so we have an enabled date + await clearAuth(page); + await loginUser(page, ADMIN_USER.email, ADMIN_USER.password); + await setAvailability(page, getTomorrowDateStr()); + await clearAuth(page); + await loginUser(page, REGULAR_USER.email, REGULAR_USER.password); + await page.goto("/booking"); - // Click first date button - const dateButton = page.locator("button").filter({ hasText: /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)/ }).first(); - await dateButton.click(); + // Wait for availability check to complete + await page.waitForTimeout(2000); + + // Find an enabled date button (one with availability) + const dateButtons = page.locator("button").filter({ hasText: /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)/ }); + let enabledButton = null; + const buttonCount = await dateButtons.count(); + for (let i = 0; i < buttonCount; i++) { + const button = dateButtons.nth(i); + const isDisabled = await button.isDisabled().catch(() => true); + if (!isDisabled) { + enabledButton = button; + break; + } + } + + // Should have at least one enabled date (tomorrow) + expect(enabledButton).not.toBeNull(); + await enabledButton!.click(); // Should show Available Slots section (use heading to be specific) await expect(page.getByRole("heading", { name: /Available Slots for/ })).toBeVisible(); @@ -94,25 +117,38 @@ test.describe("Booking Page - Regular User Access", () => { test("shows no slots or message when no availability", async ({ page }) => { await page.goto("/booking"); - // Click a date button - pick a date far in the future to avoid any set availability + // Wait for date buttons to load and availability check to complete + await page.waitForTimeout(2000); + + // Find an enabled date button (one that has availability or is still loading) + // If all dates are disabled, we can't test clicking, so verify disabled state const dateButtons = page.locator("button").filter({ hasText: /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun)/ }); - // Click the last date button (30 days out, unlikely to have availability) - await dateButtons.last().click(); + const enabledButtons = dateButtons.filter({ hasNotText: /disabled/ }); + const enabledCount = await enabledButtons.count(); - // Wait for the section to appear - await expect(page.getByRole("heading", { name: /Available Slots for/ })).toBeVisible(); - - // Should either show no slots message OR show no slot buttons - // Wait a moment for API to return - await page.waitForTimeout(1000); - - // If no availability is set, we'll see the "No available slots" message - const noSlotsMessage = page.getByText("No available slots for this date"); - const isNoSlotsVisible = await noSlotsMessage.isVisible().catch(() => false); - - if (!isNoSlotsVisible) { - // There might be some slots from shared state - just verify the section loads + if (enabledCount > 0) { + // Click the first enabled date button + await enabledButtons.first().click(); + + // Wait for the section to appear await expect(page.getByRole("heading", { name: /Available Slots for/ })).toBeVisible(); + + // Should either show no slots message OR show no slot buttons + // Wait a moment for API to return + await page.waitForTimeout(1000); + + // If no availability is set, we'll see the "No available slots" message + const noSlotsMessage = page.getByText("No available slots for this date"); + const isNoSlotsVisible = await noSlotsMessage.isVisible().catch(() => false); + + if (!isNoSlotsVisible) { + // There might be some slots from shared state - just verify the section loads + await expect(page.getByRole("heading", { name: /Available Slots for/ })).toBeVisible(); + } + } else { + // All dates are disabled - verify that disabled dates are shown + const disabledButtons = dateButtons.filter({ hasText: /disabled/ }); + await expect(disabledButtons.first()).toBeDisabled(); } }); }); diff --git a/frontend/test-results/.last-run.json b/frontend/test-results/.last-run.json index cbcc1fb..25562fa 100644 --- a/frontend/test-results/.last-run.json +++ b/frontend/test-results/.last-run.json @@ -1,4 +1,6 @@ { - "status": "passed", - "failedTests": [] + "status": "failed", + "failedTests": [ + "50879ed375f8988ef978-f750653a4c0921ce483e" + ] } \ No newline at end of file