Skip to content
Closed
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
35 changes: 18 additions & 17 deletions integration/bug-report-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,28 +49,27 @@ test.beforeAll(async () => {
files: {
"app/routes/index.jsx": js`
import { json } from "@remix-run/node";
import { useLoaderData, Link } from "@remix-run/react";
import { useActionData, Link } from "@remix-run/react";

export let action = async ({ request }) => {
const fdata = await request.formData();

export function loader() {
return json("pizza");
}
};

export default function Index() {
let data = useLoaderData();
const data = useActionData();

return (
<div>
<form method="post" action="/?index" encType="multipart/form-data">
My Form
{data}
<Link to="/burgers">Other Route</Link>
</div>
<input type="file" name="test" />
<button type="submit">Submit</button>
</form>
)
}
`,

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

Expand All @@ -85,16 +84,18 @@ test.afterAll(async () => appFixture.close());
// add a good description for what you expect Remix to do 👇🏽
////////////////////////////////////////////////////////////////////////////////

test("[description of what you expect it to do]", async ({ page }) => {
test("request.formData() should not crash when a file is not provided", async ({ page }) => {
let app = new PlaywrightFixture(appFixture, page);
// You can test any request your app might get using `fixture`.
let response = await fixture.requestDocument("/");
expect(await response.text()).toMatch("pizza");
expect(await response.text()).toMatch("My Form");

// If you need to test interactivity use the `app`
await app.goto("/");
await app.clickLink("/burgers");
expect(await app.getHtml()).toMatch("cheeseburger");
await app.clickSubmitButton("/?index");

let html = await app.getHtml();
expect(html).toMatch("pizza");

// 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