Skip to content

Commit

Permalink
PLANET-7656 Prepare for WordPress 6.7 upgrade (#2472)
Browse files Browse the repository at this point in the history
- The core Posts List variation of the Query Loop block has been removed so we don't need to unregister it anymore
- Some of the e2e tests were broken
- Add pages and offset to allowed controls for our QLB variations, they have been moved to the sidebar
  • Loading branch information
mleray authored Dec 18, 2024
1 parent c5b779c commit 7fe3e28
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 10 deletions.
2 changes: 1 addition & 1 deletion assets/src/blocks/ActionsList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ export const registerActionsListBlock = () => {
description: __('Integrate images and text cards to automatically display tags, take action pages, or Posts in a three or four column layout displayed in a grid or carousel.', 'planet4-blocks-backend'),
icon: 'list-view',
scope: ['inserter'],
allowedControls: ['taxQuery'],
allowedControls: ['taxQuery', 'pages', 'offset'],
category: 'planet4-blocks-beta',
isActive: ({namespace, query}) => namespace === ACTIONS_LIST_BLOCK_NAME && query.postType === queryPostType,
attributes: {
Expand Down
2 changes: 1 addition & 1 deletion assets/src/blocks/PostsList/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export const registerPostsListBlock = () => {
description: __('Insert a list or grid of the latest articles, press releases, and/or publications, organized by publication date. ', 'planet4-blocks-backend'),
category: 'planet4-blocks-beta',
scope: ['inserter'],
allowedControls: ['taxQuery'],
allowedControls: ['taxQuery', 'pages', 'offset'],
isActive: ({namespace, query}) => namespace === POSTS_LIST_BLOCK_NAME && query.postType === 'post',
attributes: {
namespace: POSTS_LIST_BLOCK_NAME,
Expand Down
3 changes: 0 additions & 3 deletions assets/src/editorIndex.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,6 @@ import {registerBlockVariations} from './block-variations';
import {registerActionButtonTextBlock} from './blocks/ActionCustomButtonText';

wp.domReady(() => {
// Make sure to unregister the posts-list native variation before registering planet4-blocks/posts-list
wp.blocks.unregisterBlockVariation('core/query', 'posts-list');

// Blocks
registerTableOfContentsBlock();
registerColumnsBlock();
Expand Down
8 changes: 3 additions & 5 deletions tests/e2e/navigation-bar.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ test('Test navigation bar menu', async ({page, admin, requestUtils}) => {
const testPageTitle = `Navbar test ${testId}`;

// Create a new page with a dummy paragraph
await requestUtils.rest({
const newPage = await requestUtils.rest({
path: '/wp/v2/pages',
method: 'POST',
data: {
Expand All @@ -30,14 +30,12 @@ test('Test navigation bar menu', async ({page, admin, requestUtils}) => {
const pageOptions = page.locator('#add-post-type-page');
await pageOptions.getByRole('checkbox', {name: testPageTitle}).first().check();
await pageOptions.getByRole('button', {name: 'Add to Menu'}).click();
const newMenuItem = page.locator('.menu-item-depth-0', {hasText: testPageTitle});
await expect(newMenuItem).toBeVisible();
const newMenuItemLink = await newMenuItem.locator('.link-to-original a').getAttribute('href');
await page.locator('#menu-to-edit .menu-item-title').filter({hasText: testPageTitle}).waitFor();
await page.getByRole('button', {name: 'Save Menu'}).click();
await expect(page.locator('.updated.notice')).toBeVisible();

// Check in the frontend that the new menu item is correctly added
await page.goto('./');
await expect(page.getByRole('link', {name: testPageTitle})).toBeVisible();
await expect(page.getByRole('link', {name: testPageTitle})).toHaveAttribute('href', newMenuItemLink);
await expect(page.getByRole('link', {name: testPageTitle})).toHaveAttribute('href', newPage.link);
});
5 changes: 5 additions & 0 deletions tests/e2e/tools/lib/post.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import {expect} from './test-utils';
* @return {Promise<string>} The URL of the published post.
*/
async function publishPost({page, editor}) {
// We should be able to remove this check once we update Playwright to the latest version.
const closeSettingsSidebar = await page.getByRole('button', {name: 'Close Settings'});
if (await closeSettingsSidebar.isVisible()) {
await closeSettingsSidebar.click();
}
await editor.publishPost();

const urlString = await page
Expand Down

0 comments on commit 7fe3e28

Please sign in to comment.