-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #62 from vordgi/get-61
get-56 improve intercepted routes parsing in get-params
- Loading branch information
Showing
10 changed files
with
155 additions
and
26 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
14 changes: 0 additions & 14 deletions
14
tests/nextjs-app/app/(frontend)/(corporate)/groups/groups.spec.ts
This file was deleted.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { getPathname } from "@nimpl/getters/get-pathname"; | ||
import { getParams } from "@nimpl/getters/get-params"; | ||
import Nav from "../../../components/Nav"; | ||
|
||
export default function Page() { | ||
const pathname = getPathname(); | ||
const params = getParams(); | ||
|
||
return ( | ||
<div id="intercepted-page"> | ||
<Nav /> | ||
<div> | ||
<p id="intercepted-get-pathname">{pathname}</p> | ||
<p id="intercepted-get-params">{JSON.stringify(params)}</p> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { test, expect } from "@playwright/test"; | ||
|
||
test("should return correct page params and pathname for nested groups", async ({ page }) => { | ||
await page.goto("/groups"); | ||
page.waitForSelector("#groups-page"); | ||
|
||
const pathname = await page.$("#get-pathname"); | ||
const pathnameRow = await pathname?.textContent(); | ||
expect(pathnameRow).toEqual("/groups"); | ||
|
||
const params = await page.$("#get-params"); | ||
const paramsRow = await params?.textContent(); | ||
expect(paramsRow && JSON.parse(paramsRow)).toEqual({}); | ||
}); | ||
|
||
test("should return correct page params and pathname for intercepting route", async ({ page }) => { | ||
await page.goto("/intercepted"); | ||
page.waitForSelector("#intercepted-page"); | ||
|
||
const pathname = await page.$("#get-pathname"); | ||
const pathnameRow = await pathname?.textContent(); | ||
expect(pathnameRow).toEqual("/intercepted"); | ||
|
||
const params = await page.$("#get-params"); | ||
const paramsRow = await params?.textContent(); | ||
expect(paramsRow && JSON.parse(paramsRow)).toEqual({}); | ||
}); | ||
|
||
test("should return correct page params and pathname for intercepted route", async ({ page }) => { | ||
await page.goto("/"); | ||
await page.waitForSelector("#home-page"); | ||
page.click("#to-intercepted"); | ||
await page.waitForSelector("#intercepted-page"); | ||
|
||
const pathname = await page.$("#intercepted-get-pathname"); | ||
const pathnameRow = await pathname?.textContent(); | ||
expect(pathnameRow).toEqual("/intercepted"); | ||
|
||
const params = await page.$("#intercepted-get-params"); | ||
const paramsRow = await params?.textContent(); | ||
expect(paramsRow && JSON.parse(paramsRow)).toEqual({}); | ||
}); | ||
|
||
test("should return correct page params and pathname for nested intercepted route", async ({ page }) => { | ||
await page.goto("/nested"); | ||
await page.waitForSelector("#nested-page"); | ||
page.click("#to-nested-intercepted"); | ||
await page.waitForSelector("#nested-intercepted-page"); | ||
|
||
const pathname = await page.$("#intercepted-get-pathname"); | ||
const pathnameRow = await pathname?.textContent(); | ||
expect(pathnameRow).toEqual("/nested-intercepted"); | ||
|
||
const params = await page.$("#intercepted-get-params"); | ||
const paramsRow = await params?.textContent(); | ||
expect(paramsRow && JSON.parse(paramsRow)).toEqual({}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { getPathname } from "@nimpl/getters/get-pathname"; | ||
import { getParams } from "@nimpl/getters/get-params"; | ||
|
||
export default function Page() { | ||
const pathname = getPathname(); | ||
const params = getParams(); | ||
|
||
return ( | ||
<div id="intercepted-page"> | ||
<div> | ||
<p id="get-pathname">{pathname}</p> | ||
<p id="get-params">{JSON.stringify(params)}</p> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
import { getPathname } from "@nimpl/getters/get-pathname"; | ||
import { getParams } from "@nimpl/getters/get-params"; | ||
|
||
export default function Page() { | ||
const pathname = getPathname(); | ||
const params = getParams(); | ||
|
||
return ( | ||
<div id="nested-intercepted-page"> | ||
<div> | ||
<p id="get-pathname">{pathname}</p> | ||
<p id="get-params">{JSON.stringify(params)}</p> | ||
</div> | ||
</div> | ||
); | ||
} |
18 changes: 18 additions & 0 deletions
18
tests/nextjs-app/app/(group1)/nested/(..)nested-intercepted/page.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import { getPathname } from "@nimpl/getters/get-pathname"; | ||
import { getParams } from "@nimpl/getters/get-params"; | ||
import Nav from "../../../../components/Nav"; | ||
|
||
export default function Page() { | ||
const pathname = getPathname(); | ||
const params = getParams(); | ||
|
||
return ( | ||
<div id="nested-intercepted-page"> | ||
<Nav /> | ||
<div> | ||
<p id="intercepted-get-pathname">{pathname}</p> | ||
<p id="intercepted-get-params">{JSON.stringify(params)}</p> | ||
</div> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
import Nav from "../../../components/Nav"; | ||
|
||
export default function Page() { | ||
return ( | ||
<div id="nested-page"> | ||
<Nav /> | ||
</div> | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,20 @@ | ||
import Link from "next/link"; | ||
|
||
export default function Nav() { | ||
return ( | ||
<nav> | ||
<Link href="/dynamic/auto">dynamic/auto</Link> | ||
</nav> | ||
); | ||
return ( | ||
<nav> | ||
<Link href="/dynamic/auto" id="to-dynamic-auto"> | ||
dynamic/auto | ||
</Link> | ||
<Link href="/intercepted" id="to-intercepted"> | ||
intercepted | ||
</Link> | ||
<Link href="/nested" id="to-nested"> | ||
nested | ||
</Link> | ||
<Link href="/nested-intercepted" id="to-nested-intercepted"> | ||
nested-intercepted | ||
</Link> | ||
</nav> | ||
); | ||
} |