diff --git a/examples/error_boundary/e2e/tests/clear_number.spec.ts b/examples/error_boundary/e2e/tests/clear_number.spec.ts index 2617d76183..890fe001f5 100644 --- a/examples/error_boundary/e2e/tests/clear_number.spec.ts +++ b/examples/error_boundary/e2e/tests/clear_number.spec.ts @@ -6,6 +6,7 @@ test.describe("Clear Number", () => { const ui = new HomePage(page); await ui.goto(); + await ui.enterValue("7"); await ui.clearInput(); await expect(ui.errorMessage).toHaveText("Not a number! Errors: "); @@ -14,6 +15,7 @@ test.describe("Clear Number", () => { const ui = new HomePage(page); await ui.goto(); + await ui.enterValue("7"); await ui.clearInput(); await expect(ui.errorList).toHaveText( diff --git a/examples/error_boundary/e2e/tests/click_down_arrow.spec.ts b/examples/error_boundary/e2e/tests/click_down_arrow.spec.ts deleted file mode 100644 index 6c41cda84b..0000000000 --- a/examples/error_boundary/e2e/tests/click_down_arrow.spec.ts +++ /dev/null @@ -1,17 +0,0 @@ -import { test, expect } from "@playwright/test"; -import { HomePage } from "./fixtures/home_page"; - -test.describe("Click Down Arrow", () => { - test("should see the negative number", async ({ page }) => { - const ui = new HomePage(page); - await ui.goto(); - - await ui.clickDownArrow(); - await ui.clickDownArrow(); - await ui.clickDownArrow(); - await ui.clickDownArrow(); - await ui.clickDownArrow(); - - await expect(ui.successMessage).toHaveText("You entered -5"); - }); -}); diff --git a/examples/error_boundary/e2e/tests/click_up_arrow.spec.ts b/examples/error_boundary/e2e/tests/click_up_arrow.spec.ts deleted file mode 100644 index d8d10260a4..0000000000 --- a/examples/error_boundary/e2e/tests/click_up_arrow.spec.ts +++ /dev/null @@ -1,15 +0,0 @@ -import { test, expect } from "@playwright/test"; -import { HomePage } from "./fixtures/home_page"; - -test.describe("Click Up Arrow", () => { - test("should see the positive number", async ({ page }) => { - const ui = new HomePage(page); - await ui.goto(); - - await ui.clickUpArrow(); - await ui.clickUpArrow(); - await ui.clickUpArrow(); - - await expect(ui.successMessage).toHaveText("You entered 3"); - }); -}); diff --git a/examples/error_boundary/e2e/tests/fixtures/home_page.ts b/examples/error_boundary/e2e/tests/fixtures/home_page.ts index bf46af7ae3..c18636106a 100644 --- a/examples/error_boundary/e2e/tests/fixtures/home_page.ts +++ b/examples/error_boundary/e2e/tests/fixtures/home_page.ts @@ -3,7 +3,7 @@ import { expect, Locator, Page } from "@playwright/test"; export class HomePage { readonly page: Page; readonly pageTitle: Locator; - readonly numberInput: Locator; + readonly valueInput: Locator; readonly successMessage: Locator; readonly errorMessage: Locator; @@ -13,7 +13,7 @@ export class HomePage { this.page = page; this.pageTitle = page.locator("h1"); - this.numberInput = page.getByLabel( + this.valueInput = page.getByLabel( "Type a number (or something that's not a number!)" ); this.successMessage = page.locator("label p"); @@ -25,32 +25,17 @@ export class HomePage { await this.page.goto("/"); } - async enterNumber(count: string, index: number = 0) { + async enterValue(value: string) { await Promise.all([ - this.numberInput.waitFor(), - this.numberInput.fill(count), - ]); - } - - async clickUpArrow() { - await Promise.all([ - this.numberInput.waitFor(), - this.numberInput.press("ArrowUp"), - ]); - } - - async clickDownArrow() { - await Promise.all([ - this.numberInput.waitFor(), - this.numberInput.press("ArrowDown"), + this.valueInput.waitFor(), + this.valueInput.fill(value), ]); } async clearInput() { await Promise.all([ - this.numberInput.waitFor(), - this.clickUpArrow(), - this.numberInput.press("Backspace"), + this.valueInput.waitFor(), + this.valueInput.press("Backspace"), ]); } } diff --git a/examples/error_boundary/e2e/tests/type_number.spec.ts b/examples/error_boundary/e2e/tests/type_number.spec.ts index da02dbb15b..31210fa02f 100644 --- a/examples/error_boundary/e2e/tests/type_number.spec.ts +++ b/examples/error_boundary/e2e/tests/type_number.spec.ts @@ -6,7 +6,7 @@ test.describe("Type Number", () => { const ui = new HomePage(page); await ui.goto(); - await ui.enterNumber("7"); + await ui.enterValue("7"); await expect(ui.successMessage).toHaveText("You entered 7"); }); diff --git a/examples/error_boundary/e2e/tests/type_string.spec.ts b/examples/error_boundary/e2e/tests/type_string.spec.ts new file mode 100644 index 0000000000..1732e85abb --- /dev/null +++ b/examples/error_boundary/e2e/tests/type_string.spec.ts @@ -0,0 +1,23 @@ +import { test, expect } from "@playwright/test"; +import { HomePage } from "./fixtures/home_page"; + +test.describe("Type String", () => { + test("should see the error message", async ({ page }) => { + const ui = new HomePage(page); + await ui.goto(); + + await ui.enterValue("leptos"); + + await expect(ui.errorMessage).toHaveText("Not a number! Errors: "); + }); + test("should see the error list", async ({ page }) => { + const ui = new HomePage(page); + await ui.goto(); + + await ui.enterValue("leptos"); + + await expect(ui.errorList).toHaveText( + "invalid digit found in string" + ); + }); +}); diff --git a/examples/error_boundary/src/lib.rs b/examples/error_boundary/src/lib.rs index 9dea35c450..e6c1e70227 100644 --- a/examples/error_boundary/src/lib.rs +++ b/examples/error_boundary/src/lib.rs @@ -11,7 +11,7 @@ pub fn App() -> impl IntoView {

"Error Handling"