fixes
This commit is contained in:
parent
f81e7a88bd
commit
bf1e42a498
3 changed files with 60 additions and 21 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
|
@ -9,6 +9,7 @@ uv.lock
|
|||
node_modules/
|
||||
.next/
|
||||
.turbo/
|
||||
test-results/
|
||||
|
||||
# Env
|
||||
.env
|
||||
|
|
|
|||
|
|
@ -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();
|
||||
if (enabledCount > 0) {
|
||||
// Click the first enabled date button
|
||||
await enabledButtons.first().click();
|
||||
|
||||
// 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
|
||||
// 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();
|
||||
}
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
{
|
||||
"status": "passed",
|
||||
"failedTests": []
|
||||
"status": "failed",
|
||||
"failedTests": [
|
||||
"50879ed375f8988ef978-f750653a4c0921ce483e"
|
||||
]
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue