Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 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
13 changes: 10 additions & 3 deletions packages/e2e-test-utils-playwright/src/request-utils/themes.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,16 @@ async function getCurrentThemeGlobalStylesPostId( this: RequestUtils ) {
const globalStylesURL =
currentTheme?._links?.[ 'wp:user-global-styles' ]?.[ 0 ]?.href;
if ( globalStylesURL ) {
themeGlobalStylesId = globalStylesURL?.split(
'rest_route=/wp/v2/global-styles/'
)[ 1 ];
// Extract the ID from the URL. The URL format depends on
// the permalink structure:
// - Plain: ?rest_route=/wp/v2/global-styles/123
// - Pretty: /wp-json/wp/v2/global-styles/123
const idMatch = globalStylesURL.match(
/\/wp\/v2\/global-styles\/(\d+)/
);
if ( idMatch ) {
themeGlobalStylesId = idMatch[ 1 ];
}
}
}
return themeGlobalStylesId;
Expand Down
1 change: 1 addition & 0 deletions packages/env/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

### Breaking Changes

- Pretty permalinks (`/%year%/%monthnum%/%day%/%postname%/`) are now enabled by default, matching WordPress core behavior on fresh installs. Previously, plain permalinks were used because the loopback test that WordPress runs during installation fails inside Docker.
- Replaced `install-path` command with `status` command. The work directory path is now available as part of the status output.

### New Features
Expand Down
2 changes: 1 addition & 1 deletion packages/env/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -488,7 +488,7 @@ Success: Installed 1 of 1 plugins.

#### Changing the permalink structure

You might want to do this to enable access to the REST API (`wp-env/wp/v2/`) endpoint in your wp-env environment. The endpoint is not available with plain permalinks.
Pretty permalinks are enabled by default using the `/%year%/%monthnum%/%day%/%postname%/` structure, matching the WordPress core behavior on fresh installs. You can change the structure if needed:

**Examples**

Expand Down
5 changes: 5 additions & 0 deletions packages/env/lib/runtime/docker/wordpress.js
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,11 @@ async function configureWordPress( environment, config, spinner ) {
'set -eo pipefail',
cliConfigCommand,
installCommand,
// Enable pretty permalinks by default to match what WordPress core
// does on a fresh install. The loopback test that WordPress normally
// uses to verify pretty permalinks fails in Docker because the CLI
// container can't reach the WordPress container at the site URL.
`wp rewrite structure '/%year%/%monthnum%/%day%/%postname%/' --hard`,
];

// Bootstrap .htaccess for multisite
Expand Down
15 changes: 6 additions & 9 deletions test/e2e/specs/editor/blocks/links.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -53,14 +53,11 @@ test.describe( 'Links', () => {
{
name: 'core/paragraph',
attributes: {
content:
'Here comes a link: <a href="http://localhost:8889/?p=' +
postId +
'" data-type="post" data-id="' +
postId +
'">' +
titleText +
'</a>',
content: expect.stringMatching(
new RegExp(
`Here comes a link: <a href="[^"]*" data-type="post" data-id="${ postId }">${ titleText }</a>`
)
),
},
},
] );
Expand Down Expand Up @@ -385,7 +382,7 @@ test.describe( 'Links', () => {
await expect(
page.getByRole( 'option', {
// "post" disambiguates from the "Create page" option.
name: `${ titleText } post`,
name: new RegExp( `${ titleText }.*post` ),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How is this related? There doesn't seem to be any URL in the text we're matching.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

The "LinkControl" component shows both the slug and the title within each suggestion when pretty permalinks are enabled. This means that the "name" of the DOM element changes a bit.

} )
).toBeVisible();

Expand Down
1 change: 1 addition & 0 deletions test/e2e/specs/editor/blocks/navigation-list-view.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -598,6 +598,7 @@ class LinkControl {

return result
.locator( '.components-menu-item__item' ) // this is the only way to get the label text without the URL.
.last()

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

How is this change related?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Same as above, the LinkControl component shows both the slug and the name of the page when pretty permalinks are enabled, this means that there are two "components-menuitem__item" per element.

.innerText();
}
}
2 changes: 1 addition & 1 deletion test/e2e/specs/site-editor/page-list.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@
name: 'Edit Status & Visibility',
} )
.locator( '..' );
await expect( statusAndVisibility ).toContainText(

Check failure on line 152 in test/e2e/specs/site-editor/page-list.spec.js

View workflow job for this annotation

GitHub Actions / Playwright - 6

[chromium] › test/e2e/specs/site-editor/page-list.spec.js:374:5 › Page List › Quick Edit Mode › should initialize

1) [chromium] › test/e2e/specs/site-editor/page-list.spec.js:374:5 › Page List › Quick Edit Mode › should initialize, edit, and update statusVisibility field correctly Error: expect(locator).toContainText(expected) failed Locator: getByRole('button', { name: 'Edit Status & Visibility' }).locator('..') Expected substring: "Published" Received string: "Status & VisibilityDraft" Timeout: 5000ms Call log: - Expect "toContainText" with timeout 5000ms - waiting for getByRole('button', { name: 'Edit Status & Visibility' }).locator('..') 9 × locator resolved to <div class="dataforms-layouts-panel__field-trigger dataforms-layouts-panel__field-trigger--label-side">…</div> - unexpected value "Status & VisibilityDraft" 150 | } ) 151 | .locator( '..' ); > 152 | await expect( statusAndVisibility ).toContainText( | ^ 153 | 'Published' 154 | ); 155 | }, at assertInitialState (/home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/page-list.spec.js:152:42) at /home/runner/work/gutenberg/gutenberg/test/e2e/specs/site-editor/page-list.spec.js:377:12
'Published'
);
},
Expand Down Expand Up @@ -252,7 +252,7 @@
await editButton.click();
await expect(
page.getByRole( 'link', {
name: 'http://localhost:8889/?',
name: /http:\/\/localhost:8889\//,
} )
).toBeVisible();
},
Expand Down
15 changes: 14 additions & 1 deletion test/e2e/specs/site-editor/preload.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,20 @@ test.describe( 'Preload', () => {
urlObject.searchParams.delete( '_locale' );
requests.push( restRoute + urlObject.search );
} else {
requests.push( url );
// With pretty permalinks, REST API calls use
// the /wp-json/ prefix instead of ?rest_route=.
const wpJsonPrefix = '/wp-json';
const wpJsonIndex =
urlObject.pathname.indexOf( wpJsonPrefix );
if ( wpJsonIndex !== -1 ) {
const route = urlObject.pathname.substring(
wpJsonIndex + wpJsonPrefix.length
);
urlObject.searchParams.delete( '_locale' );
requests.push( route + urlObject.search );
} else {
requests.push( url );
}

@jsnajdr jsnajdr Feb 19, 2026 •

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

For simplicity, we could extract and match just the path, like /wp-abilities/v1/categories. Ignore the query params like per_page=100&context=edit. The test doesn't really care, it wants to verify an explicit list of preload requests.

20 lines of code that processes the request URL are not justified here, let's cut them to something like 2 lines.

The evolution of this test is generally unfortunate. The description says "should make no requests" but as the preload requests have been creeping in, here we are checking that there are in fact four request 🙁

}
}
}
Expand Down
Loading