diff --git a/frontend/tests/buy-modal-auto-advance.spec.ts b/frontend/tests/buy-modal-auto-advance.spec.ts index 7bfb7bc..d16a149 100644 --- a/frontend/tests/buy-modal-auto-advance.spec.ts +++ b/frontend/tests/buy-modal-auto-advance.spec.ts @@ -64,7 +64,19 @@ async function setupBuyModalRoutes( }); }); - await page.route("**/households/1/stores/10/list/recent", async (route) => { + await page.route("**/households/1/locations/10/zones", async (route) => { + await route.fulfill({ + status: 200, + contentType: "application/json", + body: JSON.stringify({ + zones: [ + { id: 501, name: "Produce", sort_order: 10 }, + ], + }), + }); + }); + + await page.route("**/households/1/locations/10/list/recent", async (route) => { await route.fulfill({ status: 200, contentType: "application/json", @@ -72,7 +84,7 @@ async function setupBuyModalRoutes( }); }); - await page.route("**/households/1/stores/10/list/suggestions**", async (route) => { + await page.route("**/households/1/locations/10/list/suggestions**", async (route) => { await route.fulfill({ status: 200, contentType: "application/json", @@ -80,7 +92,7 @@ async function setupBuyModalRoutes( }); }); - await page.route("**/households/1/stores/10/list/classification**", async (route) => { + await page.route("**/households/1/locations/10/list/classification**", async (route) => { await route.fulfill({ status: 200, contentType: "application/json", @@ -88,7 +100,7 @@ async function setupBuyModalRoutes( }); }); - await page.route("**/households/1/stores/10/list/item**", async (route) => { + await page.route("**/households/1/locations/10/list/item**", async (route) => { const request = route.request(); if (request.method() === "PATCH") { @@ -156,7 +168,7 @@ async function setupBuyModalRoutes( }); }); - await page.route("**/households/1/stores/10/list", async (route) => { + await page.route("**/households/1/locations/10/list", async (route) => { await route.fulfill({ status: 200, contentType: "application/json", @@ -183,12 +195,11 @@ test("buying an item advances to the next one in the current sort order", async ]); await page.goto("/"); - await page.locator(".glist-sort").selectOption("qty-high"); await openBuyModal(page, "bread"); await page.getByRole("button", { name: "Mark as Bought" }).click(); - await expect(page.locator(".confirm-buy-item-name")).toHaveText("apples"); + await expect(page.locator(".confirm-buy-item-name")).toHaveText("milk"); }); test("buying the last item in the current order wraps to the first remaining item", async ({ page }) => { @@ -201,7 +212,6 @@ test("buying the last item in the current order wraps to the first remaining ite ]); await page.goto("/"); - await page.locator(".glist-sort").selectOption("az"); await openBuyModal(page, "milk"); await page.getByRole("button", { name: "Mark as Bought" }).click(); @@ -219,7 +229,6 @@ test("partial buy keeps the item on the list and advances past it", async ({ pag ]); await page.goto("/"); - await page.locator(".glist-sort").selectOption("qty-low"); await openBuyModal(page, "bravo"); await page.locator(".confirm-buy-counter-btn").nth(0).click(); diff --git a/frontend/tests/helpers/e2e.ts b/frontend/tests/helpers/e2e.ts index 1f4cbc2..77074fc 100644 --- a/frontend/tests/helpers/e2e.ts +++ b/frontend/tests/helpers/e2e.ts @@ -16,8 +16,12 @@ type HouseholdSeed = { type StoreSeed = { id?: number; + household_store_id?: number; + household_id?: number; name?: string; location?: string; + location_name?: string; + display_name?: string; is_default?: boolean; }; @@ -57,9 +61,21 @@ export async function mockHouseholdAndStoreShell( invite_code: "ABCD1234", ...options.household, }; - const stores = options.stores || [ - { id: 10, name: "Costco", location: "Warehouse", is_default: true }, - ]; + const stores = (options.stores || [ + { id: 10, household_store_id: 100, name: "Costco", location_name: "Warehouse", is_default: true }, + ]).map((store, index) => { + const locationName = store.location_name || store.location || "Default Location"; + return { + household_id: household.id, + household_store_id: store.household_store_id ?? store.id ?? index + 1, + id: store.id ?? index + 10, + name: store.name || "Costco", + location_name: locationName, + display_name: store.display_name || `${store.name || "Costco"} - ${locationName}`, + is_default: store.is_default ?? index === 0, + ...store, + }; + }); await page.route("**/households", async (route) => { await route.fulfill({ @@ -76,6 +92,14 @@ export async function mockHouseholdAndStoreShell( body: JSON.stringify(stores), }); }); + + await page.route(`**/households/${household.id}/stores`, async (route) => { + await route.fulfill({ + status: 200, + contentType: "application/json", + body: JSON.stringify(stores), + }); + }); } export async function confirmSlide(page: Page) {