From 06efcd8e7b536568e6a89c141a621350d589f151 Mon Sep 17 00:00:00 2001 From: cm-dyoshikawa <94024734+cm-dyoshikawa@users.noreply.github.com> Date: Thu, 5 Oct 2023 00:20:02 +0900 Subject: [PATCH] Add an e2e test about query parameters (#521) * feat: Be usable non-ladle query params * feat: move the query parameters example to e2e * fix: e2e tests * add click the menu and open the story case to e2e tests * Add resetParams to updateStory * Add an e2e test to query parameters * fix the test --- e2e/addons/tests/query-parameters.spec.ts | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/e2e/addons/tests/query-parameters.spec.ts b/e2e/addons/tests/query-parameters.spec.ts index 1886b3fe..5d8e7e3f 100644 --- a/e2e/addons/tests/query-parameters.spec.ts +++ b/e2e/addons/tests/query-parameters.spec.ts @@ -22,6 +22,22 @@ test("when click the menu and open the story, remain non-ladle query parameters" expect(url).toContain("foo=bar"); }); +test("when move a story from the query parameters story, remove non-ladle query parameters", async ({ + page, +}) => { + // Open the query parameters story + await page.goto("/?story=query-parameters--query-parameters"); + await page.waitForSelector("[data-storyloaded]"); + + // Open a some story + await page.getByText("A11y").click(); + await page.getByRole("link", { name: "Issues" }).click(); + await page.waitForSelector("[data-storyloaded]"); + const url = page.url(); + expect(url).toContain("story=a11y--issues"); + expect(url).not.toContain("foo=bar"); // The non-ladle query parameter is removed +}); + test("preserve user query params after ladle query param update", async ({ page, }) => {