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

chore: convert screenshots.js to screenshots.ts #30758

Merged
merged 16 commits into from
Dec 20, 2024

Conversation

jennifer-shehane
Copy link
Member

@jennifer-shehane jennifer-shehane commented Dec 12, 2024

Additional details

Converting screenshots.js to screenshots.ts. I was initially looking at this to update our mime dependency and with a lot of deps moving to esm its just easier to upgrade if files are in TS.

I am not a TypeScript expert, so please review each change! 😄 Some stuff I just ignored the TS error, but the code likely needs actual fixing.

Steps to test

Unit/Integration/System tests should pass

How has the user experience changed?

PR Tasks

@jennifer-shehane jennifer-shehane self-assigned this Dec 12, 2024
Copy link

cypress bot commented Dec 12, 2024

cypress    Run #59228

Run Properties:  status check passed Passed #59228  •  git commit 6ee3416e4e: revert outputFile change
Project cypress
Branch Review js-to-ts-screenshots
Run status status check passed Passed #59228
Run duration 24m 32s
Commit git commit 6ee3416e4e: revert outputFile change
Committer Jennifer Shehane
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 8
Tests that did not run due to a developer annotating a test with .skip  Pending 1326
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 29400
View all changes introduced in this branch ↗︎
UI Coverage  46.24%
  Untested elements 188  
  Tested elements 166  
Accessibility  92.54%
  Failed rules  3 critical   8 serious   2 moderate   2 minor
  Failed elements 903  

@AtofStryker AtofStryker self-requested a review December 13, 2024 14:51
Copy link
Contributor

@cacieprins cacieprins left a comment

Choose a reason for hiding this comment

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

Looks good - just some suggestions on how to resolve some of the typescript errors!

packages/server/lib/screenshots.ts Outdated Show resolved Hide resolved
@@ -350,6 +368,7 @@ const getPath = function (data, ext, screenshotsFolder, overwrite) {
.chain(data.titles)
.map(sanitizeToString)
.join(RUNNABLE_SEPARATOR)
// @ts-ignore
Copy link
Contributor

Choose a reason for hiding this comment

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

I'm not sure what the next line is even doing; _.concat only operates on arrays, and "someString".concat([]) === "someString". The next line can likely be removed, but I'd make sure the values are what they're expected to be if you do.

Copy link
Member Author

Choose a reason for hiding this comment

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

Ryan had some thoughts on what this is doing here: #30758 (comment)

Copy link
Member Author

Choose a reason for hiding this comment

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

@cacieprins @ryanthemanuel Yah....it does not like any changes to this area. I'm going to leave it alone. 😬 I don't really understand why it's needed either.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Yeah I think I get what it's doing, but lodash types don't like it even though you can do it.

Copy link

Choose a reason for hiding this comment

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

Hey, while I was working on this part of code in my PR, I found that this is done so that type of the variable is same in both if and else branch. I guess that is why it breaks, as the type for name variable becomes different in case of if and else branches, and the remaining code that uses names breaks on one type or other. I fixed it by replacing the concat by putting it in array.

Relevant lines from my PR https://github.com/cypress-io/cypress/pull/30673/files#diff-471ce7b0d88e3cdc126b6c5e781d074d86a828e5a7d88b9584db3385be09e569R88-R97

packages/server/lib/screenshots.ts Outdated Show resolved Hide resolved
packages/server/lib/screenshots.ts Outdated Show resolved Hide resolved
packages/server/lib/screenshots.ts Outdated Show resolved Hide resolved
@AtofStryker AtofStryker self-requested a review December 13, 2024 20:43
@jennifer-shehane jennifer-shehane marked this pull request as draft December 16, 2024 14:29
@jennifer-shehane
Copy link
Member Author

I'm going to take a closer look at this again.

@jennifer-shehane jennifer-shehane marked this pull request as ready for review December 16, 2024 19:19
@jennifer-shehane jennifer-shehane merged commit 0a8a130 into develop Dec 20, 2024
84 of 85 checks passed
@jennifer-shehane jennifer-shehane deleted the js-to-ts-screenshots branch December 20, 2024 21:29
jennifer-shehane pushed a commit that referenced this pull request Dec 23, 2024
* chore: updating v8 snapshot cache

* index on develop: 0a8a130 chore: convert screenshots.js to screenshots.ts (#30758)

* index on develop: 0a8a130 chore: convert screenshots.js to screenshots.ts (#30758)

---------

Co-authored-by: cypress-bot[bot] <+cypress-bot[bot]@users.noreply.github.com>
jennifer-shehane pushed a commit that referenced this pull request Dec 23, 2024
* chore: updating v8 snapshot cache

* index on develop: 0a8a130 chore: convert screenshots.js to screenshots.ts (#30758)

* index on develop: 0a8a130 chore: convert screenshots.js to screenshots.ts (#30758)

---------

Co-authored-by: cypress-bot[bot] <+cypress-bot[bot]@users.noreply.github.com>
jennifer-shehane pushed a commit that referenced this pull request Dec 23, 2024
* chore: updating v8 snapshot cache

* index on develop: 0a8a130 chore: convert screenshots.js to screenshots.ts (#30758)

* index on develop: 0a8a130 chore: convert screenshots.js to screenshots.ts (#30758)

---------

Co-authored-by: cypress-bot[bot] <+cypress-bot[bot]@users.noreply.github.com>
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.

5 participants