Skip to content

fix: repair Smartling CAT visual context#1360

Open
stevejalim wants to merge 2 commits into
mainfrom
WT-1184--wagtail-localize-smartling-fixups
Open

fix: repair Smartling CAT visual context#1360
stevejalim wants to merge 2 commits into
mainfrom
WT-1184--wagtail-localize-smartling-fixups

Conversation

@stevejalim
Copy link
Copy Markdown
Contributor

GCP IAP is stopping the preview URL being used by CAT, so this changeset rewrites the HTML artifact sent over to try to make the CAT not need anything from the IAP-protected service. (Instead it loads CSS/JS from the public CDN)

This changeset also fixes a bug with the callback that was using the published hostname (www.firefox.com) for the preview link, not the internal CMS hostname. (This is somehwat academic because IAP is blocking the CMS host, but it helps us narrow down what may be causing CAT to fail on Smartling)

Issue / Bugzilla link

Jira: https://mozilla-hub.atlassian.net/browse/WT-1184

Testing

I've tested this manually locally and it's working fine - hopefully it'll also fix things in a deployed environment. Will test on Dev as soon as it's merged

GCP IAP is stopping the preview URL being used by CAT, so this changeset rewrites the HTML artifact
sent over to try to make the CAT not need anything from the IAP-protected service. (Instead it loads
CSS/JS from the public CDN)

This changeset also fixes a bug with the callback that was using the published hostname (www.firefox.com)
for the preview link, not the internal CMS hostname. (This is somehwat academic because IAP is
blocking the CMS host, but it helps us narrow down what may be causing CAT to fail on Smartling)

Jira: https://mozilla-hub.atlassian.net/browse/WT-1184
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR updates the Smartling visual context callback to avoid relying on an IAP-protected CMS preview origin by rewriting the exported HTML to resolve assets against the public canonical domain, and fixes the preview URL host selection for the Smartling callback.

Changes:

  • Build the Smartling preview URL using settings.WAGTAILADMIN_BASE_URL instead of the published hostname derived from the Wagtail Site.
  • Post-process the exported HTML to strip the CMS hostname and inject a <base href="{CANONICAL_URL}/"> tag so Smartling resolves relative asset URLs against the public domain.
  • Extend callback tests to cover the base-tag injection and CMS-hostname stripping behavior.

Assessment / Risks:

  • Logging the full draft sharing URL leaks the draft-sharing token into logs (must be addressed).
  • WAGTAILADMIN_BASE_URL can be empty by default, which can silently produce a relative URL that likely violates the Smartling callback contract (must be addressed).

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
springfield/cms/wagtail_localize_smartling/callbacks.py Adjusts Smartling visual context URL construction and rewrites exported HTML to avoid CMS-origin dependencies.
springfield/cms/tests/test_callbacks.py Updates and adds tests for the new URL construction and HTML rewriting behavior.

Comment thread springfield/cms/wagtail_localize_smartling/callbacks.py Outdated
Comment thread springfield/cms/wagtail_localize_smartling/callbacks.py
@codecov
Copy link
Copy Markdown

codecov Bot commented May 18, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 78.19%. Comparing base (70680ed) to head (d5f6675).

Additional details and impacted files
@@            Coverage Diff             @@
##             main    #1360      +/-   ##
==========================================
+ Coverage   78.17%   78.19%   +0.02%     
==========================================
  Files         152      152              
  Lines       10057    10067      +10     
==========================================
+ Hits         7862     7872      +10     
  Misses       2195     2195              

☔ 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.

Co-authored-by: Copilot Autofix powered by AI <175728472+Copilot@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.

2 participants