test(solid): add params.spec.ts to start/router #5617
Mergedbirkskyum(GitHub profile, opens in a new tab)merged 3 commits into
main fromrefs/pull/5617/headmerged by birkskyum(GitHub profile, opens in a new tab) birkskyum(GitHub profile, opens in a new tab) closed this
- e2e/solid-router/basic/src/main.tsx lines 288 to 292@@ -209,0 +272,21 @@272+ </li>273+ <li>274+ <Link275+ data-testid="l-to-wildcard-foosuffix"276+ to="/params-ps/wildcard/{$}suffix"277+ params={{ _splat: 'foo' }}278+ >279+ /params-ps/wildcard/{'{$}suffix'}280+ </Link>281+ </li>282+ </ul>283+ </div>284+ )285+ },286+})287+288+const paramsPsNamedRoute = createRoute({289+ getParentRoute: () => paramsPsRoute,290+ path: '/named',291+})292+e2e/solid-router/basic/src/main.tsx lines 301 to 313@@ -209,0 +293,21 @@293+const paramsPsNamedIndexRoute = createRoute({294+ getParentRoute: () => paramsPsNamedRoute,295+ path: '/',296+ beforeLoad: () => {297+ throw redirect({ to: '/params-ps' })298+ },299+})300+301+const paramsPsNamedFooRoute = createRoute({302+ getParentRoute: () => paramsPsNamedRoute,303+ path: '/$foo',304+ component: function ParamsNamedFoo() {305+ const p = paramsPsNamedFooRoute.useParams()306+ return (307+ <div>308+ <h3>ParamsNamedFoo</h3>309+ <div data-testid="params-output">{JSON.stringify(p())}</div>310+ </div>311+ )312+ },313+})e2e/solid-router/basic/src/main.tsx lines 315 to 327@@ -209,0 +307,21 @@307+ <div>308+ <h3>ParamsNamedFoo</h3>309+ <div data-testid="params-output">{JSON.stringify(p())}</div>310+ </div>311+ )312+ },313+})314+315+const paramsPsNamedFooPrefixRoute = createRoute({316+ getParentRoute: () => paramsPsNamedRoute,317+ path: '/prefix{$foo}',318+ component: function ParamsNamedFooMarkdown() {319+ const p = paramsPsNamedFooPrefixRoute.useParams()320+ return (321+ <div>322+ <h3>ParamsNamedFooPrefix</h3>323+ <div data-testid="params-output">{JSON.stringify(p())}</div>324+ </div>325+ )326+ },327+})e2e/solid-router/basic/src/main.tsx lines 329 to 341@@ -209,0 +321,21 @@321+ <div>322+ <h3>ParamsNamedFooPrefix</h3>323+ <div data-testid="params-output">{JSON.stringify(p())}</div>324+ </div>325+ )326+ },327+})328+329+const paramsPsNamedFooSuffixRoute = createRoute({330+ getParentRoute: () => paramsPsNamedRoute,331+ path: '/{$foo}suffix',332+ component: function ParamsNamedFooSuffix() {333+ const p = paramsPsNamedFooSuffixRoute.useParams()334+ return (335+ <div>336+ <h3>ParamsNamedFooSuffix</h3>337+ <div data-testid="params-output">{JSON.stringify(p())}</div>338+ </div>339+ )340+ },341+})e2e/solid-router/basic/src/main.tsx lines 343 to 346@@ -209,0 +326,21 @@326+ },327+})328+329+const paramsPsNamedFooSuffixRoute = createRoute({330+ getParentRoute: () => paramsPsNamedRoute,331+ path: '/{$foo}suffix',332+ component: function ParamsNamedFooSuffix() {333+ const p = paramsPsNamedFooSuffixRoute.useParams()334+ return (335+ <div>336+ <h3>ParamsNamedFooSuffix</h3>337+ <div data-testid="params-output">{JSON.stringify(p())}</div>338+ </div>339+ )340+ },341+})342+343+const paramsPsWildcardRoute = createRoute({344+ getParentRoute: () => paramsPsRoute,345+ path: '/wildcard',346+})e2e/solid-router/basic/src/main.tsx lines 403 to 417@@ -210,5 +397,21 @@397+210398 const routeTree = rootRoute.addChildren([211399 postsRoute.addChildren([postRoute, postsIndexRoute]),212400 layoutRoute.addChildren([213401 layout2Route.addChildren([layoutARoute, layoutBRoute]),214402 ]),403+ paramsPsRoute.addChildren([404+ paramsPsNamedRoute.addChildren([405+ paramsPsNamedFooPrefixRoute,406+ paramsPsNamedFooSuffixRoute,407+ paramsPsNamedFooRoute,408+ paramsPsNamedIndexRoute,409+ ]),410+ paramsPsWildcardRoute.addChildren([411+ paramsPsWildcardSplatRoute,412+ paramsPsWildcardSplatPrefixRoute,413+ paramsPsWildcardSplatSuffixRoute,414+ paramsPsWildcardIndexRoute,415+ ]),416+ paramsPsIndexRoute,417+ ]),
Sign in to join this conversation.
Walkthrough#
Adds E2E Playwright tests for named and wildcard route parameters and a Unicode route, plus new route files and generated route-tree entries registering the Unicode path "/대한민국" in two e2e fixtures.
Changes#
e2e/solid-router/basic/tests/params.spec.tse2e/solid-start/basic/tests/params.spec.ts/대한민국, asserting rendered text and that the URL is percent-encoded as expected.e2e/solid-router/basic-file-based/src/routeTree.gen.ts,e2e/solid-start/basic/src/routeTree.gen.ts/대한민국, updating FileRoutesByFullPath/FileRoutesByTo/FileRoutesById unions, RootRouteChildren, module augmentation and wiring the route into the root children map.e2e/solid-router/basic-file-based/src/routes/대한민국.tsx,e2e/solid-start/basic/src/routes/대한민국.tsxRouteviacreateFileRoute('/대한민국')and aRouteComponentrenderingHello "/대한민국"!.e2e/solid-router/basic/src/main.tsxredirect), and components usinguseParamsto render params andparams-output.Sequence Diagram(s)#
Estimated code review effort#
🎯 3 (Moderate) | ⏱️ ~20–30 minutes
/대한민국._splat/*mappings).Possibly related PRs#
Suggested labels#
package: solid-routerSuggested reviewers#
Poem#
Pre-merge checks and finishing touches#
❌ Failed checks (1 warning)
@coderabbitai generate docstringsto improve docstring coverage.✅ Passed checks (2 passed)
e2e/solid-router/basic/tests/params.spec.tsande2e/solid-start/basic/tests/params.spec.ts. The title accurately identifies these test files as the primary focus. However, the changeset also includes substantial supporting implementation work, including a comprehensive params route subtree ine2e/solid-router/basic/src/main.tsx(estimated HIGH code review effort) and Unicode route support files. While the supporting code is necessary infrastructure for the tests, the title focuses narrowly on the test file additions and does not reflect the significant route structure implementation work also included in this PR.✨ Finishing touches
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.
❤️ Share