Skip to content

fix: manage if the BASE_URL does not have the protocol for themes urls #779

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

Merged
merged 3 commits into from
Mar 21, 2025

Conversation

dcoa
Copy link
Contributor

@dcoa dcoa commented Mar 20, 2025

Description:

This PR manages the cases where the protocol is not present in the BASE_URL environment variable when is used for creating urls in the themes hook.

Merge checklist:

  • Consider running your code modifications in the included example app within frontend-platform. This can be done by running npm start and opening http://localhost:8080.
  • Consider testing your code modifications in another local micro-frontend using local aliases configured via the module.config.js file in frontend-build.
  • Verify your commit title/body conforms to the conventional commits format (e.g., fix, feat) and is appropriate for your code change. Consider whether your code is a breaking change, and modify your commit accordingly.

Post merge:

  • After the build finishes for the merged commit, verify the new release has been pushed to NPM.

Sorry, something went wrong.

@openedx-webhooks openedx-webhooks added the open-source-contribution PR author is not from Axim or 2U label Mar 20, 2025
@openedx-webhooks
Copy link

Thanks for the pull request, @dcoa!

This repository is currently maintained by @openedx/committers-frontend.

Once you've gone through the following steps feel free to tag them in a comment and let them know that your changes are ready for engineering review.

🔘 Get product approval

If you haven't already, check this list to see if your contribution needs to go through the product review process.

  • If it does, you'll need to submit a product proposal for your contribution, and have it reviewed by the Product Working Group.
    • This process (including the steps you'll need to take) is documented here.
  • If it doesn't, simply proceed with the next step.
🔘 Provide context

To help your reviewers and other members of the community understand the purpose and larger context of your changes, feel free to add as much of the following information to the PR description as you can:

  • Dependencies

    This PR must be merged before / after / at the same time as ...

  • Blockers

    This PR is waiting for OEP-1234 to be accepted.

  • Timeline information

    This PR must be merged by XX date because ...

  • Partner information

    This is for a course on edx.org.

  • Supporting documentation
  • Relevant Open edX discussion forum threads
🔘 Get a green build

If one or more checks are failing, continue working on your changes until this is no longer the case and your build turns green.


Where can I find more information?

If you'd like to get more details on all aspects of the review process for open source pull requests (OSPRs), check out the following resources:

When can I expect my changes to be merged?

Our goal is to get community contributions seen and reviewed as efficiently as possible.

However, the amount of time that it takes to review and merge a PR can vary significantly based on factors such as:

  • The size and impact of the changes that it introduces
  • The need for product review
  • Maintenance status of the parent repository

💡 As a result it may take up to several weeks or months to complete a review and merge your PR.

Copy link

codecov bot commented Mar 20, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 86.71%. Comparing base (e19cbc5) to head (3ec5cb5).
Report is 5 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master     #779   +/-   ##
=======================================
  Coverage   86.70%   86.71%           
=======================================
  Files          48       48           
  Lines        1392     1393    +1     
  Branches      292      296    +4     
=======================================
+ Hits         1207     1208    +1     
  Misses        172      172           
  Partials       13       13           

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
Contributor

@brian-smith-tcril brian-smith-tcril left a comment

Choose a reason for hiding this comment

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

Thanks for updating this!

It's not fully clear to me what the updates to the tests are changing. It looks like the changes are some combination of "this needed to change to get this to pass" and "I want to verify the new functionality of fallbackThemeUrl." I see those two goals as separate, and I think we can test them separately.

Ideally we'd have tests to show:

  • calling fallbackThemeUrl with //example.com/my.css results in //example.com/my.css
  • calling fallbackThemeUrl with example.com/my.css results in //example.com/my.css
  • calling fallbackThemeUrl with http://example.com/my.css results in http://example.com/my.css
  • calling fallbackThemeUrl with https://example.com/my.css results in https://example.com/my.css

Then we could leave the existing tests as untouched as possible - making minimal updates to ensure they still pass.

Verified

This commit was signed with the committer’s verified signature.
@dcoa dcoa force-pushed the dcoa/fix-url-creation branch from 8b782e0 to 3ec5cb5 Compare March 21, 2025 02:56
@dcoa
Copy link
Contributor Author

dcoa commented Mar 21, 2025

I made test for the function that illustrates all the possible cases at return with BASE_URL definition.

The reason why the test was updated is how we are defining the env variables for testing, in this case BASE_URL is just the domain part, needs to resolve as relative url in the test and once the link is created the href returns the url with the http

process.env.BASE_URL = 'localhost:8080';

Let me know if that should be good, or should I do different change :) @brian-smith-tcril

Copy link
Contributor

@brian-smith-tcril brian-smith-tcril left a comment

Choose a reason for hiding this comment

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

LGTM!

Thanks for adding the tests for all the different BASE_URL cases!

@brian-smith-tcril brian-smith-tcril merged commit 12cb5bc into openedx:master Mar 21, 2025
6 checks passed
@github-project-automation github-project-automation bot moved this from Needs Triage to Done in Contributions Mar 21, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
open-source-contribution PR author is not from Axim or 2U
Projects
Status: Done
Development

Successfully merging this pull request may close these issues.

None yet

4 participants