-
Notifications
You must be signed in to change notification settings - Fork 53
Expand file tree
/
Copy pathcommand-palette.spec.ts
More file actions
91 lines (74 loc) · 2.45 KB
/
command-palette.spec.ts
File metadata and controls
91 lines (74 loc) · 2.45 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
/**
* Internal dependencies
*/
const { test, expect, wpVersionAtLeast } = require( './fixtures' );
test.describe( 'Command Palette', () => {
test.beforeAll( async ( { requestUtils } ) => {
await requestUtils.activatePlugin( 'secure-custom-fields' );
} );
test.afterAll( async ( { requestUtils } ) => {
await requestUtils.deactivatePlugin( 'secure-custom-fields' );
} );
test( 'should register SCF create commands', async ( { page, admin } ) => {
await admin.visitAdminPage( 'index.php' );
test.skip(
! ( await wpVersionAtLeast( page, 6, 3 ) ),
'Command Palette requires WordPress 6.3+'
);
// Open the command palette via keyboard shortcut.
await page.keyboard.press( 'ControlOrMeta+k' );
const input = page.getByRole( 'combobox', {
name: 'Search commands and settings',
} );
await expect( input ).toBeVisible();
// Search for a create command — these are always registered by SCF.
await input.fill( 'Create New Field Group' );
await expect(
page.getByRole( 'option', { name: /Create New Field Group/ } )
).toBeVisible();
} );
test( 'should register SCF view commands without duplicates', async ( {
page,
admin,
} ) => {
await admin.visitAdminPage( 'index.php' );
test.skip(
! ( await wpVersionAtLeast( page, 6, 3 ) ),
'Command Palette requires WordPress 6.3+'
);
await page.keyboard.press( 'ControlOrMeta+k' );
const input = page.getByRole( 'combobox', {
name: 'Search commands and settings',
} );
// Search for a view command that exists in both WP's auto-registered
// admin menu commands and SCF's view commands list.
await input.fill( 'Field Groups' );
const options = page.getByRole( 'option', {
name: /Field Groups/,
} );
// There should be exactly one match, not two (no duplicate).
await expect( options ).toHaveCount( 1 );
} );
test( 'should navigate to field groups via command palette', async ( {
page,
admin,
} ) => {
await admin.visitAdminPage( 'index.php' );
// Command Palette was introduced in WordPress 6.3
test.skip(
! ( await wpVersionAtLeast( page, 6, 3 ) ),
'Command Palette requires WordPress 6.3+'
);
await page.keyboard.press( 'ControlOrMeta+k' );
const input = page.getByRole( 'combobox', {
name: 'Search commands and settings',
} );
await input.fill( 'Field Groups' );
await page
.getByRole( 'option', { name: /Field Groups/ } )
.click();
await expect( page ).toHaveURL(
/edit\.php\?post_type=acf-field-group/
);
} );
} );