Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .github/workflows/test-actions.yml
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,7 @@ jobs:
uses: ./actions/setup-elementor-env
with:
env: 'testing'
enable-svg-upload: true
experiments: |-
pages_panel:true
editor_v2:false
Expand Down
4 changes: 4 additions & 0 deletions actions/setup-elementor-env/action.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ inputs:
description: Which wp-env environment to use (allowed values are `development` or `testing`)
required: false
default: 'testing'
enable-svg-upload:
required: false
description: Whether to enable SVG and JSON uploads or not
default: 'false'
Copy link

Copilot AI Mar 20, 2025

Choose a reason for hiding this comment

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

The default value is defined as a string while the code uses z.boolean() for parsing; this may lead to unexpected type conversion issues.

Suggested change
default: 'false'
default: false

Copilot uses AI. Check for mistakes.
templates:
required: false
description: Paths to the Elementor templates directory, separated by new lines (e.g. `./path/to/elementor-templates \n ./another/path/to/elementor-templates`)
Expand Down
48 changes: 24 additions & 24 deletions actions/setup-elementor-env/dist/index.js

Large diffs are not rendered by default.

38 changes: 34 additions & 4 deletions actions/setup-elementor-env/main.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,14 +5,13 @@ import {
getArrayInput,
getMapInput,
getStringInput,
getBooleanInput,
} from '@elementor-editor-github-actions/utils';

export async function run() {
try {
const { container, experiments, templates } = await core.group(
'Parsing inputs',
parseInputs,
);
const { container, experiments, templates, wpOptions } =
await core.group('Parsing inputs', parseInputs);

await core.group('Validating wp-env installation', async () => {
await runOnContainer({
Expand All @@ -30,6 +29,16 @@ export async function run() {
});
});

await core.group('Setting WP Options', async () => {
for (const { key, value } of wpOptions) {
await runOnContainer({
container,
command: ['wp', 'option', 'update', key, value],
error: `Failed to set option: ${key} to ${value}`,
});
}
});

if (experiments.on.length > 0) {
await core.group('Activating Experiments', async () => {
await runOnContainer({
Expand Down Expand Up @@ -114,11 +123,13 @@ async function parseInputs() {
z.string().regex(/^[a-z0-9-_]+$/),
z.union([z.literal('true'), z.literal('false')]),
),
enableSvgUpload: z.boolean(),
})
.parse({
env: getStringInput('env'),
templates: getArrayInput('templates'),
experiments: getMapInput('experiments'),
enableSvgUpload: getBooleanInput('enable-svg-upload'),
});

const experimentsEntries = Object.entries(parsed.experiments);
Expand All @@ -129,6 +140,9 @@ async function parseInputs() {
? ('cli' as const)
: ('tests-cli' as const),
templates: parsed.templates,
wpOptions: normalizeWpOptions({
enableSvgUpload: parsed.enableSvgUpload,
}),
experiments: {
on: experimentsEntries
.filter(([, value]) => value === 'true')
Expand All @@ -151,6 +165,22 @@ async function parseInputs() {
}
}

function normalizeWpOptions({ enableSvgUpload }: { enableSvgUpload: boolean }) {
const wpOptions: {
key: string;
value: string;
}[] = [];

if (enableSvgUpload) {
wpOptions.push({
key: 'elementor_unfiltered_files_upload',
value: '1',
});
}

return wpOptions;
}

async function runOnContainer({
container,
command,
Expand Down
2 changes: 1 addition & 1 deletion stubs/elementor-templates/test.json
Original file line number Diff line number Diff line change
Expand Up @@ -85,5 +85,5 @@
"elType": "container"
}
],
"settings": { "template": "elementor_canvas" }
"page_settings": { "template": "elementor_canvas" }
}