;
}
`,
},
@@ -103,22 +98,24 @@ test.afterAll(() => {
// add a good description for what you expect React Router to do 👇🏽
////////////////////////////////////////////////////////////////////////////////
-test("[description of what you expect it to do]", async ({ page }) => {
+test("useParams should not decode param containing double-encoded forward slash", 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");
-
- // 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!
- // await app.poke(20);
+ const encodedId = encodeURIComponent(encodeURIComponent("beforeslash/afterslash@"));
+ await app.goto(`/use-params/${encodedId}`);
+ let el = page.locator("[data-testid='item-id']");
+ await expect(el).toHaveText(`Item ID: ${encodedId}`);
+});
- // Go check out the other tests to see what else you can do.
+test("matchPath should not decode param containing double-encoded forward slash", async ({
+ page,
+}) => {
+ let app = new PlaywrightFixture(appFixture, page);
+ const encodedId = encodeURIComponent(encodeURIComponent("beforeslash/afterslash@"));
+ await app.goto(`/match-path/${encodedId}`);
+ let el = page.locator("[data-testid='item-id']");
+ await expect(el).toHaveText(`Item ID: ${encodedId}`);
});
////////////////////////////////////////////////////////////////////////////////