From a1494b87311a92f46a02068ce9039b99d1fee4d3 Mon Sep 17 00:00:00 2001 From: Steffen Deusch Date: Wed, 10 Jan 2024 20:59:02 +0100 Subject: [PATCH] add example test for #2656 --- test/e2e/test_helper.exs | 3 ++- test/e2e/tests/streams.spec.js | 35 ++++++++++++++++++++++++++++++++-- 2 files changed, 35 insertions(+), 3 deletions(-) diff --git a/test/e2e/test_helper.exs b/test/e2e/test_helper.exs index 7724440d5c..42f7c8acaa 100644 --- a/test/e2e/test_helper.exs +++ b/test/e2e/test_helper.exs @@ -51,7 +51,8 @@ defmodule Phoenix.LiveViewTest.E2E.Router do scope "/" do pipe_through(:browser) - live("/stream", Phoenix.LiveViewTest.StreamLive, :index) + live "/stream", Phoenix.LiveViewTest.StreamLive + live "/healthy/:category", Phoenix.LiveViewTest.HealthyLive end end end diff --git a/test/e2e/tests/streams.spec.js b/test/e2e/tests/streams.spec.js index d5b3881c53..86fbffce7c 100644 --- a/test/e2e/tests/streams.spec.js +++ b/test/e2e/tests/streams.spec.js @@ -60,7 +60,7 @@ test("elements can be updated and deleted (LV)", async ({ page }) => { { id: "admins-2", text: "callan-admin" } ]); - await page.locator("#users-1").getByRole("button", { name: "Delete" }).click(); + await page.locator("#users-1").getByRole("button", { name: "delete" }).click(); await syncLV(page); await expect(await usersInDom(page, "users")).toEqual([ @@ -104,7 +104,7 @@ test("elements can be updated and deleted (LC)", async ({ page }) => { { id: "admins-2", text: "callan-admin" } ]); - await page.locator("#c_users-1").getByRole("button", { name: "Delete" }).click(); + await page.locator("#c_users-1").getByRole("button", { name: "delete" }).click(); await syncLV(page); await expect(await usersInDom(page, "c_users")).toEqual([ @@ -160,3 +160,34 @@ test("stream reset properly reorders items", async ({ page }) => { { id: "users-4", text: "mona" } ]); }); + +test.describe("Issue #2656", () => { + test("stream reset works when patching", async ({ page }) => { + await page.goto("/healthy/fruits"); + await syncLV(page); + + await expect(page.locator("h1")).toContainText("Fruits"); + await expect(page.locator("ul")).toContainText("Apples"); + await expect(page.locator("ul")).toContainText("Oranges"); + + await page.getByRole("link", { name: "Switch" }).click(); + await expect(page).toHaveURL("/healthy/veggies"); + await syncLV(page); + + await expect(page.locator("h1")).toContainText("Veggies"); + + await expect(page.locator("ul")).toContainText("Carrots"); + await expect(page.locator("ul")).toContainText("Tomatoes"); + await expect(page.locator("ul")).not.toContainText("Apples"); + await expect(page.locator("ul")).not.toContainText("Oranges"); + + await page.getByRole("link", { name: "Switch" }).click(); + await expect(page).toHaveURL("/healthy/fruits"); + await syncLV(page); + + await expect(page.locator("ul")).not.toContainText("Carrots"); + await expect(page.locator("ul")).not.toContainText("Tomatoes"); + await expect(page.locator("ul")).toContainText("Apples"); + await expect(page.locator("ul")).toContainText("Oranges"); + }); +});