Skip to content

Commit

Permalink
Add integration test
Browse files Browse the repository at this point in the history
  • Loading branch information
brophdawg11 committed Aug 22, 2023
1 parent 17261f2 commit 3c23a88
Showing 1 changed file with 49 additions and 0 deletions.
49 changes: 49 additions & 0 deletions integration/redirects-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,41 @@ test.describe("redirects", () => {
return redirect("https://remix.run/");
}
`,

"app/routes/redirect-document.tsx": js`
import * as React from "react";
import { Outlet } from "@remix-run/react";
export default function Component() {
let [count, setCount] = React.useState(0);
let countText = 'Count:' + count;
return (
<>
<button onClick={() => setCount(count+1)}>{countText}</button>
<Outlet />
</>
);
}
`,

"app/routes/redirect-document._index.tsx": js`
import { Link } from "@remix-run/react";
export default function Component() {
return <Link to="/redirect-document/a">Link</Link>
}
`,

"app/routes/redirect-document.a.tsx": js`
import { redirectDocument } from "@remix-run/node";
export const loader = () => redirectDocument("/redirect-document/b");
`,

"app/routes/redirect-document.b.tsx": js`
export default function Component() {
return <h1>Hello B!</h1>
}
`,
},
});

Expand Down Expand Up @@ -230,4 +265,18 @@ test.describe("redirects", () => {
await page.waitForSelector(`#app:has-text("Page 2")`);
await page.waitForSelector(`#count:has-text("3")`);
});

test("supports hard redirects within the app via reloadDocument", async ({
page,
}) => {
let app = new PlaywrightFixture(appFixture, page);
await app.goto("/redirect-document", true);
expect(await app.getHtml("button")).toMatch("Count:0");
await app.clickElement("button");
expect(await app.getHtml("button")).toMatch("Count:1");
await app.waitForNetworkAfter(() => app.clickLink("/redirect-document/a"));
await page.waitForSelector(`h1`);
// Hard reload resets client side react state
expect(await app.getHtml("button")).toMatch("Count:0");
});
});

0 comments on commit 3c23a88

Please # to comment.