|
| 1 | +import { expect, test } from "@playwright/test"; |
| 2 | + |
| 3 | +test.describe("URL Query Parameter Persistence", () => { |
| 4 | + test.use({ storageState: { cookies: [], origins: [] } }); |
| 5 | + |
| 6 | + test("should update URL when switching tabs on item price list", async ({ |
| 7 | + page, |
| 8 | + }) => { |
| 9 | + await page.goto("/item-price-list"); |
| 10 | + await page.locator("table tbody tr").first().waitFor(); |
| 11 | + |
| 12 | + // Initial URL should not have tab parameter (default tab) |
| 13 | + expect(page.url()).not.toContain("tab="); |
| 14 | + |
| 15 | + // Click auction item tab |
| 16 | + await page.getByRole("tab", { name: "경매장 아이템" }).click(); |
| 17 | + await page.locator("table tbody tr").first().waitFor(); |
| 18 | + |
| 19 | + // URL should now contain tab=auction-item |
| 20 | + expect(page.url()).toContain("tab=auction-item"); |
| 21 | + }); |
| 22 | + |
| 23 | + test("should persist tab selection after page refresh", async ({ page }) => { |
| 24 | + // Navigate directly to auction item tab |
| 25 | + await page.goto("/item-price-list?tab=auction-item"); |
| 26 | + await page.locator("table tbody tr").first().waitFor(); |
| 27 | + |
| 28 | + // Verify auction item tab is selected |
| 29 | + await expect( |
| 30 | + page.getByRole("tab", { name: "경매장 아이템" }) |
| 31 | + ).toHaveAttribute("aria-selected", "true"); |
| 32 | + |
| 33 | + // Refresh page |
| 34 | + await page.reload(); |
| 35 | + await page.locator("table tbody tr").first().waitFor(); |
| 36 | + |
| 37 | + // Tab should still be selected after refresh |
| 38 | + await expect( |
| 39 | + page.getByRole("tab", { name: "경매장 아이템" }) |
| 40 | + ).toHaveAttribute("aria-selected", "true"); |
| 41 | + expect(page.url()).toContain("tab=auction-item"); |
| 42 | + }); |
| 43 | + |
| 44 | + test("should persist extra item tab selection", async ({ page }) => { |
| 45 | + await page.goto("/item-price-list"); |
| 46 | + await page.locator("table tbody tr").first().waitFor(); |
| 47 | + |
| 48 | + // Click extra item tab |
| 49 | + await page.getByRole("tab", { name: "기타 아이템" }).click(); |
| 50 | + |
| 51 | + // URL should contain tab=extra-item |
| 52 | + await expect(async () => { |
| 53 | + expect(page.url()).toContain("tab=extra-item"); |
| 54 | + }).toPass({ timeout: 5000 }); |
| 55 | + |
| 56 | + // Verify extra item tab is selected |
| 57 | + await expect( |
| 58 | + page.getByRole("tab", { name: "기타 아이템" }) |
| 59 | + ).toHaveAttribute("aria-selected", "true"); |
| 60 | + }); |
| 61 | +}); |
0 commit comments