Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update createPage to support windows paths #243

Merged
merged 1 commit into from
Jun 27, 2023

Conversation

oshi97
Copy link
Contributor

@oshi97 oshi97 commented Jun 27, 2023

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
Copy link
Contributor

@tmeyer2115 tmeyer2115 left a comment

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
Copy link
Contributor

@tmeyer2115 tmeyer2115 left a comment

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
Copy link
Contributor Author

oshi97 commented Jun 27, 2023

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
8 of 11 checks passed
@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 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