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

Use configured downloadsFolder for Cypress #164

Merged
merged 10 commits into from
Jul 5, 2024
Merged

Conversation

tevanoff
Copy link
Contributor

@tevanoff tevanoff commented Jun 21, 2024

Issue: #

What Changed

The Cypress integration was hardcoded to use Cypress's default value for downloadsFolder, cypress/downloads. Changes to that in the Cypress config would not be respected, and archive files would always be written to the default.

This fixes that by reading the correct value from the Cypress config object.

How to test

  • Set downloadsFolder to a non-default value in cypress.config.ts
  • Run Cypress tests, ensure Chromatic archives ouput in the directory set above, not in cypress/downloads
  • Run a Chromatic build, ensure all is 💯

@tevanoff tevanoff force-pushed the todd/cypress-dl-dir branch from 4312a9e to 6144340 Compare June 21, 2024 23:37
Copy link

codacy-production bot commented Jun 21, 2024

Coverage summary from Codacy

See diff coverage on Codacy

Coverage variation Diff coverage
+0.02% (target: -1.00%) 100.00% (target: 80.00%)
Coverage variation details
Coverable lines Covered lines Coverage
Common ancestor commit (753f167) 259 245 94.59%
Head commit (a4cd9c4) 260 (+1) 246 (+1) 94.62% (+0.02%)

Coverage variation is the difference between the coverage for the head and common ancestor commits of the pull request branch: <coverage of head commit> - <coverage of common ancestor commit>

Diff coverage details
Coverable lines Covered lines Diff coverage
Pull request (#164) 2 2 100.00%

Diff coverage is the percentage of lines that are covered by tests out of the coverable lines that the pull request added or modified: <covered lines added or modified>/<coverable lines added or modified> * 100%

See your quality gate settings    Change summary preferences


🚀 Don’t miss a bit, follow what’s new on Codacy.

Codacy stopped sending the deprecated coverage status on June 5th, 2024. Learn more

Copy link
Contributor

@andrewortwein andrewortwein left a comment

Choose a reason for hiding this comment

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

⬇️🗂️ Changes look good to me 👍🏻

@tevanoff tevanoff requested a review from skitterm June 25, 2024 15:57
@tevanoff tevanoff marked this pull request as ready for review June 25, 2024 17:12
Copy link
Member

@skitterm skitterm left a comment

Choose a reason for hiding this comment

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

Nice work @tevanoff! Glad that awkward ./cypress/downloads/some business I had written in is now gone.

// outputDir gives us the test-specific subfolder (https://playwright.dev/docs/api/class-testconfig#test-config-output-dir);
// we want to write one level above that
const finalOutputDir = join(outputDir, '..', 'chromatic-archives');
const finalOutputDir = join(outputDir, 'chromatic-archives');
Copy link
Member

Choose a reason for hiding this comment

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

@tevanoff it seems like the directory traversal wouldn't be as much of a risk since people are configuring their own outputDir, which looks on "their" OS/container for files. Is it worth making this change to be totally safe, or is outputDir a relative path?

packages/playwright/src/makeTest.ts Show resolved Hide resolved
@andrewortwein
Copy link
Contributor

@skitterm, Todd brought up that we don't currently have any unit tests that verify things are written to a configured outputDir. But we also don't have any tests covering the default case, so this could be a bit of a rabbit hole. Do you have any opinion on whether it's worth prolonging this fix to implement tests in this area?

@skitterm
Copy link
Member

Do you have any opinion on whether it's worth prolonging this fix to implement tests in this area?

@andrewortwein @tevanoff my gut says that it's not worth the time to add the tests, where we didn't see an easy way of putting them in.

Copy link
Member

@skitterm skitterm left a comment

Choose a reason for hiding this comment

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

A couple small questions, but I'm glad we're able to cover this with tests without too much hassle!

Copy link
Member

@skitterm skitterm 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!

@tevanoff tevanoff merged commit 9b2557f into main Jul 5, 2024
10 of 11 checks 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.

3 participants