Skip to content
This repository was archived by the owner on Jul 6, 2026. It is now read-only.

Update createPage to support windows paths - #243

Merged
oshi97 merged 1 commit into
feature/windows-testsfrom
dev/create-page-tests-windows
Jun 27, 2023
Merged

oshi97 merged 1 commit into
feature/windows-testsfrom
dev/create-page-tests-windows

Conversation

@oshi97

@oshi97 oshi97 commented Jun 27, 2023 •

Copy link
Copy Markdown
Contributor

Paths like C:\Users\username\Documents\Github\studio-prototype\packages\studio\tests\__mocks__/test.tsx are not considered absolute by path.isAbsolute in the frontend. This is because we are using path-browserify (a browser version of nodejs's path) which does not have proper windows support. In real nodejs, path.isAbsolute will return true for a windows path like the above.
browserify/path-browserify#1

We could look for an alternative but I'm not sure if that will be necessary. I think I'll have a better picture of that when I'm further in with getting the unit tests compatibility.

For the createPage action, the path.isAbsolute check is unnecessary since we do a filepath.startsWith(pagesPath) check as well, and pagesPath is always absolute. We may want to support a relative pagesPath at which point we may need to add additional validation, but it would probably make more sense for that validation to go into the backend.

J=SLAP-2791
TEST=auto

tests for createPage.ts and AddPageButton are now passing

@oshi97
oshi97 marked this pull request as ready for review June 27, 2023 16:55

@tmeyer2115 tmeyer2115 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Did this only impact tests run on Windows? Or did this bug actually prevent Windows users from creating pages?

@tmeyer2115
tmeyer2115 self-requested a review June 27, 2023 17:28

@tmeyer2115 tmeyer2115 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Did this only impact tests run on Windows? Or did this bug actually prevent Windows users from creating pages?

@oshi97

oshi97 commented Jun 27, 2023 •

Copy link
Copy Markdown
Contributor Author

Did this only impact tests run on Windows? Or did this bug actually prevent Windows users from creating pages?

It prevented users from creating pages! Users would get an error message in the modal

@oshi97
oshi97 merged commit f3ae998 into feature/windows-tests Jun 27, 2023
@oshi97
oshi97 deleted the dev/create-page-tests-windows branch June 27, 2023 17:56
oshi97 added a commit that referenced this pull request Jun 27, 2023
This is the same change as in #243 but for modules.

This gets the createModule tests passing. In theory it also was preventing windows users from creating new modules
(though we currently don't allow anybody to create modules anyways).
With this all of the frontend jest tests are passing!

J=SLAP-2790
TEST=auto
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants