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
6 changes: 3 additions & 3 deletions includes/assets.php
Original file line number Diff line number Diff line change
Expand Up @@ -258,7 +258,7 @@ public function register_scripts() {
$version,
array(
'in_footer' => true,
'defer' => true,
'strategy' => 'defer',
)
);

Expand All @@ -269,7 +269,7 @@ public function register_scripts() {
$version,
array(
'in_footer' => true,
'defer' => true,
'strategy' => 'defer',
)
);

Expand Down Expand Up @@ -762,4 +762,4 @@ function acf_enqueue_scripts( $args = array() ) {
*/
function acf_enqueue_uploader() {
return acf_get_instance( 'ACF_Assets' )->enqueue_uploader();
}
}
48 changes: 37 additions & 11 deletions tests/e2e/field-helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -141,7 +141,10 @@
*/
async function uploadImageViaModal( page, imagePath ) {
// Wait for media modal to open
await page.waitForSelector( '.media-modal', { state: 'visible' } );
await page.waitForSelector( '.media-modal', {

Check failure on line 144 in tests/e2e/field-helpers.js

View workflow job for this annotation

GitHub Actions / E2E - Node 22 / WP trunk / Shard 3/4

[chromium] › tests/e2e/field-type-image.spec.ts:106:2 › Field Type > Image › should allow removing an image

2) [chromium] › tests/e2e/field-type-image.spec.ts:106:2 › Field Type > Image › should allow removing an image Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── TimeoutError: page.waitForSelector: Timeout 20000ms exceeded. Call log: - waiting for locator('.media-modal') to be visible at field-helpers.js:144 142 | async function uploadImageViaModal( page, imagePath ) { 143 | // Wait for media modal to open > 144 | await page.waitForSelector( '.media-modal', { | ^ 145 | state: 'visible', 146 | timeout: 20000, 147 | } ); at uploadImageViaModal (/home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/field-helpers.js:144:13) at /home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/field-type-image.spec.ts:151:9

Check failure on line 144 in tests/e2e/field-helpers.js

View workflow job for this annotation

GitHub Actions / E2E - Node 22 / WP trunk / Shard 3/4

[chromium] › tests/e2e/field-type-image.spec.ts:106:2 › Field Type > Image › should allow removing an image

2) [chromium] › tests/e2e/field-type-image.spec.ts:106:2 › Field Type > Image › should allow removing an image Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── TimeoutError: page.waitForSelector: Timeout 20000ms exceeded. Call log: - waiting for locator('.media-modal') to be visible at field-helpers.js:144 142 | async function uploadImageViaModal( page, imagePath ) { 143 | // Wait for media modal to open > 144 | await page.waitForSelector( '.media-modal', { | ^ 145 | state: 'visible', 146 | timeout: 20000, 147 | } ); at uploadImageViaModal (/home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/field-helpers.js:144:13) at /home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/field-type-image.spec.ts:151:9

Check failure on line 144 in tests/e2e/field-helpers.js

View workflow job for this annotation

GitHub Actions / E2E - Node 22 / WP trunk / Shard 3/4

[chromium] › tests/e2e/field-type-image.spec.ts:106:2 › Field Type > Image › should allow removing an image

2) [chromium] › tests/e2e/field-type-image.spec.ts:106:2 › Field Type > Image › should allow removing an image TimeoutError: page.waitForSelector: Timeout 20000ms exceeded. Call log: - waiting for locator('.media-modal') to be visible at field-helpers.js:144 142 | async function uploadImageViaModal( page, imagePath ) { 143 | // Wait for media modal to open > 144 | await page.waitForSelector( '.media-modal', { | ^ 145 | state: 'visible', 146 | timeout: 20000, 147 | } ); at uploadImageViaModal (/home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/field-helpers.js:144:13) at /home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/field-type-image.spec.ts:151:9

Check failure on line 144 in tests/e2e/field-helpers.js

View workflow job for this annotation

GitHub Actions / E2E - Node 22 / WP trunk / Shard 3/4

[chromium] › tests/e2e/field-type-image.spec.ts:36:2 › Field Type > Image › should create an image field and upload an image

1) [chromium] › tests/e2e/field-type-image.spec.ts:36:2 › Field Type > Image › should create an image field and upload an image Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── TimeoutError: page.waitForSelector: Timeout 20000ms exceeded. Call log: - waiting for locator('.media-modal') to be visible at field-helpers.js:144 142 | async function uploadImageViaModal( page, imagePath ) { 143 | // Wait for media modal to open > 144 | await page.waitForSelector( '.media-modal', { | ^ 145 | state: 'visible', 146 | timeout: 20000, 147 | } ); at uploadImageViaModal (/home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/field-helpers.js:144:13) at /home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/field-type-image.spec.ts:85:9

Check failure on line 144 in tests/e2e/field-helpers.js

View workflow job for this annotation

GitHub Actions / E2E - Node 22 / WP trunk / Shard 3/4

[chromium] › tests/e2e/field-type-image.spec.ts:36:2 › Field Type > Image › should create an image field and upload an image

1) [chromium] › tests/e2e/field-type-image.spec.ts:36:2 › Field Type > Image › should create an image field and upload an image Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── TimeoutError: page.waitForSelector: Timeout 20000ms exceeded. Call log: - waiting for locator('.media-modal') to be visible at field-helpers.js:144 142 | async function uploadImageViaModal( page, imagePath ) { 143 | // Wait for media modal to open > 144 | await page.waitForSelector( '.media-modal', { | ^ 145 | state: 'visible', 146 | timeout: 20000, 147 | } ); at uploadImageViaModal (/home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/field-helpers.js:144:13) at /home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/field-type-image.spec.ts:85:9

Check failure on line 144 in tests/e2e/field-helpers.js

View workflow job for this annotation

GitHub Actions / E2E - Node 22 / WP trunk / Shard 3/4

[chromium] › tests/e2e/field-type-image.spec.ts:36:2 › Field Type > Image › should create an image field and upload an image

1) [chromium] › tests/e2e/field-type-image.spec.ts:36:2 › Field Type > Image › should create an image field and upload an image TimeoutError: page.waitForSelector: Timeout 20000ms exceeded. Call log: - waiting for locator('.media-modal') to be visible at field-helpers.js:144 142 | async function uploadImageViaModal( page, imagePath ) { 143 | // Wait for media modal to open > 144 | await page.waitForSelector( '.media-modal', { | ^ 145 | state: 'visible', 146 | timeout: 20000, 147 | } ); at uploadImageViaModal (/home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/field-helpers.js:144:13) at /home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/field-type-image.spec.ts:85:9
state: 'visible',
timeout: 20000,
} );

// Click "Upload files" tab if not already there
const uploadTab = page.locator( '.media-modal #menu-item-upload' );
Expand All @@ -153,17 +156,40 @@
const fileInput = page.locator( '.media-modal input[type="file"]' );
await fileInput.setInputFiles( imagePath );

// Wait for upload to complete
await page.waitForSelector( '.media-modal .attachment.selected', {
state: 'visible',
timeout: 15000,
} );
// Wait for upload to complete and ensure an attachment is selected.
try {
await page.waitForSelector( '.media-modal .attachment.selected', {
state: 'visible',
timeout: 60000,
} );
} catch {
await page.waitForSelector( '.media-modal .attachments .attachment', {
state: 'visible',
timeout: 60000,
} );
await page.locator( '.media-modal .attachments .attachment' ).first().click();
await page.waitForSelector( '.media-modal .attachment.selected', {
state: 'visible',
timeout: 15000,
} );
}

// Click "Select" button
const selectButton = page.locator(
'.media-modal .media-toolbar-primary .media-button-select'
);
await selectButton.click();
// Wait for "Select" to be enabled before clicking.
const selectButtonSelector =
'.media-modal .media-toolbar-primary .media-button-select:not([disabled])';
try {
await page.waitForSelector( selectButtonSelector, {
state: 'visible',
timeout: 60000,
} );
} catch {
await page.locator( '.media-modal .attachments .attachment' ).first().click();

Check failure on line 186 in tests/e2e/field-helpers.js

View workflow job for this annotation

GitHub Actions / E2E - Node 22 / WP trunk / Shard 2/4

[chromium] › tests/e2e/all-field-types.spec.ts:59:2 › All Field Types › should save and display all field types correctly

1) [chromium] › tests/e2e/all-field-types.spec.ts:59:2 › All Field Types › should save and display all field types correctly Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: locator.click: Target page, context or browser has been closed at field-helpers.js:186 184 | } ); 185 | } catch { > 186 | await page.locator( '.media-modal .attachments .attachment' ).first().click(); | ^ 187 | await page.waitForSelector( selectButtonSelector, { 188 | state: 'visible', 189 | timeout: 30000, at uploadImageViaModal (/home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/field-helpers.js:186:73) at /home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/all-field-types.spec.ts:232:3

Check failure on line 186 in tests/e2e/field-helpers.js

View workflow job for this annotation

GitHub Actions / E2E - Node 22 / WP trunk / Shard 2/4

[chromium] › tests/e2e/all-field-types.spec.ts:59:2 › All Field Types › should save and display all field types correctly

1) [chromium] › tests/e2e/all-field-types.spec.ts:59:2 › All Field Types › should save and display all field types correctly Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: locator.click: Target page, context or browser has been closed at field-helpers.js:186 184 | } ); 185 | } catch { > 186 | await page.locator( '.media-modal .attachments .attachment' ).first().click(); | ^ 187 | await page.waitForSelector( selectButtonSelector, { 188 | state: 'visible', 189 | timeout: 30000, at uploadImageViaModal (/home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/field-helpers.js:186:73) at /home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/all-field-types.spec.ts:232:3

Check failure on line 186 in tests/e2e/field-helpers.js

View workflow job for this annotation

GitHub Actions / E2E - Node 22 / WP trunk / Shard 2/4

[chromium] › tests/e2e/all-field-types.spec.ts:59:2 › All Field Types › should save and display all field types correctly

1) [chromium] › tests/e2e/all-field-types.spec.ts:59:2 › All Field Types › should save and display all field types correctly Error: locator.click: Target page, context or browser has been closed at field-helpers.js:186 184 | } ); 185 | } catch { > 186 | await page.locator( '.media-modal .attachments .attachment' ).first().click(); | ^ 187 | await page.waitForSelector( selectButtonSelector, { 188 | state: 'visible', 189 | timeout: 30000, at uploadImageViaModal (/home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/field-helpers.js:186:73) at /home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/all-field-types.spec.ts:232:3
await page.waitForSelector( selectButtonSelector, {
state: 'visible',
timeout: 30000,
} );
}
await page.locator( selectButtonSelector ).click();

// Wait for modal to close
await page.waitForSelector( '.media-modal', { state: 'hidden' } );
Expand Down
53 changes: 3 additions & 50 deletions tests/e2e/field-type-image.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ const {
PLUGIN_SLUG,
deleteFieldGroups,
waitForMetaBoxes,
uploadImageViaModal,
} = require( './field-helpers' );
const path = require( 'path' );

Expand Down Expand Up @@ -81,34 +82,7 @@ test.describe( 'Field Type > Image', () => {
'.acf-field[data-name="test_image"] .acf-image-uploader[data-uploader="wp"] .acf-button-edit, .acf-field[data-name="test_image"] .acf-image-uploader a[data-name="add"]'
);
await addImageButton.click();

// Wait for media modal
await page.waitForSelector( '.media-modal', { state: 'visible' } );

// Click "Upload files" tab
const uploadTab = page.locator( '.media-modal #menu-item-upload' );
if ( await uploadTab.isVisible() ) {
await uploadTab.click();
}

// Upload the file
const fileInput = page.locator( '.media-modal input[type="file"]' );
await fileInput.setInputFiles( TEST_IMAGE_PATH );

// Wait for upload to complete
await page.waitForSelector( '.media-modal .attachment.selected', {
state: 'visible',
timeout: 30000,
} );

// Click "Select" button
const selectButton = page.locator(
'.media-modal .media-toolbar-primary .media-button-select'
);
await selectButton.click();

// Wait for modal to close
await page.waitForSelector( '.media-modal', { state: 'hidden' } );
await uploadImageViaModal( page, TEST_IMAGE_PATH );

// Verify image is displayed in the field
const imagePreview = page.locator(
Expand Down Expand Up @@ -174,28 +148,7 @@ test.describe( 'Field Type > Image', () => {
'.acf-field[data-name="removable_image"] .acf-image-uploader a[data-name="add"]'
);
await addImageButton.click();

await page.waitForSelector( '.media-modal', { state: 'visible' } );

const uploadTab = page.locator( '.media-modal #menu-item-upload' );
if ( await uploadTab.isVisible() ) {
await uploadTab.click();
}

const fileInput = page.locator( '.media-modal input[type="file"]' );
await fileInput.setInputFiles( TEST_IMAGE_PATH );

await page.waitForSelector( '.media-modal .attachment.selected', {
state: 'visible',
timeout: 30000,
} );

const selectButton = page.locator(
'.media-modal .media-toolbar-primary .media-button-select'
);
await selectButton.click();

await page.waitForSelector( '.media-modal', { state: 'hidden' } );
await uploadImageViaModal( page, TEST_IMAGE_PATH );

// Verify image is there
const imagePreview = page.locator(
Expand Down
Loading