Skip to content

Commit

Permalink
fix: remove wait for patterns to load
Browse files Browse the repository at this point in the history
  • Loading branch information
Sidsector9 committed Jun 7, 2022
1 parent a535b32 commit 2be2101
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
12 changes: 10 additions & 2 deletions src/commands/check-block-pattern-exists.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,16 @@ export const checkBlockPatternExists = ({
const { wp } = win;

/* eslint-disable */
const { getSettings } = wp.data.select('core/block-editor');
const allRegisteredPatterns = getSettings().__experimentalBlockPatterns;
let allRegisteredPatterns = wp.data
.select('core/block-editor')
.getSettings().__experimentalBlockPatterns;

if (Array.isArray(allRegisteredPatterns) && !allRegisteredPatterns.length) {
cy.wait(1000);
allRegisteredPatterns = wp.data
.select('core/block-editor')
.getSettings().__experimentalBlockPatterns;
}

if (undefined !== allRegisteredPatterns) {
for (let i = 0; i < allRegisteredPatterns.length; i++) {
Expand Down
3 changes: 0 additions & 3 deletions tests/cypress/integration/check-block-pattern-exists.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,9 +19,6 @@ describe('Command: checkBlockPatternExists', () => {
testPatterns.forEach(testCase => {
const shouldIt = testCase.expected ? 'should' : 'should not';
it(`Pattern "${testCase.title}" ${shouldIt} exist in category "${testCase.cat}"`, () => {
// Wait for patterns to load on the post edit page.
cy.wait(1000);

const args = {
title: testCase.title,
};
Expand Down

0 comments on commit 2be2101

Please sign in to comment.