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

Allow archiving from specified external domains #37

Merged
merged 21 commits into from
Nov 17, 2023

Conversation

skitterm
Copy link
Member

@skitterm skitterm commented Nov 16, 2023

Issue: #CAP-1124

What Changed

Allows users to specify which external (to the site being tested) domains whose resources will be archived. This is done by specifying the allowedArchiveDomains value in the user's playwright.config.js file.

I've updated the calling code from Cypress to still work, but it doesn't pass this config option through yet.

I've also inlined more of the test's expected values, both to limit how much test-specific logic we have and to make it more explicit what the test expects.

How it works

We now (internally) make note of what URL the test is being run against. We then compare URLs against our external-domain-allow-list and archive resources from the origins that match.

When archiving other-domain URLs, we prepend their file path with the host.

How to test

  1. Use this version of the package in your Playwright test
  2. Create a test that references multiple assets (like images) from another domain
  3. In the playwright.config.js file, specify one of these domains
  4. Run npx playwright test
  5. Verify that the asset at this domain has been archived
  6. Run archive-storybook
  7. Verify that the asset loads in as expected

Change Type

  • maintenance
  • documentation
  • patch
  • minor
  • major
📦 Published PR as canary version: 0.0.39--canary.37.88cfa0f.0

✨ Test out this PR locally via:

npm install @chromaui/test-archiver@0.0.39--canary.37.88cfa0f.0
# or 
yarn add @chromaui/test-archiver@0.0.39--canary.37.88cfa0f.0

src/types.ts Outdated Show resolved Hide resolved
Copy link
Contributor

@tevanoff tevanoff left a comment

Choose a reason for hiding this comment

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

This is looking great!

It may also be nice to add to our asset E2E test to ensure this is working. I think we could use Playwright's mock API in those tests to serve one of the test images from a fake domain, and then ensure that it is archived and loads over in Chromatic.

Copy link
Contributor

@tevanoff tevanoff left a comment

Choose a reason for hiding this comment

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

Left one minor suggestion but not blocking. Looks great!

@skitterm skitterm merged commit 7f6af95 into main Nov 17, 2023
4 checks passed
@thafryer
Copy link
Member

🚀 PR was released in v0.0.39 🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants