Skip to content

chore(storybook): use relative path for msw - #4173

Merged
tjuanitas merged 3 commits into
masterfrom
chore-fix-msw-storybook-path
Jul 9, 2025
Merged

chore(storybook): use relative path for msw#4173
tjuanitas merged 3 commits into
masterfrom
chore-fix-msw-storybook-path

Conversation

@tjuanitas

@tjuanitas tjuanitas commented Jul 8, 2025

Copy link
Copy Markdown
Contributor

There is an error in the published storybook:

Error: [MSW] Failed to register a Service Worker for scope ('https://opensource.box.com/') with script ('https://opensource.box.com/mockServiceWorker.js'): Service Worker script does not exist at the given path.

This is because the mockServiceWorker.js is hosted at:
https://opensource.box.com/box-ui-elements/mockServiceWorker.js
but storybook is trying to find it at:
https://opensource.box.com/mockServiceWorker.js

solution:
mswjs/msw-storybook-addon#77

Summary by CodeRabbit

  • Chores
    • Updated configuration for the mock service worker in Storybook to explicitly set the service worker script location.
    • Removed unused "msw" configuration from project settings.

@tjuanitas
tjuanitas requested a review from a team as a code owner July 8, 2025 19:40
@coderabbitai

coderabbitai Bot commented Jul 8, 2025

Copy link
Copy Markdown
Contributor

Walkthrough

The changes update the configuration for the mock service worker used in Storybook. The service worker URL is now explicitly set in the initialization code, and the related configuration block has been removed from the package.json file.

Changes

File(s) Change Summary
.storybook/preview.tsx Modified the initialize() call from msw-storybook-addon to specify the service worker URL.
package.json Removed the "msw" configuration block specifying "workerDirectory".

Suggested labels

ready-to-merge

Suggested reviewers

  • jpan-box

Poem

In Storybook’s warren, a tweak was made,
The worker’s path now clearly laid.
No more confusion, no more dread,
The config block is gone—just as said!
With paws on keys and whiskers neat,
This bunny’s work is now complete. 🐇✨


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 21c71cf and 3e8ac10.

📒 Files selected for processing (2)
  • .storybook/preview.tsx (1 hunks)
  • package.json (0 hunks)
💤 Files with no reviewable changes (1)
  • package.json
🧰 Additional context used
🧠 Learnings (1)
📓 Common learnings
Learnt from: tjuanitas
PR: box/box-ui-elements#4126
File: scripts/webpack.config.js:72-76
Timestamp: 2025-06-17T15:21:36.180Z
Learning: The Box UI Elements project does not run webpack builds on Windows machines, so Windows path separator compatibility is not a concern for their build scripts.
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: lint_test_build
  • GitHub Check: Summary
🔇 Additional comments (1)
.storybook/preview.tsx (1)

16-20: LGTM! This change effectively addresses the Service Worker path issue.

The relative path configuration './mockServiceWorker.js' correctly resolves the path discrepancy described in the PR objectives. By making the service worker URL relative to the current location instead of absolute, this ensures the script will be found at the correct path when Storybook is published to a subdirectory like https://opensource.box.com/box-ui-elements/.

The configuration structure follows the msw-storybook-addon API and properly replaces the previous package.json configuration approach.

✨ Finishing Touches
  • 📝 Generate Docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Explain this complex logic.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Comment thread package.json
@tjuanitas
tjuanitas merged commit 035cffb into master Jul 9, 2025
6 checks passed
@tjuanitas
tjuanitas deleted the chore-fix-msw-storybook-path branch July 9, 2025 02:24
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