Skip to content

WIP: refactor router tests#15510

Draft
matthewp wants to merge 3 commits intomainfrom
refactor-analysis
Draft

WIP: refactor router tests#15510
matthewp wants to merge 3 commits intomainfrom
refactor-analysis

Conversation

@matthewp
Copy link
Contributor

Summary

  • add a Router abstraction with unit tests covering routing priority and base/trailingSlash behavior
  • refactor route manifest creation to accept in-memory entries for unit testing
  • migrate routing integration tests to routing unit suites and remove user-route-priority fixture

Testing

  • pnpm run build
  • pnpm -C packages/astro exec astro-scripts test "test/units/routing/**/*.test.js" --teardown ./test/units/teardown.js

@changeset-bot
Copy link

changeset-bot bot commented Feb 13, 2026

⚠️ No Changeset found

Latest commit: c1379e4

Merging this PR will not cause a version bump for any packages. If these changes should not result in a new version, you're good to go. If these changes should result in a version bump, you need to add a changeset.

Click here to learn what changesets are, and how to add one.

Click here if you're a maintainer who wants to add a changeset to this PR

@github-actions github-actions bot added the pkg: astro Related to the core `astro` package (scope) label Feb 13, 2026

private createRouter(manifestData: RoutesList): Router {
return new Router(manifestData.routes, {
base: '/',
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is not correct

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should be in the manifest I think.

const staticPart = (content) => ({ content, dynamic: false, spread: false });
const dynamicPart = (content) => ({ content, dynamic: true, spread: false });

const makeRoute = ({ segments, trailingSlash, route, pathname, isIndex = false }) => {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These helpers are repeated in every test. Should this be in core routing as a utility? Is this something it would use?

Or should we have a Route type that you can do like Route.parse("/blog/[id]/post.astro") or something?

If none of the above, should these helpers be in a like a local test-helpers file?

@codspeed-hq
Copy link

codspeed-hq bot commented Feb 13, 2026

Merging this PR will degrade performance by 10.5%

❌ 1 regressed benchmark
✅ 8 untouched benchmarks

⚠️ Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation Build: hybrid site (static + server) 7.7 s 8.6 s -10.5%

Comparing refactor-analysis (c1379e4) with main (2c6484a)

Open in CodSpeed

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

pkg: astro Related to the core `astro` package (scope)

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant