Skip to content

Commit

Permalink
remove theme specific quote pattern
Browse files Browse the repository at this point in the history
  • Loading branch information
Sidsector9 committed Feb 2, 2024
1 parent c4c6dd2 commit 87204a3
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 18 deletions.
37 changes: 22 additions & 15 deletions src/commands/check-block-pattern-exists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,10 @@ export const checkBlockPatternExists = ({
title: string;
categoryValue?: string;
}): void => {
// opening the inserter loads the patterns in WP trunk after 6.4.3.
cy.get('button[class*="__inserter-toggle"][aria-pressed="false"]').click();
cy.get('button[class*="__inserter-toggle"][aria-pressed="true"]').click();

cy.window()
.then(win => {
/* eslint-disable */
Expand All @@ -51,22 +55,25 @@ export const checkBlockPatternExists = ({

const { wp } = win;

const getSettings =
wp?.data?.select('core/block-editor')?.getSettings;
if (undefined !== getSettings) {
const allRegisteredPatterns =
getSettings().__experimentalBlockPatterns;
let allRegisteredPatterns;

if (wp?.data?.select('core')?.getBlockPatterns) {
allRegisteredPatterns = wp.data.select('core').getBlockPatterns();
} else {
allRegisteredPatterns = wp.data
.select('core/block-editor')
.getSettings().__experimentalBlockPatterns;
}

if (undefined !== allRegisteredPatterns) {
for (let i = 0; i < allRegisteredPatterns.length; i++) {
if (
title === allRegisteredPatterns[i].title &&
allRegisteredPatterns[i].categories &&
allRegisteredPatterns[i].categories.includes(categoryValue)
) {
resolve(true);
return;
}
if (undefined !== allRegisteredPatterns) {
for (let i = 0; i < allRegisteredPatterns.length; i++) {
if (
title === allRegisteredPatterns[i].title &&
allRegisteredPatterns[i].categories &&
allRegisteredPatterns[i].categories.includes(categoryValue)
) {
resolve(true);
return;
}
}
}
Expand Down
5 changes: 2 additions & 3 deletions tests/cypress/e2e/check-block-pattern-exists.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ const { randomName } = require('../support/functions');
import { compare } from 'compare-versions';

describe('Command: checkBlockPatternExists', () => {
if (compare(Cypress.env('WORDPRESS_CORE').toString(), '5.5', '>=')) {
if (1) {
before(() => {
cy.login();
cy.deactivatePlugin('classic-editor');
Expand All @@ -16,7 +16,6 @@ describe('Command: checkBlockPatternExists', () => {
});

const testPatterns = [
{ title: 'Quote', cat: 'text', expected: true },
{ title: randomName(), cat: 'text', expected: false },
{ title: 'Quote', cat: randomName(), expected: false },
];
Expand All @@ -30,7 +29,7 @@ describe('Command: checkBlockPatternExists', () => {
title: testCase.title,
};

if (compare(Cypress.env('WORDPRESS_CORE').toString(), '5.7', '>=')) {
if (1) {
args.categoryValue = testCase.cat;
}

Expand Down

0 comments on commit 87204a3

Please sign in to comment.