From 9be0b7940ea3e66aea0bb57cce3ce3a191190c16 Mon Sep 17 00:00:00 2001 From: Cursor Agent Date: Mon, 23 Nov 2026 12:27:44 +0000 Subject: [PATCH 01/12] feat: add shared fetch-cdn-scenario action for Core and Pro 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 --- actions/fetch-cdn-scenario/.gitignore | 2 + actions/fetch-cdn-scenario/README.md | 170 ++++++ actions/fetch-cdn-scenario/action.yml | 69 +++ .../fetch-cdn-scenario/fetch-cdn-scenario.mjs | 116 ++++ .../editor-promotions/v1/connect-page.json | 5 + .../v1/conversion-banner.json | 5 + .../editor-promotions/v1/plugins-page.json | 5 + .../editor-promotions/v1/pointer.json | 5 + .../editor-promotions/v1/pro-setup-panel.json | 5 + .../editor-promotions/v1/side-menu.json | 5 + .../editor-promotions/v1/sticky-panel.json | 5 + .../editor-promotions/v1/theme-builder.json | 5 + .../home-screen/v1/home-screen.json | 556 ++++++++++++++++++ .../notifications/v1/notifications.json | 3 + .../mock-editor-assets-cdn.php | 85 +++ 15 files changed, 1041 insertions(+) create mode 100644 actions/fetch-cdn-scenario/.gitignore create mode 100644 actions/fetch-cdn-scenario/README.md create mode 100644 actions/fetch-cdn-scenario/action.yml create mode 100644 actions/fetch-cdn-scenario/fetch-cdn-scenario.mjs create mode 100644 actions/fetch-cdn-scenario/fixtures/no-promotion/editor-promotions/v1/connect-page.json create mode 100644 actions/fetch-cdn-scenario/fixtures/no-promotion/editor-promotions/v1/conversion-banner.json create mode 100644 actions/fetch-cdn-scenario/fixtures/no-promotion/editor-promotions/v1/plugins-page.json create mode 100644 actions/fetch-cdn-scenario/fixtures/no-promotion/editor-promotions/v1/pointer.json create mode 100644 actions/fetch-cdn-scenario/fixtures/no-promotion/editor-promotions/v1/pro-setup-panel.json create mode 100644 actions/fetch-cdn-scenario/fixtures/no-promotion/editor-promotions/v1/side-menu.json create mode 100644 actions/fetch-cdn-scenario/fixtures/no-promotion/editor-promotions/v1/sticky-panel.json create mode 100644 actions/fetch-cdn-scenario/fixtures/no-promotion/editor-promotions/v1/theme-builder.json create mode 100644 actions/fetch-cdn-scenario/fixtures/no-promotion/home-screen/v1/home-screen.json create mode 100644 actions/fetch-cdn-scenario/fixtures/no-promotion/notifications/v1/notifications.json create mode 100644 actions/fetch-cdn-scenario/mock-editor-assets-cdn.php diff --git a/actions/fetch-cdn-scenario/.gitignore b/actions/fetch-cdn-scenario/.gitignore new file mode 100644 index 000000000..536a53d54 --- /dev/null +++ b/actions/fetch-cdn-scenario/.gitignore @@ -0,0 +1,2 @@ +# Temporary files created during fetch +*.tmp-* diff --git a/actions/fetch-cdn-scenario/README.md b/actions/fetch-cdn-scenario/README.md new file mode 100644 index 000000000..2d04606a1 --- /dev/null +++ b/actions/fetch-cdn-scenario/README.md @@ -0,0 +1,170 @@ +# Fetch CDN Scenario + +Shared GitHub Actions composite action that provides CDN campaign promotion test infrastructure for both Elementor Core and Elementor Pro. + +## Overview + +This action consolidates the CDN test infrastructure previously duplicated in [elementor/elementor#38251](https://github.com/elementor/elementor/pull/38251) and [elementor/elementor-pro#7989](https://github.com/elementor/elementor-pro/pull/7989). It provides: + +1. **Fetch script** (`fetch-cdn-scenario.mjs`) - Downloads current CDN JSON files with retry logic, timeout handling, and optional failure tolerance +2. **Mock mu-plugin** (`mock-editor-assets-cdn.php`) - Intercepts WordPress HTTP requests to serve local fixtures instead of live CDN +3. **Shared fixtures** - No-promotion scenario fixtures shared between Core and Pro + +## Features + +- **Retry logic**: Up to 3 attempts with exponential backoff (2s, 4s, 6s) +- **Timeout handling**: 15s request timeout per file +- **Graceful failure**: Optional `--allow-failure` to allow WordPress to start even if CDN is down +- **Atomic updates**: Fetches to staging directory and swaps in only on complete success +- **Flexible source**: Fetch from live CDN, custom URL, or local directory + +## Inputs + +| Input | Description | Required | Default | +|-------|-------------|----------|---------| +| `cdn-source` | CDN source URL or local directory | No | `https://assets.elementor.com` | +| `allow-failure` | Allow WordPress to start if fetch fails | No | `false` | +| `output-dir` | Target directory for fetched CDN files | **Yes** | - | +| `mu-plugins-dir` | Target directory for mock mu-plugin | No | `''` | +| `copy-fixtures` | Copy shared no-promotion fixtures | No | `true` | + +## Usage + +### Elementor Core + +**In your workflow** (e.g., `.github/workflows/playwright-suite.yml`): + +```yaml +steps: + - uses: actions/checkout@v6 + + - name: Fetch live CDN scenario + uses: elementor/elementor-editor-github-actions/actions/fetch-cdn-scenario@main + with: + output-dir: tests/playwright/mu-plugins/editor-assets-cdn/live + mu-plugins-dir: tests/playwright/mu-plugins + copy-fixtures: true + + - name: Install WordPress environment + run: npm run start-local-server +``` + +**Files you can delete from Core**: +- `scripts/fetch-live-cdn-scenario.mjs` ✓ +- `tests/playwright/mu-plugins/mock-editor-assets-cdn.php` (replace with shared version) +- `tests/playwright/mu-plugins/editor-assets-cdn/no-promotion/**/*` (use shared fixtures) + +**Keep in Core**: +- `tests/playwright/sanity/modules/promotions/campaign/campaign-promotions.test.ts` +- `tests/playwright/sanity/modules/promotions/campaign/cdn-scenario.ts` +- `tests/playwright/mu-plugins/editor-assets-cdn/live/` (git-ignored, populated by action) + +**Update in Core**: +- Remove `npm run test:playwright:fetch-cdn` from `package.json` scripts +- Update workflows to use this action instead of the local script + +### Elementor Pro + +**In your workflow** (e.g., `start-local-server` script or workflow): + +```yaml +steps: + - uses: actions/checkout@v6 + + - name: Fetch live CDN scenario with failure tolerance + uses: elementor/elementor-editor-github-actions/actions/fetch-cdn-scenario@main + with: + output-dir: tests/playwright/mu-plugins/editor-assets-cdn/live + mu-plugins-dir: tests/playwright/mu-plugins + allow-failure: true + copy-fixtures: true + + - name: Start wp-env + run: bash ./.github/scripts/start-wp-env.sh +``` + +**Files you can delete from Pro**: +- `scripts/fetch-live-cdn-scenario.mjs` ✓ +- `tests/playwright/mu-plugins/mock-editor-assets-cdn.php` (replace with shared version) +- `tests/playwright/mu-plugins/editor-assets-cdn/no-promotion/**/*` (use shared fixtures) +- `tests/playwright/mu-plugins/editor-assets-cdn/active-campaign/**/*` (Pro-specific, keep if needed for Pro tests) + +**Keep in Pro**: +- `tests/playwright/sanity/modules/promotions/cdn-free-promotions-hidden.test.ts` +- `tests/playwright/sanity/modules/promotions/cdn-scenario.ts` +- `tests/playwright/mu-plugins/editor-assets-cdn/live/` (git-ignored, populated by action) + +**Update in Pro**: +- Remove `npm run test:playwright:fetch-cdn` from `package.json` scripts +- Update `start-local-server` to use this action instead of the local script + +## Advanced Usage + +### Testing a campaign before it goes live + +**Core example**: +```yaml +- name: Fetch CDN from local editor-assets build + uses: elementor/elementor-editor-github-actions/actions/fetch-cdn-scenario@main + with: + cdn-source: ../editor-assets/out + output-dir: tests/playwright/mu-plugins/editor-assets-cdn/live + mu-plugins-dir: tests/playwright/mu-plugins +``` + +**Pro example**: +```yaml +- name: Fetch CDN from custom URL + uses: elementor/elementor-editor-github-actions/actions/fetch-cdn-scenario@main + with: + cdn-source: https://staging.assets.elementor.com + output-dir: tests/playwright/mu-plugins/editor-assets-cdn/live + mu-plugins-dir: tests/playwright/mu-plugins + allow-failure: true +``` + +### Skip copying fixtures (if you have custom ones) + +```yaml +- uses: elementor/elementor-editor-github-actions/actions/fetch-cdn-scenario@main + with: + output-dir: tests/playwright/mu-plugins/editor-assets-cdn/live + mu-plugins-dir: tests/playwright/mu-plugins + copy-fixtures: false +``` + +## How It Works + +1. **Fetch**: Downloads 10 CDN JSON files from the specified source +2. **Atomic swap**: Fetches to a temporary staging directory, then renames to target only on success +3. **Fallback**: If a file is missing from source, logs a warning and uses default scenario +4. **Mock plugin**: PHP mu-plugin intercepts `assets.elementor.com` requests and serves local fixtures +5. **Cookie-based scenarios**: Tests set `e2e_cdn_scenario` cookie to switch between scenarios + +## Key Differences from Original PRs + +| Feature | Core PR #38251 | Pro PR #7989 | Shared Action | +|---------|---------------|--------------|---------------| +| Timeout | ❌ None | ✅ 15s | ✅ 15s | +| Retry | ❌ None | ✅ 3 attempts | ✅ 3 attempts | +| `--allow-failure` | ❌ | ✅ | ✅ | +| Atomic staging | ❌ | ✅ | ✅ | +| Backoff | ❌ | ✅ Exponential | ✅ Exponential | + +The shared action uses Pro's more robust implementation as the baseline. + +## Migration Path + +Both Core and Pro can migrate incrementally: + +1. Keep existing `fetch-live-cdn-scenario.mjs` initially +2. Add this action to workflows alongside the local script +3. Verify tests pass with the action +4. Remove local script and update workflows to use only the action +5. Clean up fixture directories + +## Related + +- Core PR: [elementor/elementor#38251](https://github.com/elementor/elementor/pull/38251) +- Pro PR: [elementor/elementor-pro#7989](https://github.com/elementor/elementor-pro/pull/7989) +- Jira: [ED-26391](https://elementor.atlassian.net/browse/ED-26391) diff --git a/actions/fetch-cdn-scenario/action.yml b/actions/fetch-cdn-scenario/action.yml new file mode 100644 index 000000000..70e0ef130 --- /dev/null +++ b/actions/fetch-cdn-scenario/action.yml @@ -0,0 +1,69 @@ +name: Fetch CDN Scenario +description: Fetch live editor-assets CDN data and set up mock CDN infrastructure for Playwright tests + +inputs: + cdn-source: + description: 'CDN source URL or local directory to fetch from (default: https://assets.elementor.com)' + required: false + default: 'https://assets.elementor.com' + allow-failure: + description: 'Allow WordPress to start even if CDN fetch fails (default: false)' + required: false + default: 'false' + output-dir: + description: 'Target directory for fetched CDN files (required)' + required: true + mu-plugins-dir: + description: 'Target directory for the mock CDN mu-plugin (optional, if you want to copy the mu-plugin)' + required: false + default: '' + copy-fixtures: + description: 'Copy the shared no-promotion fixtures to the fixtures directory (default: true)' + required: false + default: 'true' + +runs: + using: composite + steps: + - name: Fetch CDN scenario + shell: bash + env: + ACTION_PATH: ${{ github.action_path }} + CDN_SOURCE: ${{ inputs.cdn-source }} + ALLOW_FAILURE: ${{ inputs.allow-failure }} + OUTPUT_DIR: ${{ inputs.output-dir }} + run: | + ALLOW_FAILURE_FLAG="" + if [ "$ALLOW_FAILURE" = "true" ]; then + ALLOW_FAILURE_FLAG="--allow-failure" + fi + + FROM_FLAG="--from=$CDN_SOURCE" + + node "$ACTION_PATH/fetch-cdn-scenario.mjs" \ + --output="$OUTPUT_DIR" \ + $FROM_FLAG \ + $ALLOW_FAILURE_FLAG + + - name: Copy mock CDN mu-plugin + if: inputs.mu-plugins-dir != '' + shell: bash + env: + ACTION_PATH: ${{ github.action_path }} + MU_PLUGINS_DIR: ${{ inputs.mu-plugins-dir }} + run: | + mkdir -p "$MU_PLUGINS_DIR" + cp "$ACTION_PATH/mock-editor-assets-cdn.php" "$MU_PLUGINS_DIR/" + echo "Copied mock-editor-assets-cdn.php to $MU_PLUGINS_DIR" + + - name: Copy shared no-promotion fixtures + if: inputs.copy-fixtures == 'true' + shell: bash + env: + ACTION_PATH: ${{ github.action_path }} + OUTPUT_DIR: ${{ inputs.output-dir }} + run: | + FIXTURES_BASE=$(dirname "$OUTPUT_DIR") + mkdir -p "$FIXTURES_BASE/no-promotion" + cp -r "$ACTION_PATH/fixtures/no-promotion/"* "$FIXTURES_BASE/no-promotion/" + echo "Copied shared no-promotion fixtures to $FIXTURES_BASE/no-promotion" diff --git a/actions/fetch-cdn-scenario/fetch-cdn-scenario.mjs b/actions/fetch-cdn-scenario/fetch-cdn-scenario.mjs new file mode 100644 index 000000000..489d18834 --- /dev/null +++ b/actions/fetch-cdn-scenario/fetch-cdn-scenario.mjs @@ -0,0 +1,116 @@ +import { mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises'; +import { existsSync } from 'node:fs'; +import { dirname, resolve } from 'node:path'; +import { fileURLToPath } from 'node:url'; +import { parseArgs } from 'node:util'; +import { setTimeout as sleep } from 'node:timers/promises'; + +const CDN_ORIGIN = 'https://assets.elementor.com'; +const HTTP_NOT_FOUND = 404; +const MAX_ATTEMPTS = 3; +const RETRY_DELAY_MS = 2000; +const REQUEST_TIMEOUT_MS = 15000; + +const CDN_PATHS = [ + 'editor-promotions/v1/connect-page.json', + 'editor-promotions/v1/conversion-banner.json', + 'editor-promotions/v1/plugins-page.json', + 'editor-promotions/v1/pointer.json', + 'editor-promotions/v1/pro-setup-panel.json', + 'editor-promotions/v1/side-menu.json', + 'editor-promotions/v1/sticky-panel.json', + 'editor-promotions/v1/theme-builder.json', + 'notifications/v1/notifications.json', + 'home-screen/v1/home-screen.json', +]; + +// `--allow-failure` lets workflows boot WordPress when the CDN is down. The promotions tests still fail +// on their own, because the live scenario is missing. +const { values: { from: source = CDN_ORIGIN, 'allow-failure': allowFailure = false, output: outputDir } } = parseArgs( { + options: { + from: { type: 'string' }, + 'allow-failure': { type: 'boolean' }, + output: { type: 'string' }, + }, +} ); + +if ( ! outputDir ) { + console.error( 'Error: --output is required. Specify the target directory for CDN files.' ); + process.exitCode = 1; + throw new Error( 'Missing required --output argument' ); +} + +const LIVE_SCENARIO_DIR = resolve( outputDir ); +const STAGING_DIR = `${ LIVE_SCENARIO_DIR }.tmp-${ process.pid }`; +const isUrl = /^https?:\/\//.test( source ); + +const fetchOnce = async ( path ) => { + const response = await fetch( `${ source.replace( /\/$/, '' ) }/${ path }`, { + cache: 'no-store', + signal: AbortSignal.timeout( REQUEST_TIMEOUT_MS ), + } ); + + if ( HTTP_NOT_FOUND === response.status ) { + return null; + } + + if ( ! response.ok ) { + throw new Error( `${ source } answered ${ response.status } for ${ path }` ); + } + + return response.json(); +}; + +const readFromUrl = async ( path ) => { + for ( let attempt = 1; ; attempt++ ) { + try { + return await fetchOnce( path ); + } catch ( error ) { + if ( attempt >= MAX_ATTEMPTS ) { + throw error; + } + + console.warn( `Attempt ${ attempt } of ${ MAX_ATTEMPTS } failed for ${ path }: ${ error.message }` ); + await sleep( RETRY_DELAY_MS * attempt ); + } + } +}; + +const readFromDir = async ( path ) => { + const file = resolve( source, path ); + + return existsSync( file ) ? JSON.parse( await readFile( file, 'utf8' ) ) : null; +}; + +const copyCdnFile = async ( path ) => { + const json = await ( isUrl ? readFromUrl( path ) : readFromDir( path ) ); + + if ( null === json ) { + console.warn( `Missing in ${ source }, the default scenario answers instead: ${ path }` ); + return; + } + + const target = resolve( STAGING_DIR, path ); + + await mkdir( dirname( target ), { recursive: true } ); + await writeFile( target, JSON.stringify( json, null, '\t' ) + '\n' ); + console.log( `Saved ${ path }` ); +}; + +// Fetch into a staging folder and swap it in only when every file arrived, so a failed run keeps the last good scenario. +try { + await rm( STAGING_DIR, { recursive: true, force: true } ); + await mkdir( STAGING_DIR, { recursive: true } ); + await Promise.all( CDN_PATHS.map( copyCdnFile ) ); + await rm( LIVE_SCENARIO_DIR, { recursive: true, force: true } ); + await rename( STAGING_DIR, LIVE_SCENARIO_DIR ); +} catch ( error ) { + await rm( STAGING_DIR, { recursive: true, force: true } ); + + const kept = existsSync( LIVE_SCENARIO_DIR ) ? 'The previous live scenario is kept.' : 'There is no live scenario, so the live CDN promotion tests will fail.'; + console.error( `Could not fetch the CDN scenario from ${ source }: ${ error.message }. ${ kept }` ); + + if ( ! allowFailure ) { + process.exitCode = 1; + } +} diff --git a/actions/fetch-cdn-scenario/fixtures/no-promotion/editor-promotions/v1/connect-page.json b/actions/fetch-cdn-scenario/fixtures/no-promotion/editor-promotions/v1/connect-page.json new file mode 100644 index 000000000..7db944d88 --- /dev/null +++ b/actions/fetch-cdn-scenario/fixtures/no-promotion/editor-promotions/v1/connect-page.json @@ -0,0 +1,5 @@ +{ + "connect-page": { + "is_active": false + } +} diff --git a/actions/fetch-cdn-scenario/fixtures/no-promotion/editor-promotions/v1/conversion-banner.json b/actions/fetch-cdn-scenario/fixtures/no-promotion/editor-promotions/v1/conversion-banner.json new file mode 100644 index 000000000..6bc6d39ab --- /dev/null +++ b/actions/fetch-cdn-scenario/fixtures/no-promotion/editor-promotions/v1/conversion-banner.json @@ -0,0 +1,5 @@ +{ + "conversion-banner": { + "is_active": false + } +} diff --git a/actions/fetch-cdn-scenario/fixtures/no-promotion/editor-promotions/v1/plugins-page.json b/actions/fetch-cdn-scenario/fixtures/no-promotion/editor-promotions/v1/plugins-page.json new file mode 100644 index 000000000..3f1e4f3e5 --- /dev/null +++ b/actions/fetch-cdn-scenario/fixtures/no-promotion/editor-promotions/v1/plugins-page.json @@ -0,0 +1,5 @@ +{ + "plugins-page": { + "is_active": false + } +} diff --git a/actions/fetch-cdn-scenario/fixtures/no-promotion/editor-promotions/v1/pointer.json b/actions/fetch-cdn-scenario/fixtures/no-promotion/editor-promotions/v1/pointer.json new file mode 100644 index 000000000..4b51615d5 --- /dev/null +++ b/actions/fetch-cdn-scenario/fixtures/no-promotion/editor-promotions/v1/pointer.json @@ -0,0 +1,5 @@ +{ + "pointer": { + "is_active": false + } +} diff --git a/actions/fetch-cdn-scenario/fixtures/no-promotion/editor-promotions/v1/pro-setup-panel.json b/actions/fetch-cdn-scenario/fixtures/no-promotion/editor-promotions/v1/pro-setup-panel.json new file mode 100644 index 000000000..ae74b5248 --- /dev/null +++ b/actions/fetch-cdn-scenario/fixtures/no-promotion/editor-promotions/v1/pro-setup-panel.json @@ -0,0 +1,5 @@ +{ + "pro-setup-panel": { + "is_active": false + } +} diff --git a/actions/fetch-cdn-scenario/fixtures/no-promotion/editor-promotions/v1/side-menu.json b/actions/fetch-cdn-scenario/fixtures/no-promotion/editor-promotions/v1/side-menu.json new file mode 100644 index 000000000..94fd45f0f --- /dev/null +++ b/actions/fetch-cdn-scenario/fixtures/no-promotion/editor-promotions/v1/side-menu.json @@ -0,0 +1,5 @@ +{ + "side-menu": { + "is_active": false + } +} diff --git a/actions/fetch-cdn-scenario/fixtures/no-promotion/editor-promotions/v1/sticky-panel.json b/actions/fetch-cdn-scenario/fixtures/no-promotion/editor-promotions/v1/sticky-panel.json new file mode 100644 index 000000000..562804d0b --- /dev/null +++ b/actions/fetch-cdn-scenario/fixtures/no-promotion/editor-promotions/v1/sticky-panel.json @@ -0,0 +1,5 @@ +{ + "sticky-panel": { + "is_active": false + } +} diff --git a/actions/fetch-cdn-scenario/fixtures/no-promotion/editor-promotions/v1/theme-builder.json b/actions/fetch-cdn-scenario/fixtures/no-promotion/editor-promotions/v1/theme-builder.json new file mode 100644 index 000000000..fe6fcb5d3 --- /dev/null +++ b/actions/fetch-cdn-scenario/fixtures/no-promotion/editor-promotions/v1/theme-builder.json @@ -0,0 +1,5 @@ +{ + "theme-builder": { + "is_active": false + } +} diff --git a/actions/fetch-cdn-scenario/fixtures/no-promotion/home-screen/v1/home-screen.json b/actions/fetch-cdn-scenario/fixtures/no-promotion/home-screen/v1/home-screen.json new file mode 100644 index 000000000..9f916e773 --- /dev/null +++ b/actions/fetch-cdn-scenario/fixtures/no-promotion/home-screen/v1/home-screen.json @@ -0,0 +1,556 @@ +{ + "lastUpdated": "2026-11-17T12:57:56.662Z", + "home-screen": { + "top_with_licences": [ + { + "license": [ + "free" + ], + "title_small": "Hi!", + "title": "Unleash your imagination with Elementor", + "description": "Start building your website with Elementor's no code drag & drop editor.", + "button_create_page_title": "Create a Page", + "button_watch_title": "Watch a guide", + "button_watch_url": "https://www.youtube.com/watch?v=le72grP_Q6k&t=1s", + "youtube_embed_id": "le72grP_Q6k?si=g2akyWNODL6usu6u" + }, + { + "license": [ + "pro" + ], + "title_small": "Hi!", + "title": "Unleash your imagination with Elementor", + "description": "Now you've got all the tools to start creating professional, high-performing websites - and that journey begins by creating your first page.", + "button_create_page_title": "Create a Page", + "button_watch_title": "Watch a guide", + "button_watch_url": "https://www.youtube.com/watch?v=QdkDGrS8ZZs", + "youtube_embed_id": "QdkDGrS8ZZs?si=s_VjZCQR6Fh1jgB5" + }, + { + "license": [ + "one" + ], + "title_small": "Hi!", + "title": "Unleash your imagination with Elementor", + "description": "Now you've got all the tools to start creating professional, high-performing websites - and that journey begins by creating your first page.", + "button_create_page_title": "Create a Page", + "button_watch_title": "Watch a guide", + "button_watch_url": "https://www.youtube.com/watch?v=QdkDGrS8ZZs", + "youtube_embed_id": "QdkDGrS8ZZs?si=s_VjZCQR6Fh1jgB5" + } + ], + "get_started": [ + { + "license": [ + "free" + ], + "header": { + "title": "Jumpstart your web-creation", + "description": "These quick actions will get your site airborne with a customized design." + }, + "repeater": [ + { + "title": "Site Settings", + "title_small": "Customize", + "url": "", + "is_relative_url": false, + "title_small_color": "text.tertiary", + "image": "https://assets.elementor.com/home-screen/v1/images/site-settings.svg" + }, + { + "title": "Site Logo", + "title_small": "Customize", + "url": "", + "is_relative_url": false, + "title_small_color": "text.tertiary", + "tab_id": "settings-site-identity", + "image": "https://assets.elementor.com/home-screen/v1/images/site-logo.svg" + }, + { + "title": "Global Colors", + "title_small": "Customize", + "url": "", + "is_relative_url": false, + "title_small_color": "text.tertiary", + "tab_id": "global-colors", + "image": "https://assets.elementor.com/home-screen/v1/images/global-colors.svg" + }, + { + "title": "Global Fonts", + "title_small": "Customize", + "url": "", + "is_relative_url": false, + "title_small_color": "text.tertiary", + "tab_id": "global-typography", + "image": "https://assets.elementor.com/home-screen/v1/images/global-fonts.svg" + }, + { + "title": "Theme Builder", + "title_small": "Customize", + "url": "admin.php?page=elementor-app", + "is_relative_url": false, + "title_small_color": "text.tertiary", + "image": "https://assets.elementor.com/home-screen/v1/images/theme-builder.svg" + }, + { + "title": "Popups", + "title_small": "Customize", + "url": "edit.php?post_type=elementor_library&page=popup_templates", + "is_relative_url": true, + "title_small_color": "text.tertiary", + "image": "https://assets.elementor.com/home-screen/v1/images/popups.svg" + }, + { + "title": "Custom Icons", + "title_small": "Customize", + "url": "admin.php?page=elementor_custom_icons", + "is_relative_url": false, + "title_small_color": "text.tertiary", + "image": "https://assets.elementor.com/home-screen/v1/images/custom-icons.svg" + }, + { + "title": "Custom Fonts", + "title_small": "Customize", + "url": "admin.php?page=elementor_custom_fonts", + "is_relative_url": true, + "image": "https://assets.elementor.com/home-screen/v1/images/custom-fonts.svg", + "title_small_color": "text.tertiary" + } + ] + }, + { + "license": [ + "pro" + ], + "header": { + "title": "Jumpstart your web-creation", + "description": "These quick actions will get your site airborne with a customized design." + }, + "repeater": [ + { + "title": "Site Settings", + "title_small": "Customize", + "url": "", + "is_relative_url": false, + "image": "https://assets.elementor.com/home-screen/v1/images/site-settings.svg" + }, + { + "title": "Site Logo", + "title_small": "Customize", + "url": "", + "is_relative_url": false, + "tab_id": "settings-site-identity", + "image": "https://assets.elementor.com/home-screen/v1/images/site-logo.svg" + }, + { + "title": "Global Colors", + "title_small": "Customize", + "url": "", + "is_relative_url": false, + "tab_id": "global-colors", + "image": "https://assets.elementor.com/home-screen/v1/images/global-colors.svg" + }, + { + "title": "Global Fonts", + "title_small": "Customize", + "url": "", + "is_relative_url": false, + "tab_id": "global-typography", + "image": "https://assets.elementor.com/home-screen/v1/images/global-fonts.svg" + }, + { + "title": "Theme Builder", + "title_small": "Customize", + "url": "admin.php?page=elementor-app", + "is_relative_url": false, + "image": "https://assets.elementor.com/home-screen/v1/images/theme-builder.svg" + }, + { + "title": "Popups", + "title_small": "Customize", + "url": "edit.php?post_type=elementor_library&tabs_group=popup&elementor_library_type=popup", + "is_relative_url": true, + "image": "https://assets.elementor.com/home-screen/v1/images/popups.svg" + }, + { + "title": "Custom Icons", + "title_small": "Customize", + "url": "admin.php?page=elementor_custom_icons", + "is_relative_url": false, + "image": "https://assets.elementor.com/home-screen/v1/images/custom-icons.svg" + }, + { + "title": "Custom Fonts", + "title_small": "Customize", + "url": "admin.php?page=elementor_custom_fonts", + "is_relative_url": true, + "image": "https://assets.elementor.com/home-screen/v1/images/custom-fonts.svg" + } + ] + }, + { + "license": [ + "one" + ], + "header": { + "title": "Jumpstart your web-creation", + "description": "These quick actions will get your site airborne with a customized design." + }, + "repeater": [ + { + "title": "Site Settings", + "title_small": "Customize", + "url": "", + "is_relative_url": false, + "image": "https://assets.elementor.com/home-screen/v1/images/site-settings.svg" + }, + { + "title": "Site Logo", + "title_small": "Customize", + "url": "", + "is_relative_url": false, + "tab_id": "settings-site-identity", + "image": "https://assets.elementor.com/home-screen/v1/images/site-logo.svg" + }, + { + "title": "Global Colors", + "title_small": "Customize", + "url": "", + "is_relative_url": false, + "tab_id": "global-colors", + "image": "https://assets.elementor.com/home-screen/v1/images/global-colors.svg" + }, + { + "title": "Global Fonts", + "title_small": "Customize", + "url": "", + "is_relative_url": false, + "tab_id": "global-typography", + "image": "https://assets.elementor.com/home-screen/v1/images/global-fonts.svg" + }, + { + "title": "Theme Builder", + "title_small": "Customize", + "url": "admin.php?page=elementor-app", + "is_relative_url": false, + "image": "https://assets.elementor.com/home-screen/v1/images/theme-builder.svg" + }, + { + "title": "Popups", + "title_small": "Customize", + "url": "edit.php?post_type=elementor_library&tabs_group=popup&elementor_library_type=popup", + "is_relative_url": true, + "image": "https://assets.elementor.com/home-screen/v1/images/popups.svg" + }, + { + "title": "Custom Icons", + "title_small": "Customize", + "url": "admin.php?page=elementor_custom_icons", + "is_relative_url": false, + "image": "https://assets.elementor.com/home-screen/v1/images/custom-icons.svg" + }, + { + "title": "Custom Fonts", + "title_small": "Customize", + "url": "admin.php?page=elementor_custom_fonts", + "is_relative_url": true, + "image": "https://assets.elementor.com/home-screen/v1/images/custom-fonts.svg" + } + ] + } + ], + "add_ons": { + "hide_section": [ + "free", + "essential", + "pro", + "one" + ], + "header": { + "title": "Expand your design toolkit", + "description": "These plugins, add-ons, and tools, have been selected to streamline your workflow and maximize your creativity." + }, + "repeater": [ + { + "file_path": "pojo-accessibility/pojo-accessibility.php", + "title": "Ally - Web Accessibility. Simplified.", + "url": "", + "description": "Make your website more accessible with powerful tools to detect and fix issues, enhance usability, and create a better experience for all visitors.", + "button_label": "Install", + "image": "https://assets.elementor.com/home-screen/v1/images/ally_logo.svg", + "type": "wporg" + }, + { + "file_path": "site-mailer/site-mailer.php", + "title": "Site Mailer", + "url": "", + "description": "Keep your WordPress emails out of the spam folder with improved deliverability and an easy setup—no need for an SMTP plugin or complicated configurations.", + "button_label": "Install", + "image": "https://assets.elementor.com/home-screen/v1/images/site-mailer.svg", + "type": "wporg" + }, + { + "file_path": "image-optimization/image-optimization.php", + "title": "Image Optimizer", + "url": "https://go.elementor.com/wp-dash-apps-author-uri-elementor-io/", + "description": "Check out this incredibly useful plugin that will compress and optimize your images, giving you leaner, faster websites.", + "button_label": "Install", + "image": "https://assets.elementor.com/home-screen/v1/images/image-optimizer.svg", + "type": "wporg" + }, + { + "title": "Elementor AI", + "url": "https://go.elementor.com/wp-dash-apps-author-uri-elementor-ai/", + "description": "Boost creativity with Elementor AI. Craft & enhance copy, create custom CSS & Code, and generate images to elevate your website.", + "button_label": "Let's go", + "image": "https://assets.elementor.com/home-screen/v1/images/elementor.svg", + "type": "link", + "condition": { + "key": "introduction_meta", + "value": "ai_get_started" + } + } + ], + "footer": { + "label": "Explore more add-ons", + "file_path": "wp-admin/admin.php?page=elementor-apps" + } + }, + "sidebar_promotion_variants": [ + { + "license": [ + "essential" + ], + "is_enabled": "true", + "type": "banner", + "data": { + "image": "https://assets.elementor.com/home-screen/v1/images/essential-upgrade.svg", + "link": "https://go.elementor.com/go-pro-advanced-home-sidebar-upgrade/" + } + }, + { + "license": [ + "free" + ], + "is_enabled": "true", + "type": "banner", + "data": { + "image": "https://assets.elementor.com/home-screen/v1/images/upgrade-free.svg", + "link": "https://go.elementor.com/go-pro-home-sidebar-upgrade/" + } + }, + { + "license": [ + "expired" + ], + "is_enabled": "true", + "type": "banner", + "data": { + "image": "https://assets.elementor.com/home-screen/v1/images/upgrade-free.svg", + "link": "https://go.elementor.com/go-pro-home-sidebar-expired/" + } + }, + { + "license": [ + "free" + ], + "is_enabled": "false", + "type": "default", + "data": { + "header": { + "title": "Bring your vision to life", + "description": "Get complete design flexibility for your website with Elementor Pro's advanced tools and premium features.", + "image": "https://assets.elementor.com/home-screen/v1/images/update-sidebar.svg" + }, + "cta": { + "label": "Upgrade Now", + "url": "https://go.elementor.com/go-pro-home-sidebar-upgrade/", + "image": "https://assets.elementor.com/home-screen/v1/images/icon-crown.svg" + }, + "repeater": [ + { + "title": "Popup Builder" + }, + { + "title": "Custom Code & CSS" + }, + { + "title": "E-commerce Features" + }, + { + "title": "Collaborative Notes" + }, + { + "title": "Form Submission" + }, + { + "title": "Form Integrations" + }, + { + "title": "Custom Attributes" + }, + { + "title": "Role Manager" + } + ] + } + }, + { + "license": [ + "pro" + ], + "is_enabled": "false", + "type": "default", + "data": { + "header": { + "title": "Bring your vision to life", + "description": "Get complete design flexibility for your website with Elementor Pro's advanced tools and premium features.", + "image": "https://assets.elementor.com/home-screen/v1/images/update-sidebar.svg" + }, + "cta": { + "label": "Upgrade Now", + "url": "https://go.elementor.com/go-pro-home-sidebar-upgrade/", + "image": "https://assets.elementor.com/home-screen/v1/images/icon-crown.svg" + }, + "repeater": [ + { + "title": "Popup Builder" + }, + { + "title": "Custom Code & CSS" + }, + { + "title": "E-commerce Features" + }, + { + "title": "Collaborative Notes" + }, + { + "title": "Form Submission" + }, + { + "title": "Form Integrations" + }, + { + "title": "Custom Attributes" + }, + { + "title": "Role Manager" + } + ] + } + }, + { + "license": [ + "one" + ], + "is_enabled": "false", + "type": "default", + "data": { + "header": { + "title": "Bring your vision to life", + "description": "Get complete design flexibility for your website with Elementor Pro's advanced tools and premium features.", + "image": "https://assets.elementor.com/home-screen/v1/images/update-sidebar.svg" + }, + "cta": { + "label": "Upgrade Now", + "url": "https://go.elementor.com/go-pro-home-sidebar-upgrade/", + "image": "https://assets.elementor.com/home-screen/v1/images/icon-crown.svg" + }, + "repeater": [ + { + "title": "Popup Builder" + }, + { + "title": "Custom Code & CSS" + }, + { + "title": "E-commerce Features" + }, + { + "title": "Collaborative Notes" + }, + { + "title": "Form Submission" + }, + { + "title": "Form Integrations" + }, + { + "title": "Custom Attributes" + }, + { + "title": "Role Manager" + } + ] + } + } + ], + "external_links": [ + { + "label": "Help Center", + "image": "https://assets.elementor.com/home-screen/v1/images/icon-question-mark.svg", + "url": "https://elementor.com/help/" + }, + { + "label": "Youtube", + "image": "https://assets.elementor.com/home-screen/v1/images/icon-youtube.svg", + "url": "https://www.youtube.com/@Elementor" + }, + { + "label": "Facebook Community", + "image": "https://assets.elementor.com/home-screen/v1/images/icon-community.svg", + "url": "https://www.facebook.com/groups/Elementors" + }, + { + "label": "Blog", + "image": "https://assets.elementor.com/home-screen/v1/images/icon-academic-hat.svg", + "url": "https://elementor.com/blog/" + } + ], + "site_builder": { + "0": { + "hasInput": true, + "title": "From idea to website in minutes", + "placeholder": "What site do you want to build?", + "buttonLabel": "Create my site" + }, + "1": { + "hasInput": false, + "title": "From idea to website in minutes", + "text": "Review your brief and generate your website", + "buttonLabel": "Create site" + }, + "2": { + "hasInput": false, + "title": "Let's turn your sitemap into a design", + "text": "Your sitemap is waiting for you to continue.", + "buttonLabel": "Visit sitemap" + }, + "3": { + "hasInput": false, + "title": "Your site design is waiting", + "text": "Jump back in to review, edit, and add to Elementor.", + "buttonLabel": "Review design" + }, + "4": { + "hasInput": false, + "title": "Your site design is ready to go live", + "text": "Review and publish your site to continue editing in Elementor.", + "buttonLabel": "Review & publish" + }, + "5": { + "hasInput": true, + "title": "Expand your site with Elementor AI", + "placeholder": "Which page do you want to create?", + "buttonLabel": "Create page" + }, + "6": { + "hasInput": true, + "title": "Expand your site with Elementor AI", + "placeholder": "Which page do you want to create?", + "buttonLabel": "Create page" + } + } + } +} diff --git a/actions/fetch-cdn-scenario/fixtures/no-promotion/notifications/v1/notifications.json b/actions/fetch-cdn-scenario/fixtures/no-promotion/notifications/v1/notifications.json new file mode 100644 index 000000000..f1c6f2bbe --- /dev/null +++ b/actions/fetch-cdn-scenario/fixtures/no-promotion/notifications/v1/notifications.json @@ -0,0 +1,3 @@ +{ + "notifications": [] +} diff --git a/actions/fetch-cdn-scenario/mock-editor-assets-cdn.php b/actions/fetch-cdn-scenario/mock-editor-assets-cdn.php new file mode 100644 index 000000000..4bc9acf3a --- /dev/null +++ b/actions/fetch-cdn-scenario/mock-editor-assets-cdn.php @@ -0,0 +1,85 @@ + [ 'content-type' => 'application/json' ], + 'body' => (string) file_get_contents( $fixture ), + 'response' => [ + 'code' => 200, + 'message' => 'OK', + ], + 'cookies' => [], + 'filename' => null, + ]; +}, 10, 3 ); + +// Campaign requests skip the shared CDN cache, so their data never leaks into parallel default-scenario requests. +if ( ELEMENTOR_E2E_CDN_DEFAULT_SCENARIO !== elementor_e2e_cdn_scenario() ) { + foreach ( ELEMENTOR_E2E_CDN_CACHE_OPTIONS as $elementor_e2e_cdn_cache_option ) { + add_filter( "pre_option_{$elementor_e2e_cdn_cache_option}", '__return_empty_array' ); + add_filter( "pre_update_option_{$elementor_e2e_cdn_cache_option}", fn( $value, $old_value ) => $old_value, 10, 2 ); + } +} From 193fe6eeabd83bdd4cea5b630be3cee58b11aa2c Mon Sep 17 00:00:00 2001 From: svitlanadykun Date: Mon, 23 Nov 2026 15:06:18 +0100 Subject: [PATCH 02/12] feat: add shared active-campaign fixtures and fetch-live toggle [ED-26391] --- actions/fetch-cdn-scenario/action.yml | 17 +- .../fetch-cdn-scenario/fetch-cdn-scenario.mjs | 1 - .../v1/conversion-banner.json | 9 + .../editor-promotions/v1/plugins-page.json | 7 + .../editor-promotions/v1/pointer.json | 10 + .../editor-promotions/v1/side-menu.json | 7 + .../editor-promotions/v1/sticky-panel.json | 8 + .../editor-promotions/v1/theme-builder.json | 7 + .../home-screen/v1/home-screen.json | 556 ++++++++++++++++++ .../notifications/v1/notifications.json | 22 + 10 files changed, 638 insertions(+), 6 deletions(-) create mode 100644 actions/fetch-cdn-scenario/fixtures/active-campaign/editor-promotions/v1/conversion-banner.json create mode 100644 actions/fetch-cdn-scenario/fixtures/active-campaign/editor-promotions/v1/plugins-page.json create mode 100644 actions/fetch-cdn-scenario/fixtures/active-campaign/editor-promotions/v1/pointer.json create mode 100644 actions/fetch-cdn-scenario/fixtures/active-campaign/editor-promotions/v1/side-menu.json create mode 100644 actions/fetch-cdn-scenario/fixtures/active-campaign/editor-promotions/v1/sticky-panel.json create mode 100644 actions/fetch-cdn-scenario/fixtures/active-campaign/editor-promotions/v1/theme-builder.json create mode 100644 actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/home-screen.json create mode 100644 actions/fetch-cdn-scenario/fixtures/active-campaign/notifications/v1/notifications.json diff --git a/actions/fetch-cdn-scenario/action.yml b/actions/fetch-cdn-scenario/action.yml index 70e0ef130..db592c436 100644 --- a/actions/fetch-cdn-scenario/action.yml +++ b/actions/fetch-cdn-scenario/action.yml @@ -18,7 +18,11 @@ inputs: required: false default: '' copy-fixtures: - description: 'Copy the shared no-promotion fixtures to the fixtures directory (default: true)' + description: 'Copy the shared no-promotion and active-campaign fixtures to the fixtures directory (default: true)' + required: false + default: 'true' + fetch-live: + description: 'Fetch live CDN data into output-dir (default: true). Set to false on PR CI to stay offline.' required: false default: 'true' @@ -26,6 +30,7 @@ runs: using: composite steps: - name: Fetch CDN scenario + if: inputs.fetch-live == 'true' shell: bash env: ACTION_PATH: ${{ github.action_path }} @@ -56,7 +61,7 @@ runs: cp "$ACTION_PATH/mock-editor-assets-cdn.php" "$MU_PLUGINS_DIR/" echo "Copied mock-editor-assets-cdn.php to $MU_PLUGINS_DIR" - - name: Copy shared no-promotion fixtures + - name: Copy shared fixtures if: inputs.copy-fixtures == 'true' shell: bash env: @@ -64,6 +69,8 @@ runs: OUTPUT_DIR: ${{ inputs.output-dir }} run: | FIXTURES_BASE=$(dirname "$OUTPUT_DIR") - mkdir -p "$FIXTURES_BASE/no-promotion" - cp -r "$ACTION_PATH/fixtures/no-promotion/"* "$FIXTURES_BASE/no-promotion/" - echo "Copied shared no-promotion fixtures to $FIXTURES_BASE/no-promotion" + for scenario in no-promotion active-campaign; do + mkdir -p "$FIXTURES_BASE/$scenario" + cp -r "$ACTION_PATH/fixtures/$scenario/"* "$FIXTURES_BASE/$scenario/" + echo "Copied shared $scenario fixtures to $FIXTURES_BASE/$scenario" + done diff --git a/actions/fetch-cdn-scenario/fetch-cdn-scenario.mjs b/actions/fetch-cdn-scenario/fetch-cdn-scenario.mjs index 489d18834..f466a2947 100644 --- a/actions/fetch-cdn-scenario/fetch-cdn-scenario.mjs +++ b/actions/fetch-cdn-scenario/fetch-cdn-scenario.mjs @@ -1,7 +1,6 @@ import { mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises'; import { existsSync } from 'node:fs'; import { dirname, resolve } from 'node:path'; -import { fileURLToPath } from 'node:url'; import { parseArgs } from 'node:util'; import { setTimeout as sleep } from 'node:timers/promises'; diff --git a/actions/fetch-cdn-scenario/fixtures/active-campaign/editor-promotions/v1/conversion-banner.json b/actions/fetch-cdn-scenario/fixtures/active-campaign/editor-promotions/v1/conversion-banner.json new file mode 100644 index 000000000..3f878eef7 --- /dev/null +++ b/actions/fetch-cdn-scenario/fixtures/active-campaign/editor-promotions/v1/conversion-banner.json @@ -0,0 +1,9 @@ +{ + "conversion-banner": { + "is_active": true, + "title": "E2E campaign conversion banner title", + "text": "E2E campaign conversion banner text", + "cta_text": "E2E campaign conversion banner button", + "cta_url": "https://go.elementor.com/e2e-campaign-conversion-banner/" + } +} diff --git a/actions/fetch-cdn-scenario/fixtures/active-campaign/editor-promotions/v1/plugins-page.json b/actions/fetch-cdn-scenario/fixtures/active-campaign/editor-promotions/v1/plugins-page.json new file mode 100644 index 000000000..d1a960b39 --- /dev/null +++ b/actions/fetch-cdn-scenario/fixtures/active-campaign/editor-promotions/v1/plugins-page.json @@ -0,0 +1,7 @@ +{ + "plugins-page": { + "is_active": true, + "label": "E2E campaign plugins page label", + "url": "https://go.elementor.com/e2e-campaign-plugins-page/" + } +} diff --git a/actions/fetch-cdn-scenario/fixtures/active-campaign/editor-promotions/v1/pointer.json b/actions/fetch-cdn-scenario/fixtures/active-campaign/editor-promotions/v1/pointer.json new file mode 100644 index 000000000..dec4bd862 --- /dev/null +++ b/actions/fetch-cdn-scenario/fixtures/active-campaign/editor-promotions/v1/pointer.json @@ -0,0 +1,10 @@ +{ + "pointer": { + "is_active": true, + "campaign_id": "e2e-campaign", + "title": "E2E campaign pointer title", + "text": "E2E campaign pointer text", + "cta_text": "E2E campaign pointer button", + "cta_url": "https://go.elementor.com/e2e-campaign-pointer/" + } +} diff --git a/actions/fetch-cdn-scenario/fixtures/active-campaign/editor-promotions/v1/side-menu.json b/actions/fetch-cdn-scenario/fixtures/active-campaign/editor-promotions/v1/side-menu.json new file mode 100644 index 000000000..179b1bc1f --- /dev/null +++ b/actions/fetch-cdn-scenario/fixtures/active-campaign/editor-promotions/v1/side-menu.json @@ -0,0 +1,7 @@ +{ + "side-menu": { + "is_active": true, + "label": "E2E campaign side menu label", + "url": "https://go.elementor.com/e2e-campaign-side-menu/" + } +} diff --git a/actions/fetch-cdn-scenario/fixtures/active-campaign/editor-promotions/v1/sticky-panel.json b/actions/fetch-cdn-scenario/fixtures/active-campaign/editor-promotions/v1/sticky-panel.json new file mode 100644 index 000000000..aebbdb285 --- /dev/null +++ b/actions/fetch-cdn-scenario/fixtures/active-campaign/editor-promotions/v1/sticky-panel.json @@ -0,0 +1,8 @@ +{ + "sticky-panel": { + "is_active": true, + "message": "E2E campaign sticky panel message", + "button_text": "E2E campaign sticky panel button", + "url": "https://go.elementor.com/e2e-campaign-sticky-panel/" + } +} diff --git a/actions/fetch-cdn-scenario/fixtures/active-campaign/editor-promotions/v1/theme-builder.json b/actions/fetch-cdn-scenario/fixtures/active-campaign/editor-promotions/v1/theme-builder.json new file mode 100644 index 000000000..f740e61f2 --- /dev/null +++ b/actions/fetch-cdn-scenario/fixtures/active-campaign/editor-promotions/v1/theme-builder.json @@ -0,0 +1,7 @@ +{ + "theme-builder": { + "is_active": true, + "button_text": "E2E campaign theme builder button", + "url": "https://go.elementor.com/e2e-campaign-theme-builder/" + } +} diff --git a/actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/home-screen.json b/actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/home-screen.json new file mode 100644 index 000000000..54549f2a6 --- /dev/null +++ b/actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/home-screen.json @@ -0,0 +1,556 @@ +{ + "lastUpdated": "2026-11-17T12:57:56.662Z", + "home-screen": { + "top_with_licences": [ + { + "license": [ + "free" + ], + "title_small": "Hi!", + "title": "Unleash your imagination with Elementor", + "description": "Start building your website with Elementor's no code drag & drop editor.", + "button_create_page_title": "Create a Page", + "button_watch_title": "Watch a guide", + "button_watch_url": "https://www.youtube.com/watch?v=le72grP_Q6k&t=1s", + "youtube_embed_id": "le72grP_Q6k?si=g2akyWNODL6usu6u" + }, + { + "license": [ + "pro" + ], + "title_small": "Hi!", + "title": "Unleash your imagination with Elementor", + "description": "Now you've got all the tools to start creating professional, high-performing websites - and that journey begins by creating your first page.", + "button_create_page_title": "Create a Page", + "button_watch_title": "Watch a guide", + "button_watch_url": "https://www.youtube.com/watch?v=QdkDGrS8ZZs", + "youtube_embed_id": "QdkDGrS8ZZs?si=s_VjZCQR6Fh1jgB5" + }, + { + "license": [ + "one" + ], + "title_small": "Hi!", + "title": "Unleash your imagination with Elementor", + "description": "Now you've got all the tools to start creating professional, high-performing websites - and that journey begins by creating your first page.", + "button_create_page_title": "Create a Page", + "button_watch_title": "Watch a guide", + "button_watch_url": "https://www.youtube.com/watch?v=QdkDGrS8ZZs", + "youtube_embed_id": "QdkDGrS8ZZs?si=s_VjZCQR6Fh1jgB5" + } + ], + "get_started": [ + { + "license": [ + "free" + ], + "header": { + "title": "Jumpstart your web-creation", + "description": "These quick actions will get your site airborne with a customized design." + }, + "repeater": [ + { + "title": "Site Settings", + "title_small": "Customize", + "url": "", + "is_relative_url": false, + "title_small_color": "text.tertiary", + "image": "https://assets.elementor.com/home-screen/v1/images/site-settings.svg" + }, + { + "title": "Site Logo", + "title_small": "Customize", + "url": "", + "is_relative_url": false, + "title_small_color": "text.tertiary", + "tab_id": "settings-site-identity", + "image": "https://assets.elementor.com/home-screen/v1/images/site-logo.svg" + }, + { + "title": "Global Colors", + "title_small": "Customize", + "url": "", + "is_relative_url": false, + "title_small_color": "text.tertiary", + "tab_id": "global-colors", + "image": "https://assets.elementor.com/home-screen/v1/images/global-colors.svg" + }, + { + "title": "Global Fonts", + "title_small": "Customize", + "url": "", + "is_relative_url": false, + "title_small_color": "text.tertiary", + "tab_id": "global-typography", + "image": "https://assets.elementor.com/home-screen/v1/images/global-fonts.svg" + }, + { + "title": "Theme Builder", + "title_small": "Customize", + "url": "admin.php?page=elementor-app", + "is_relative_url": false, + "title_small_color": "text.tertiary", + "image": "https://assets.elementor.com/home-screen/v1/images/theme-builder.svg" + }, + { + "title": "Popups", + "title_small": "Customize", + "url": "edit.php?post_type=elementor_library&page=popup_templates", + "is_relative_url": true, + "title_small_color": "text.tertiary", + "image": "https://assets.elementor.com/home-screen/v1/images/popups.svg" + }, + { + "title": "Custom Icons", + "title_small": "Customize", + "url": "admin.php?page=elementor_custom_icons", + "is_relative_url": false, + "title_small_color": "text.tertiary", + "image": "https://assets.elementor.com/home-screen/v1/images/custom-icons.svg" + }, + { + "title": "Custom Fonts", + "title_small": "Customize", + "url": "admin.php?page=elementor_custom_fonts", + "is_relative_url": true, + "image": "https://assets.elementor.com/home-screen/v1/images/custom-fonts.svg", + "title_small_color": "text.tertiary" + } + ] + }, + { + "license": [ + "pro" + ], + "header": { + "title": "Jumpstart your web-creation", + "description": "These quick actions will get your site airborne with a customized design." + }, + "repeater": [ + { + "title": "Site Settings", + "title_small": "Customize", + "url": "", + "is_relative_url": false, + "image": "https://assets.elementor.com/home-screen/v1/images/site-settings.svg" + }, + { + "title": "Site Logo", + "title_small": "Customize", + "url": "", + "is_relative_url": false, + "tab_id": "settings-site-identity", + "image": "https://assets.elementor.com/home-screen/v1/images/site-logo.svg" + }, + { + "title": "Global Colors", + "title_small": "Customize", + "url": "", + "is_relative_url": false, + "tab_id": "global-colors", + "image": "https://assets.elementor.com/home-screen/v1/images/global-colors.svg" + }, + { + "title": "Global Fonts", + "title_small": "Customize", + "url": "", + "is_relative_url": false, + "tab_id": "global-typography", + "image": "https://assets.elementor.com/home-screen/v1/images/global-fonts.svg" + }, + { + "title": "Theme Builder", + "title_small": "Customize", + "url": "admin.php?page=elementor-app", + "is_relative_url": false, + "image": "https://assets.elementor.com/home-screen/v1/images/theme-builder.svg" + }, + { + "title": "Popups", + "title_small": "Customize", + "url": "edit.php?post_type=elementor_library&tabs_group=popup&elementor_library_type=popup", + "is_relative_url": true, + "image": "https://assets.elementor.com/home-screen/v1/images/popups.svg" + }, + { + "title": "Custom Icons", + "title_small": "Customize", + "url": "admin.php?page=elementor_custom_icons", + "is_relative_url": false, + "image": "https://assets.elementor.com/home-screen/v1/images/custom-icons.svg" + }, + { + "title": "Custom Fonts", + "title_small": "Customize", + "url": "admin.php?page=elementor_custom_fonts", + "is_relative_url": true, + "image": "https://assets.elementor.com/home-screen/v1/images/custom-fonts.svg" + } + ] + }, + { + "license": [ + "one" + ], + "header": { + "title": "Jumpstart your web-creation", + "description": "These quick actions will get your site airborne with a customized design." + }, + "repeater": [ + { + "title": "Site Settings", + "title_small": "Customize", + "url": "", + "is_relative_url": false, + "image": "https://assets.elementor.com/home-screen/v1/images/site-settings.svg" + }, + { + "title": "Site Logo", + "title_small": "Customize", + "url": "", + "is_relative_url": false, + "tab_id": "settings-site-identity", + "image": "https://assets.elementor.com/home-screen/v1/images/site-logo.svg" + }, + { + "title": "Global Colors", + "title_small": "Customize", + "url": "", + "is_relative_url": false, + "tab_id": "global-colors", + "image": "https://assets.elementor.com/home-screen/v1/images/global-colors.svg" + }, + { + "title": "Global Fonts", + "title_small": "Customize", + "url": "", + "is_relative_url": false, + "tab_id": "global-typography", + "image": "https://assets.elementor.com/home-screen/v1/images/global-fonts.svg" + }, + { + "title": "Theme Builder", + "title_small": "Customize", + "url": "admin.php?page=elementor-app", + "is_relative_url": false, + "image": "https://assets.elementor.com/home-screen/v1/images/theme-builder.svg" + }, + { + "title": "Popups", + "title_small": "Customize", + "url": "edit.php?post_type=elementor_library&tabs_group=popup&elementor_library_type=popup", + "is_relative_url": true, + "image": "https://assets.elementor.com/home-screen/v1/images/popups.svg" + }, + { + "title": "Custom Icons", + "title_small": "Customize", + "url": "admin.php?page=elementor_custom_icons", + "is_relative_url": false, + "image": "https://assets.elementor.com/home-screen/v1/images/custom-icons.svg" + }, + { + "title": "Custom Fonts", + "title_small": "Customize", + "url": "admin.php?page=elementor_custom_fonts", + "is_relative_url": true, + "image": "https://assets.elementor.com/home-screen/v1/images/custom-fonts.svg" + } + ] + } + ], + "add_ons": { + "hide_section": [ + "free", + "essential", + "pro", + "one" + ], + "header": { + "title": "Expand your design toolkit", + "description": "These plugins, add-ons, and tools, have been selected to streamline your workflow and maximize your creativity." + }, + "repeater": [ + { + "file_path": "pojo-accessibility/pojo-accessibility.php", + "title": "Ally - Web Accessibility. Simplified.", + "url": "", + "description": "Make your website more accessible with powerful tools to detect and fix issues, enhance usability, and create a better experience for all visitors.", + "button_label": "Install", + "image": "https://assets.elementor.com/home-screen/v1/images/ally_logo.svg", + "type": "wporg" + }, + { + "file_path": "site-mailer/site-mailer.php", + "title": "Site Mailer", + "url": "", + "description": "Keep your WordPress emails out of the spam folder with improved deliverability and an easy setup—no need for an SMTP plugin or complicated configurations.", + "button_label": "Install", + "image": "https://assets.elementor.com/home-screen/v1/images/site-mailer.svg", + "type": "wporg" + }, + { + "file_path": "image-optimization/image-optimization.php", + "title": "Image Optimizer", + "url": "https://go.elementor.com/wp-dash-apps-author-uri-elementor-io/", + "description": "Check out this incredibly useful plugin that will compress and optimize your images, giving you leaner, faster websites.", + "button_label": "Install", + "image": "https://assets.elementor.com/home-screen/v1/images/image-optimizer.svg", + "type": "wporg" + }, + { + "title": "Elementor AI", + "url": "https://go.elementor.com/wp-dash-apps-author-uri-elementor-ai/", + "description": "Boost creativity with Elementor AI. Craft & enhance copy, create custom CSS & Code, and generate images to elevate your website.", + "button_label": "Let's go", + "image": "https://assets.elementor.com/home-screen/v1/images/elementor.svg", + "type": "link", + "condition": { + "key": "introduction_meta", + "value": "ai_get_started" + } + } + ], + "footer": { + "label": "Explore more add-ons", + "file_path": "wp-admin/admin.php?page=elementor-apps" + } + }, + "sidebar_promotion_variants": [ + { + "license": [ + "essential" + ], + "is_enabled": "true", + "type": "banner", + "data": { + "image": "https://assets.elementor.com/home-screen/v1/images/essential-upgrade.svg", + "link": "https://go.elementor.com/go-pro-advanced-home-sidebar-upgrade/" + } + }, + { + "license": [ + "free" + ], + "is_enabled": "true", + "type": "banner", + "data": { + "image": "https://assets.elementor.com/home-screen/v1/images/upgrade-free.svg", + "link": "https://go.elementor.com/e2e-campaign-home-sidebar/" + } + }, + { + "license": [ + "expired" + ], + "is_enabled": "true", + "type": "banner", + "data": { + "image": "https://assets.elementor.com/home-screen/v1/images/upgrade-free.svg", + "link": "https://go.elementor.com/go-pro-home-sidebar-expired/" + } + }, + { + "license": [ + "free" + ], + "is_enabled": "false", + "type": "default", + "data": { + "header": { + "title": "Bring your vision to life", + "description": "Get complete design flexibility for your website with Elementor Pro's advanced tools and premium features.", + "image": "https://assets.elementor.com/home-screen/v1/images/update-sidebar.svg" + }, + "cta": { + "label": "Upgrade Now", + "url": "https://go.elementor.com/go-pro-home-sidebar-upgrade/", + "image": "https://assets.elementor.com/home-screen/v1/images/icon-crown.svg" + }, + "repeater": [ + { + "title": "Popup Builder" + }, + { + "title": "Custom Code & CSS" + }, + { + "title": "E-commerce Features" + }, + { + "title": "Collaborative Notes" + }, + { + "title": "Form Submission" + }, + { + "title": "Form Integrations" + }, + { + "title": "Custom Attributes" + }, + { + "title": "Role Manager" + } + ] + } + }, + { + "license": [ + "pro" + ], + "is_enabled": "false", + "type": "default", + "data": { + "header": { + "title": "Bring your vision to life", + "description": "Get complete design flexibility for your website with Elementor Pro's advanced tools and premium features.", + "image": "https://assets.elementor.com/home-screen/v1/images/update-sidebar.svg" + }, + "cta": { + "label": "Upgrade Now", + "url": "https://go.elementor.com/go-pro-home-sidebar-upgrade/", + "image": "https://assets.elementor.com/home-screen/v1/images/icon-crown.svg" + }, + "repeater": [ + { + "title": "Popup Builder" + }, + { + "title": "Custom Code & CSS" + }, + { + "title": "E-commerce Features" + }, + { + "title": "Collaborative Notes" + }, + { + "title": "Form Submission" + }, + { + "title": "Form Integrations" + }, + { + "title": "Custom Attributes" + }, + { + "title": "Role Manager" + } + ] + } + }, + { + "license": [ + "one" + ], + "is_enabled": "false", + "type": "default", + "data": { + "header": { + "title": "Bring your vision to life", + "description": "Get complete design flexibility for your website with Elementor Pro's advanced tools and premium features.", + "image": "https://assets.elementor.com/home-screen/v1/images/update-sidebar.svg" + }, + "cta": { + "label": "Upgrade Now", + "url": "https://go.elementor.com/go-pro-home-sidebar-upgrade/", + "image": "https://assets.elementor.com/home-screen/v1/images/icon-crown.svg" + }, + "repeater": [ + { + "title": "Popup Builder" + }, + { + "title": "Custom Code & CSS" + }, + { + "title": "E-commerce Features" + }, + { + "title": "Collaborative Notes" + }, + { + "title": "Form Submission" + }, + { + "title": "Form Integrations" + }, + { + "title": "Custom Attributes" + }, + { + "title": "Role Manager" + } + ] + } + } + ], + "external_links": [ + { + "label": "Help Center", + "image": "https://assets.elementor.com/home-screen/v1/images/icon-question-mark.svg", + "url": "https://elementor.com/help/" + }, + { + "label": "Youtube", + "image": "https://assets.elementor.com/home-screen/v1/images/icon-youtube.svg", + "url": "https://www.youtube.com/@Elementor" + }, + { + "label": "Facebook Community", + "image": "https://assets.elementor.com/home-screen/v1/images/icon-community.svg", + "url": "https://www.facebook.com/groups/Elementors" + }, + { + "label": "Blog", + "image": "https://assets.elementor.com/home-screen/v1/images/icon-academic-hat.svg", + "url": "https://elementor.com/blog/" + } + ], + "site_builder": { + "0": { + "hasInput": true, + "title": "From idea to website in minutes", + "placeholder": "What site do you want to build?", + "buttonLabel": "Create my site" + }, + "1": { + "hasInput": false, + "title": "From idea to website in minutes", + "text": "Review your brief and generate your website", + "buttonLabel": "Create site" + }, + "2": { + "hasInput": false, + "title": "Let's turn your sitemap into a design", + "text": "Your sitemap is waiting for you to continue.", + "buttonLabel": "Visit sitemap" + }, + "3": { + "hasInput": false, + "title": "Your site design is waiting", + "text": "Jump back in to review, edit, and add to Elementor.", + "buttonLabel": "Review design" + }, + "4": { + "hasInput": false, + "title": "Your site design is ready to go live", + "text": "Review and publish your site to continue editing in Elementor.", + "buttonLabel": "Review & publish" + }, + "5": { + "hasInput": true, + "title": "Expand your site with Elementor AI", + "placeholder": "Which page do you want to create?", + "buttonLabel": "Create page" + }, + "6": { + "hasInput": true, + "title": "Expand your site with Elementor AI", + "placeholder": "Which page do you want to create?", + "buttonLabel": "Create page" + } + } + } +} diff --git a/actions/fetch-cdn-scenario/fixtures/active-campaign/notifications/v1/notifications.json b/actions/fetch-cdn-scenario/fixtures/active-campaign/notifications/v1/notifications.json new file mode 100644 index 000000000..5934b3330 --- /dev/null +++ b/actions/fetch-cdn-scenario/fixtures/active-campaign/notifications/v1/notifications.json @@ -0,0 +1,22 @@ +{ + "notifications": [ + { + "id": "e2e-campaign-free", + "title": "E2E campaign notification title", + "description": "E2E campaign notification description", + "topic": "Campaign", + "cta": "E2E campaign notification button", + "ctaLink": "https://go.elementor.com/e2e-campaign-notification/", + "featured": true, + "conditions": [ + [ + { + "type": "plugin", + "operator": "!=", + "plugin": "elementor-pro/elementor-pro.php" + } + ] + ] + } + ] +} From 2f929431ac9b693f70d5cde32a1cac58e3fa781e Mon Sep 17 00:00:00 2001 From: svitlanadykun Date: Mon, 23 Nov 2026 17:22:28 +0100 Subject: [PATCH 03/12] chore: fix eslint and prettier checks in fetch-cdn-scenario [ED-26391] Co-authored-by: Cursor --- actions/fetch-cdn-scenario/README.md | 36 +++-- .../fetch-cdn-scenario/fetch-cdn-scenario.mjs | 142 +++++++++++------- .../home-screen/v1/home-screen.json | 55 ++----- .../home-screen/v1/home-screen.json | 55 ++----- 4 files changed, 139 insertions(+), 149 deletions(-) diff --git a/actions/fetch-cdn-scenario/README.md b/actions/fetch-cdn-scenario/README.md index 2d04606a1..6b5d9636a 100644 --- a/actions/fetch-cdn-scenario/README.md +++ b/actions/fetch-cdn-scenario/README.md @@ -20,13 +20,13 @@ This action consolidates the CDN test infrastructure previously duplicated in [e ## Inputs -| Input | Description | Required | Default | -|-------|-------------|----------|---------| -| `cdn-source` | CDN source URL or local directory | No | `https://assets.elementor.com` | -| `allow-failure` | Allow WordPress to start if fetch fails | No | `false` | -| `output-dir` | Target directory for fetched CDN files | **Yes** | - | -| `mu-plugins-dir` | Target directory for mock mu-plugin | No | `''` | -| `copy-fixtures` | Copy shared no-promotion fixtures | No | `true` | +| Input | Description | Required | Default | +| ---------------- | --------------------------------------- | -------- | ------------------------------ | +| `cdn-source` | CDN source URL or local directory | No | `https://assets.elementor.com` | +| `allow-failure` | Allow WordPress to start if fetch fails | No | `false` | +| `output-dir` | Target directory for fetched CDN files | **Yes** | - | +| `mu-plugins-dir` | Target directory for mock mu-plugin | No | `''` | +| `copy-fixtures` | Copy shared no-promotion fixtures | No | `true` | ## Usage @@ -50,16 +50,19 @@ steps: ``` **Files you can delete from Core**: + - `scripts/fetch-live-cdn-scenario.mjs` ✓ - `tests/playwright/mu-plugins/mock-editor-assets-cdn.php` (replace with shared version) - `tests/playwright/mu-plugins/editor-assets-cdn/no-promotion/**/*` (use shared fixtures) **Keep in Core**: + - `tests/playwright/sanity/modules/promotions/campaign/campaign-promotions.test.ts` - `tests/playwright/sanity/modules/promotions/campaign/cdn-scenario.ts` - `tests/playwright/mu-plugins/editor-assets-cdn/live/` (git-ignored, populated by action) **Update in Core**: + - Remove `npm run test:playwright:fetch-cdn` from `package.json` scripts - Update workflows to use this action instead of the local script @@ -84,17 +87,20 @@ steps: ``` **Files you can delete from Pro**: + - `scripts/fetch-live-cdn-scenario.mjs` ✓ - `tests/playwright/mu-plugins/mock-editor-assets-cdn.php` (replace with shared version) - `tests/playwright/mu-plugins/editor-assets-cdn/no-promotion/**/*` (use shared fixtures) - `tests/playwright/mu-plugins/editor-assets-cdn/active-campaign/**/*` (Pro-specific, keep if needed for Pro tests) **Keep in Pro**: + - `tests/playwright/sanity/modules/promotions/cdn-free-promotions-hidden.test.ts` - `tests/playwright/sanity/modules/promotions/cdn-scenario.ts` - `tests/playwright/mu-plugins/editor-assets-cdn/live/` (git-ignored, populated by action) **Update in Pro**: + - Remove `npm run test:playwright:fetch-cdn` from `package.json` scripts - Update `start-local-server` to use this action instead of the local script @@ -103,6 +109,7 @@ steps: ### Testing a campaign before it goes live **Core example**: + ```yaml - name: Fetch CDN from local editor-assets build uses: elementor/elementor-editor-github-actions/actions/fetch-cdn-scenario@main @@ -113,6 +120,7 @@ steps: ``` **Pro example**: + ```yaml - name: Fetch CDN from custom URL uses: elementor/elementor-editor-github-actions/actions/fetch-cdn-scenario@main @@ -143,13 +151,13 @@ steps: ## Key Differences from Original PRs -| Feature | Core PR #38251 | Pro PR #7989 | Shared Action | -|---------|---------------|--------------|---------------| -| Timeout | ❌ None | ✅ 15s | ✅ 15s | -| Retry | ❌ None | ✅ 3 attempts | ✅ 3 attempts | -| `--allow-failure` | ❌ | ✅ | ✅ | -| Atomic staging | ❌ | ✅ | ✅ | -| Backoff | ❌ | ✅ Exponential | ✅ Exponential | +| Feature | Core PR #38251 | Pro PR #7989 | Shared Action | +| ----------------- | -------------- | -------------- | -------------- | +| Timeout | ❌ None | ✅ 15s | ✅ 15s | +| Retry | ❌ None | ✅ 3 attempts | ✅ 3 attempts | +| `--allow-failure` | ❌ | ✅ | ✅ | +| Atomic staging | ❌ | ✅ | ✅ | +| Backoff | ❌ | ✅ Exponential | ✅ Exponential | The shared action uses Pro's more robust implementation as the baseline. diff --git a/actions/fetch-cdn-scenario/fetch-cdn-scenario.mjs b/actions/fetch-cdn-scenario/fetch-cdn-scenario.mjs index f466a2947..7241408ac 100644 --- a/actions/fetch-cdn-scenario/fetch-cdn-scenario.mjs +++ b/actions/fetch-cdn-scenario/fetch-cdn-scenario.mjs @@ -1,8 +1,8 @@ -import { mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises'; import { existsSync } from 'node:fs'; +import { mkdir, readFile, rename, rm, writeFile } from 'node:fs/promises'; import { dirname, resolve } from 'node:path'; -import { parseArgs } from 'node:util'; import { setTimeout as sleep } from 'node:timers/promises'; +import { parseArgs } from 'node:util'; const CDN_ORIGIN = 'https://assets.elementor.com'; const HTTP_NOT_FOUND = 404; @@ -23,93 +23,133 @@ const CDN_PATHS = [ 'home-screen/v1/home-screen.json', ]; -// `--allow-failure` lets workflows boot WordPress when the CDN is down. The promotions tests still fail -// on their own, because the live scenario is missing. -const { values: { from: source = CDN_ORIGIN, 'allow-failure': allowFailure = false, output: outputDir } } = parseArgs( { +const { + values: { + from: source = CDN_ORIGIN, + 'allow-failure': allowFailure = false, + output: outputDir, + }, +} = parseArgs({ options: { from: { type: 'string' }, 'allow-failure': { type: 'boolean' }, output: { type: 'string' }, }, -} ); +}); -if ( ! outputDir ) { - console.error( 'Error: --output is required. Specify the target directory for CDN files.' ); +if (!outputDir) { + console.error( + 'Error: --output is required. Specify the target directory for CDN files.', + ); process.exitCode = 1; - throw new Error( 'Missing required --output argument' ); + throw new Error('Missing required --output argument'); } -const LIVE_SCENARIO_DIR = resolve( outputDir ); -const STAGING_DIR = `${ LIVE_SCENARIO_DIR }.tmp-${ process.pid }`; -const isUrl = /^https?:\/\//.test( source ); +const LIVE_SCENARIO_DIR = resolve(outputDir); +const STAGING_DIR = `${LIVE_SCENARIO_DIR}.tmp-${String(process.pid)}`; +const isUrl = /^https?:\/\//.test(source); -const fetchOnce = async ( path ) => { - const response = await fetch( `${ source.replace( /\/$/, '' ) }/${ path }`, { +/** @param {unknown} error */ +const getErrorMessage = (error) => + error instanceof Error ? error.message : String(error); + +/** + * @param {string} path + * @returns {Promise} + */ +const fetchOnce = async (path) => { + const response = await fetch(`${source.replace(/\/$/, '')}/${path}`, { cache: 'no-store', - signal: AbortSignal.timeout( REQUEST_TIMEOUT_MS ), - } ); + signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS), + }); - if ( HTTP_NOT_FOUND === response.status ) { + if (HTTP_NOT_FOUND === response.status) { return null; } - if ( ! response.ok ) { - throw new Error( `${ source } answered ${ response.status } for ${ path }` ); + if (!response.ok) { + throw new Error( + `${source} answered ${String(response.status)} for ${path}`, + ); } - return response.json(); + const data = /** @type {unknown} */ (await response.json()); + return data; }; -const readFromUrl = async ( path ) => { - for ( let attempt = 1; ; attempt++ ) { +/** + * @param {string} path + * @returns {Promise} + */ +const readFromUrl = async (path) => { + for (let attempt = 1; ; attempt++) { try { - return await fetchOnce( path ); - } catch ( error ) { - if ( attempt >= MAX_ATTEMPTS ) { + return await fetchOnce(path); + } catch (error) { + if (attempt >= MAX_ATTEMPTS) { throw error; } - console.warn( `Attempt ${ attempt } of ${ MAX_ATTEMPTS } failed for ${ path }: ${ error.message }` ); - await sleep( RETRY_DELAY_MS * attempt ); + console.warn( + `Attempt ${String(attempt)} of ${String(MAX_ATTEMPTS)} failed for ${path}: ${getErrorMessage(error)}`, + ); + await sleep(RETRY_DELAY_MS * attempt); } } }; -const readFromDir = async ( path ) => { - const file = resolve( source, path ); +/** + * @param {string} path + * @returns {Promise} + */ +const readFromDir = async (path) => { + const file = resolve(source, path); + + if (!existsSync(file)) { + return null; + } - return existsSync( file ) ? JSON.parse( await readFile( file, 'utf8' ) ) : null; + const data = /** @type {unknown} */ ( + JSON.parse(await readFile(file, 'utf8')) + ); + return data; }; -const copyCdnFile = async ( path ) => { - const json = await ( isUrl ? readFromUrl( path ) : readFromDir( path ) ); +/** @param {string} path */ +const copyCdnFile = async (path) => { + const json = await (isUrl ? readFromUrl(path) : readFromDir(path)); - if ( null === json ) { - console.warn( `Missing in ${ source }, the default scenario answers instead: ${ path }` ); + if (null === json) { + console.warn( + `Missing in ${source}, the default scenario answers instead: ${path}`, + ); return; } - const target = resolve( STAGING_DIR, path ); + const target = resolve(STAGING_DIR, path); - await mkdir( dirname( target ), { recursive: true } ); - await writeFile( target, JSON.stringify( json, null, '\t' ) + '\n' ); - console.log( `Saved ${ path }` ); + await mkdir(dirname(target), { recursive: true }); + await writeFile(target, JSON.stringify(json, null, '\t') + '\n'); + console.log(`Saved ${path}`); }; -// Fetch into a staging folder and swap it in only when every file arrived, so a failed run keeps the last good scenario. try { - await rm( STAGING_DIR, { recursive: true, force: true } ); - await mkdir( STAGING_DIR, { recursive: true } ); - await Promise.all( CDN_PATHS.map( copyCdnFile ) ); - await rm( LIVE_SCENARIO_DIR, { recursive: true, force: true } ); - await rename( STAGING_DIR, LIVE_SCENARIO_DIR ); -} catch ( error ) { - await rm( STAGING_DIR, { recursive: true, force: true } ); - - const kept = existsSync( LIVE_SCENARIO_DIR ) ? 'The previous live scenario is kept.' : 'There is no live scenario, so the live CDN promotion tests will fail.'; - console.error( `Could not fetch the CDN scenario from ${ source }: ${ error.message }. ${ kept }` ); - - if ( ! allowFailure ) { + await rm(STAGING_DIR, { recursive: true, force: true }); + await mkdir(STAGING_DIR, { recursive: true }); + await Promise.all(CDN_PATHS.map(copyCdnFile)); + await rm(LIVE_SCENARIO_DIR, { recursive: true, force: true }); + await rename(STAGING_DIR, LIVE_SCENARIO_DIR); +} catch (error) { + await rm(STAGING_DIR, { recursive: true, force: true }); + + const kept = existsSync(LIVE_SCENARIO_DIR) + ? 'The previous live scenario is kept.' + : 'There is no live scenario, so the live CDN promotion tests will fail.'; + console.error( + `Could not fetch the CDN scenario from ${source}: ${getErrorMessage(error)}. ${kept}`, + ); + + if (!allowFailure) { process.exitCode = 1; } } diff --git a/actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/home-screen.json b/actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/home-screen.json index 54549f2a6..32657f317 100644 --- a/actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/home-screen.json +++ b/actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/home-screen.json @@ -3,9 +3,7 @@ "home-screen": { "top_with_licences": [ { - "license": [ - "free" - ], + "license": ["free"], "title_small": "Hi!", "title": "Unleash your imagination with Elementor", "description": "Start building your website with Elementor's no code drag & drop editor.", @@ -15,9 +13,7 @@ "youtube_embed_id": "le72grP_Q6k?si=g2akyWNODL6usu6u" }, { - "license": [ - "pro" - ], + "license": ["pro"], "title_small": "Hi!", "title": "Unleash your imagination with Elementor", "description": "Now you've got all the tools to start creating professional, high-performing websites - and that journey begins by creating your first page.", @@ -27,9 +23,7 @@ "youtube_embed_id": "QdkDGrS8ZZs?si=s_VjZCQR6Fh1jgB5" }, { - "license": [ - "one" - ], + "license": ["one"], "title_small": "Hi!", "title": "Unleash your imagination with Elementor", "description": "Now you've got all the tools to start creating professional, high-performing websites - and that journey begins by creating your first page.", @@ -41,9 +35,7 @@ ], "get_started": [ { - "license": [ - "free" - ], + "license": ["free"], "header": { "title": "Jumpstart your web-creation", "description": "These quick actions will get your site airborne with a customized design." @@ -119,9 +111,7 @@ ] }, { - "license": [ - "pro" - ], + "license": ["pro"], "header": { "title": "Jumpstart your web-creation", "description": "These quick actions will get your site airborne with a customized design." @@ -189,9 +179,7 @@ ] }, { - "license": [ - "one" - ], + "license": ["one"], "header": { "title": "Jumpstart your web-creation", "description": "These quick actions will get your site airborne with a customized design." @@ -260,12 +248,7 @@ } ], "add_ons": { - "hide_section": [ - "free", - "essential", - "pro", - "one" - ], + "hide_section": ["free", "essential", "pro", "one"], "header": { "title": "Expand your design toolkit", "description": "These plugins, add-ons, and tools, have been selected to streamline your workflow and maximize your creativity." @@ -318,9 +301,7 @@ }, "sidebar_promotion_variants": [ { - "license": [ - "essential" - ], + "license": ["essential"], "is_enabled": "true", "type": "banner", "data": { @@ -329,9 +310,7 @@ } }, { - "license": [ - "free" - ], + "license": ["free"], "is_enabled": "true", "type": "banner", "data": { @@ -340,9 +319,7 @@ } }, { - "license": [ - "expired" - ], + "license": ["expired"], "is_enabled": "true", "type": "banner", "data": { @@ -351,9 +328,7 @@ } }, { - "license": [ - "free" - ], + "license": ["free"], "is_enabled": "false", "type": "default", "data": { @@ -396,9 +371,7 @@ } }, { - "license": [ - "pro" - ], + "license": ["pro"], "is_enabled": "false", "type": "default", "data": { @@ -441,9 +414,7 @@ } }, { - "license": [ - "one" - ], + "license": ["one"], "is_enabled": "false", "type": "default", "data": { diff --git a/actions/fetch-cdn-scenario/fixtures/no-promotion/home-screen/v1/home-screen.json b/actions/fetch-cdn-scenario/fixtures/no-promotion/home-screen/v1/home-screen.json index 9f916e773..07ac681e1 100644 --- a/actions/fetch-cdn-scenario/fixtures/no-promotion/home-screen/v1/home-screen.json +++ b/actions/fetch-cdn-scenario/fixtures/no-promotion/home-screen/v1/home-screen.json @@ -3,9 +3,7 @@ "home-screen": { "top_with_licences": [ { - "license": [ - "free" - ], + "license": ["free"], "title_small": "Hi!", "title": "Unleash your imagination with Elementor", "description": "Start building your website with Elementor's no code drag & drop editor.", @@ -15,9 +13,7 @@ "youtube_embed_id": "le72grP_Q6k?si=g2akyWNODL6usu6u" }, { - "license": [ - "pro" - ], + "license": ["pro"], "title_small": "Hi!", "title": "Unleash your imagination with Elementor", "description": "Now you've got all the tools to start creating professional, high-performing websites - and that journey begins by creating your first page.", @@ -27,9 +23,7 @@ "youtube_embed_id": "QdkDGrS8ZZs?si=s_VjZCQR6Fh1jgB5" }, { - "license": [ - "one" - ], + "license": ["one"], "title_small": "Hi!", "title": "Unleash your imagination with Elementor", "description": "Now you've got all the tools to start creating professional, high-performing websites - and that journey begins by creating your first page.", @@ -41,9 +35,7 @@ ], "get_started": [ { - "license": [ - "free" - ], + "license": ["free"], "header": { "title": "Jumpstart your web-creation", "description": "These quick actions will get your site airborne with a customized design." @@ -119,9 +111,7 @@ ] }, { - "license": [ - "pro" - ], + "license": ["pro"], "header": { "title": "Jumpstart your web-creation", "description": "These quick actions will get your site airborne with a customized design." @@ -189,9 +179,7 @@ ] }, { - "license": [ - "one" - ], + "license": ["one"], "header": { "title": "Jumpstart your web-creation", "description": "These quick actions will get your site airborne with a customized design." @@ -260,12 +248,7 @@ } ], "add_ons": { - "hide_section": [ - "free", - "essential", - "pro", - "one" - ], + "hide_section": ["free", "essential", "pro", "one"], "header": { "title": "Expand your design toolkit", "description": "These plugins, add-ons, and tools, have been selected to streamline your workflow and maximize your creativity." @@ -318,9 +301,7 @@ }, "sidebar_promotion_variants": [ { - "license": [ - "essential" - ], + "license": ["essential"], "is_enabled": "true", "type": "banner", "data": { @@ -329,9 +310,7 @@ } }, { - "license": [ - "free" - ], + "license": ["free"], "is_enabled": "true", "type": "banner", "data": { @@ -340,9 +319,7 @@ } }, { - "license": [ - "expired" - ], + "license": ["expired"], "is_enabled": "true", "type": "banner", "data": { @@ -351,9 +328,7 @@ } }, { - "license": [ - "free" - ], + "license": ["free"], "is_enabled": "false", "type": "default", "data": { @@ -396,9 +371,7 @@ } }, { - "license": [ - "pro" - ], + "license": ["pro"], "is_enabled": "false", "type": "default", "data": { @@ -441,9 +414,7 @@ } }, { - "license": [ - "one" - ], + "license": ["one"], "is_enabled": "false", "type": "default", "data": { From 43a334db216f075873789701646bcdc6f20388f5 Mon Sep 17 00:00:00 2001 From: svitlanadykun Date: Tue, 24 Nov 2026 22:16:37 +0100 Subject: [PATCH 04/12] fix: mock every promotion CDN file and give each case a distinct campaign 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 --- actions/fetch-cdn-scenario/README.md | 162 ++++++------------ actions/fetch-cdn-scenario/action.yml | 2 +- .../fetch-cdn-scenario/fetch-cdn-scenario.mjs | 12 +- .../v1/free-to-pro-upsell.json | 29 ++++ .../home-screen/v1/home-screen.json | 13 +- .../notifications/v1/notifications.json | 26 +++ .../packages/v1/promotions.json | 75 ++++++++ .../v1/free-to-pro-upsell.json | 29 ++++ .../no-promotion/packages/v1/promotions.json | 75 ++++++++ .../mock-editor-assets-cdn.php | 2 + 10 files changed, 316 insertions(+), 109 deletions(-) create mode 100644 actions/fetch-cdn-scenario/fixtures/active-campaign/free-to-pro-upsell/v1/free-to-pro-upsell.json create mode 100644 actions/fetch-cdn-scenario/fixtures/active-campaign/packages/v1/promotions.json create mode 100644 actions/fetch-cdn-scenario/fixtures/no-promotion/free-to-pro-upsell/v1/free-to-pro-upsell.json create mode 100644 actions/fetch-cdn-scenario/fixtures/no-promotion/packages/v1/promotions.json diff --git a/actions/fetch-cdn-scenario/README.md b/actions/fetch-cdn-scenario/README.md index 6b5d9636a..1002fc4a7 100644 --- a/actions/fetch-cdn-scenario/README.md +++ b/actions/fetch-cdn-scenario/README.md @@ -6,103 +6,77 @@ Shared GitHub Actions composite action that provides CDN campaign promotion test This action consolidates the CDN test infrastructure previously duplicated in [elementor/elementor#38251](https://github.com/elementor/elementor/pull/38251) and [elementor/elementor-pro#7989](https://github.com/elementor/elementor-pro/pull/7989). It provides: -1. **Fetch script** (`fetch-cdn-scenario.mjs`) - Downloads current CDN JSON files with retry logic, timeout handling, and optional failure tolerance -2. **Mock mu-plugin** (`mock-editor-assets-cdn.php`) - Intercepts WordPress HTTP requests to serve local fixtures instead of live CDN -3. **Shared fixtures** - No-promotion scenario fixtures shared between Core and Pro +1. **Fetch script** (`fetch-cdn-scenario.mjs`) - Downloads the current CDN JSON files into a `live` scenario, with retries, a request timeout and optional failure tolerance +2. **Mock mu-plugin** (`mock-editor-assets-cdn.php`) - Answers WordPress requests to `assets.elementor.com` from local fixtures instead of the live CDN +3. **Shared fixtures** - The `no-promotion` scenario (the default, current CDN content) and the `active-campaign` scenario (a campaign with `e2e-` texts and links that differ from every Core default) -## Features - -- **Retry logic**: Up to 3 attempts with exponential backoff (2s, 4s, 6s) -- **Timeout handling**: 15s request timeout per file -- **Graceful failure**: Optional `--allow-failure` to allow WordPress to start even if CDN is down -- **Atomic updates**: Fetches to staging directory and swaps in only on complete success -- **Flexible source**: Fetch from live CDN, custom URL, or local directory - -## Inputs - -| Input | Description | Required | Default | -| ---------------- | --------------------------------------- | -------- | ------------------------------ | -| `cdn-source` | CDN source URL or local directory | No | `https://assets.elementor.com` | -| `allow-failure` | Allow WordPress to start if fetch fails | No | `false` | -| `output-dir` | Target directory for fetched CDN files | **Yes** | - | -| `mu-plugins-dir` | Target directory for mock mu-plugin | No | `''` | -| `copy-fixtures` | Copy shared no-promotion fixtures | No | `true` | - -## Usage +## Mocked CDN files -### Elementor Core +| CDN path | Used by | +| ----------------------------------------------- | ------------------------------------------------------------ | +| `editor-promotions/v1/*.json` | Plugins page, admin menu, conversion banner, pointer, editor | +| `notifications/v1/notifications.json` | What's New | +| `home-screen/v1/home-screen.json` | Home screen, including the sidebar banner for each tier | +| `packages/v1/promotions.json` | V4 (atomic) promotions, `elementor.config.v4Promotions` | +| `free-to-pro-upsell/v1/free-to-pro-upsell.json` | Widget upsell images, `elementorPromotionsData` | -**In your workflow** (e.g., `.github/workflows/playwright-suite.yml`): +A CDN file without a fixture is not mocked and reaches the live CDN, so a new CDN file needs a fixture here, a path in `CDN_PATHS` and its cache option in `ELEMENTOR_E2E_CDN_CACHE_OPTIONS`. -```yaml -steps: - - uses: actions/checkout@v6 - - - name: Fetch live CDN scenario - uses: elementor/elementor-editor-github-actions/actions/fetch-cdn-scenario@main - with: - output-dir: tests/playwright/mu-plugins/editor-assets-cdn/live - mu-plugins-dir: tests/playwright/mu-plugins - copy-fixtures: true - - - name: Install WordPress environment - run: npm run start-local-server -``` +The `active-campaign` scenario gives every case a value that the live CDN and the defaults do not have, so a test that finds it proves the mock answered: -**Files you can delete from Core**: +- What's New: a Free-only card, a Pro-only card and a card for everyone +- Home screen sidebar: a different `e2e-campaign-home-sidebar-*` link for the `free`, `essential`, `essential-oct2023` and `expired` tiers -- `scripts/fetch-live-cdn-scenario.mjs` ✓ -- `tests/playwright/mu-plugins/mock-editor-assets-cdn.php` (replace with shared version) -- `tests/playwright/mu-plugins/editor-assets-cdn/no-promotion/**/*` (use shared fixtures) +## Features -**Keep in Core**: +- **Retries**: Up to 3 attempts per file, waiting 2s and then 4s +- **Timeout**: 15s per request +- **Graceful failure**: `allow-failure` lets WordPress start even if the CDN is down. The previous `live` scenario is kept. +- **Atomic updates**: Files are fetched into a staging directory, which replaces `live` only when every file succeeded +- **Flexible source**: The live CDN, another URL, or a local directory -- `tests/playwright/sanity/modules/promotions/campaign/campaign-promotions.test.ts` -- `tests/playwright/sanity/modules/promotions/campaign/cdn-scenario.ts` -- `tests/playwright/mu-plugins/editor-assets-cdn/live/` (git-ignored, populated by action) +## Inputs -**Update in Core**: +| Input | Description | Required | Default | +| ---------------- | -------------------------------------------------------------------------------------------- | -------- | ------------------------------ | +| `output-dir` | Directory of the `live` scenario. The shared scenarios are copied next to it. | **Yes** | - | +| `fetch-live` | Fetch the live CDN into `output-dir`. Set to `false` on PR CI to stay offline. | No | `true` | +| `cdn-source` | CDN source URL or local directory | No | `https://assets.elementor.com` | +| `allow-failure` | Allow WordPress to start if the fetch fails | No | `false` | +| `mu-plugins-dir` | Directory to copy the mock mu-plugin into | No | `''` | +| `copy-fixtures` | Copy the shared `no-promotion` and `active-campaign` scenarios to the parent of `output-dir` | No | `true` | -- Remove `npm run test:playwright:fetch-cdn` from `package.json` scripts -- Update workflows to use this action instead of the local script +## Usage -### Elementor Pro +PR CI runs offline against the shared fixtures. A scheduled job fetches the live CDN and runs the promotion tests against it with `E2E_CDN_SCENARIO=live`, so a broken live campaign is reported within a day. -**In your workflow** (e.g., `start-local-server` script or workflow): +### PR CI ```yaml -steps: - - uses: actions/checkout@v6 - - - name: Fetch live CDN scenario with failure tolerance - uses: elementor/elementor-editor-github-actions/actions/fetch-cdn-scenario@main - with: - output-dir: tests/playwright/mu-plugins/editor-assets-cdn/live - mu-plugins-dir: tests/playwright/mu-plugins - allow-failure: true - copy-fixtures: true - - - name: Start wp-env - run: bash ./.github/scripts/start-wp-env.sh +- name: Setup CDN promotion fixtures + uses: elementor/elementor-editor-github-actions/actions/fetch-cdn-scenario@ + with: + output-dir: tests/playwright/mu-plugins/editor-assets-cdn/live + mu-plugins-dir: tests/playwright/mu-plugins + fetch-live: false ``` -**Files you can delete from Pro**: - -- `scripts/fetch-live-cdn-scenario.mjs` ✓ -- `tests/playwright/mu-plugins/mock-editor-assets-cdn.php` (replace with shared version) -- `tests/playwright/mu-plugins/editor-assets-cdn/no-promotion/**/*` (use shared fixtures) -- `tests/playwright/mu-plugins/editor-assets-cdn/active-campaign/**/*` (Pro-specific, keep if needed for Pro tests) +### Nightly live CDN check -**Keep in Pro**: - -- `tests/playwright/sanity/modules/promotions/cdn-free-promotions-hidden.test.ts` -- `tests/playwright/sanity/modules/promotions/cdn-scenario.ts` -- `tests/playwright/mu-plugins/editor-assets-cdn/live/` (git-ignored, populated by action) +```yaml +- name: Fetch live CDN scenario + uses: elementor/elementor-editor-github-actions/actions/fetch-cdn-scenario@ + with: + output-dir: tests/playwright/mu-plugins/editor-assets-cdn/live + mu-plugins-dir: tests/playwright/mu-plugins -**Update in Pro**: +- name: Run promotion tests against the live CDN + env: + E2E_CDN_SCENARIO: live + run: npx playwright test --grep @promotions +``` -- Remove `npm run test:playwright:fetch-cdn` from `package.json` scripts -- Update `start-local-server` to use this action instead of the local script +`fetch-live` keeps `allow-failure: false` here on purpose: a CDN that cannot be fetched fails the job. ## Advanced Usage @@ -143,33 +117,11 @@ steps: ## How It Works -1. **Fetch**: Downloads 10 CDN JSON files from the specified source -2. **Atomic swap**: Fetches to a temporary staging directory, then renames to target only on success -3. **Fallback**: If a file is missing from source, logs a warning and uses default scenario -4. **Mock plugin**: PHP mu-plugin intercepts `assets.elementor.com` requests and serves local fixtures -5. **Cookie-based scenarios**: Tests set `e2e_cdn_scenario` cookie to switch between scenarios - -## Key Differences from Original PRs - -| Feature | Core PR #38251 | Pro PR #7989 | Shared Action | -| ----------------- | -------------- | -------------- | -------------- | -| Timeout | ❌ None | ✅ 15s | ✅ 15s | -| Retry | ❌ None | ✅ 3 attempts | ✅ 3 attempts | -| `--allow-failure` | ❌ | ✅ | ✅ | -| Atomic staging | ❌ | ✅ | ✅ | -| Backoff | ❌ | ✅ Exponential | ✅ Exponential | - -The shared action uses Pro's more robust implementation as the baseline. - -## Migration Path - -Both Core and Pro can migrate incrementally: - -1. Keep existing `fetch-live-cdn-scenario.mjs` initially -2. Add this action to workflows alongside the local script -3. Verify tests pass with the action -4. Remove local script and update workflows to use only the action -5. Clean up fixture directories +1. **Fetch**: Downloads the mocked CDN files from the source into a staging directory +2. **Atomic swap**: The staging directory replaces `output-dir` only when every file succeeded +3. **Missing files**: A file that the source does not have is skipped with a warning, and the default scenario answers for it +4. **Mock plugin**: The mu-plugin answers `assets.elementor.com` requests from the fixtures of the selected scenario, or of the default scenario +5. **Scenarios**: Tests select a scenario with the `e2e_cdn_scenario` cookie. A non-default scenario skips the CDN cache options, so its data never reaches requests of the default scenario. ## Related diff --git a/actions/fetch-cdn-scenario/action.yml b/actions/fetch-cdn-scenario/action.yml index db592c436..457ba17ba 100644 --- a/actions/fetch-cdn-scenario/action.yml +++ b/actions/fetch-cdn-scenario/action.yml @@ -18,7 +18,7 @@ inputs: required: false default: '' copy-fixtures: - description: 'Copy the shared no-promotion and active-campaign fixtures to the fixtures directory (default: true)' + description: 'Copy the shared no-promotion and active-campaign scenarios to the parent of output-dir (default: true)' required: false default: 'true' fetch-live: diff --git a/actions/fetch-cdn-scenario/fetch-cdn-scenario.mjs b/actions/fetch-cdn-scenario/fetch-cdn-scenario.mjs index 7241408ac..2b7a2d709 100644 --- a/actions/fetch-cdn-scenario/fetch-cdn-scenario.mjs +++ b/actions/fetch-cdn-scenario/fetch-cdn-scenario.mjs @@ -21,6 +21,8 @@ const CDN_PATHS = [ 'editor-promotions/v1/theme-builder.json', 'notifications/v1/notifications.json', 'home-screen/v1/home-screen.json', + 'packages/v1/promotions.json', + 'free-to-pro-upsell/v1/free-to-pro-upsell.json', ]; const { @@ -136,7 +138,15 @@ const copyCdnFile = async (path) => { try { await rm(STAGING_DIR, { recursive: true, force: true }); await mkdir(STAGING_DIR, { recursive: true }); - await Promise.all(CDN_PATHS.map(copyCdnFile)); + // Every write settles before the staging directory may be removed below. + const results = await Promise.allSettled(CDN_PATHS.map(copyCdnFile)); + + for (const result of results) { + if ('rejected' === result.status) { + throw result.reason; + } + } + await rm(LIVE_SCENARIO_DIR, { recursive: true, force: true }); await rename(STAGING_DIR, LIVE_SCENARIO_DIR); } catch (error) { diff --git a/actions/fetch-cdn-scenario/fixtures/active-campaign/free-to-pro-upsell/v1/free-to-pro-upsell.json b/actions/fetch-cdn-scenario/fixtures/active-campaign/free-to-pro-upsell/v1/free-to-pro-upsell.json new file mode 100644 index 000000000..a116f49d6 --- /dev/null +++ b/actions/fetch-cdn-scenario/fixtures/active-campaign/free-to-pro-upsell/v1/free-to-pro-upsell.json @@ -0,0 +1,29 @@ +{ + "lastUpdated": "2026-11-19T13:44:16.080Z", + "free-to-pro-upsell": [ + { + "id": "animated_headline", + "imageSrc": "https://assets.elementor.com/free-to-pro-upsell/v1/images/animated_headline.jpg?e2e-campaign" + }, + { + "id": "video_playlist", + "imageSrc": "https://assets.elementor.com/free-to-pro-upsell/v1/images/video_playlist.jpg" + }, + { + "id": "cta", + "imageSrc": "https://assets.elementor.com/free-to-pro-upsell/v1/images/cta.jpg" + }, + { + "id": "testimonial_widget", + "imageSrc": "https://assets.elementor.com/free-to-pro-upsell/v1/images/testimonial_widget.jpg" + }, + { + "id": "image_carousel", + "imageSrc": "https://assets.elementor.com/free-to-pro-upsell/v1/images/image_carousel.jpg" + }, + { + "id": "connect-pro-upgrade", + "imageSrc": "https://assets.elementor.com/free-to-pro-upsell/v1/images/connect-pro-upgrade.jpg" + } + ] +} diff --git a/actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/home-screen.json b/actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/home-screen.json index 32657f317..c04cc8eb2 100644 --- a/actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/home-screen.json +++ b/actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/home-screen.json @@ -306,7 +306,16 @@ "type": "banner", "data": { "image": "https://assets.elementor.com/home-screen/v1/images/essential-upgrade.svg", - "link": "https://go.elementor.com/go-pro-advanced-home-sidebar-upgrade/" + "link": "https://go.elementor.com/e2e-campaign-home-sidebar-essential/" + } + }, + { + "license": ["essential-oct2023"], + "is_enabled": "true", + "type": "banner", + "data": { + "image": "https://assets.elementor.com/home-screen/v1/images/essential-upgrade.svg", + "link": "https://go.elementor.com/e2e-campaign-home-sidebar-essential-oct2023/" } }, { @@ -324,7 +333,7 @@ "type": "banner", "data": { "image": "https://assets.elementor.com/home-screen/v1/images/upgrade-free.svg", - "link": "https://go.elementor.com/go-pro-home-sidebar-expired/" + "link": "https://go.elementor.com/e2e-campaign-home-sidebar-expired/" } }, { diff --git a/actions/fetch-cdn-scenario/fixtures/active-campaign/notifications/v1/notifications.json b/actions/fetch-cdn-scenario/fixtures/active-campaign/notifications/v1/notifications.json index 5934b3330..8f87bd8e4 100644 --- a/actions/fetch-cdn-scenario/fixtures/active-campaign/notifications/v1/notifications.json +++ b/actions/fetch-cdn-scenario/fixtures/active-campaign/notifications/v1/notifications.json @@ -17,6 +17,32 @@ } ] ] + }, + { + "id": "e2e-campaign-pro", + "title": "E2E campaign Pro notification title", + "description": "E2E campaign Pro notification description", + "topic": "Campaign", + "cta": "E2E campaign Pro notification button", + "ctaLink": "https://go.elementor.com/e2e-campaign-notification-pro/", + "featured": true, + "conditions": [ + [ + { + "type": "plugin", + "operator": "==", + "plugin": "elementor-pro/elementor-pro.php" + } + ] + ] + }, + { + "id": "e2e-campaign-all", + "title": "E2E campaign notification for everyone", + "description": "E2E campaign notification for everyone description", + "topic": "Campaign", + "cta": "E2E campaign notification for everyone button", + "ctaLink": "https://go.elementor.com/e2e-campaign-notification-all/" } ] } diff --git a/actions/fetch-cdn-scenario/fixtures/active-campaign/packages/v1/promotions.json b/actions/fetch-cdn-scenario/fixtures/active-campaign/packages/v1/promotions.json new file mode 100644 index 000000000..21cea3ef6 --- /dev/null +++ b/actions/fetch-cdn-scenario/fixtures/active-campaign/packages/v1/promotions.json @@ -0,0 +1,75 @@ +{ + "lastUpdated": "2026-11-19T13:44:16.241Z", + "promotions": [ + { + "customCss": { + "title": "Custom CSS", + "content": "Add custom CSS to refine and enrich the appearance of any element on your site.", + "ctaUrl": "https://go.elementor.com/go-pro-style-custom-css/", + "image": "https://assets.elementor.com/packages/v1/images/custom_css_promotion.png" + }, + "displayConditions": { + "title": "Display conditions", + "content": "Control when and where elements are shown across your site.", + "ctaUrl": "https://go.elementor.com/go-pro-display-conditions-modal/", + "image": "https://assets.elementor.com/packages/v1/images/display_conditions_promotion.png" + }, + "attributes": { + "title": "E2E campaign attributes title", + "content": "E2E campaign attributes content", + "ctaUrl": "https://go.elementor.com/e2e-campaign-attributes/", + "image": "https://assets.elementor.com/packages/v1/images/attributes_promotion.png?e2e-campaign" + }, + "Portfolio": { + "title": "Portfolio", + "content": "Upgrade to build dynamic portfolio grids featuring interactive category filtering and engaging hover effects designed to captivate your site visitors.", + "image": "https://assets.elementor.com/packages/v1/images/Portfolio_promotion.png" + }, + "Form": { + "title": "Form", + "content": "Upgrade to build advanced forms featuring custom fields, multi-step layouts, automated email notifications, and direct CRM integrations.", + "image": "https://assets.elementor.com/packages/v1/images/Form_promotion.png" + }, + "PriceList": { + "title": "Price list", + "content": "Upgrade to present items, descriptions, and pricing within a cohesive structure that aligned perfectly with your site.", + "image": "https://assets.elementor.com/packages/v1/images/Price_list_promotion.png" + }, + "PriceTable": { + "title": "Price table", + "content": "Upgrade to build pricing matrices featuring highlighted columns, interactive check mark lists, and integrated action buttons.", + "image": "https://assets.elementor.com/packages/v1/images/Price_table_promotion.png" + }, + "LoopGrid": { + "title": "Loop Grid", + "content": "Upgrade to connect custom layouts directly to your site database, seamlessly rendering dynamic content queries that engage your site visitors.", + "image": "https://assets.elementor.com/packages/v1/images/Loop_grid_promotion.png" + }, + "CallToAction": { + "title": "Call to Action", + "content": "Upgrade to build Call to Action blocks with image overlays, custom hover animations, and promotional layout control across your site.", + "image": "https://assets.elementor.com/packages/v1/images/CTA_promotion.png" + }, + "Template": { + "title": "Template", + "content": "Upgrade to embed saved templates that sync automatically across your entire site, preserving layout integrity and accelerating your production speed.", + "image": "https://assets.elementor.com/packages/v1/images/Template_promotion.png" + }, + "Gallery": { + "title": "Gallery pro", + "content": "Upgrade to build gallery with dynamic categorization and custom layout control across your site.", + "image": "https://assets.elementor.com/packages/v1/images/Gallery_pro_promotion.png" + }, + "MediaCarousel": { + "title": "Media carousel", + "content": "Upgrade to build advanced Media Carousel with dynamic video elements into your sliders to better engage your site visitors.", + "image": "https://assets.elementor.com/packages/v1/images/Media_carousel_promotion.png" + }, + "LoopCarousel": { + "title": "Loop carousel", + "content": "Upgrade to build advanced Loop Carousel with dynamic posts, custom layouts seamlessly to better engage your site visitors.", + "image": "https://assets.elementor.com/packages/v1/images/Loop_carousel_promotion.png" + } + } + ] +} diff --git a/actions/fetch-cdn-scenario/fixtures/no-promotion/free-to-pro-upsell/v1/free-to-pro-upsell.json b/actions/fetch-cdn-scenario/fixtures/no-promotion/free-to-pro-upsell/v1/free-to-pro-upsell.json new file mode 100644 index 000000000..2ae738ec2 --- /dev/null +++ b/actions/fetch-cdn-scenario/fixtures/no-promotion/free-to-pro-upsell/v1/free-to-pro-upsell.json @@ -0,0 +1,29 @@ +{ + "lastUpdated": "2026-11-19T13:44:16.080Z", + "free-to-pro-upsell": [ + { + "id": "animated_headline", + "imageSrc": "https://assets.elementor.com/free-to-pro-upsell/v1/images/animated_headline.jpg" + }, + { + "id": "video_playlist", + "imageSrc": "https://assets.elementor.com/free-to-pro-upsell/v1/images/video_playlist.jpg" + }, + { + "id": "cta", + "imageSrc": "https://assets.elementor.com/free-to-pro-upsell/v1/images/cta.jpg" + }, + { + "id": "testimonial_widget", + "imageSrc": "https://assets.elementor.com/free-to-pro-upsell/v1/images/testimonial_widget.jpg" + }, + { + "id": "image_carousel", + "imageSrc": "https://assets.elementor.com/free-to-pro-upsell/v1/images/image_carousel.jpg" + }, + { + "id": "connect-pro-upgrade", + "imageSrc": "https://assets.elementor.com/free-to-pro-upsell/v1/images/connect-pro-upgrade.jpg" + } + ] +} diff --git a/actions/fetch-cdn-scenario/fixtures/no-promotion/packages/v1/promotions.json b/actions/fetch-cdn-scenario/fixtures/no-promotion/packages/v1/promotions.json new file mode 100644 index 000000000..f0b347025 --- /dev/null +++ b/actions/fetch-cdn-scenario/fixtures/no-promotion/packages/v1/promotions.json @@ -0,0 +1,75 @@ +{ + "lastUpdated": "2026-11-19T13:44:16.241Z", + "promotions": [ + { + "customCss": { + "title": "Custom CSS", + "content": "Add custom CSS to refine and enrich the appearance of any element on your site.", + "ctaUrl": "https://go.elementor.com/go-pro-style-custom-css/", + "image": "https://assets.elementor.com/packages/v1/images/custom_css_promotion.png" + }, + "displayConditions": { + "title": "Display conditions", + "content": "Control when and where elements are shown across your site.", + "ctaUrl": "https://go.elementor.com/go-pro-display-conditions-modal/", + "image": "https://assets.elementor.com/packages/v1/images/display_conditions_promotion.png" + }, + "attributes": { + "title": "Attributes", + "content": "Add custom attributes when you need deeper customization and better accessibility.", + "ctaUrl": "https://go.elementor.com/go-pro-attributes-modal/", + "image": "https://assets.elementor.com/packages/v1/images/attributes_promotion.png" + }, + "Portfolio": { + "title": "Portfolio", + "content": "Upgrade to build dynamic portfolio grids featuring interactive category filtering and engaging hover effects designed to captivate your site visitors.", + "image": "https://assets.elementor.com/packages/v1/images/Portfolio_promotion.png" + }, + "Form": { + "title": "Form", + "content": "Upgrade to build advanced forms featuring custom fields, multi-step layouts, automated email notifications, and direct CRM integrations.", + "image": "https://assets.elementor.com/packages/v1/images/Form_promotion.png" + }, + "PriceList": { + "title": "Price list", + "content": "Upgrade to present items, descriptions, and pricing within a cohesive structure that aligned perfectly with your site.", + "image": "https://assets.elementor.com/packages/v1/images/Price_list_promotion.png" + }, + "PriceTable": { + "title": "Price table", + "content": "Upgrade to build pricing matrices featuring highlighted columns, interactive check mark lists, and integrated action buttons.", + "image": "https://assets.elementor.com/packages/v1/images/Price_table_promotion.png" + }, + "LoopGrid": { + "title": "Loop Grid", + "content": "Upgrade to connect custom layouts directly to your site database, seamlessly rendering dynamic content queries that engage your site visitors.", + "image": "https://assets.elementor.com/packages/v1/images/Loop_grid_promotion.png" + }, + "CallToAction": { + "title": "Call to Action", + "content": "Upgrade to build Call to Action blocks with image overlays, custom hover animations, and promotional layout control across your site.", + "image": "https://assets.elementor.com/packages/v1/images/CTA_promotion.png" + }, + "Template": { + "title": "Template", + "content": "Upgrade to embed saved templates that sync automatically across your entire site, preserving layout integrity and accelerating your production speed.", + "image": "https://assets.elementor.com/packages/v1/images/Template_promotion.png" + }, + "Gallery": { + "title": "Gallery pro", + "content": "Upgrade to build gallery with dynamic categorization and custom layout control across your site.", + "image": "https://assets.elementor.com/packages/v1/images/Gallery_pro_promotion.png" + }, + "MediaCarousel": { + "title": "Media carousel", + "content": "Upgrade to build advanced Media Carousel with dynamic video elements into your sliders to better engage your site visitors.", + "image": "https://assets.elementor.com/packages/v1/images/Media_carousel_promotion.png" + }, + "LoopCarousel": { + "title": "Loop carousel", + "content": "Upgrade to build advanced Loop Carousel with dynamic posts, custom layouts seamlessly to better engage your site visitors.", + "image": "https://assets.elementor.com/packages/v1/images/Loop_carousel_promotion.png" + } + } + ] +} diff --git a/actions/fetch-cdn-scenario/mock-editor-assets-cdn.php b/actions/fetch-cdn-scenario/mock-editor-assets-cdn.php index 4bc9acf3a..b6f2d76e3 100644 --- a/actions/fetch-cdn-scenario/mock-editor-assets-cdn.php +++ b/actions/fetch-cdn-scenario/mock-editor-assets-cdn.php @@ -25,6 +25,8 @@ 'elementor_theme_builder_promotion_assets_data', '_elementor_notifications_data', '_elementor_home_screen_data', + '_elementor_v4_promotions', + '_elementor_free_to_pro_upsell', ]; function elementor_e2e_cdn_scenario(): string { From 2844c6e9cadd7bd338fc06afaf331471ac85a6c4 Mon Sep 17 00:00:00 2001 From: svitlanadykun Date: Wed, 25 Nov 2026 13:09:47 +0100 Subject: [PATCH 05/12] fix: treat an empty cdn-source as the production CDN [ED-26391] Co-Authored-By: Claude Opus 5.5 --- actions/fetch-cdn-scenario/README.md | 8 ++++---- actions/fetch-cdn-scenario/action.yml | 18 +++++++++--------- .../fetch-cdn-scenario/fetch-cdn-scenario.mjs | 8 +++----- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/actions/fetch-cdn-scenario/README.md b/actions/fetch-cdn-scenario/README.md index 1002fc4a7..9046c8551 100644 --- a/actions/fetch-cdn-scenario/README.md +++ b/actions/fetch-cdn-scenario/README.md @@ -41,7 +41,7 @@ The `active-campaign` scenario gives every case a value that the live CDN and th | ---------------- | -------------------------------------------------------------------------------------------- | -------- | ------------------------------ | | `output-dir` | Directory of the `live` scenario. The shared scenarios are copied next to it. | **Yes** | - | | `fetch-live` | Fetch the live CDN into `output-dir`. Set to `false` on PR CI to stay offline. | No | `true` | -| `cdn-source` | CDN source URL or local directory | No | `https://assets.elementor.com` | +| `cdn-source` | CDN source URL or local directory, empty means the production CDN | No | `https://assets.elementor.com` | | `allow-failure` | Allow WordPress to start if the fetch fails | No | `false` | | `mu-plugins-dir` | Directory to copy the mock mu-plugin into | No | `''` | | `copy-fixtures` | Copy the shared `no-promotion` and `active-campaign` scenarios to the parent of `output-dir` | No | `true` | @@ -93,13 +93,13 @@ PR CI runs offline against the shared fixtures. A scheduled job fetches the live mu-plugins-dir: tests/playwright/mu-plugins ``` -**Pro example**: +**Staging example**: every editor-assets pull request to `master` is deployed to `https://assets.stg.elementor.red`. ```yaml -- name: Fetch CDN from custom URL +- name: Fetch CDN from staging uses: elementor/elementor-editor-github-actions/actions/fetch-cdn-scenario@main with: - cdn-source: https://staging.assets.elementor.com + cdn-source: https://assets.stg.elementor.red output-dir: tests/playwright/mu-plugins/editor-assets-cdn/live mu-plugins-dir: tests/playwright/mu-plugins allow-failure: true diff --git a/actions/fetch-cdn-scenario/action.yml b/actions/fetch-cdn-scenario/action.yml index 457ba17ba..0827ea518 100644 --- a/actions/fetch-cdn-scenario/action.yml +++ b/actions/fetch-cdn-scenario/action.yml @@ -3,7 +3,7 @@ description: Fetch live editor-assets CDN data and set up mock CDN infrastructur inputs: cdn-source: - description: 'CDN source URL or local directory to fetch from (default: https://assets.elementor.com)' + description: 'CDN source URL or local directory to fetch from, e.g. https://assets.stg.elementor.red. Empty means https://assets.elementor.com.' required: false default: 'https://assets.elementor.com' allow-failure: @@ -38,17 +38,17 @@ runs: ALLOW_FAILURE: ${{ inputs.allow-failure }} OUTPUT_DIR: ${{ inputs.output-dir }} run: | - ALLOW_FAILURE_FLAG="" - if [ "$ALLOW_FAILURE" = "true" ]; then - ALLOW_FAILURE_FLAG="--allow-failure" + ARGS=( --output="$OUTPUT_DIR" ) + + if [ -n "$CDN_SOURCE" ]; then + ARGS+=( --from="$CDN_SOURCE" ) fi - FROM_FLAG="--from=$CDN_SOURCE" + if [ "$ALLOW_FAILURE" = "true" ]; then + ARGS+=( --allow-failure ) + fi - node "$ACTION_PATH/fetch-cdn-scenario.mjs" \ - --output="$OUTPUT_DIR" \ - $FROM_FLAG \ - $ALLOW_FAILURE_FLAG + node "$ACTION_PATH/fetch-cdn-scenario.mjs" "${ARGS[@]}" - name: Copy mock CDN mu-plugin if: inputs.mu-plugins-dir != '' diff --git a/actions/fetch-cdn-scenario/fetch-cdn-scenario.mjs b/actions/fetch-cdn-scenario/fetch-cdn-scenario.mjs index 2b7a2d709..6d13c3644 100644 --- a/actions/fetch-cdn-scenario/fetch-cdn-scenario.mjs +++ b/actions/fetch-cdn-scenario/fetch-cdn-scenario.mjs @@ -26,11 +26,7 @@ const CDN_PATHS = [ ]; const { - values: { - from: source = CDN_ORIGIN, - 'allow-failure': allowFailure = false, - output: outputDir, - }, + values: { from, 'allow-failure': allowFailure = false, output: outputDir }, } = parseArgs({ options: { from: { type: 'string' }, @@ -47,6 +43,8 @@ if (!outputDir) { throw new Error('Missing required --output argument'); } +// Callers pass an empty source when they have none, so it means the production CDN. +const source = from || CDN_ORIGIN; const LIVE_SCENARIO_DIR = resolve(outputDir); const STAGING_DIR = `${LIVE_SCENARIO_DIR}.tmp-${String(process.pid)}`; const isUrl = /^https?:\/\//.test(source); From 6c808e75218f62c883a77a67c6bbc21bfbd48a94 Mon Sep 17 00:00:00 2001 From: svitlanadykun Date: Wed, 25 Nov 2026 15:48:13 +0100 Subject: [PATCH 06/12] fix: fail when the CDN source has none of the files [ED-26391] Co-Authored-By: Claude Opus 5.5 --- actions/fetch-cdn-scenario/fetch-cdn-scenario.mjs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/actions/fetch-cdn-scenario/fetch-cdn-scenario.mjs b/actions/fetch-cdn-scenario/fetch-cdn-scenario.mjs index 6d13c3644..d77f97897 100644 --- a/actions/fetch-cdn-scenario/fetch-cdn-scenario.mjs +++ b/actions/fetch-cdn-scenario/fetch-cdn-scenario.mjs @@ -115,7 +115,10 @@ const readFromDir = async (path) => { return data; }; -/** @param {string} path */ +/** + * @param {string} path + * @returns {Promise} Whether the source has the file. + */ const copyCdnFile = async (path) => { const json = await (isUrl ? readFromUrl(path) : readFromDir(path)); @@ -123,7 +126,7 @@ const copyCdnFile = async (path) => { console.warn( `Missing in ${source}, the default scenario answers instead: ${path}`, ); - return; + return false; } const target = resolve(STAGING_DIR, path); @@ -131,6 +134,7 @@ const copyCdnFile = async (path) => { await mkdir(dirname(target), { recursive: true }); await writeFile(target, JSON.stringify(json, null, '\t') + '\n'); console.log(`Saved ${path}`); + return true; }; try { @@ -145,6 +149,13 @@ try { } } + // A source without any of the files is a wrong source, not a CDN that dropped a file. + if (!results.some((result) => result.value)) { + throw new Error( + `none of the ${String(CDN_PATHS.length)} CDN files exist there, check the source`, + ); + } + await rm(LIVE_SCENARIO_DIR, { recursive: true, force: true }); await rename(STAGING_DIR, LIVE_SCENARIO_DIR); } catch (error) { From a826ea6077df7c82428ea1784767797620889777 Mon Sep 17 00:00:00 2001 From: svitlanadykun Date: Wed, 25 Nov 2026 16:47:11 +0100 Subject: [PATCH 07/12] test: give the active-campaign sidebar banners their own images [ED-26391] Co-Authored-By: Claude Opus 5.5 --- actions/fetch-cdn-scenario/README.md | 4 +++- .../active-campaign/home-screen/v1/home-screen.json | 8 ++++---- .../v1/images/e2e-campaign-essential-oct2023.svg | 6 ++++++ .../home-screen/v1/images/e2e-campaign-essential.svg | 6 ++++++ .../home-screen/v1/images/e2e-campaign-expired.svg | 6 ++++++ .../home-screen/v1/images/e2e-campaign-free.svg | 6 ++++++ 6 files changed, 31 insertions(+), 5 deletions(-) create mode 100644 actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/images/e2e-campaign-essential-oct2023.svg create mode 100644 actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/images/e2e-campaign-essential.svg create mode 100644 actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/images/e2e-campaign-expired.svg create mode 100644 actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/images/e2e-campaign-free.svg diff --git a/actions/fetch-cdn-scenario/README.md b/actions/fetch-cdn-scenario/README.md index 9046c8551..e484fca49 100644 --- a/actions/fetch-cdn-scenario/README.md +++ b/actions/fetch-cdn-scenario/README.md @@ -25,7 +25,9 @@ A CDN file without a fixture is not mocked and reaches the live CDN, so a new CD The `active-campaign` scenario gives every case a value that the live CDN and the defaults do not have, so a test that finds it proves the mock answered: - What's New: a Free-only card, a Pro-only card and a card for everyone -- Home screen sidebar: a different `e2e-campaign-home-sidebar-*` link for the `free`, `essential`, `essential-oct2023` and `expired` tiers +- Home screen sidebar: a different `e2e-campaign-home-sidebar-*` link and `e2e-campaign-*.svg` image for the `free`, `essential`, `essential-oct2023` and `expired` tiers + +The sidebar images are part of the fixture, at the same paths as on the CDN. The browser loads images from the CDN itself, not through the mock, so the tests answer those requests from the fixture. This keeps screenshots of the scenario independent of the live CDN. ## Features diff --git a/actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/home-screen.json b/actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/home-screen.json index c04cc8eb2..5c213b4b0 100644 --- a/actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/home-screen.json +++ b/actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/home-screen.json @@ -305,7 +305,7 @@ "is_enabled": "true", "type": "banner", "data": { - "image": "https://assets.elementor.com/home-screen/v1/images/essential-upgrade.svg", + "image": "https://assets.elementor.com/home-screen/v1/images/e2e-campaign-essential.svg", "link": "https://go.elementor.com/e2e-campaign-home-sidebar-essential/" } }, @@ -314,7 +314,7 @@ "is_enabled": "true", "type": "banner", "data": { - "image": "https://assets.elementor.com/home-screen/v1/images/essential-upgrade.svg", + "image": "https://assets.elementor.com/home-screen/v1/images/e2e-campaign-essential-oct2023.svg", "link": "https://go.elementor.com/e2e-campaign-home-sidebar-essential-oct2023/" } }, @@ -323,7 +323,7 @@ "is_enabled": "true", "type": "banner", "data": { - "image": "https://assets.elementor.com/home-screen/v1/images/upgrade-free.svg", + "image": "https://assets.elementor.com/home-screen/v1/images/e2e-campaign-free.svg", "link": "https://go.elementor.com/e2e-campaign-home-sidebar/" } }, @@ -332,7 +332,7 @@ "is_enabled": "true", "type": "banner", "data": { - "image": "https://assets.elementor.com/home-screen/v1/images/upgrade-free.svg", + "image": "https://assets.elementor.com/home-screen/v1/images/e2e-campaign-expired.svg", "link": "https://go.elementor.com/e2e-campaign-home-sidebar-expired/" } }, diff --git a/actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/images/e2e-campaign-essential-oct2023.svg b/actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/images/e2e-campaign-essential-oct2023.svg new file mode 100644 index 000000000..6784f300a --- /dev/null +++ b/actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/images/e2e-campaign-essential-oct2023.svg @@ -0,0 +1,6 @@ + + + E2E campaign + sidebar banner + essential-oct2023 + diff --git a/actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/images/e2e-campaign-essential.svg b/actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/images/e2e-campaign-essential.svg new file mode 100644 index 000000000..a2ed5dc9e --- /dev/null +++ b/actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/images/e2e-campaign-essential.svg @@ -0,0 +1,6 @@ + + + E2E campaign + sidebar banner + essential + diff --git a/actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/images/e2e-campaign-expired.svg b/actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/images/e2e-campaign-expired.svg new file mode 100644 index 000000000..b6d04531d --- /dev/null +++ b/actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/images/e2e-campaign-expired.svg @@ -0,0 +1,6 @@ + + + E2E campaign + sidebar banner + expired + diff --git a/actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/images/e2e-campaign-free.svg b/actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/images/e2e-campaign-free.svg new file mode 100644 index 000000000..07ffd524e --- /dev/null +++ b/actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/images/e2e-campaign-free.svg @@ -0,0 +1,6 @@ + + + E2E campaign + sidebar banner + free + From f2600f9c561064eacc423e406864a50656f94aa8 Mon Sep 17 00:00:00 2001 From: svitlanadykun Date: Wed, 25 Nov 2026 21:36:06 +0100 Subject: [PATCH 08/12] fix: harden fetch-cdn-scenario URL validation, retries, and fixture sync [ED-26391] Co-authored-by: Cursor --- actions/fetch-cdn-scenario/README.md | 2 +- actions/fetch-cdn-scenario/action.yml | 1 + .../fetch-cdn-scenario/fetch-cdn-scenario.mjs | 56 +++++++++++++++++-- .../mock-editor-assets-cdn.php | 12 +++- 4 files changed, 61 insertions(+), 10 deletions(-) diff --git a/actions/fetch-cdn-scenario/README.md b/actions/fetch-cdn-scenario/README.md index e484fca49..15a35b4bf 100644 --- a/actions/fetch-cdn-scenario/README.md +++ b/actions/fetch-cdn-scenario/README.md @@ -27,7 +27,7 @@ The `active-campaign` scenario gives every case a value that the live CDN and th - What's New: a Free-only card, a Pro-only card and a card for everyone - Home screen sidebar: a different `e2e-campaign-home-sidebar-*` link and `e2e-campaign-*.svg` image for the `free`, `essential`, `essential-oct2023` and `expired` tiers -The sidebar images are part of the fixture, at the same paths as on the CDN. The browser loads images from the CDN itself, not through the mock, so the tests answer those requests from the fixture. This keeps screenshots of the scenario independent of the live CDN. +The sidebar images are part of the fixture, at the same paths as on the CDN. The browser loads images from the CDN itself, not through the mock, so the tests answer those requests from the fixture. This keeps offline tests independent of the live CDN. ## Features diff --git a/actions/fetch-cdn-scenario/action.yml b/actions/fetch-cdn-scenario/action.yml index 0827ea518..8d276b994 100644 --- a/actions/fetch-cdn-scenario/action.yml +++ b/actions/fetch-cdn-scenario/action.yml @@ -70,6 +70,7 @@ runs: run: | FIXTURES_BASE=$(dirname "$OUTPUT_DIR") for scenario in no-promotion active-campaign; do + rm -rf "$FIXTURES_BASE/$scenario" mkdir -p "$FIXTURES_BASE/$scenario" cp -r "$ACTION_PATH/fixtures/$scenario/"* "$FIXTURES_BASE/$scenario/" echo "Copied shared $scenario fixtures to $FIXTURES_BASE/$scenario" diff --git a/actions/fetch-cdn-scenario/fetch-cdn-scenario.mjs b/actions/fetch-cdn-scenario/fetch-cdn-scenario.mjs index d77f97897..2070d6ada 100644 --- a/actions/fetch-cdn-scenario/fetch-cdn-scenario.mjs +++ b/actions/fetch-cdn-scenario/fetch-cdn-scenario.mjs @@ -5,7 +5,13 @@ import { setTimeout as sleep } from 'node:timers/promises'; import { parseArgs } from 'node:util'; const CDN_ORIGIN = 'https://assets.elementor.com'; +const ALLOWED_CDN_ORIGINS = new Set([ + CDN_ORIGIN, + 'https://assets.stg.elementor.red', +]); const HTTP_NOT_FOUND = 404; +const HTTP_TOO_MANY_REQUESTS = 429; +const HTTP_SERVER_ERROR_MIN = 500; const MAX_ATTEMPTS = 3; const RETRY_DELAY_MS = 2000; const REQUEST_TIMEOUT_MS = 15000; @@ -47,7 +53,37 @@ if (!outputDir) { const source = from || CDN_ORIGIN; const LIVE_SCENARIO_DIR = resolve(outputDir); const STAGING_DIR = `${LIVE_SCENARIO_DIR}.tmp-${String(process.pid)}`; -const isUrl = /^https?:\/\//.test(source); +const isUrl = /^https?:\/\//i.test(source); + +/** + * @param {string} rawUrl + * @returns {string} + */ +const resolveAllowedUrlBase = (rawUrl) => { + const parsed = new URL(rawUrl); + + if ( + 'https:' !== parsed.protocol || + !ALLOWED_CDN_ORIGINS.has(parsed.origin) + ) { + throw new Error( + `Unsupported CDN URL origin "${parsed.origin}". Allowed origins: ${[...ALLOWED_CDN_ORIGINS].join(', ')}`, + ); + } + + if (parsed.username || parsed.password || parsed.search || parsed.hash) { + throw new Error( + `CDN URL must not include credentials, query, or hash: ${rawUrl}`, + ); + } + + const normalizedPath = parsed.pathname.replace(/\/+$/, ''); + return `${parsed.origin}${normalizedPath}`; +}; + +const urlBase = isUrl ? resolveAllowedUrlBase(source) : ''; + +class NonRetryableHttpError extends Error {} /** @param {unknown} error */ const getErrorMessage = (error) => @@ -58,7 +94,7 @@ const getErrorMessage = (error) => * @returns {Promise} */ const fetchOnce = async (path) => { - const response = await fetch(`${source.replace(/\/$/, '')}/${path}`, { + const response = await fetch(`${urlBase}/${path}`, { cache: 'no-store', signal: AbortSignal.timeout(REQUEST_TIMEOUT_MS), }); @@ -68,9 +104,14 @@ const fetchOnce = async (path) => { } if (!response.ok) { - throw new Error( - `${source} answered ${String(response.status)} for ${path}`, - ); + const message = `${urlBase} answered ${String(response.status)} for ${path}`; + const isRetryable = + HTTP_TOO_MANY_REQUESTS === response.status || + response.status >= HTTP_SERVER_ERROR_MIN; + + throw isRetryable + ? new Error(message) + : new NonRetryableHttpError(message); } const data = /** @type {unknown} */ (await response.json()); @@ -86,7 +127,10 @@ const readFromUrl = async (path) => { try { return await fetchOnce(path); } catch (error) { - if (attempt >= MAX_ATTEMPTS) { + if ( + error instanceof NonRetryableHttpError || + attempt >= MAX_ATTEMPTS + ) { throw error; } diff --git a/actions/fetch-cdn-scenario/mock-editor-assets-cdn.php b/actions/fetch-cdn-scenario/mock-editor-assets-cdn.php index b6f2d76e3..5bd773753 100644 --- a/actions/fetch-cdn-scenario/mock-editor-assets-cdn.php +++ b/actions/fetch-cdn-scenario/mock-editor-assets-cdn.php @@ -40,14 +40,20 @@ function elementor_e2e_cdn_scenario(): string { } function elementor_e2e_cdn_find_fixture( string $path ): string { - if ( false !== strpos( $path, '..' ) ) { + if ( false !== strpos( $path, '..' ) || '.json' !== strtolower( substr( $path, -5 ) ) ) { + return ''; + } + + $base_dir = realpath( ELEMENTOR_E2E_CDN_FIXTURES_DIR ); + + if ( false === $base_dir ) { return ''; } foreach ( array_unique( [ elementor_e2e_cdn_scenario(), ELEMENTOR_E2E_CDN_DEFAULT_SCENARIO ] ) as $scenario ) { - $fixture = ELEMENTOR_E2E_CDN_FIXTURES_DIR . '/' . $scenario . $path; + $fixture = realpath( $base_dir . '/' . $scenario . $path ); - if ( is_file( $fixture ) ) { + if ( false !== $fixture && 0 === strpos( $fixture, $base_dir . DIRECTORY_SEPARATOR ) && is_file( $fixture ) ) { return $fixture; } } From 54ceb5131747a5faa52db17ed376fc4f92de4a05 Mon Sep 17 00:00:00 2001 From: svitlanadykun Date: Wed, 25 Nov 2026 21:49:34 +0100 Subject: [PATCH 09/12] fix: distinguish missing CDN files from JSON null values [ED-26391] Co-authored-by: Cursor --- actions/fetch-cdn-scenario/fetch-cdn-scenario.mjs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/actions/fetch-cdn-scenario/fetch-cdn-scenario.mjs b/actions/fetch-cdn-scenario/fetch-cdn-scenario.mjs index 2070d6ada..33fe4f595 100644 --- a/actions/fetch-cdn-scenario/fetch-cdn-scenario.mjs +++ b/actions/fetch-cdn-scenario/fetch-cdn-scenario.mjs @@ -100,7 +100,7 @@ const fetchOnce = async (path) => { }); if (HTTP_NOT_FOUND === response.status) { - return null; + return undefined; } if (!response.ok) { @@ -150,7 +150,7 @@ const readFromDir = async (path) => { const file = resolve(source, path); if (!existsSync(file)) { - return null; + return undefined; } const data = /** @type {unknown} */ ( @@ -166,7 +166,7 @@ const readFromDir = async (path) => { const copyCdnFile = async (path) => { const json = await (isUrl ? readFromUrl(path) : readFromDir(path)); - if (null === json) { + if (undefined === json) { console.warn( `Missing in ${source}, the default scenario answers instead: ${path}`, ); From baf6746c83ad2214ff898fb4c99eaed861c3ecd3 Mon Sep 17 00:00:00 2001 From: svitlanadykun Date: Wed, 25 Nov 2026 23:15:43 +0100 Subject: [PATCH 10/12] docs: clarify allowed CDN origins in fetch-cdn-scenario README [ED-26391] Co-authored-by: Cursor --- actions/fetch-cdn-scenario/README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/actions/fetch-cdn-scenario/README.md b/actions/fetch-cdn-scenario/README.md index 15a35b4bf..9056b273f 100644 --- a/actions/fetch-cdn-scenario/README.md +++ b/actions/fetch-cdn-scenario/README.md @@ -35,7 +35,7 @@ The sidebar images are part of the fixture, at the same paths as on the CDN. The - **Timeout**: 15s per request - **Graceful failure**: `allow-failure` lets WordPress start even if the CDN is down. The previous `live` scenario is kept. - **Atomic updates**: Files are fetched into a staging directory, which replaces `live` only when every file succeeded -- **Flexible source**: The live CDN, another URL, or a local directory +- **Flexible source**: The live CDN (`assets.elementor.com`), staging CDN (`assets.stg.elementor.red`), or a local directory ## Inputs From 1c331b8a089cb664c2ee8b168db02a790911dcd5 Mon Sep 17 00:00:00 2001 From: svitlanadykun Date: Thu, 26 Nov 2026 08:48:07 +0100 Subject: [PATCH 11/12] test: drop the active-campaign sidebar banner images [ED-26391] 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 --- actions/fetch-cdn-scenario/README.md | 4 ++-- .../v1/images/e2e-campaign-essential-oct2023.svg | 6 ------ .../home-screen/v1/images/e2e-campaign-essential.svg | 6 ------ .../home-screen/v1/images/e2e-campaign-expired.svg | 6 ------ .../home-screen/v1/images/e2e-campaign-free.svg | 6 ------ 5 files changed, 2 insertions(+), 26 deletions(-) delete mode 100644 actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/images/e2e-campaign-essential-oct2023.svg delete mode 100644 actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/images/e2e-campaign-essential.svg delete mode 100644 actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/images/e2e-campaign-expired.svg delete mode 100644 actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/images/e2e-campaign-free.svg diff --git a/actions/fetch-cdn-scenario/README.md b/actions/fetch-cdn-scenario/README.md index 9056b273f..3907bfb67 100644 --- a/actions/fetch-cdn-scenario/README.md +++ b/actions/fetch-cdn-scenario/README.md @@ -25,9 +25,9 @@ A CDN file without a fixture is not mocked and reaches the live CDN, so a new CD The `active-campaign` scenario gives every case a value that the live CDN and the defaults do not have, so a test that finds it proves the mock answered: - What's New: a Free-only card, a Pro-only card and a card for everyone -- Home screen sidebar: a different `e2e-campaign-home-sidebar-*` link and `e2e-campaign-*.svg` image for the `free`, `essential`, `essential-oct2023` and `expired` tiers +- Home screen sidebar: a different `e2e-campaign-home-sidebar-*` link and `e2e-campaign-*.svg` image URL for the `free`, `essential`, `essential-oct2023` and `expired` tiers -The sidebar images are part of the fixture, at the same paths as on the CDN. The browser loads images from the CDN itself, not through the mock, so the tests answer those requests from the fixture. This keeps offline tests independent of the live CDN. +The fixtures hold JSON only. The browser loads images from the CDN itself, not through the mock, and the `e2e-campaign-*.svg` images do not exist there: the tests check the image URL, not the picture. ## Features diff --git a/actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/images/e2e-campaign-essential-oct2023.svg b/actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/images/e2e-campaign-essential-oct2023.svg deleted file mode 100644 index 6784f300a..000000000 --- a/actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/images/e2e-campaign-essential-oct2023.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - E2E campaign - sidebar banner - essential-oct2023 - diff --git a/actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/images/e2e-campaign-essential.svg b/actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/images/e2e-campaign-essential.svg deleted file mode 100644 index a2ed5dc9e..000000000 --- a/actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/images/e2e-campaign-essential.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - E2E campaign - sidebar banner - essential - diff --git a/actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/images/e2e-campaign-expired.svg b/actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/images/e2e-campaign-expired.svg deleted file mode 100644 index b6d04531d..000000000 --- a/actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/images/e2e-campaign-expired.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - E2E campaign - sidebar banner - expired - diff --git a/actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/images/e2e-campaign-free.svg b/actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/images/e2e-campaign-free.svg deleted file mode 100644 index 07ffd524e..000000000 --- a/actions/fetch-cdn-scenario/fixtures/active-campaign/home-screen/v1/images/e2e-campaign-free.svg +++ /dev/null @@ -1,6 +0,0 @@ - - - E2E campaign - sidebar banner - free - From 9d9726ff257729cde0e3a6e55939bd56ce2ef9cd Mon Sep 17 00:00:00 2001 From: svitlanadykun Date: Thu, 26 Nov 2026 09:12:02 +0100 Subject: [PATCH 12/12] docs: describe fetch-cdn-scenario as it is now [ED-26391] Co-Authored-By: Claude Opus 5.5 --- actions/fetch-cdn-scenario/README.md | 20 +++++++++----------- 1 file changed, 9 insertions(+), 11 deletions(-) diff --git a/actions/fetch-cdn-scenario/README.md b/actions/fetch-cdn-scenario/README.md index 3907bfb67..0e004b5e3 100644 --- a/actions/fetch-cdn-scenario/README.md +++ b/actions/fetch-cdn-scenario/README.md @@ -4,7 +4,7 @@ Shared GitHub Actions composite action that provides CDN campaign promotion test ## Overview -This action consolidates the CDN test infrastructure previously duplicated in [elementor/elementor#38251](https://github.com/elementor/elementor/pull/38251) and [elementor/elementor-pro#7989](https://github.com/elementor/elementor-pro/pull/7989). It provides: +The action provides: 1. **Fetch script** (`fetch-cdn-scenario.mjs`) - Downloads the current CDN JSON files into a `live` scenario, with retries, a request timeout and optional failure tolerance 2. **Mock mu-plugin** (`mock-editor-assets-cdn.php`) - Answers WordPress requests to `assets.elementor.com` from local fixtures instead of the live CDN @@ -56,7 +56,7 @@ PR CI runs offline against the shared fixtures. A scheduled job fetches the live ```yaml - name: Setup CDN promotion fixtures - uses: elementor/elementor-editor-github-actions/actions/fetch-cdn-scenario@ + uses: elementor/elementor-editor-github-actions/actions/fetch-cdn-scenario@main with: output-dir: tests/playwright/mu-plugins/editor-assets-cdn/live mu-plugins-dir: tests/playwright/mu-plugins @@ -67,7 +67,7 @@ PR CI runs offline against the shared fixtures. A scheduled job fetches the live ```yaml - name: Fetch live CDN scenario - uses: elementor/elementor-editor-github-actions/actions/fetch-cdn-scenario@ + uses: elementor/elementor-editor-github-actions/actions/fetch-cdn-scenario@main with: output-dir: tests/playwright/mu-plugins/editor-assets-cdn/live mu-plugins-dir: tests/playwright/mu-plugins @@ -75,10 +75,10 @@ PR CI runs offline against the shared fixtures. A scheduled job fetches the live - name: Run promotion tests against the live CDN env: E2E_CDN_SCENARIO: live - run: npx playwright test --grep @promotions + run: npx playwright test --grep "live @promotions" ``` -`fetch-live` keeps `allow-failure: false` here on purpose: a CDN that cannot be fetched fails the job. +`allow-failure` stays `false` here on purpose: a CDN that cannot be fetched fails the job. ## Advanced Usage @@ -104,7 +104,6 @@ PR CI runs offline against the shared fixtures. A scheduled job fetches the live cdn-source: https://assets.stg.elementor.red output-dir: tests/playwright/mu-plugins/editor-assets-cdn/live mu-plugins-dir: tests/playwright/mu-plugins - allow-failure: true ``` ### Skip copying fixtures (if you have custom ones) @@ -121,12 +120,11 @@ PR CI runs offline against the shared fixtures. A scheduled job fetches the live 1. **Fetch**: Downloads the mocked CDN files from the source into a staging directory 2. **Atomic swap**: The staging directory replaces `output-dir` only when every file succeeded -3. **Missing files**: A file that the source does not have is skipped with a warning, and the default scenario answers for it +3. **Missing files**: A file that the source does not have is skipped with a warning, and the default scenario answers for it. A source without any of the files fails the fetch. 4. **Mock plugin**: The mu-plugin answers `assets.elementor.com` requests from the fixtures of the selected scenario, or of the default scenario 5. **Scenarios**: Tests select a scenario with the `e2e_cdn_scenario` cookie. A non-default scenario skips the CDN cache options, so its data never reaches requests of the default scenario. -## Related +## Used by -- Core PR: [elementor/elementor#38251](https://github.com/elementor/elementor/pull/38251) -- Pro PR: [elementor/elementor-pro#7989](https://github.com/elementor/elementor-pro/pull/7989) -- Jira: [ED-26391](https://elementor.atlassian.net/browse/ED-26391) +- Elementor Core: the `Playwright` workflow, nightly `live @promotions` at 04:30 UTC +- Elementor Pro: the `Playwright CDN Promotions` workflow, nightly at 04:30 UTC