1+ /**
2+ * WordPress dependencies
3+ */
4+ const { test, expect } = require ( '@wordpress/e2e-test-utils-playwright' ) ;
5+
6+ const PLUGIN_SLUG = 'secure-custom-fields' ;
7+ const PLUGIN_PATH = `${ PLUGIN_SLUG } /${ PLUGIN_SLUG } .php` ;
8+ const FIELD_GROUP_LABEL = 'Movies' ;
9+ const MOVIE_FIELD_LABEL = 'Movie Title' ;
10+
11+ test . describe ( 'Field Group > Input Text' , ( ) => {
12+
13+ test . beforeEach ( async ( { page, requestUtils } ) => {
14+ // Login to WordPress admin
15+ await page . goto ( '/wp-admin' ) ;
16+ await page . fill ( '#user_login' , 'admin' ) ;
17+ await page . fill ( '#user_pass' , 'password' ) ;
18+ await page . click ( '#wp-submit' ) ;
19+ await requestUtils . activatePlugin ( PLUGIN_SLUG ) ;
20+ } ) ;
21+
22+ test . afterAll ( async ( { requestUtils } ) => {
23+ await requestUtils . deactivatePlugin ( PLUGIN_SLUG ) ;
24+ } ) ;
25+
26+ test ( 'should be able to create a new field group with a text field' , async ( { page, admin } ) => {
27+ // Navigate to Custom Fields → Post Types.
28+ await admin . visitAdminPage ( 'edit.php' , 'post_type=acf-field-group' ) ;
29+
30+ // Click "Add New" using the specific ACF button.
31+ const addNewButton = page . locator ( 'a.acf-btn.acf-btn-sm:has-text("Add New")' ) ;
32+ await addNewButton . click ( ) ;
33+
34+ // Fill in basic settings.
35+ await page . fill ( '#title' , FIELD_GROUP_LABEL ) ;
36+
37+ // Fill in labels using a more robust selector that ignores dynamic IDs.
38+ const fieldLabel = page . locator ( 'input[id^="acf_fields-field_"][id$="-label"]' ) ;
39+ await fieldLabel . fill ( MOVIE_FIELD_LABEL ) ;
40+
41+ // Save and publish using the correct ACF button selector.
42+ const submitButton = page . locator ( 'button.acf-btn.acf-publish[type="submit"]' ) ;
43+ await submitButton . click ( ) ;
44+
45+ // Verify field group and field were created.
46+ await expect ( page . locator ( '.notice-success' ) ) . toBeVisible ( ) ;
47+ } ) ;
48+
49+ } ) ;
0 commit comments