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

Bug report: Calling navigate more than once causes 404 error #12853

Open
wants to merge 2 commits 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 @@ -41,6 +41,7 @@
- ayushmanchhabra
- babafemij-k
- barclayd
- Bastian
- bavardage
- bbrowning918
- BDomzalski
Expand Down
20 changes: 16 additions & 4 deletions integration/bug-report-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -59,14 +59,22 @@ test.beforeAll(async () => {
////////////////////////////////////////////////////////////////////////////
files: {
"app/routes/_index.tsx": js`
import { useLoaderData, Link } from "react-router";
import { useEffect } from "react";
import { useLoaderData, Link, useNavigate } from "react-router";

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

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

const navigate = useNavigate();
useEffect(() => {
navigate("/burgers");
navigate("/burgers");
}, []);

return (
<div>
{data}
Expand Down Expand Up @@ -97,16 +105,20 @@ test.afterAll(() => {
// add a good description for what you expect Remix to do 👇🏽
////////////////////////////////////////////////////////////////////////////////

test("[description of what you expect it to do]", async ({ page }) => {
test("should not show 404 page on multiple navigate calls", 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");

// If you need to test interactivity use the `app`
await app.goto("/");
await app.clickLink("/burgers");
await page.waitForSelector("text=cheeseburger");
await page.waitForURL("**/burgers");
// await app.poke(20);
await expect(page.locator("text=Not Found")).not.toBeVisible();
await expect(page.locator("text=cheeseburger")).toBeVisible();

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