diff --git a/lib/commands/check-block-pattern-exists.js b/lib/commands/check-block-pattern-exists.js index 85f310f..19aa4a4 100644 --- a/lib/commands/check-block-pattern-exists.js +++ b/lib/commands/check-block-pattern-exists.js @@ -7,20 +7,24 @@ const checkBlockPatternExists = ({ title, categoryValue = 'featured', }) => { /* eslint-disable */ return new Promise(resolve => { let elapsed = 0; - setInterval(function () { + const inverval = setInterval(function () { + var _a, _b; if (elapsed > 2500) { + clearInterval(inverval); resolve(false); } const { wp } = win; - const { getSettings } = wp.data.select('core/block-editor'); - const allRegisteredPatterns = 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; + const getSettings = (_b = (_a = wp === null || wp === void 0 ? void 0 : wp.data) === null || _a === void 0 ? void 0 : _a.select('core/block-editor')) === null || _b === void 0 ? void 0 : _b.getSettings; + if (undefined !== getSettings) { + const allRegisteredPatterns = 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; + } } } } diff --git a/lib/commands/login.js b/lib/commands/login.js index 30fcc63..730b389 100644 --- a/lib/commands/login.js +++ b/lib/commands/login.js @@ -20,13 +20,15 @@ exports.login = void 0; * ``` */ const login = (username = 'admin', password = 'password') => { - cy.visit('/wp-admin/'); - cy.get('body').then($body => { - if ($body.find('#wpwrap').length == 0) { - cy.get('input#user_login').clear(); - cy.get('input#user_login').click().type(username); - cy.get('input#user_pass').type(`${password}{enter}`); - } + cy.session([username, password], () => { + cy.visit('/wp-admin/'); + cy.get('body').then($body => { + if ($body.find('#wpwrap').length == 0) { + cy.get('input#user_login').clear(); + cy.get('input#user_login').click().type(username); + cy.get('input#user_pass').type(`${password}{enter}`); + } + }); }); }; exports.login = login; diff --git a/package.json b/package.json index 4943a3a..39167e1 100644 --- a/package.json +++ b/package.json @@ -51,7 +51,7 @@ "@wordpress/env": "^5.5.0", "codecov": "^3.8.1", "compare-versions": "^4.1.3", - "cypress": "^10.11.0", + "cypress": "^13.0.0", "cypress-mochawesome-reporter": "^3.2.3", "eslint": "^7.25.0", "eslint-config-prettier": "^8.3.0",