From e3ae80a14eacca2a64d7081d7be806f3e0f889c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Clovis=20Ram=C3=ADrez?= Date: Wed, 11 Dec 2024 12:01:04 -0400 Subject: [PATCH] Add test case for returning http204 --- contributors.yml | 1 + integration/bug-report-test.ts | 26 ++++++++++++++++---------- 2 files changed, 17 insertions(+), 10 deletions(-) diff --git a/contributors.yml b/contributors.yml index 0afaae5a09..ca6c1dca11 100644 --- a/contributors.yml +++ b/contributors.yml @@ -316,3 +316,4 @@ - yuleicul - zeromask1337 - zheng-chuang +- clovis1122 diff --git a/integration/bug-report-test.ts b/integration/bug-report-test.ts index 5e272b897a..98bc54a880 100644 --- a/integration/bug-report-test.ts +++ b/integration/bug-report-test.ts @@ -59,28 +59,28 @@ test.beforeAll(async () => { //////////////////////////////////////////////////////////////////////////// files: { "app/routes/_index.tsx": js` - import { useLoaderData, Link } from "react-router"; + import { useLoaderData, Form, Link } from "react-router"; export function loader() { return "pizza"; } + export function action() { + return new Response(null, { status: 204 }); + } + export default function Index() { let data = useLoaderData(); return (
{data} - Other Route +
+ +
) } `, - - "app/routes/burgers.tsx": js` - export default function Index() { - return
cheeseburger
; - } - `, }, }); @@ -99,14 +99,20 @@ test.afterAll(() => { test("[description of what you expect it to do]", async ({ page }) => { let app = new PlaywrightFixture(appFixture, page); + + page.on("console", (message) => { + if (message.type() === "error") { + throw new Error(message.text()); + } + }); + // You can test any request your app might get using `fixture`. let response = await fixture.requestDocument("/"); expect(await response.text()).toMatch("pizza"); // If you need to test interactivity use the `app` await app.goto("/"); - await app.clickLink("/burgers"); - await page.waitForSelector("text=cheeseburger"); + await app.clickElement('button[type="submit"]'); // If you're not sure what's going on, you can "poke" the app, it'll // automatically open up in your browser for 20 seconds, so be quick!