Skip to content

Conversation

socsieng
Copy link
Contributor

@socsieng socsieng commented Oct 20, 2024

I split the change into two commits. One with the additional tests and another to rename the file.

Copy link

changeset-bot bot commented Oct 20, 2024

⚠️ No Changeset found

Latest commit: 6358c7c

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.

This PR includes no changesets

When changesets are added to this PR, you'll see the packages that this PR includes changesets for and the associated semver types

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

Copy link
Contributor

@conico974 conico974 left a comment

Choose a reason for hiding this comment

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

Sorry for the delay, just a few question/comment

it("returns url parts for /", () => {
expect(getUrlParts("/", false)).toEqual({
hostname: "",
pathname: "", // TODO: This behaviour is inconsistent with external pathname
Copy link
Contributor

Choose a reason for hiding this comment

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

What do you mean it's inconsistent ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

External pathnames start with / where internal ones don't. Examples:

  • Internal:
    • url: "/" -> pathname: ""
    • url: "/path" -> pathname: "path"
  • External:
    • url: "http://localhost/" -> pathname: "/"
    • url: "http://localhost/path" -> pathname: "/path"

Copy link
Contributor

Choose a reason for hiding this comment

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

Ho right, we'll need to look into that

});

it("converts mixed multi-value and single value parameters", () => {
const querystring = "key=value1&key=value2&another=value3";
Copy link
Contributor

Choose a reason for hiding this comment

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

It would be great to test if the multi-value key are not following each other

describe("regex", () => {
describe("escapeRegex", () => {
it("should escape (.) with _µ1_", () => {
const result = escapeRegex("/a(.)b");
Copy link
Contributor

Choose a reason for hiding this comment

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

For this and all the other below, it would be great to use some realistic example. This is used for intercepting route

Copy link
Contributor Author

@socsieng socsieng Oct 24, 2024

Choose a reason for hiding this comment

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

I'm not sure how this is actually used. Are you able to provide some examples that I can incorporate?

Copy link
Contributor

Choose a reason for hiding this comment

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

It's for interception route https://nextjs.org/docs/app/building-your-application/routing/intercepting-routes
it would be /a/(.)b for example

});
});

describe.skip("TODO: proxyRequest", () => {});
Copy link
Contributor

Choose a reason for hiding this comment

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

This one will be hard to properly test with unit test. This is one that we want to test mostly on e2e

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yeah, I thought it would be difficult too.

Did you want me to remove this altogether or update the description to say that it covered by e2e tests?

Copy link
Contributor

Choose a reason for hiding this comment

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

Updating the description makes more sense so that if someone change they'll know that they should implement test in e2e

};

addOpenNextHeader(headers);
expect(headers).toHaveProperty("X-OpenNext-Version");
Copy link
Contributor

Choose a reason for hiding this comment

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

Why not test the value as well ?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Can do.

@socsieng socsieng requested a review from conico974 October 25, 2024 04:38
Copy link
Contributor

@conico974 conico974 left a comment

Choose a reason for hiding this comment

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

LGTM Thanks

@conico974 conico974 merged commit 8498ca2 into opennextjs:main Oct 25, 2024
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants