Skip to content
Open
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
33 changes: 31 additions & 2 deletions assets/src/js/commands/admin-commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ import {
tool,
upload,
download,
page,
} from '@wordpress/icons';

/**
Expand Down Expand Up @@ -165,10 +166,34 @@ const registerAdminCommands = () => {
} );
};

// Options page commands — one per registered SCF options page.
const optionsPageCommands = [];
if ( Array.isArray( window.scfOptionsPages ) ) {
window.scfOptionsPages.forEach( ( optionsPage ) => {
if ( ! optionsPage?.menu_slug ) {
return;
}
optionsPageCommands.push( {
name: 'options-page-' + optionsPage.menu_slug,
label: optionsPage.menu_title || optionsPage.page_title,
url: 'admin.php',
urlArgs: { page: optionsPage.menu_slug },
icon: page,
keywords: [
'options',
'settings',
'scf',
optionsPage.menu_title,
optionsPage.page_title,
].filter( Boolean ),
} );
} );
}

// WordPress 6.9+ adds Command Palette commands for all admin menu items.
// For older versions, we need to register them manually. The most reliable way to
// detect this is to check if the commands are already registered.
viewCommands.forEach( ( command ) => {
const registerIfNotAutoRegistered = ( command ) => {
const commandUrl = addQueryArgs( command.url, command.urlArgs );
// WordPress stores destination URLs in the command *name*, appended to
// the menu slug (which is also a relative URL), resulting in somewhat
Expand All @@ -178,11 +203,15 @@ const registerAdminCommands = () => {
return;
}
registerCommand( command );
} );
};

viewCommands.forEach( registerIfNotAutoRegistered );

// "Create New" commands are not automatically registered by WordPress,
// so we always register them.
createCommands.forEach( registerCommand );

optionsPageCommands.forEach( registerIfNotAutoRegistered );
};

if ( 'requestIdleCallback' in window ) {
Expand Down
25 changes: 25 additions & 0 deletions includes/admin/admin-commands.php
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,31 @@ function acf_commands_init() {
// Only load admin commands if user has SCF admin capabilities.
if ( current_user_can( acf_get_setting( 'capability' ) ) ) {
wp_enqueue_script( 'scf-commands-admin' );

// Localize registered options pages so the JS can register a palette
// command per page. Filtered by capability so users only see pages
// they can access.
$pages = acf_get_options_pages();
if ( ! empty( $pages ) ) {
$localized = array();
foreach ( $pages as $page ) {
if ( ! current_user_can( $page['capability'] ) ) {
continue;
}
$localized[] = array(
'menu_slug' => $page['menu_slug'],
'menu_title' => $page['menu_title'],
'page_title' => $page['page_title'],
);
}
if ( ! empty( $localized ) ) {
wp_localize_script(
'scf-commands-admin',
'scfOptionsPages',
$localized
);
}
}
}
}

Expand Down
50 changes: 50 additions & 0 deletions tests/e2e/command-palette.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,56 @@
).toHaveValue( 'SCF E2E Test Type' );
} );
} );

test.describe( 'Options page-specific commands', () => {
test.beforeAll( async ( { requestUtils } ) => {
await requestUtils.activatePlugin(
'scf-test-setup-options-page'
);
} );

test.afterAll( async ( { requestUtils } ) => {
await requestUtils.deactivatePlugin(
'scf-test-setup-options-page'
);
} );

test( 'should register a command for the registered options page', async ( {
page,
} ) => {
await openCommandPalette( page );

const input = getCommandPaletteInput( page );

await input.fill( 'SCF E2E Test Options' );

const option = page.getByRole( 'option', {
name: /SCF E2E Test Options/,
} );

await expect( option ).toHaveCount( 1 );

Check failure on line 201 in tests/e2e/command-palette.spec.ts

View workflow job for this annotation

GitHub Actions / E2E - WP latest / Shard 2/4

[chromium] › tests/e2e/command-palette.spec.ts:188:5 › Command Palette › opened in wp-admin › Options page-specific commands › should register a command for the registered options page

3) [chromium] › tests/e2e/command-palette.spec.ts:188:5 › Command Palette › opened in wp-admin › Options page-specific commands › should register a command for the registered options page Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(locator).toHaveCount(expected) failed Locator: getByRole('option', { name: /SCF E2E Test Options/ }) Expected: 1 Received: 0 Timeout: 5000ms Call log: - Expect "toHaveCount" with timeout 5000ms - waiting for getByRole('option', { name: /SCF E2E Test Options/ }) 9 × locator resolved to 0 elements - unexpected value "0" 199 | } ); 200 | > 201 | await expect( option ).toHaveCount( 1 ); | ^ 202 | } ); 203 | 204 | test( 'should navigate to the options page via command palette', async ( { at /home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/command-palette.spec.ts:201:29

Check failure on line 201 in tests/e2e/command-palette.spec.ts

View workflow job for this annotation

GitHub Actions / E2E - WP latest / Shard 2/4

[chromium] › tests/e2e/command-palette.spec.ts:188:5 › Command Palette › opened in wp-admin › Options page-specific commands › should register a command for the registered options page

3) [chromium] › tests/e2e/command-palette.spec.ts:188:5 › Command Palette › opened in wp-admin › Options page-specific commands › should register a command for the registered options page Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(locator).toHaveCount(expected) failed Locator: getByRole('option', { name: /SCF E2E Test Options/ }) Expected: 1 Received: 0 Timeout: 5000ms Call log: - Expect "toHaveCount" with timeout 5000ms - waiting for getByRole('option', { name: /SCF E2E Test Options/ }) 9 × locator resolved to 0 elements - unexpected value "0" 199 | } ); 200 | > 201 | await expect( option ).toHaveCount( 1 ); | ^ 202 | } ); 203 | 204 | test( 'should navigate to the options page via command palette', async ( { at /home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/command-palette.spec.ts:201:29

Check failure on line 201 in tests/e2e/command-palette.spec.ts

View workflow job for this annotation

GitHub Actions / E2E - WP latest / Shard 2/4

[chromium] › tests/e2e/command-palette.spec.ts:188:5 › Command Palette › opened in wp-admin › Options page-specific commands › should register a command for the registered options page

3) [chromium] › tests/e2e/command-palette.spec.ts:188:5 › Command Palette › opened in wp-admin › Options page-specific commands › should register a command for the registered options page Error: expect(locator).toHaveCount(expected) failed Locator: getByRole('option', { name: /SCF E2E Test Options/ }) Expected: 1 Received: 0 Timeout: 5000ms Call log: - Expect "toHaveCount" with timeout 5000ms - waiting for getByRole('option', { name: /SCF E2E Test Options/ }) 9 × locator resolved to 0 elements - unexpected value "0" 199 | } ); 200 | > 201 | await expect( option ).toHaveCount( 1 ); | ^ 202 | } ); 203 | 204 | test( 'should navigate to the options page via command palette', async ( { at /home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/command-palette.spec.ts:201:29

Check failure on line 201 in tests/e2e/command-palette.spec.ts

View workflow job for this annotation

GitHub Actions / E2E - WP latest / Shard 2/4

[chromium] › tests/e2e/command-palette.spec.ts:188:5 › Command Palette › opened in post-editor › Options page-specific commands › should register a command for the registered options page

1) [chromium] › tests/e2e/command-palette.spec.ts:188:5 › Command Palette › opened in post-editor › Options page-specific commands › should register a command for the registered options page Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(locator).toHaveCount(expected) failed Locator: getByRole('option', { name: /SCF E2E Test Options/ }) Expected: 1 Received: 0 Timeout: 5000ms Call log: - Expect "toHaveCount" with timeout 5000ms - waiting for getByRole('option', { name: /SCF E2E Test Options/ }) 9 × locator resolved to 0 elements - unexpected value "0" 199 | } ); 200 | > 201 | await expect( option ).toHaveCount( 1 ); | ^ 202 | } ); 203 | 204 | test( 'should navigate to the options page via command palette', async ( { at /home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/command-palette.spec.ts:201:29

Check failure on line 201 in tests/e2e/command-palette.spec.ts

View workflow job for this annotation

GitHub Actions / E2E - WP latest / Shard 2/4

[chromium] › tests/e2e/command-palette.spec.ts:188:5 › Command Palette › opened in post-editor › Options page-specific commands › should register a command for the registered options page

1) [chromium] › tests/e2e/command-palette.spec.ts:188:5 › Command Palette › opened in post-editor › Options page-specific commands › should register a command for the registered options page Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(locator).toHaveCount(expected) failed Locator: getByRole('option', { name: /SCF E2E Test Options/ }) Expected: 1 Received: 0 Timeout: 5000ms Call log: - Expect "toHaveCount" with timeout 5000ms - waiting for getByRole('option', { name: /SCF E2E Test Options/ }) 9 × locator resolved to 0 elements - unexpected value "0" 199 | } ); 200 | > 201 | await expect( option ).toHaveCount( 1 ); | ^ 202 | } ); 203 | 204 | test( 'should navigate to the options page via command palette', async ( { at /home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/command-palette.spec.ts:201:29

Check failure on line 201 in tests/e2e/command-palette.spec.ts

View workflow job for this annotation

GitHub Actions / E2E - WP latest / Shard 2/4

[chromium] › tests/e2e/command-palette.spec.ts:188:5 › Command Palette › opened in post-editor › Options page-specific commands › should register a command for the registered options page

1) [chromium] › tests/e2e/command-palette.spec.ts:188:5 › Command Palette › opened in post-editor › Options page-specific commands › should register a command for the registered options page Error: expect(locator).toHaveCount(expected) failed Locator: getByRole('option', { name: /SCF E2E Test Options/ }) Expected: 1 Received: 0 Timeout: 5000ms Call log: - Expect "toHaveCount" with timeout 5000ms - waiting for getByRole('option', { name: /SCF E2E Test Options/ }) 9 × locator resolved to 0 elements - unexpected value "0" 199 | } ); 200 | > 201 | await expect( option ).toHaveCount( 1 ); | ^ 202 | } ); 203 | 204 | test( 'should navigate to the options page via command palette', async ( { at /home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/command-palette.spec.ts:201:29

Check failure on line 201 in tests/e2e/command-palette.spec.ts

View workflow job for this annotation

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

[chromium] › tests/e2e/command-palette.spec.ts:188:5 › Command Palette › opened in wp-admin › Options page-specific commands › should register a command for the registered options page

3) [chromium] › tests/e2e/command-palette.spec.ts:188:5 › Command Palette › opened in wp-admin › Options page-specific commands › should register a command for the registered options page Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(locator).toHaveCount(expected) failed Locator: getByRole('option', { name: /SCF E2E Test Options/ }) Expected: 1 Received: 0 Timeout: 5000ms Call log: - Expect "toHaveCount" with timeout 5000ms - waiting for getByRole('option', { name: /SCF E2E Test Options/ }) 9 × locator resolved to 0 elements - unexpected value "0" 199 | } ); 200 | > 201 | await expect( option ).toHaveCount( 1 ); | ^ 202 | } ); 203 | 204 | test( 'should navigate to the options page via command palette', async ( { at /home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/command-palette.spec.ts:201:29

Check failure on line 201 in tests/e2e/command-palette.spec.ts

View workflow job for this annotation

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

[chromium] › tests/e2e/command-palette.spec.ts:188:5 › Command Palette › opened in wp-admin › Options page-specific commands › should register a command for the registered options page

3) [chromium] › tests/e2e/command-palette.spec.ts:188:5 › Command Palette › opened in wp-admin › Options page-specific commands › should register a command for the registered options page Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(locator).toHaveCount(expected) failed Locator: getByRole('option', { name: /SCF E2E Test Options/ }) Expected: 1 Received: 0 Timeout: 5000ms Call log: - Expect "toHaveCount" with timeout 5000ms - waiting for getByRole('option', { name: /SCF E2E Test Options/ }) 9 × locator resolved to 0 elements - unexpected value "0" 199 | } ); 200 | > 201 | await expect( option ).toHaveCount( 1 ); | ^ 202 | } ); 203 | 204 | test( 'should navigate to the options page via command palette', async ( { at /home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/command-palette.spec.ts:201:29

Check failure on line 201 in tests/e2e/command-palette.spec.ts

View workflow job for this annotation

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

[chromium] › tests/e2e/command-palette.spec.ts:188:5 › Command Palette › opened in wp-admin › Options page-specific commands › should register a command for the registered options page

3) [chromium] › tests/e2e/command-palette.spec.ts:188:5 › Command Palette › opened in wp-admin › Options page-specific commands › should register a command for the registered options page Error: expect(locator).toHaveCount(expected) failed Locator: getByRole('option', { name: /SCF E2E Test Options/ }) Expected: 1 Received: 0 Timeout: 5000ms Call log: - Expect "toHaveCount" with timeout 5000ms - waiting for getByRole('option', { name: /SCF E2E Test Options/ }) 9 × locator resolved to 0 elements - unexpected value "0" 199 | } ); 200 | > 201 | await expect( option ).toHaveCount( 1 ); | ^ 202 | } ); 203 | 204 | test( 'should navigate to the options page via command palette', async ( { at /home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/command-palette.spec.ts:201:29

Check failure on line 201 in tests/e2e/command-palette.spec.ts

View workflow job for this annotation

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

[chromium] › tests/e2e/command-palette.spec.ts:188:5 › Command Palette › opened in post-editor › Options page-specific commands › should register a command for the registered options page

1) [chromium] › tests/e2e/command-palette.spec.ts:188:5 › Command Palette › opened in post-editor › Options page-specific commands › should register a command for the registered options page Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(locator).toHaveCount(expected) failed Locator: getByRole('option', { name: /SCF E2E Test Options/ }) Expected: 1 Received: 0 Timeout: 5000ms Call log: - Expect "toHaveCount" with timeout 5000ms - waiting for getByRole('option', { name: /SCF E2E Test Options/ }) 9 × locator resolved to 0 elements - unexpected value "0" 199 | } ); 200 | > 201 | await expect( option ).toHaveCount( 1 ); | ^ 202 | } ); 203 | 204 | test( 'should navigate to the options page via command palette', async ( { at /home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/command-palette.spec.ts:201:29

Check failure on line 201 in tests/e2e/command-palette.spec.ts

View workflow job for this annotation

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

[chromium] › tests/e2e/command-palette.spec.ts:188:5 › Command Palette › opened in post-editor › Options page-specific commands › should register a command for the registered options page

1) [chromium] › tests/e2e/command-palette.spec.ts:188:5 › Command Palette › opened in post-editor › Options page-specific commands › should register a command for the registered options page Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(locator).toHaveCount(expected) failed Locator: getByRole('option', { name: /SCF E2E Test Options/ }) Expected: 1 Received: 0 Timeout: 5000ms Call log: - Expect "toHaveCount" with timeout 5000ms - waiting for getByRole('option', { name: /SCF E2E Test Options/ }) 9 × locator resolved to 0 elements - unexpected value "0" 199 | } ); 200 | > 201 | await expect( option ).toHaveCount( 1 ); | ^ 202 | } ); 203 | 204 | test( 'should navigate to the options page via command palette', async ( { at /home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/command-palette.spec.ts:201:29

Check failure on line 201 in tests/e2e/command-palette.spec.ts

View workflow job for this annotation

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

[chromium] › tests/e2e/command-palette.spec.ts:188:5 › Command Palette › opened in post-editor › Options page-specific commands › should register a command for the registered options page

1) [chromium] › tests/e2e/command-palette.spec.ts:188:5 › Command Palette › opened in post-editor › Options page-specific commands › should register a command for the registered options page Error: expect(locator).toHaveCount(expected) failed Locator: getByRole('option', { name: /SCF E2E Test Options/ }) Expected: 1 Received: 0 Timeout: 5000ms Call log: - Expect "toHaveCount" with timeout 5000ms - waiting for getByRole('option', { name: /SCF E2E Test Options/ }) 9 × locator resolved to 0 elements - unexpected value "0" 199 | } ); 200 | > 201 | await expect( option ).toHaveCount( 1 ); | ^ 202 | } ); 203 | 204 | test( 'should navigate to the options page via command palette', async ( { at /home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/command-palette.spec.ts:201:29

Check failure on line 201 in tests/e2e/command-palette.spec.ts

View workflow job for this annotation

GitHub Actions / E2E - WP 6.9 / Shard 2/4

[chromium] › tests/e2e/command-palette.spec.ts:188:5 › Command Palette › opened in wp-admin › Options page-specific commands › should register a command for the registered options page

3) [chromium] › tests/e2e/command-palette.spec.ts:188:5 › Command Palette › opened in wp-admin › Options page-specific commands › should register a command for the registered options page Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(locator).toHaveCount(expected) failed Locator: getByRole('option', { name: /SCF E2E Test Options/ }) Expected: 1 Received: 0 Timeout: 5000ms Call log: - Expect "toHaveCount" with timeout 5000ms - waiting for getByRole('option', { name: /SCF E2E Test Options/ }) 9 × locator resolved to 0 elements - unexpected value "0" 199 | } ); 200 | > 201 | await expect( option ).toHaveCount( 1 ); | ^ 202 | } ); 203 | 204 | test( 'should navigate to the options page via command palette', async ( { at /home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/command-palette.spec.ts:201:29

Check failure on line 201 in tests/e2e/command-palette.spec.ts

View workflow job for this annotation

GitHub Actions / E2E - WP 6.9 / Shard 2/4

[chromium] › tests/e2e/command-palette.spec.ts:188:5 › Command Palette › opened in wp-admin › Options page-specific commands › should register a command for the registered options page

3) [chromium] › tests/e2e/command-palette.spec.ts:188:5 › Command Palette › opened in wp-admin › Options page-specific commands › should register a command for the registered options page Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(locator).toHaveCount(expected) failed Locator: getByRole('option', { name: /SCF E2E Test Options/ }) Expected: 1 Received: 0 Timeout: 5000ms Call log: - Expect "toHaveCount" with timeout 5000ms - waiting for getByRole('option', { name: /SCF E2E Test Options/ }) 9 × locator resolved to 0 elements - unexpected value "0" 199 | } ); 200 | > 201 | await expect( option ).toHaveCount( 1 ); | ^ 202 | } ); 203 | 204 | test( 'should navigate to the options page via command palette', async ( { at /home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/command-palette.spec.ts:201:29

Check failure on line 201 in tests/e2e/command-palette.spec.ts

View workflow job for this annotation

GitHub Actions / E2E - WP 6.9 / Shard 2/4

[chromium] › tests/e2e/command-palette.spec.ts:188:5 › Command Palette › opened in wp-admin › Options page-specific commands › should register a command for the registered options page

3) [chromium] › tests/e2e/command-palette.spec.ts:188:5 › Command Palette › opened in wp-admin › Options page-specific commands › should register a command for the registered options page Error: expect(locator).toHaveCount(expected) failed Locator: getByRole('option', { name: /SCF E2E Test Options/ }) Expected: 1 Received: 0 Timeout: 5000ms Call log: - Expect "toHaveCount" with timeout 5000ms - waiting for getByRole('option', { name: /SCF E2E Test Options/ }) 9 × locator resolved to 0 elements - unexpected value "0" 199 | } ); 200 | > 201 | await expect( option ).toHaveCount( 1 ); | ^ 202 | } ); 203 | 204 | test( 'should navigate to the options page via command palette', async ( { at /home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/command-palette.spec.ts:201:29

Check failure on line 201 in tests/e2e/command-palette.spec.ts

View workflow job for this annotation

GitHub Actions / E2E - WP 6.9 / Shard 2/4

[chromium] › tests/e2e/command-palette.spec.ts:188:5 › Command Palette › opened in post-editor › Options page-specific commands › should register a command for the registered options page

1) [chromium] › tests/e2e/command-palette.spec.ts:188:5 › Command Palette › opened in post-editor › Options page-specific commands › should register a command for the registered options page Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(locator).toHaveCount(expected) failed Locator: getByRole('option', { name: /SCF E2E Test Options/ }) Expected: 1 Received: 0 Timeout: 5000ms Call log: - Expect "toHaveCount" with timeout 5000ms - waiting for getByRole('option', { name: /SCF E2E Test Options/ }) 9 × locator resolved to 0 elements - unexpected value "0" 199 | } ); 200 | > 201 | await expect( option ).toHaveCount( 1 ); | ^ 202 | } ); 203 | 204 | test( 'should navigate to the options page via command palette', async ( { at /home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/command-palette.spec.ts:201:29

Check failure on line 201 in tests/e2e/command-palette.spec.ts

View workflow job for this annotation

GitHub Actions / E2E - WP 6.9 / Shard 2/4

[chromium] › tests/e2e/command-palette.spec.ts:188:5 › Command Palette › opened in post-editor › Options page-specific commands › should register a command for the registered options page

1) [chromium] › tests/e2e/command-palette.spec.ts:188:5 › Command Palette › opened in post-editor › Options page-specific commands › should register a command for the registered options page Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── Error: expect(locator).toHaveCount(expected) failed Locator: getByRole('option', { name: /SCF E2E Test Options/ }) Expected: 1 Received: 0 Timeout: 5000ms Call log: - Expect "toHaveCount" with timeout 5000ms - waiting for getByRole('option', { name: /SCF E2E Test Options/ }) 9 × locator resolved to 0 elements - unexpected value "0" 199 | } ); 200 | > 201 | await expect( option ).toHaveCount( 1 ); | ^ 202 | } ); 203 | 204 | test( 'should navigate to the options page via command palette', async ( { at /home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/command-palette.spec.ts:201:29

Check failure on line 201 in tests/e2e/command-palette.spec.ts

View workflow job for this annotation

GitHub Actions / E2E - WP 6.9 / Shard 2/4

[chromium] › tests/e2e/command-palette.spec.ts:188:5 › Command Palette › opened in post-editor › Options page-specific commands › should register a command for the registered options page

1) [chromium] › tests/e2e/command-palette.spec.ts:188:5 › Command Palette › opened in post-editor › Options page-specific commands › should register a command for the registered options page Error: expect(locator).toHaveCount(expected) failed Locator: getByRole('option', { name: /SCF E2E Test Options/ }) Expected: 1 Received: 0 Timeout: 5000ms Call log: - Expect "toHaveCount" with timeout 5000ms - waiting for getByRole('option', { name: /SCF E2E Test Options/ }) 9 × locator resolved to 0 elements - unexpected value "0" 199 | } ); 200 | > 201 | await expect( option ).toHaveCount( 1 ); | ^ 202 | } ); 203 | 204 | test( 'should navigate to the options page via command palette', async ( { at /home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/command-palette.spec.ts:201:29
} );

test( 'should navigate to the options page via command palette', async ( {
page,
} ) => {
await openCommandPalette( page );

const input = getCommandPaletteInput( page );

await input.fill( 'SCF E2E Test Options' );

await page
.getByRole( 'option', {
name: /SCF E2E Test Options/,
} )
.click();

Check failure on line 217 in tests/e2e/command-palette.spec.ts

View workflow job for this annotation

GitHub Actions / E2E - WP latest / Shard 2/4

[chromium] › tests/e2e/command-palette.spec.ts:204:5 › Command Palette › opened in wp-admin › Options page-specific commands › should navigate to the options page via command palette

4) [chromium] › tests/e2e/command-palette.spec.ts:204:5 › Command Palette › opened in wp-admin › Options page-specific commands › should navigate to the options page via command palette TimeoutError: locator.click: Timeout 10000ms exceeded. Call log: - waiting for getByRole('option', { name: /SCF E2E Test Options/ }) 215 | name: /SCF E2E Test Options/, 216 | } ) > 217 | .click(); | ^ 218 | 219 | await expect( page ).toHaveURL( 220 | /admin\.php\?page=scf-e2e-test-options/ at /home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/command-palette.spec.ts:217:8

Check failure on line 217 in tests/e2e/command-palette.spec.ts

View workflow job for this annotation

GitHub Actions / E2E - WP latest / Shard 2/4

[chromium] › tests/e2e/command-palette.spec.ts:204:5 › Command Palette › opened in post-editor › Options page-specific commands › should navigate to the options page via command palette

2) [chromium] › tests/e2e/command-palette.spec.ts:204:5 › Command Palette › opened in post-editor › Options page-specific commands › should navigate to the options page via command palette Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── TimeoutError: locator.click: Timeout 10000ms exceeded. Call log: - waiting for getByRole('option', { name: /SCF E2E Test Options/ }) 215 | name: /SCF E2E Test Options/, 216 | } ) > 217 | .click(); | ^ 218 | 219 | await expect( page ).toHaveURL( 220 | /admin\.php\?page=scf-e2e-test-options/ at /home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/command-palette.spec.ts:217:8

Check failure on line 217 in tests/e2e/command-palette.spec.ts

View workflow job for this annotation

GitHub Actions / E2E - WP latest / Shard 2/4

[chromium] › tests/e2e/command-palette.spec.ts:204:5 › Command Palette › opened in post-editor › Options page-specific commands › should navigate to the options page via command palette

2) [chromium] › tests/e2e/command-palette.spec.ts:204:5 › Command Palette › opened in post-editor › Options page-specific commands › should navigate to the options page via command palette Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── TimeoutError: locator.click: Timeout 10000ms exceeded. Call log: - waiting for getByRole('option', { name: /SCF E2E Test Options/ }) 215 | name: /SCF E2E Test Options/, 216 | } ) > 217 | .click(); | ^ 218 | 219 | await expect( page ).toHaveURL( 220 | /admin\.php\?page=scf-e2e-test-options/ at /home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/command-palette.spec.ts:217:8

Check failure on line 217 in tests/e2e/command-palette.spec.ts

View workflow job for this annotation

GitHub Actions / E2E - WP latest / Shard 2/4

[chromium] › tests/e2e/command-palette.spec.ts:204:5 › Command Palette › opened in post-editor › Options page-specific commands › should navigate to the options page via command palette

2) [chromium] › tests/e2e/command-palette.spec.ts:204:5 › Command Palette › opened in post-editor › Options page-specific commands › should navigate to the options page via command palette TimeoutError: locator.click: Timeout 10000ms exceeded. Call log: - waiting for getByRole('option', { name: /SCF E2E Test Options/ }) 215 | name: /SCF E2E Test Options/, 216 | } ) > 217 | .click(); | ^ 218 | 219 | await expect( page ).toHaveURL( 220 | /admin\.php\?page=scf-e2e-test-options/ at /home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/command-palette.spec.ts:217:8

Check failure on line 217 in tests/e2e/command-palette.spec.ts

View workflow job for this annotation

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

[chromium] › tests/e2e/command-palette.spec.ts:204:5 › Command Palette › opened in wp-admin › Options page-specific commands › should navigate to the options page via command palette

4) [chromium] › tests/e2e/command-palette.spec.ts:204:5 › Command Palette › opened in wp-admin › Options page-specific commands › should navigate to the options page via command palette TimeoutError: locator.click: Timeout 10000ms exceeded. Call log: - waiting for getByRole('option', { name: /SCF E2E Test Options/ }) 215 | name: /SCF E2E Test Options/, 216 | } ) > 217 | .click(); | ^ 218 | 219 | await expect( page ).toHaveURL( 220 | /admin\.php\?page=scf-e2e-test-options/ at /home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/command-palette.spec.ts:217:8

Check failure on line 217 in tests/e2e/command-palette.spec.ts

View workflow job for this annotation

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

[chromium] › tests/e2e/command-palette.spec.ts:204:5 › Command Palette › opened in post-editor › Options page-specific commands › should navigate to the options page via command palette

2) [chromium] › tests/e2e/command-palette.spec.ts:204:5 › Command Palette › opened in post-editor › Options page-specific commands › should navigate to the options page via command palette Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── TimeoutError: locator.click: Timeout 10000ms exceeded. Call log: - waiting for getByRole('option', { name: /SCF E2E Test Options/ }) 215 | name: /SCF E2E Test Options/, 216 | } ) > 217 | .click(); | ^ 218 | 219 | await expect( page ).toHaveURL( 220 | /admin\.php\?page=scf-e2e-test-options/ at /home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/command-palette.spec.ts:217:8

Check failure on line 217 in tests/e2e/command-palette.spec.ts

View workflow job for this annotation

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

[chromium] › tests/e2e/command-palette.spec.ts:204:5 › Command Palette › opened in post-editor › Options page-specific commands › should navigate to the options page via command palette

2) [chromium] › tests/e2e/command-palette.spec.ts:204:5 › Command Palette › opened in post-editor › Options page-specific commands › should navigate to the options page via command palette Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── TimeoutError: locator.click: Timeout 10000ms exceeded. Call log: - waiting for getByRole('option', { name: /SCF E2E Test Options/ }) 215 | name: /SCF E2E Test Options/, 216 | } ) > 217 | .click(); | ^ 218 | 219 | await expect( page ).toHaveURL( 220 | /admin\.php\?page=scf-e2e-test-options/ at /home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/command-palette.spec.ts:217:8

Check failure on line 217 in tests/e2e/command-palette.spec.ts

View workflow job for this annotation

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

[chromium] › tests/e2e/command-palette.spec.ts:204:5 › Command Palette › opened in post-editor › Options page-specific commands › should navigate to the options page via command palette

2) [chromium] › tests/e2e/command-palette.spec.ts:204:5 › Command Palette › opened in post-editor › Options page-specific commands › should navigate to the options page via command palette TimeoutError: locator.click: Timeout 10000ms exceeded. Call log: - waiting for getByRole('option', { name: /SCF E2E Test Options/ }) 215 | name: /SCF E2E Test Options/, 216 | } ) > 217 | .click(); | ^ 218 | 219 | await expect( page ).toHaveURL( 220 | /admin\.php\?page=scf-e2e-test-options/ at /home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/command-palette.spec.ts:217:8

Check failure on line 217 in tests/e2e/command-palette.spec.ts

View workflow job for this annotation

GitHub Actions / E2E - WP 6.9 / Shard 2/4

[chromium] › tests/e2e/command-palette.spec.ts:204:5 › Command Palette › opened in wp-admin › Options page-specific commands › should navigate to the options page via command palette

4) [chromium] › tests/e2e/command-palette.spec.ts:204:5 › Command Palette › opened in wp-admin › Options page-specific commands › should navigate to the options page via command palette TimeoutError: locator.click: Timeout 10000ms exceeded. Call log: - waiting for getByRole('option', { name: /SCF E2E Test Options/ }) 215 | name: /SCF E2E Test Options/, 216 | } ) > 217 | .click(); | ^ 218 | 219 | await expect( page ).toHaveURL( 220 | /admin\.php\?page=scf-e2e-test-options/ at /home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/command-palette.spec.ts:217:8

Check failure on line 217 in tests/e2e/command-palette.spec.ts

View workflow job for this annotation

GitHub Actions / E2E - WP 6.9 / Shard 2/4

[chromium] › tests/e2e/command-palette.spec.ts:204:5 › Command Palette › opened in post-editor › Options page-specific commands › should navigate to the options page via command palette

2) [chromium] › tests/e2e/command-palette.spec.ts:204:5 › Command Palette › opened in post-editor › Options page-specific commands › should navigate to the options page via command palette Retry #2 ─────────────────────────────────────────────────────────────────────────────────────── TimeoutError: locator.click: Timeout 10000ms exceeded. Call log: - waiting for getByRole('option', { name: /SCF E2E Test Options/ }) 215 | name: /SCF E2E Test Options/, 216 | } ) > 217 | .click(); | ^ 218 | 219 | await expect( page ).toHaveURL( 220 | /admin\.php\?page=scf-e2e-test-options/ at /home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/command-palette.spec.ts:217:8

Check failure on line 217 in tests/e2e/command-palette.spec.ts

View workflow job for this annotation

GitHub Actions / E2E - WP 6.9 / Shard 2/4

[chromium] › tests/e2e/command-palette.spec.ts:204:5 › Command Palette › opened in post-editor › Options page-specific commands › should navigate to the options page via command palette

2) [chromium] › tests/e2e/command-palette.spec.ts:204:5 › Command Palette › opened in post-editor › Options page-specific commands › should navigate to the options page via command palette Retry #1 ─────────────────────────────────────────────────────────────────────────────────────── TimeoutError: locator.click: Timeout 10000ms exceeded. Call log: - waiting for getByRole('option', { name: /SCF E2E Test Options/ }) 215 | name: /SCF E2E Test Options/, 216 | } ) > 217 | .click(); | ^ 218 | 219 | await expect( page ).toHaveURL( 220 | /admin\.php\?page=scf-e2e-test-options/ at /home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/command-palette.spec.ts:217:8

Check failure on line 217 in tests/e2e/command-palette.spec.ts

View workflow job for this annotation

GitHub Actions / E2E - WP 6.9 / Shard 2/4

[chromium] › tests/e2e/command-palette.spec.ts:204:5 › Command Palette › opened in post-editor › Options page-specific commands › should navigate to the options page via command palette

2) [chromium] › tests/e2e/command-palette.spec.ts:204:5 › Command Palette › opened in post-editor › Options page-specific commands › should navigate to the options page via command palette TimeoutError: locator.click: Timeout 10000ms exceeded. Call log: - waiting for getByRole('option', { name: /SCF E2E Test Options/ }) 215 | name: /SCF E2E Test Options/, 216 | } ) > 217 | .click(); | ^ 218 | 219 | await expect( page ).toHaveURL( 220 | /admin\.php\?page=scf-e2e-test-options/ at /home/runner/work/secure-custom-fields/secure-custom-fields/tests/e2e/command-palette.spec.ts:217:8

await expect( page ).toHaveURL(
/admin\.php\?page=scf-e2e-test-options/
);
} );
} );
} );
} );
} );
37 changes: 37 additions & 0 deletions tests/e2e/plugins/scf-test-setup-options-page.php
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
<?php
/**
* Plugin Name: SCF Test Setup Options Page
* Description: Creates SCF options page for E2E testing
* Version: 1.0.0
* Author: SCF Testing
* Requires Plugins: secure-custom-fields
*
* @package wordpress/secure-custom-fields
*/

// Exit if accessed directly.
if ( ! defined( 'ABSPATH' ) ) {
exit;
}

/**
* Register an options page for command palette E2E tests.
*/
function scf_test_register_options_page() {
if ( ! function_exists( 'acf_update_options_page' ) || acf_get_options_page( 'scf-e2e-test-options' ) ) {
return;
}

acf_update_options_page(
'scf-e2e-test-options',
array(
'page_title' => 'SCF E2E Test Options',
'menu_title' => 'SCF E2E Test Options',
'menu_slug' => 'scf-e2e-test-options',
'capability' => 'edit_posts',
'redirect' => false,
)
);
}

add_action( 'acf/init', 'scf_test_register_options_page', 20 );
Loading