Skip to content

feat: add shared fetch-cdn-scenario action for Core and Pro [ED-26391] - #71

Merged
Svitlana-Dykun merged 12 commits into
mainfrom
cursor/shared-cdn-test-infra-ed-26391-2158
Nov 26, 2026
Merged

Svitlana-Dykun merged 12 commits into
mainfrom
cursor/shared-cdn-test-infra-ed-26391-2158

Conversation

@Svitlana-Dykun

@Svitlana-Dykun Svitlana-Dykun commented Nov 23, 2026 •

Copy link
Copy Markdown
Contributor

Summary

Creates a reusable composite action (actions/fetch-cdn-scenario) that consolidates the CDN campaign promotion test infrastructure shared by elementor/elementor#38251, elementor/elementor-pro#7989, and elementor/elementor-pro#7992.

Requested by reviewer @davseve on:

What's Included

  1. Fetch script (fetch-cdn-scenario.mjs)

    • Downloads CDN JSON files with timeout (15s), retry on transient errors (network, 429, 5xx; 3 attempts, 2s/4s backoff), and HTTPS allowlist (assets.elementor.com, assets.stg.elementor.red)
    • Optional --allow-failure flag to continue when CDN is unreachable
    • Atomic staging swap so partial downloads never overwrite an existing live scenario
    • Supports fetching from an allowlisted CDN URL or a local directory
  2. Mock CDN mu-plugin (mock-editor-assets-cdn.php)

    • Intercepts WordPress HTTP requests to assets.elementor.com for .json fixtures inside editor-assets-cdn/ (validated with realpath)
    • Selects the scenario via the e2e_cdn_scenario cookie with fallback to no-promotion
    • Mocks editor promotions, notifications, home screen, V4 promotions (packages/v1/promotions.json), and free-to-pro upsell
    • Prevents CDN option cache pollution between parallel scenarios
  3. Shared fixtures (fixtures/no-promotion/, fixtures/active-campaign/)

    • Default no-promotion scenario and active-campaign scenario (including sidebar SVG fixtures) used by both Core and Pro Playwright tests

Action Inputs

Input Description Required Default
output-dir Target directory for fetched CDN files Yes -
cdn-source Allowlisted CDN URL (e.g. https://assets.stg.elementor.red) or local directory. Empty means https://assets.elementor.com No https://assets.elementor.com
allow-failure Allow WordPress to start if fetch fails No false
mu-plugins-dir Target directory for the mock CDN mu-plugin No ''
copy-fixtures Copy shared no-promotion and active-campaign fixtures to the parent of output-dir No true
fetch-live Fetch live CDN data into output-dir. Set to false on PR CI to stay offline No true

Jira

Ref: ED-26391

✨ PR Description

1. Problem & Context

Implements a shared test infrastructure for CDN campaign promotions (ED-26391) to eliminate duplication between Core and Pro. It allows testing against live, staging, or mocked CDN data to ensure marketing campaigns don't break the editor.

2. What Changed (Where)

File Change
fetch-cdn-scenario.mjs Logic to fetch CDN JSONs with retries, atomic swaps, and source validation.
mock-editor-assets-cdn.php WP mu-plugin to intercept CDN requests and serve local fixtures via cookies.
action.yml Composite GitHub Action orchestrating fetch, plugin installation, and fixture setup.
fixtures/ Pre-defined no-promotion and active-campaign JSON scenarios for stable E2E testing.
README.md Technical documentation for action inputs and usage scenarios.

3. How It Works

The GitHub Action calls fetch-cdn-scenario.mjs to download specific JSON paths from a source into a staging directory, swapping it to live only upon total success. The mock-editor-assets-cdn.php plugin then intercepts assets.elementor.com HTTP requests, serving files from the specified scenario directory (determined by the e2e_cdn_scenario cookie) or falling back to the default scenario.

4. Risks

  • CDN Schema Drift: New CDN files won't be mocked unless manually added to CDN_PATHS and ELEMENTOR_E2E_CDN_CACHE_OPTIONS.
  • Stale Fixtures: no-promotion and active-campaign fixtures may diverge from actual CDN structures over time.

Generated by LinearB AI and added by gitStream.
AI-generated content may contain inaccuracies. Please verify before using.
💡 Tip: You can customize your AI Description using Guidelines Learn how

Creates a reusable composite action that consolidates the CDN campaign
promotion test infrastructure previously duplicated in Core and Pro.

Provides:
- Fetch script with retry, timeout, and --allow-failure (from Pro)
- Mock CDN mu-plugin for intercepting HTTP requests
- Shared no-promotion fixture files

This eliminates duplication between elementor/elementor#38251 and
elementor/elementor-pro#7989 and uses Pro's more robust implementation
(timeout, retry, atomic swap) as the baseline.

Ref: ED-26391
Co-authored-by: Svitlana-Dykun <Svitlana-Dykun@users.noreply.github.com>
@wiz-9a149474ff

wiz-9a149474ff Bot commented Nov 23, 2026 •

Copy link
Copy Markdown

Wiz Scan Summary

Scanner Findings
Vulnerability Finding Vulnerabilities -
Data Finding Sensitive Data -
Secret Finding Secrets -
IaC Misconfiguration IaC Misconfigurations -
SAST Finding SAST Findings 1 Medium
Software Management Finding Software Management Findings -
Total 1 Medium

View scan details in Wiz

To detect these findings earlier in the dev lifecycle, try the Wiz Code extension for VS Code, JetBrains, or Visual Studio.

Co-authored-by: Cursor <cursoragent@cursor.com>
…aign value [ED-26391]

- Mock packages/v1/promotions.json and free-to-pro-upsell.json, which Core
  requests on every editor load, also with Pro, so live campaigns no longer
  leak into tests.
- active-campaign: add a Pro-only and an everyone What's New card, and a
  distinct sidebar link for the free, essential, essential-oct2023 and
  expired tiers, so tests with Pro can prove the mock answered.
- Let every fetch settle before the staging directory is removed.
- Update the README.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Svitlana-Dykun and others added 2 commits November 25, 2026 13:09
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Svitlana-Dykun and others added 3 commits November 25, 2026 16:47
…6391]

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…ync [ED-26391]

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Cursor <cursoragent@cursor.com>
Svitlana-Dykun and others added 3 commits November 25, 2026 23:15
…391]

Co-authored-by: Cursor <cursoragent@cursor.com>
The active-campaign scenario has no screenshots any more, so the tests
check the image URL only and the fixtures hold JSON only.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Svitlana-Dykun
Svitlana-Dykun merged commit a224676 into main Nov 26, 2026
18 checks passed
@Svitlana-Dykun
Svitlana-Dykun deleted the cursor/shared-cdn-test-infra-ed-26391-2158 branch November 26, 2026 13:54
Svitlana-Dykun added a commit to elementor/elementor that referenced this pull request Nov 27, 2026
## PR Checklist
- [x] The commit message follows our guidelines:
https://github.com/elementor/elementor/blob/master/.github/CONTRIBUTING.md

## PR Type
- [ ] Bugfix
- [ ] Feature
- [ ] Code style update (formatting, local variables)
- [ ] Refactoring (no functional changes, no api changes)
- [ ] Build related changes
- [x] CI related changes
- [ ] Documentation content changes
- [x] Other... Please describe: Playwright e2e tests

## Summary

This PR can be summarized in the following changelog entry:

* Internal: Add CDN campaign promotion tests

## Visual proof

#skip_proof
Playwright tests only, no user-facing change.

## Description

Follows #38248 and uses the shared
`elementor/elementor-editor-github-actions/actions/fetch-cdn-scenario`
action (elementor/elementor-editor-github-actions#71).

Tests that Core renders CDN promotions accurately when a campaign is
active and falls back to Core defaults when inactive.

**How it works**

* PR CI runs `fetch-cdn-scenario` with `fetch-live: false` and
`allow-failure: true`, installing the shared
`mock-editor-assets-cdn.php` mu-plugin and copying the deterministic
`no-promotion` and `active-campaign` fixtures. PR CI does not call
`assets.elementor.com`.
* `mock-editor-assets-cdn.php` selects the scenario from the
`e2e_cdn_scenario` cookie. The rest of the suite stays on `no-promotion`
(#38248). Campaign requests skip the shared `wp_options` CDN cache so
they never leak into parallel tests.
* Scheduled runs fetch the live CDN and set `E2E_CDN_SCENARIO=live`,
which adds `live` to the campaign scenarios, so a broken live campaign
is reported within a day. PR runs stay offline.
* Local runs and pre-campaign checks use `npm run
test:playwright:setup-cdn`, which downloads the shared fixtures and
fetches the live CDN with the action's own script.

**Coverage (free user, Core only)**

Run for both `active-campaign` and `no-promotion`:

* Plugins page row action - label and link
* Admin menu Upgrade item - label and redirect target
* Conversion banner - title, CTA text and link
* Dashboard pointer - title, text, CTA (hidden without a campaign)
* Editor widgets panel sticky footer - message, button text and link
* Theme Builder promotion header button - text and link

* V4 promotions and widget upsell images -
`elementor.config.v4Promotions` and `elementorPromotionsData`

Campaign content (`active-campaign`, plus `E2E_CDN_SCENARIO` when set):

* What's New card - title, description, CTA link for Free users, and
Pro-only cards hidden
* Home screen sidebar banner - image and link (free variant)

Pro variants are covered in elementor/elementor-pro#7989.

## Test instructions

* `npm run wp-playground` (sets up CDN fixtures first)
* `WP_CLI_TARGET=playground npx playwright test
tests/playwright/sanity/modules/promotions/campaign`

## Quality assurance

- [x] I have tested this code to the best of my abilities
- [ ] I have added unittests to verify the code works as intended
- [ ] Docs have been added / updated (for bug fixes / features)

Ref: [ED-26391](https://elementor.atlassian.net/browse/ED-26391)

[ED-26391]:
https://elementor.atlassian.net/browse/ED-26391?atlOrigin=eyJpIjoiNWRkNTljNzYxNjVmNDY3MDlhMDU5Y2ZhYzA5YTRkZjUiLCJwIjoiZ2l0aHViLWNvbS1KU1cifQ

### Campaign screenshots
- `no-promotion` and `active-campaign` have no screenshots. The tests
check them through the DOM. In `active-campaign` the tests answer the
CDN image requests from the fixture, so these runs do not depend on the
live CDN.
- A real campaign (`live`, or staging with `cdn_source`) keeps one
baseline for every approved content:
`campaign-<placement>-<fingerprint>.png`. The fingerprint is a hash of
the CDN data that the placement shows. It ignores `lastUpdated` and the
staging host, so a look approved on staging stays approved after the
launch.
- The run picks the baseline whose fingerprint matches the current CDN
content.
  - If that baseline exists, the screenshot is compared with it.
- If it does not exist, the test fails with "not approved" and attaches
the screenshot for review.
- Because approvals add up, the looks before, during and after a
campaign can all be approved ahead of time. The nightly run stays green
when the CDN switches.

### Nightly live CDN check
- The `Playwright` workflow has its own schedule for this, which runs
`live @promotions` against the production CDN every night at 04:30 UTC.
- A failure is posted to the test automation results channel, the same
channel as the other nightly results. "not approved" in the report means
new CDN content: check the attached screenshots and approve them as
described below.
- The full nightly suite no longer checks the live CDN, so a CDN change
does not fail it and is not reported twice.

### Approving the next campaign
1. Open the campaign PR in editor-assets. It deploys to
`https://assets.stg.elementor.red`.
2. Run Playwright (Core: `Playwright`, Pro: `Playwright - Custom Core`)
with `tag=@promotions` and
`cdn_source=https://assets.stg.elementor.red`. Placements with new
content fail with "not approved" and attach their screenshots.
3. Check the screenshots in the report.
4. Create a branch from `main` and run **Update Playwright Snapshots**
on it with `test_grep=live @promotions`, the same `cdn_source` and
`update_mode=changed`. Check that the workflow pushed a `test: update
playwright snapshots` commit, then open a PR and merge it.
- An approval run (`cdn_scenario=live` or `cdn_source`) fails on any
test error and commits nothing. Missing baselines are written in update
mode, so a failure there is real: the CDN was not fetched, or a text or
link is wrong. Other snapshot updates still continue on errors.
- A `cdn_source` without any of the CDN files fails the fetch ("check
the source"). A source that misses some of them falls back to the
default scenario for those, but every test checks that its files were
fetched.
5. Do the same for the PR that ends the campaign, so the look after it
is approved too.
6. Once in a while, delete the baselines of campaigns that are over.

### Campaign launch checklist
Between campaigns, only the mocks check how a campaign is shown, so the
staging run before the launch is the one that tries the real campaign
with the current code.

Before the launch:
- [ ] The campaign PR in editor-assets is deployed to
`https://assets.stg.elementor.red`.
- [ ] Core and Pro Playwright runs with
`cdn_source=https://assets.stg.elementor.red` (steps 1–3 above). Every
failure other than "not approved" is a real problem: fix it before the
launch.
- [ ] The screenshots of every placement show the campaign as designed,
for every license tier in Pro.
- [ ] The campaign look is approved in Core and Pro (step 4), and the
snapshot PRs are merged before the launch.
- [ ] The look after the campaign is approved too (step 5), so its end
does not fail the nightly run.
- [ ] A new placement or a new CDN file in the campaign has a test, and
the `active-campaign` fixture in `fetch-cdn-scenario` covers it.
- [ ] A changed JSON format is copied to the `active-campaign` and
`no-promotion` fixtures in `fetch-cdn-scenario`.

After the launch:
- [ ] The next nightly run (04:30 UTC) is green in Core and Pro. A
failure is posted to the test automation results channel.
- [ ] After the campaign ends, the nightly run stays green. "Not
approved" means the after look was not approved: check it and approve
it.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

---------

Co-authored-by: Cursor <cursoragent@cursor.com>
Co-authored-by: Svitlana-Dykun <Svitlana-Dykun@users.noreply.github.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Co-authored-by: github-actions[bot] <github-actions[bot]@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants