Skip to content

Commit

Permalink
add example test for phoenixframework#2656
Browse files Browse the repository at this point in the history
  • Loading branch information
SteffenDE committed Jan 10, 2024
1 parent b036e25 commit a1494b8
Show file tree
Hide file tree
Showing 2 changed files with 35 additions and 3 deletions.
3 changes: 2 additions & 1 deletion test/e2e/test_helper.exs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
35 changes: 33 additions & 2 deletions test/e2e/tests/streams.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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([
Expand Down Expand Up @@ -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([
Expand Down Expand Up @@ -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");
});
});

0 comments on commit a1494b8

Please sign in to comment.