Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test case for returning responses without body (like HTTP204) #12524

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions contributors.yml
Original file line number Diff line number Diff line change
Expand Up @@ -316,3 +316,4 @@
- yuleicul
- zeromask1337
- zheng-chuang
- clovis1122
26 changes: 16 additions & 10 deletions integration/bug-report-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 (
<div>
{data}
<Link to="/burgers">Other Route</Link>
<Form method="POST">
<button type="submit">Submit</button>
</Form>
</div>
)
}
`,

"app/routes/burgers.tsx": js`
export default function Index() {
return <div>cheeseburger</div>;
}
`,
},
});

Expand All @@ -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!
Expand Down
Loading