From dc5c26c0f01b240ae4bfa5b9669f896da99c0a7e Mon Sep 17 00:00:00 2001 From: Konstantinos Galanakis Date: Wed, 2 Aug 2023 16:46:14 +0300 Subject: [PATCH 1/8] Fix the "insert-block" test --- tests/cypress/e2e/insert-block.test.js | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/cypress/e2e/insert-block.test.js b/tests/cypress/e2e/insert-block.test.js index a8815ee..5ba9355 100644 --- a/tests/cypress/e2e/insert-block.test.js +++ b/tests/cypress/e2e/insert-block.test.js @@ -15,12 +15,22 @@ describe('Command: insertBlock', () => { return false; } }); + + // Ignore error related to CORS that occurs when trying to access a remote resource. + Cypress.on('uncaught:exception', (err, runnable) => { + if (err.message.includes('FastAverageColor: Error loading image')) { + return false; + } + }); }); it('Should be able to Insert first paragraph on page', () => { const paragraph = 'Paragraph ' + randomName(); cy.createPost({ beforeSave: () => { + // Close Welcome Guide. + cy.closeWelcomeGuide(); + cy.insertBlock('core/paragraph').then(id => { cy.get(`#${id}`).click().type(paragraph); }); From fbdfc123f7fcaca546f55ba6522a63460cc140e4 Mon Sep 17 00:00:00 2001 From: Konstantinos Galanakis Date: Wed, 2 Aug 2023 17:04:16 +0300 Subject: [PATCH 2/8] Enable video --- tests/cypress/cypress-config.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cypress/cypress-config.js b/tests/cypress/cypress-config.js index c0bda23..4b4a6b0 100644 --- a/tests/cypress/cypress-config.js +++ b/tests/cypress/cypress-config.js @@ -6,7 +6,7 @@ module.exports = defineConfig({ screenshotsFolder: 'tests/cypress/screenshots', videosFolder: 'tests/cypress/videos', downloadsFolder: 'tests/cypress/downloads', - video: false, + video: true, e2e: { setupNodeEvents(on, config) { return setBaseUrl(on, config); From 1bbbebf8aa0eec91ac63a0ffd7aa8ed8ef613f5b Mon Sep 17 00:00:00 2001 From: Konstantinos Galanakis Date: Wed, 2 Aug 2023 17:27:27 +0300 Subject: [PATCH 3/8] Disable video and stuff --- tests/cypress/cypress-config.js | 2 +- tests/cypress/e2e/insert-block.test.js | 3 --- 2 files changed, 1 insertion(+), 4 deletions(-) diff --git a/tests/cypress/cypress-config.js b/tests/cypress/cypress-config.js index 4b4a6b0..c0bda23 100644 --- a/tests/cypress/cypress-config.js +++ b/tests/cypress/cypress-config.js @@ -6,7 +6,7 @@ module.exports = defineConfig({ screenshotsFolder: 'tests/cypress/screenshots', videosFolder: 'tests/cypress/videos', downloadsFolder: 'tests/cypress/downloads', - video: true, + video: false, e2e: { setupNodeEvents(on, config) { return setBaseUrl(on, config); diff --git a/tests/cypress/e2e/insert-block.test.js b/tests/cypress/e2e/insert-block.test.js index 5ba9355..443b238 100644 --- a/tests/cypress/e2e/insert-block.test.js +++ b/tests/cypress/e2e/insert-block.test.js @@ -28,9 +28,6 @@ describe('Command: insertBlock', () => { const paragraph = 'Paragraph ' + randomName(); cy.createPost({ beforeSave: () => { - // Close Welcome Guide. - cy.closeWelcomeGuide(); - cy.insertBlock('core/paragraph').then(id => { cy.get(`#${id}`).click().type(paragraph); }); From 1096b0dbc7f7a9da3c2721f16053bca7d8e46aa2 Mon Sep 17 00:00:00 2001 From: Konstantinos Galanakis Date: Thu, 3 Aug 2023 11:32:45 +0300 Subject: [PATCH 4/8] FIxes for the close welcome modal command --- .../close-welcome-guide-javascript.ts | 64 +++++++++++++++++++ src/commands/create-post.ts | 2 +- src/index.ts | 3 + 3 files changed, 68 insertions(+), 1 deletion(-) create mode 100644 src/commands/close-welcome-guide-javascript.ts diff --git a/src/commands/close-welcome-guide-javascript.ts b/src/commands/close-welcome-guide-javascript.ts new file mode 100644 index 0000000..e515ed6 --- /dev/null +++ b/src/commands/close-welcome-guide-javascript.ts @@ -0,0 +1,64 @@ +/* eslint-disable tsdoc/syntax */ +/** + * Check Block Pattern Exists. Works only with WordPress \>=5.5 + * + * \@param postData { + * `title` - Patttern name/title, + * `categoryValue` - Value of the pattern category, + * } + * + * @example + * For WP v5.5 + * ``` + * cy.checkBlockPatternExists({ + * title: 'Two buttons', + * }); + * ``` + * + * @example + * For WP v5.9 + * ``` + * cy.checkBlockPatternExists({ + * title: 'Three columns with offset images', + * categoryValue: 'gallery', + * }); + * ``` + */ +declare global { + interface Window { + wp: any; + } +} + +export const closeWelcomeGuideJavascript = (): void => { + cy.window() + .then(win => { + /* eslint-disable */ + let elapsed = 0; + console.log('hello'); + + setInterval(function () { + if (elapsed > 2500) { + return; + } + + const { wp } = win; + + const { isFeatureActive } = wp.data.select('core/edit-post'); + const { toggleFeature } = wp.data.dispatch('core/edit-post'); + const isWelcomeGuideActive = isFeatureActive('welcomeGuide'); + + if (!!isWelcomeGuideActive) { + toggleFeature('welcomeGuide'); + return; + } + + elapsed += 100; + }, 100); + + + + + /* eslint-enable */ + }) +}; diff --git a/src/commands/create-post.ts b/src/commands/create-post.ts index e226474..94abef3 100644 --- a/src/commands/create-post.ts +++ b/src/commands/create-post.ts @@ -71,7 +71,7 @@ export const createPost = ({ cy.get(contentInput).should('exist'); // Close Welcome Guide. - cy.closeWelcomeGuide(); + cy.closeWelcomeGuideJavascript(); // Fill out data. if (title.length > 0) { diff --git a/src/index.ts b/src/index.ts index a711e7e..ace9a9f 100644 --- a/src/index.ts +++ b/src/index.ts @@ -23,6 +23,7 @@ import { login } from './commands/login'; import { createPost } from './commands/create-post'; import { uploadMedia } from './commands/upload-media'; import { checkSitemap } from './commands/check-sitemap-exists'; +import { closeWelcomeGuideJavascript } from "./commands/close-welcome-guide-javascript"; declare global { namespace Cypress { @@ -31,6 +32,7 @@ declare global { classicCreatePost: typeof classicCreatePost; insertBlock: typeof insertBlock; closeWelcomeGuide: typeof closeWelcomeGuide; + closeWelcomeGuideJavascript: typeof closeWelcomeGuideJavascript; wpCliEval: typeof wpCliEval; wpCli: typeof wpCli; deactivatePlugin: typeof deactivatePlugin; @@ -57,6 +59,7 @@ Cypress.Commands.add('checkPostExists', checkPostExists); Cypress.Commands.add('classicCreatePost', classicCreatePost); Cypress.Commands.add('insertBlock', insertBlock); Cypress.Commands.add('closeWelcomeGuide', closeWelcomeGuide); +Cypress.Commands.add('closeWelcomeGuideJavascript', closeWelcomeGuideJavascript); Cypress.Commands.add('wpCliEval', wpCliEval); Cypress.Commands.add('wpCli', wpCli); Cypress.Commands.add('deactivatePlugin', deactivatePlugin); From fb1b26bf113e6ceeef62fc8c3ba4535d3d4dfcfe Mon Sep 17 00:00:00 2001 From: Konstantinos Galanakis Date: Thu, 3 Aug 2023 11:34:21 +0300 Subject: [PATCH 5/8] Change the post env execution script --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index 7905813..a4c7799 100644 --- a/package.json +++ b/package.json @@ -22,7 +22,7 @@ "env": "wp-env", "env:start": "wp-env start", "env:stop": "wp-env stop", - "postenv:start": "./tests/bin/initialize.sh" + "postenv:start": "bash ./tests/bin/initialize.sh" }, "repository": { "type": "git", From c14950552b447df99ee731f25697ffe7552b53e0 Mon Sep 17 00:00:00 2001 From: Konstantinos Galanakis Date: Thu, 3 Aug 2023 11:34:41 +0300 Subject: [PATCH 6/8] Run tests with Chrome instead of Electron --- package.json | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/package.json b/package.json index a4c7799..6031009 100644 --- a/package.json +++ b/package.json @@ -18,7 +18,7 @@ "prettify": "prettier --write \"**/*.{ts,js}\"", "typecheck": "tsc --noEmit", "cypress:open": "cypress open --config-file tests/cypress/cypress-config.js --e2e --browser chrome", - "cypress:run": "cypress run --config-file tests/cypress/cypress-config.js", + "cypress:run": "cypress run --config-file tests/cypress/cypress-config.js --browser chrome", "env": "wp-env", "env:start": "wp-env start", "env:stop": "wp-env stop", From 31e1f57032bc74355ebd3d142956ecaac7c14831 Mon Sep 17 00:00:00 2001 From: Konstantinos Galanakis Date: Mon, 7 Aug 2023 14:40:38 +0300 Subject: [PATCH 7/8] Revert "FIxes for the close welcome modal command" This reverts commit 1096b0dbc7f7a9da3c2721f16053bca7d8e46aa2. --- .../close-welcome-guide-javascript.ts | 64 ------------------- src/commands/create-post.ts | 2 +- src/index.ts | 3 - 3 files changed, 1 insertion(+), 68 deletions(-) delete mode 100644 src/commands/close-welcome-guide-javascript.ts diff --git a/src/commands/close-welcome-guide-javascript.ts b/src/commands/close-welcome-guide-javascript.ts deleted file mode 100644 index e515ed6..0000000 --- a/src/commands/close-welcome-guide-javascript.ts +++ /dev/null @@ -1,64 +0,0 @@ -/* eslint-disable tsdoc/syntax */ -/** - * Check Block Pattern Exists. Works only with WordPress \>=5.5 - * - * \@param postData { - * `title` - Patttern name/title, - * `categoryValue` - Value of the pattern category, - * } - * - * @example - * For WP v5.5 - * ``` - * cy.checkBlockPatternExists({ - * title: 'Two buttons', - * }); - * ``` - * - * @example - * For WP v5.9 - * ``` - * cy.checkBlockPatternExists({ - * title: 'Three columns with offset images', - * categoryValue: 'gallery', - * }); - * ``` - */ -declare global { - interface Window { - wp: any; - } -} - -export const closeWelcomeGuideJavascript = (): void => { - cy.window() - .then(win => { - /* eslint-disable */ - let elapsed = 0; - console.log('hello'); - - setInterval(function () { - if (elapsed > 2500) { - return; - } - - const { wp } = win; - - const { isFeatureActive } = wp.data.select('core/edit-post'); - const { toggleFeature } = wp.data.dispatch('core/edit-post'); - const isWelcomeGuideActive = isFeatureActive('welcomeGuide'); - - if (!!isWelcomeGuideActive) { - toggleFeature('welcomeGuide'); - return; - } - - elapsed += 100; - }, 100); - - - - - /* eslint-enable */ - }) -}; diff --git a/src/commands/create-post.ts b/src/commands/create-post.ts index 94abef3..e226474 100644 --- a/src/commands/create-post.ts +++ b/src/commands/create-post.ts @@ -71,7 +71,7 @@ export const createPost = ({ cy.get(contentInput).should('exist'); // Close Welcome Guide. - cy.closeWelcomeGuideJavascript(); + cy.closeWelcomeGuide(); // Fill out data. if (title.length > 0) { diff --git a/src/index.ts b/src/index.ts index ace9a9f..a711e7e 100644 --- a/src/index.ts +++ b/src/index.ts @@ -23,7 +23,6 @@ import { login } from './commands/login'; import { createPost } from './commands/create-post'; import { uploadMedia } from './commands/upload-media'; import { checkSitemap } from './commands/check-sitemap-exists'; -import { closeWelcomeGuideJavascript } from "./commands/close-welcome-guide-javascript"; declare global { namespace Cypress { @@ -32,7 +31,6 @@ declare global { classicCreatePost: typeof classicCreatePost; insertBlock: typeof insertBlock; closeWelcomeGuide: typeof closeWelcomeGuide; - closeWelcomeGuideJavascript: typeof closeWelcomeGuideJavascript; wpCliEval: typeof wpCliEval; wpCli: typeof wpCli; deactivatePlugin: typeof deactivatePlugin; @@ -59,7 +57,6 @@ Cypress.Commands.add('checkPostExists', checkPostExists); Cypress.Commands.add('classicCreatePost', classicCreatePost); Cypress.Commands.add('insertBlock', insertBlock); Cypress.Commands.add('closeWelcomeGuide', closeWelcomeGuide); -Cypress.Commands.add('closeWelcomeGuideJavascript', closeWelcomeGuideJavascript); Cypress.Commands.add('wpCliEval', wpCliEval); Cypress.Commands.add('wpCli', wpCli); Cypress.Commands.add('deactivatePlugin', deactivatePlugin); From 83d01267db436d5b696f3025cc36dded1b0a2a2c Mon Sep 17 00:00:00 2001 From: Konstantinos Galanakis Date: Mon, 7 Aug 2023 17:24:03 +0300 Subject: [PATCH 8/8] Update WordPress versions for tests --- .github/workflows/cypress.yml | 4 ++-- run-all-cores.sh | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/cypress.yml b/.github/workflows/cypress.yml index 4ccfbbb..0b50c5c 100644 --- a/.github/workflows/cypress.yml +++ b/.github/workflows/cypress.yml @@ -65,8 +65,8 @@ jobs: fail-fast: false matrix: core: - - { name: 'WP latest', version: 'latest', number: '6.1' } - - { name: 'WP trunk', version: 'WordPress/WordPress#master', number: '6.2' } + - { name: 'WP latest', version: 'latest', number: '6.2.2' } + - { name: 'WP trunk', version: 'WordPress/WordPress#master', number: '6.4' } - { name: 'WP minimum', version: 'WordPress/WordPress#5.7', number: '5.7' } steps: - name: Checkout diff --git a/run-all-cores.sh b/run-all-cores.sh index 6d0f01c..7680733 100755 --- a/run-all-cores.sh +++ b/run-all-cores.sh @@ -1,6 +1,6 @@ #!/bin/bash -VERSIONS="5.7 5.8 5.9 6.0 6.1 master:6.2" +VERSIONS="5.7 5.8 5.9 6.0 6.1 6.2 master:6.4" SPEC="-- --quiet"