From 72949ff1cbbeab4f6366c56ce37682106a4c36d8 Mon Sep 17 00:00:00 2001 From: Mohammed Razzaq Date: Tue, 21 Jun 2022 22:58:43 +0530 Subject: [PATCH 01/22] Add tests for instant results feature --- .wp-env.json | 3 +- .../features/instant-results.spec.js | 52 +++++++++++++++++++ 2 files changed, 54 insertions(+), 1 deletion(-) create mode 100644 tests/cypress/integration/features/instant-results.spec.js diff --git a/.wp-env.json b/.wp-env.json index 790a395135..49159bf9bb 100644 --- a/.wp-env.json +++ b/.wp-env.json @@ -9,7 +9,8 @@ "https://downloads.wordpress.org/plugin/debug-bar.zip", "https://downloads.wordpress.org/plugin/debug-bar-elasticpress.zip", "https://downloads.wordpress.org/plugin/wordpress-importer.zip", - "https://downloads.wordpress.org/plugin/woocommerce.zip" + "https://downloads.wordpress.org/plugin/woocommerce.zip", + "10up/elasticpress-proxy#develop" ], "mappings": { "wp-content/mu-plugins/unique-index-name.php": "./tests/cypress/wordpress-files/test-mu-plugins/unique-index-name.php", diff --git a/tests/cypress/integration/features/instant-results.spec.js b/tests/cypress/integration/features/instant-results.spec.js new file mode 100644 index 0000000000..35bedf5901 --- /dev/null +++ b/tests/cypress/integration/features/instant-results.spec.js @@ -0,0 +1,52 @@ +describe('Instant Results Feature', () => { + before(() => { + cy.deactivatePlugin('elasticpress-proxy', 'wpCli'); + }); + + after(() => { + cy.deactivatePlugin('elasticpress-proxy', 'wpCli'); + }); + + it('Can activate the feature and sync automatically', () => { + cy.login(); + + cy.activatePlugin('elasticpress-proxy'); + + cy.visitAdminPage('admin.php?page=elasticpress'); + cy.get('.ep-feature-instant-results .settings-button').click(); + cy.get('.ep-feature-instant-results [name="settings[active]"][value="1"]').click(); + cy.get('.ep-feature-instant-results .button-primary').click(); + cy.on('window:confirm', () => { + return true; + }); + + cy.get('.ep-sync-progress strong', { + timeout: Cypress.config('elasticPressIndexTimeout'), + }).should('contain.text', 'Sync complete'); + + cy.wpCli('elasticpress list-features').its('stdout').should('contain', 'instant-results'); + }); + + it('Can see instant results list', () => { + cy.login(); + cy.maybeEnableFeature('instant-results'); + + cy.visit('/'); + cy.get('.wp-block-search__input').type('hello'); + cy.get('.wp-block-search__button').click(); + cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'Search results'); + }); + + it('Can click outside when instant results are shown', () => { + cy.login(); + cy.maybeEnableFeature('instant-results'); + + cy.visit('/'); + cy.get('.wp-block-search__input').type('hello'); + cy.get('.wp-block-search__button').click(); + cy.get('.ep-search-modal').should('be.visible'); + + cy.get('#wpadminbar li#wp-admin-bar-debug-bar').click(); + cy.get('#querylist').should('be.visible'); + }); +}); From 59459d1d140dff0b6c35cbb116f92338a1bfd54a Mon Sep 17 00:00:00 2001 From: Mohammed Razzaq Date: Thu, 14 Jul 2022 13:07:02 +0530 Subject: [PATCH 02/22] Change the activation to dashboard and test post name --- .../integration/features/instant-results.spec.js | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/tests/cypress/integration/features/instant-results.spec.js b/tests/cypress/integration/features/instant-results.spec.js index 35bedf5901..3d0c23dd98 100644 --- a/tests/cypress/integration/features/instant-results.spec.js +++ b/tests/cypress/integration/features/instant-results.spec.js @@ -1,17 +1,15 @@ describe('Instant Results Feature', () => { before(() => { - cy.deactivatePlugin('elasticpress-proxy', 'wpCli'); + cy.activatePlugin('elasticpress-proxy', 'dashboard'); }); after(() => { - cy.deactivatePlugin('elasticpress-proxy', 'wpCli'); + cy.deactivatePlugin('elasticpress-proxy', 'dashboard'); }); it('Can activate the feature and sync automatically', () => { cy.login(); - cy.activatePlugin('elasticpress-proxy'); - cy.visitAdminPage('admin.php?page=elasticpress'); cy.get('.ep-feature-instant-results .settings-button').click(); cy.get('.ep-feature-instant-results [name="settings[active]"][value="1"]').click(); @@ -32,9 +30,9 @@ describe('Instant Results Feature', () => { cy.maybeEnableFeature('instant-results'); cy.visit('/'); - cy.get('.wp-block-search__input').type('hello'); + cy.get('.wp-block-search__input').type('blog'); cy.get('.wp-block-search__button').click(); - cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'Search results'); + cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); }); it('Can click outside when instant results are shown', () => { @@ -42,7 +40,7 @@ describe('Instant Results Feature', () => { cy.maybeEnableFeature('instant-results'); cy.visit('/'); - cy.get('.wp-block-search__input').type('hello'); + cy.get('.wp-block-search__input').type('blog'); cy.get('.wp-block-search__button').click(); cy.get('.ep-search-modal').should('be.visible'); From b12fb4f601021b4d819d0095e05711f735479d03 Mon Sep 17 00:00:00 2001 From: Mohammed Razzaq Date: Thu, 4 Aug 2022 00:29:06 +0530 Subject: [PATCH 03/22] More test cases for instant results --- .../features/instant-results.spec.js | 45 ++++++++++++++++++- 1 file changed, 44 insertions(+), 1 deletion(-) diff --git a/tests/cypress/integration/features/instant-results.spec.js b/tests/cypress/integration/features/instant-results.spec.js index 3d0c23dd98..53ff71d1a4 100644 --- a/tests/cypress/integration/features/instant-results.spec.js +++ b/tests/cypress/integration/features/instant-results.spec.js @@ -1,12 +1,55 @@ describe('Instant Results Feature', () => { before(() => { - cy.activatePlugin('elasticpress-proxy', 'dashboard'); + cy.wpCli('eval "echo ElasticPress\\Utils\\get_host();"').then((epHost) => { + // Nothing needs to be done if EP.io. + if (epHost.stdout.match(/elasticpress\.io/)) { + return; + } + cy.activatePlugin('elasticpress-proxy', 'dashboard'); + }); }); after(() => { cy.deactivatePlugin('elasticpress-proxy', 'dashboard'); }); + it("Can't activate the feature If not in ElasticPress.io nor using a custom PHP proxy", () => { + cy.login(); + + cy.wpCli('eval "echo ElasticPress\\Utils\\get_host();"').then((epHost) => { + // Nothing needs to be done if EP.io. + if (epHost.stdout.match(/elasticpress\.io/)) { + return; + } + cy.deactivatePlugin('elasticpress-proxy', 'dashboard'); + cy.visitAdminPage('admin.php?page=elasticpress'); + cy.get('.ep-feature-instant-results .settings-button').click(); + cy.get('.requirements-status-notice').should( + 'contain.text', + 'To use this feature you need to be an ElasticPress.io customer or implement a custom proxy', + ); + cy.get('.ep-feature-instant-results .input-wrap').should('have.class', 'disabled'); + cy.activatePlugin('elasticpress-proxy', 'dashboard'); + }); + }); + + it('Can see a warning if using cusotom proxy', () => { + cy.login(); + cy.wpCli('eval "echo ElasticPress\\Utils\\get_host();"').then((epHost) => { + // Nothing needs to be done if EP.io. + if (epHost.stdout.match(/elasticpress\.io/)) { + return; + } + cy.visitAdminPage('admin.php?page=elasticpress'); + cy.get('.ep-feature-instant-results .settings-button').click(); + cy.get('.requirements-status-notice').should( + 'contain.text', + 'You are using a custom proxy. Make sure you implement all security measures needed', + ); + cy.get('.ep-feature-instant-results .input-wrap').should('not.have.class', 'disabled'); + }); + }); + it('Can activate the feature and sync automatically', () => { cy.login(); From e8c2d237d206be1a22a51a92edbc97109113064f Mon Sep 17 00:00:00 2001 From: Mohammed Razzaq Date: Tue, 9 Aug 2022 17:11:19 +0530 Subject: [PATCH 04/22] Add search widget to test the results --- .../features/instant-results.spec.js | 20 +++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/tests/cypress/integration/features/instant-results.spec.js b/tests/cypress/integration/features/instant-results.spec.js index 53ff71d1a4..e334836cfc 100644 --- a/tests/cypress/integration/features/instant-results.spec.js +++ b/tests/cypress/integration/features/instant-results.spec.js @@ -1,4 +1,18 @@ describe('Instant Results Feature', () => { + /** + * Create a Search widget. + */ + function createSearchWidget() { + cy.openWidgetsPage(); + + cy.get('.edit-widgets-header-toolbar__inserter-toggle').click(); + cy.get('.block-editor-inserter__panel-content [class*="search/default"]').click({ + force: true, + }); + + cy.get('.edit-widgets-header__actions .components-button.is-primary').click(); + cy.get('body').should('contain.text', 'Widgets saved.'); + } before(() => { cy.wpCli('eval "echo ElasticPress\\Utils\\get_host();"').then((epHost) => { // Nothing needs to be done if EP.io. @@ -7,6 +21,8 @@ describe('Instant Results Feature', () => { } cy.activatePlugin('elasticpress-proxy', 'dashboard'); }); + // Add search widget that will be used for the tests. + createSearchWidget(); }); after(() => { @@ -73,7 +89,7 @@ describe('Instant Results Feature', () => { cy.maybeEnableFeature('instant-results'); cy.visit('/'); - cy.get('.wp-block-search__input').type('blog'); + cy.get('.wp-block-search__input').type('test'); cy.get('.wp-block-search__button').click(); cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); }); @@ -83,7 +99,7 @@ describe('Instant Results Feature', () => { cy.maybeEnableFeature('instant-results'); cy.visit('/'); - cy.get('.wp-block-search__input').type('blog'); + cy.get('.wp-block-search__input').type('test'); cy.get('.wp-block-search__button').click(); cy.get('.ep-search-modal').should('be.visible'); From 23bd7263d70ce142de35f7eb3442ff4b9292499d Mon Sep 17 00:00:00 2001 From: Mohammed Razzaq Date: Tue, 9 Aug 2022 18:07:36 +0530 Subject: [PATCH 05/22] Proepr text to test against the search --- tests/cypress/integration/features/instant-results.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cypress/integration/features/instant-results.spec.js b/tests/cypress/integration/features/instant-results.spec.js index e334836cfc..eb6a63d961 100644 --- a/tests/cypress/integration/features/instant-results.spec.js +++ b/tests/cypress/integration/features/instant-results.spec.js @@ -91,7 +91,7 @@ describe('Instant Results Feature', () => { cy.visit('/'); cy.get('.wp-block-search__input').type('test'); cy.get('.wp-block-search__button').click(); - cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); + cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'test'); }); it('Can click outside when instant results are shown', () => { From 3da23cb8a40f531cb345513b1cef279b7a9aa214 Mon Sep 17 00:00:00 2001 From: Mohammed Razzaq Date: Thu, 18 Aug 2022 01:04:30 +0530 Subject: [PATCH 06/22] show the same modal after reload --- .../features/instant-results.spec.js | 19 ++++++++++++++++--- 1 file changed, 16 insertions(+), 3 deletions(-) diff --git a/tests/cypress/integration/features/instant-results.spec.js b/tests/cypress/integration/features/instant-results.spec.js index eb6a63d961..ce33140986 100644 --- a/tests/cypress/integration/features/instant-results.spec.js +++ b/tests/cypress/integration/features/instant-results.spec.js @@ -13,6 +13,7 @@ describe('Instant Results Feature', () => { cy.get('.edit-widgets-header__actions .components-button.is-primary').click(); cy.get('body').should('contain.text', 'Widgets saved.'); } + before(() => { cy.wpCli('eval "echo ElasticPress\\Utils\\get_host();"').then((epHost) => { // Nothing needs to be done if EP.io. @@ -89,9 +90,21 @@ describe('Instant Results Feature', () => { cy.maybeEnableFeature('instant-results'); cy.visit('/'); - cy.get('.wp-block-search__input').type('test'); + cy.get('.wp-block-search__input').type('blog'); + cy.get('.wp-block-search__button').click(); + cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); + }); + + it('Can show the modal in the same state after a reload', () => { + cy.login(); + cy.maybeEnableFeature('instant-results'); + + cy.visit('/'); + cy.get('.wp-block-search__input').type('blog'); cy.get('.wp-block-search__button').click(); - cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'test'); + cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); + cy.reload(); + cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); }); it('Can click outside when instant results are shown', () => { @@ -99,7 +112,7 @@ describe('Instant Results Feature', () => { cy.maybeEnableFeature('instant-results'); cy.visit('/'); - cy.get('.wp-block-search__input').type('test'); + cy.get('.wp-block-search__input').type('blog'); cy.get('.wp-block-search__button').click(); cy.get('.ep-search-modal').should('be.visible'); From c62f87e14349af73a9998270063a43265af5b93b Mon Sep 17 00:00:00 2001 From: Mohammed Razzaq Date: Thu, 18 Aug 2022 15:39:10 +0530 Subject: [PATCH 07/22] add delay to test the results --- .../features/instant-results.spec.js | 19 +++++++++++++++---- 1 file changed, 15 insertions(+), 4 deletions(-) diff --git a/tests/cypress/integration/features/instant-results.spec.js b/tests/cypress/integration/features/instant-results.spec.js index ce33140986..34ec4c3d36 100644 --- a/tests/cypress/integration/features/instant-results.spec.js +++ b/tests/cypress/integration/features/instant-results.spec.js @@ -91,8 +91,11 @@ describe('Instant Results Feature', () => { cy.visit('/'); cy.get('.wp-block-search__input').type('blog'); - cy.get('.wp-block-search__button').click(); - cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); + cy.get('.wp-block-search__button') + .click() + .then(() => { + cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); + }); }); it('Can show the modal in the same state after a reload', () => { @@ -102,9 +105,17 @@ describe('Instant Results Feature', () => { cy.visit('/'); cy.get('.wp-block-search__input').type('blog'); cy.get('.wp-block-search__button').click(); - cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); + cy.get('.wp-block-search__button') + .click() + .then(() => { + cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); + }); cy.reload(); - cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); + cy.get('.wp-block-search__button') + .click() + .then(() => { + cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); + }); }); it('Can click outside when instant results are shown', () => { From ff12865ea4405f5519b672eb30747dc0164bbbfa Mon Sep 17 00:00:00 2001 From: Mohammed Razzaq Date: Fri, 19 Aug 2022 15:35:52 +0530 Subject: [PATCH 08/22] Add more tests for Instant results --- .../features/instant-results.spec.js | 72 ++++++++++++++++++- 1 file changed, 71 insertions(+), 1 deletion(-) diff --git a/tests/cypress/integration/features/instant-results.spec.js b/tests/cypress/integration/features/instant-results.spec.js index 34ec4c3d36..6fa58ffd14 100644 --- a/tests/cypress/integration/features/instant-results.spec.js +++ b/tests/cypress/integration/features/instant-results.spec.js @@ -98,24 +98,94 @@ describe('Instant Results Feature', () => { }); }); + it('Can display the number of results', () => { + cy.login(); + cy.maybeEnableFeature('instant-results'); + + cy.visit('/'); + cy.get('.wp-block-search__input').type('blog'); + cy.get('.wp-block-search__button') + .click() + .then(() => { + cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); + cy.get('.ep-search-results__title').contains(/\d+/); + }); + }); + it('Can show the modal in the same state after a reload', () => { cy.login(); cy.maybeEnableFeature('instant-results'); cy.visit('/'); cy.get('.wp-block-search__input').type('blog'); - cy.get('.wp-block-search__button').click(); cy.get('.wp-block-search__button') .click() .then(() => { cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); }); cy.reload(); + cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); + }); + + it('Can update the results after changing the search term', () => { + cy.login(); + cy.maybeEnableFeature('instant-results'); + + cy.visit('/'); + cy.get('.wp-block-search__input').type('blog'); + cy.get('.wp-block-search__button') + .click() + .then(() => { + cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); + }); + cy.get('#ep-instant-results .ep-search-input') + .clearThenType('test') + .then(() => { + cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'test'); + }); + }); + + it('Can update the URL after changing the filters', () => { + cy.login(); + cy.maybeEnableFeature('instant-results'); + + cy.visit('/'); + cy.get('.wp-block-search__input').type('blog'); cy.get('.wp-block-search__button') .click() .then(() => { cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); }); + cy.get('ep-search-sidebar #ep-search-post-type-page') + .click() + .then(() => { + cy.url().should('include', 'ep-post_type=page'); + }); + }); + + it('Can show post type label alongside taxonomies', () => { + cy.login(); + cy.maybeEnableFeature('instant-results'); + cy.visitAdminPage('admin.php?page=elasticpress'); + cy.get('.ep-feature-instant-results .settings-button').click(); + cy.get('.ep-feature-instant-results .components-form-token-field__input') + .type('category') + .first() + .click() + .then((input) => { + input.type('category').first().click(); + }); + cy.get('.ep-feature-instant-results .button-primary').click(); + + cy.visit('/'); + cy.get('.wp-block-search__input').type('test'); + cy.get('.wp-block-search__button') + .click() + .then(() => { + cy.get('.ep-search-modal ep-search-sidebar') + .last() + .should('contain.text', 'Category (Products)'); + }); }); it('Can click outside when instant results are shown', () => { From def00fc49ab277f263492ecc6f79dbb1ef970190 Mon Sep 17 00:00:00 2001 From: Mohammed Razzaq Date: Tue, 23 Aug 2022 01:57:50 +0530 Subject: [PATCH 09/22] Change the filter --- .../features/instant-results.spec.js | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/tests/cypress/integration/features/instant-results.spec.js b/tests/cypress/integration/features/instant-results.spec.js index 6fa58ffd14..377610a942 100644 --- a/tests/cypress/integration/features/instant-results.spec.js +++ b/tests/cypress/integration/features/instant-results.spec.js @@ -150,16 +150,16 @@ describe('Instant Results Feature', () => { cy.maybeEnableFeature('instant-results'); cy.visit('/'); - cy.get('.wp-block-search__input').type('blog'); + cy.get('.wp-block-search__input').type('test'); cy.get('.wp-block-search__button') .click() .then(() => { - cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); + cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'test'); }); - cy.get('ep-search-sidebar #ep-search-post-type-page') + cy.get('ep-search-sidebar #ep-search-post-type-post') .click() .then(() => { - cy.url().should('include', 'ep-post_type=page'); + cy.url().should('include', 'ep-post_type=post'); }); }); @@ -168,14 +168,17 @@ describe('Instant Results Feature', () => { cy.maybeEnableFeature('instant-results'); cy.visitAdminPage('admin.php?page=elasticpress'); cy.get('.ep-feature-instant-results .settings-button').click(); + cy.get('.ep-feature-instant-results .components-form-token-field__input') + .type('category') + .first() + .click(); cy.get('.ep-feature-instant-results .components-form-token-field__input') .type('category') .first() .click() - .then((input) => { - input.type('category').first().click(); + .then(() => { + cy.get('.ep-feature-instant-results .button-primary').click(); }); - cy.get('.ep-feature-instant-results .button-primary').click(); cy.visit('/'); cy.get('.wp-block-search__input').type('test'); From 88cc2cda7c8193b84c8f1102a1957ee6ada875e4 Mon Sep 17 00:00:00 2001 From: Mohammed Razzaq Date: Tue, 23 Aug 2022 02:42:51 +0530 Subject: [PATCH 10/22] Proper class names --- tests/cypress/integration/features/instant-results.spec.js | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/cypress/integration/features/instant-results.spec.js b/tests/cypress/integration/features/instant-results.spec.js index 377610a942..f521341211 100644 --- a/tests/cypress/integration/features/instant-results.spec.js +++ b/tests/cypress/integration/features/instant-results.spec.js @@ -156,7 +156,7 @@ describe('Instant Results Feature', () => { .then(() => { cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'test'); }); - cy.get('ep-search-sidebar #ep-search-post-type-post') + cy.get('.ep-search-sidebar #ep-search-post-type-post') .click() .then(() => { cy.url().should('include', 'ep-post_type=post'); @@ -185,7 +185,7 @@ describe('Instant Results Feature', () => { cy.get('.wp-block-search__button') .click() .then(() => { - cy.get('.ep-search-modal ep-search-sidebar') + cy.get('.ep-search-modal .ep-search-sidebar') .last() .should('contain.text', 'Category (Products)'); }); From 92cb69c3698bb595f2a05b9f97be28518ae2e119 Mon Sep 17 00:00:00 2001 From: Mohammed Razzaq Date: Tue, 23 Aug 2022 03:14:22 +0530 Subject: [PATCH 11/22] Search for a category --- .../cypress/integration/features/instant-results.spec.js | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/tests/cypress/integration/features/instant-results.spec.js b/tests/cypress/integration/features/instant-results.spec.js index f521341211..b72b127165 100644 --- a/tests/cypress/integration/features/instant-results.spec.js +++ b/tests/cypress/integration/features/instant-results.spec.js @@ -181,13 +181,14 @@ describe('Instant Results Feature', () => { }); cy.visit('/'); - cy.get('.wp-block-search__input').type('test'); + cy.get('.wp-block-search__input').type('aciform'); cy.get('.wp-block-search__button') .click() .then(() => { - cy.get('.ep-search-modal .ep-search-sidebar') - .last() - .should('contain.text', 'Category (Products)'); + cy.get('.ep-search-modal .ep-search-sidebar').should( + 'contain.text', + 'Category (Posts)', + ); }); }); From affd195d1563c8615bf55a66617e9dedc22a0da2 Mon Sep 17 00:00:00 2001 From: Mohammed Razzaq Date: Tue, 23 Aug 2022 03:50:59 +0530 Subject: [PATCH 12/22] Search for a post with category --- tests/cypress/integration/features/instant-results.spec.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cypress/integration/features/instant-results.spec.js b/tests/cypress/integration/features/instant-results.spec.js index b72b127165..6bc6682b41 100644 --- a/tests/cypress/integration/features/instant-results.spec.js +++ b/tests/cypress/integration/features/instant-results.spec.js @@ -181,7 +181,7 @@ describe('Instant Results Feature', () => { }); cy.visit('/'); - cy.get('.wp-block-search__input').type('aciform'); + cy.get('.wp-block-search__input').type('Keyboard navigation'); cy.get('.wp-block-search__button') .click() .then(() => { From 23edea835a3e59750fc81835e0f40f6b118b4f81 Mon Sep 17 00:00:00 2001 From: Mohammed Razzaq Date: Tue, 23 Aug 2022 04:28:53 +0530 Subject: [PATCH 13/22] Remove the taxonomy label test for now --- .../features/instant-results.spec.js | 29 ------------------- 1 file changed, 29 deletions(-) diff --git a/tests/cypress/integration/features/instant-results.spec.js b/tests/cypress/integration/features/instant-results.spec.js index 6bc6682b41..5769fa81d4 100644 --- a/tests/cypress/integration/features/instant-results.spec.js +++ b/tests/cypress/integration/features/instant-results.spec.js @@ -163,35 +163,6 @@ describe('Instant Results Feature', () => { }); }); - it('Can show post type label alongside taxonomies', () => { - cy.login(); - cy.maybeEnableFeature('instant-results'); - cy.visitAdminPage('admin.php?page=elasticpress'); - cy.get('.ep-feature-instant-results .settings-button').click(); - cy.get('.ep-feature-instant-results .components-form-token-field__input') - .type('category') - .first() - .click(); - cy.get('.ep-feature-instant-results .components-form-token-field__input') - .type('category') - .first() - .click() - .then(() => { - cy.get('.ep-feature-instant-results .button-primary').click(); - }); - - cy.visit('/'); - cy.get('.wp-block-search__input').type('Keyboard navigation'); - cy.get('.wp-block-search__button') - .click() - .then(() => { - cy.get('.ep-search-modal .ep-search-sidebar').should( - 'contain.text', - 'Category (Posts)', - ); - }); - }); - it('Can click outside when instant results are shown', () => { cy.login(); cy.maybeEnableFeature('instant-results'); From 49dff57b13f5d69603d4b7a9194b8ed07ffbc2fb Mon Sep 17 00:00:00 2001 From: Mohammed Razzaq Date: Thu, 25 Aug 2022 16:48:58 +0530 Subject: [PATCH 14/22] Merge small tests and improve code --- .../features/instant-results.spec.js | 115 ++++++------------ 1 file changed, 40 insertions(+), 75 deletions(-) diff --git a/tests/cypress/integration/features/instant-results.spec.js b/tests/cypress/integration/features/instant-results.spec.js index 5769fa81d4..79ecb43a70 100644 --- a/tests/cypress/integration/features/instant-results.spec.js +++ b/tests/cypress/integration/features/instant-results.spec.js @@ -1,43 +1,44 @@ describe('Instant Results Feature', () => { /** - * Create a Search widget. + * Check if it's Elasticpress.io. */ - function createSearchWidget() { - cy.openWidgetsPage(); - - cy.get('.edit-widgets-header-toolbar__inserter-toggle').click(); - cy.get('.block-editor-inserter__panel-content [class*="search/default"]').click({ - force: true, - }); - - cy.get('.edit-widgets-header__actions .components-button.is-primary').click(); - cy.get('body').should('contain.text', 'Widgets saved.'); - } - - before(() => { + function isEpIo() { cy.wpCli('eval "echo ElasticPress\\Utils\\get_host();"').then((epHost) => { // Nothing needs to be done if EP.io. if (epHost.stdout.match(/elasticpress\.io/)) { - return; + return true; } + return false; + }); + } + + before(() => { + if (!isEpIo()) { cy.activatePlugin('elasticpress-proxy', 'dashboard'); + } + // Create a sample post and index + cy.publishPost({ + title: 'Blog post', + content: 'This is a sample Blog post.', + }); + cy.publishPost({ + title: 'Test Post', + content: 'This is a sample test post.', }); - // Add search widget that will be used for the tests. - createSearchWidget(); + cy.wpCli('elasticpress index --setup --yes'); }); after(() => { cy.deactivatePlugin('elasticpress-proxy', 'dashboard'); }); - it("Can't activate the feature If not in ElasticPress.io nor using a custom PHP proxy", () => { + /** + * Test that the feature cannot be activted when not in ElasticPress.io nor using a custom PHP proxy. + * Also, it can show a warning when using a custom PHP proxy + */ + it("Can't activate the feature If not in ElasticPress.io nor using a custom PHP proxy and can see a warning if using cusotom proxy", () => { cy.login(); - - cy.wpCli('eval "echo ElasticPress\\Utils\\get_host();"').then((epHost) => { - // Nothing needs to be done if EP.io. - if (epHost.stdout.match(/elasticpress\.io/)) { - return; - } + if (!isEpIo()) { cy.deactivatePlugin('elasticpress-proxy', 'dashboard'); cy.visitAdminPage('admin.php?page=elasticpress'); cy.get('.ep-feature-instant-results .settings-button').click(); @@ -46,17 +47,8 @@ describe('Instant Results Feature', () => { 'To use this feature you need to be an ElasticPress.io customer or implement a custom proxy', ); cy.get('.ep-feature-instant-results .input-wrap').should('have.class', 'disabled'); + // Can see the warning if using custom proxy cy.activatePlugin('elasticpress-proxy', 'dashboard'); - }); - }); - - it('Can see a warning if using cusotom proxy', () => { - cy.login(); - cy.wpCli('eval "echo ElasticPress\\Utils\\get_host();"').then((epHost) => { - // Nothing needs to be done if EP.io. - if (epHost.stdout.match(/elasticpress\.io/)) { - return; - } cy.visitAdminPage('admin.php?page=elasticpress'); cy.get('.ep-feature-instant-results .settings-button').click(); cy.get('.requirements-status-notice').should( @@ -64,9 +56,12 @@ describe('Instant Results Feature', () => { 'You are using a custom proxy. Make sure you implement all security measures needed', ); cy.get('.ep-feature-instant-results .input-wrap').should('not.have.class', 'disabled'); - }); + } }); + /** + * Test that the feature can be activted and it can sync automatically. + */ it('Can activate the feature and sync automatically', () => { cy.login(); @@ -85,20 +80,13 @@ describe('Instant Results Feature', () => { cy.wpCli('elasticpress list-features').its('stdout').should('contain', 'instant-results'); }); - it('Can see instant results list', () => { - cy.login(); - cy.maybeEnableFeature('instant-results'); - - cy.visit('/'); - cy.get('.wp-block-search__input').type('blog'); - cy.get('.wp-block-search__button') - .click() - .then(() => { - cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); - }); - }); - - it('Can display the number of results', () => { + /** + * Test that the instant results list is visible + * It can display the number of test results + * It can show the modal in the same state after a reload + * Can change the URL when search term is changed + */ + it('Can see instant results list, number of results, modal in the same state after reload, and updated result after changing the search term', () => { cy.login(); cy.maybeEnableFeature('instant-results'); @@ -108,36 +96,13 @@ describe('Instant Results Feature', () => { .click() .then(() => { cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); + // Show the number of results cy.get('.ep-search-results__title').contains(/\d+/); }); - }); - - it('Can show the modal in the same state after a reload', () => { - cy.login(); - cy.maybeEnableFeature('instant-results'); - - cy.visit('/'); - cy.get('.wp-block-search__input').type('blog'); - cy.get('.wp-block-search__button') - .click() - .then(() => { - cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); - }); + // Show the modal in the same state after a reload cy.reload(); cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); - }); - - it('Can update the results after changing the search term', () => { - cy.login(); - cy.maybeEnableFeature('instant-results'); - - cy.visit('/'); - cy.get('.wp-block-search__input').type('blog'); - cy.get('.wp-block-search__button') - .click() - .then(() => { - cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); - }); + // Update the results when search term is changed cy.get('#ep-instant-results .ep-search-input') .clearThenType('test') .then(() => { From fc68cf5102e28c596236aa3c077c915d93b492fb Mon Sep 17 00:00:00 2001 From: Mohammed Razzaq Date: Thu, 25 Aug 2022 17:21:36 +0530 Subject: [PATCH 15/22] Add search widget --- .../features/instant-results.spec.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tests/cypress/integration/features/instant-results.spec.js b/tests/cypress/integration/features/instant-results.spec.js index 79ecb43a70..0031eb23ac 100644 --- a/tests/cypress/integration/features/instant-results.spec.js +++ b/tests/cypress/integration/features/instant-results.spec.js @@ -1,4 +1,19 @@ describe('Instant Results Feature', () => { + /** + * Create a Search widget. + */ + function createSearchWidget() { + cy.openWidgetsPage(); + + cy.get('.edit-widgets-header-toolbar__inserter-toggle').click(); + cy.get('.block-editor-inserter__panel-content [class*="search/default"]').click({ + force: true, + }); + + cy.get('.edit-widgets-header__actions .components-button.is-primary').click(); + cy.get('body').should('contain.text', 'Widgets saved.'); + } + /** * Check if it's Elasticpress.io. */ @@ -26,6 +41,8 @@ describe('Instant Results Feature', () => { content: 'This is a sample test post.', }); cy.wpCli('elasticpress index --setup --yes'); + // Add search widget that will be used for the tests. + createSearchWidget(); }); after(() => { From 227558d48935bb6e6274942b0566111b81bd7c22 Mon Sep 17 00:00:00 2001 From: Mohammed Razzaq Date: Thu, 25 Aug 2022 18:08:23 +0530 Subject: [PATCH 16/22] Should be able to enable the feature when in ep.io --- tests/cypress/integration/features/instant-results.spec.js | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/cypress/integration/features/instant-results.spec.js b/tests/cypress/integration/features/instant-results.spec.js index 0031eb23ac..7f0b930031 100644 --- a/tests/cypress/integration/features/instant-results.spec.js +++ b/tests/cypress/integration/features/instant-results.spec.js @@ -73,6 +73,8 @@ describe('Instant Results Feature', () => { 'You are using a custom proxy. Make sure you implement all security measures needed', ); cy.get('.ep-feature-instant-results .input-wrap').should('not.have.class', 'disabled'); + } else { + cy.get('.ep-feature-instant-results .input-wrap').should('not.have.class', 'disabled'); } }); From bb47c93f502ca5c9e3db5e1eba1c66907d6c45af Mon Sep 17 00:00:00 2001 From: Mohammed Razzaq Date: Fri, 26 Aug 2022 02:48:41 +0530 Subject: [PATCH 17/22] Add wrap for the result --- .../features/instant-results.spec.js | 44 +++++++++---------- 1 file changed, 20 insertions(+), 24 deletions(-) diff --git a/tests/cypress/integration/features/instant-results.spec.js b/tests/cypress/integration/features/instant-results.spec.js index 7f0b930031..82f6a7dca0 100644 --- a/tests/cypress/integration/features/instant-results.spec.js +++ b/tests/cypress/integration/features/instant-results.spec.js @@ -20,10 +20,7 @@ describe('Instant Results Feature', () => { function isEpIo() { cy.wpCli('eval "echo ElasticPress\\Utils\\get_host();"').then((epHost) => { // Nothing needs to be done if EP.io. - if (epHost.stdout.match(/elasticpress\.io/)) { - return true; - } - return false; + cy.wrap(epHost.stdout.match(/elasticpress\.io/)); }); } @@ -55,27 +52,26 @@ describe('Instant Results Feature', () => { */ it("Can't activate the feature If not in ElasticPress.io nor using a custom PHP proxy and can see a warning if using cusotom proxy", () => { cy.login(); - if (!isEpIo()) { - cy.deactivatePlugin('elasticpress-proxy', 'dashboard'); - cy.visitAdminPage('admin.php?page=elasticpress'); - cy.get('.ep-feature-instant-results .settings-button').click(); - cy.get('.requirements-status-notice').should( - 'contain.text', - 'To use this feature you need to be an ElasticPress.io customer or implement a custom proxy', - ); - cy.get('.ep-feature-instant-results .input-wrap').should('have.class', 'disabled'); - // Can see the warning if using custom proxy - cy.activatePlugin('elasticpress-proxy', 'dashboard'); - cy.visitAdminPage('admin.php?page=elasticpress'); - cy.get('.ep-feature-instant-results .settings-button').click(); - cy.get('.requirements-status-notice').should( - 'contain.text', - 'You are using a custom proxy. Make sure you implement all security measures needed', - ); - cy.get('.ep-feature-instant-results .input-wrap').should('not.have.class', 'disabled'); - } else { - cy.get('.ep-feature-instant-results .input-wrap').should('not.have.class', 'disabled'); + if (isEpIo()) { + return; } + cy.deactivatePlugin('elasticpress-proxy', 'dashboard'); + cy.visitAdminPage('admin.php?page=elasticpress'); + cy.get('.ep-feature-instant-results .settings-button').click(); + cy.get('.requirements-status-notice').should( + 'contain.text', + 'To use this feature you need to be an ElasticPress.io customer or implement a custom proxy', + ); + cy.get('.ep-feature-instant-results .input-wrap').should('have.class', 'disabled'); + // Can see the warning if using custom proxy + cy.activatePlugin('elasticpress-proxy', 'dashboard'); + cy.visitAdminPage('admin.php?page=elasticpress'); + cy.get('.ep-feature-instant-results .settings-button').click(); + cy.get('.requirements-status-notice').should( + 'contain.text', + 'You are using a custom proxy. Make sure you implement all security measures needed', + ); + cy.get('.ep-feature-instant-results .input-wrap').should('not.have.class', 'disabled'); }); /** From a1f7a274da002b2341bac187a6b2c6d4a85b7e8c Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Fri, 16 Sep 2022 12:22:48 -0300 Subject: [PATCH 18/22] Instant Results e2e tests refactor --- .../features/instant-results.spec.js | 127 ++++++++---------- tests/cypress/support/global-hooks.js | 5 + 2 files changed, 61 insertions(+), 71 deletions(-) diff --git a/tests/cypress/integration/features/instant-results.spec.js b/tests/cypress/integration/features/instant-results.spec.js index 82f6a7dca0..bcbd1a29e5 100644 --- a/tests/cypress/integration/features/instant-results.spec.js +++ b/tests/cypress/integration/features/instant-results.spec.js @@ -1,33 +1,30 @@ +/* global isEpIo */ + describe('Instant Results Feature', () => { /** * Create a Search widget. + * + * As tests for facets will remove all widgets, we recreate it here. */ function createSearchWidget() { cy.openWidgetsPage(); - - cy.get('.edit-widgets-header-toolbar__inserter-toggle').click(); - cy.get('.block-editor-inserter__panel-content [class*="search/default"]').click({ - force: true, - }); - - cy.get('.edit-widgets-header__actions .components-button.is-primary').click(); - cy.get('body').should('contain.text', 'Widgets saved.'); + cy.openBlockInserter(); + cy.getBlocksList().should('contain.text', 'Search'); // Checking if it exists give JS time to process the full list. + cy.insertBlock('Search'); + cy.intercept('/wp-json/wp/v2/sidebars/*').as('sidebarsRest'); + cy.get('.edit-widgets-header__actions button').contains('Update').click(); + cy.wait('@sidebarsRest'); } - /** - * Check if it's Elasticpress.io. - */ - function isEpIo() { - cy.wpCli('eval "echo ElasticPress\\Utils\\get_host();"').then((epHost) => { - // Nothing needs to be done if EP.io. - cy.wrap(epHost.stdout.match(/elasticpress\.io/)); - }); + function maybeEnableProxy() { + if (!isEpIo) { + cy.activatePlugin('elasticpress-proxy'); + } } before(() => { - if (!isEpIo()) { - cy.activatePlugin('elasticpress-proxy', 'dashboard'); - } + createSearchWidget(); + // Create a sample post and index cy.publishPost({ title: 'Blog post', @@ -38,23 +35,21 @@ describe('Instant Results Feature', () => { content: 'This is a sample test post.', }); cy.wpCli('elasticpress index --setup --yes'); - // Add search widget that will be used for the tests. - createSearchWidget(); }); after(() => { - cy.deactivatePlugin('elasticpress-proxy', 'dashboard'); + cy.deactivatePlugin('elasticpress-proxy'); }); /** - * Test that the feature cannot be activted when not in ElasticPress.io nor using a custom PHP proxy. - * Also, it can show a warning when using a custom PHP proxy + * Test that the feature cannot be activated when not in ElasticPress.io nor using a custom PHP proxy. */ - it("Can't activate the feature If not in ElasticPress.io nor using a custom PHP proxy and can see a warning if using cusotom proxy", () => { - cy.login(); - if (isEpIo()) { + it("Can't activate the feature if not in ElasticPress.io nor using a custom PHP proxy", () => { + if (isEpIo) { return; } + + cy.login(); cy.deactivatePlugin('elasticpress-proxy', 'dashboard'); cy.visitAdminPage('admin.php?page=elasticpress'); cy.get('.ep-feature-instant-results .settings-button').click(); @@ -63,25 +58,26 @@ describe('Instant Results Feature', () => { 'To use this feature you need to be an ElasticPress.io customer or implement a custom proxy', ); cy.get('.ep-feature-instant-results .input-wrap').should('have.class', 'disabled'); - // Can see the warning if using custom proxy - cy.activatePlugin('elasticpress-proxy', 'dashboard'); - cy.visitAdminPage('admin.php?page=elasticpress'); - cy.get('.ep-feature-instant-results .settings-button').click(); - cy.get('.requirements-status-notice').should( - 'contain.text', - 'You are using a custom proxy. Make sure you implement all security measures needed', - ); - cy.get('.ep-feature-instant-results .input-wrap').should('not.have.class', 'disabled'); }); /** - * Test that the feature can be activted and it can sync automatically. + * Test that the feature can be activated and it can sync automatically. + * Also, it can show a warning when using a custom PHP proxy */ it('Can activate the feature and sync automatically', () => { cy.login(); + // Can see the warning if using custom proxy + maybeEnableProxy(); cy.visitAdminPage('admin.php?page=elasticpress'); cy.get('.ep-feature-instant-results .settings-button').click(); + + cy.get('.ep-feature-instant-results .input-wrap').should('not.have.class', 'disabled'); + cy.get('.requirements-status-notice').should( + isEpIo ? 'not.contain.text' : 'contain.text', + 'You are using a custom proxy. Make sure you implement all security measures needed', + ); + cy.get('.ep-feature-instant-results [name="settings[active]"][value="1"]').click(); cy.get('.ep-feature-instant-results .button-primary').click(); cy.on('window:confirm', () => { @@ -101,56 +97,45 @@ describe('Instant Results Feature', () => { * It can show the modal in the same state after a reload * Can change the URL when search term is changed */ - it('Can see instant results list, number of results, modal in the same state after reload, and updated result after changing the search term', () => { + it('Can see instant results elements, URL changes, reload, and update after changing search term', () => { cy.login(); cy.maybeEnableFeature('instant-results'); + maybeEnableProxy(); + + cy.intercept('*search=blog*').as('apiRequest'); cy.visit('/'); - cy.get('.wp-block-search__input').type('blog'); - cy.get('.wp-block-search__button') + + cy.get('.wp-block-search').last().as('searchBlock'); + + cy.get('@searchBlock').find('.wp-block-search__input').type('blog'); + cy.get('@searchBlock').find('.wp-block-search__button').click(); + cy.get('.ep-search-modal').as('searchModal').should('be.visible'); // Should be visible immediatly + cy.url().should('include', 'search=blog'); + + cy.wait('@apiRequest'); + cy.get('@searchModal').should('contain.text', 'blog'); + // Show the number of results + cy.get('@searchModal').find('.ep-search-results__title').contains(/\d+/); + + cy.get('.ep-search-sidebar #ep-search-post-type-post') .click() .then(() => { - cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); - // Show the number of results - cy.get('.ep-search-results__title').contains(/\d+/); + cy.url().should('include', 'ep-post_type=post'); }); + // Show the modal in the same state after a reload cy.reload(); + cy.wait('@apiRequest'); cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); + // Update the results when search term is changed cy.get('#ep-instant-results .ep-search-input') .clearThenType('test') .then(() => { cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'test'); + cy.url().should('include', 'search=test'); }); - }); - - it('Can update the URL after changing the filters', () => { - cy.login(); - cy.maybeEnableFeature('instant-results'); - - cy.visit('/'); - cy.get('.wp-block-search__input').type('test'); - cy.get('.wp-block-search__button') - .click() - .then(() => { - cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'test'); - }); - cy.get('.ep-search-sidebar #ep-search-post-type-post') - .click() - .then(() => { - cy.url().should('include', 'ep-post_type=post'); - }); - }); - - it('Can click outside when instant results are shown', () => { - cy.login(); - cy.maybeEnableFeature('instant-results'); - - cy.visit('/'); - cy.get('.wp-block-search__input').type('blog'); - cy.get('.wp-block-search__button').click(); - cy.get('.ep-search-modal').should('be.visible'); cy.get('#wpadminbar li#wp-admin-bar-debug-bar').click(); cy.get('#querylist').should('be.visible'); diff --git a/tests/cypress/support/global-hooks.js b/tests/cypress/support/global-hooks.js index f52f467b95..905594380e 100644 --- a/tests/cypress/support/global-hooks.js +++ b/tests/cypress/support/global-hooks.js @@ -1,4 +1,5 @@ window.indexNames = null; +window.isEpIo = false; before(() => { cy.wpCliEval( @@ -24,6 +25,10 @@ before(() => { ).then((wpCliResponse) => { window.indexNames = JSON.parse(wpCliResponse.stdout); }); + + cy.wpCli('eval "echo (int) \\ElasticPress\\Utils\\is_epio();"').then((response) => { + window.isEpIo = response.stdout === 1; + }); }); afterEach(() => { From 7a5cb9c6658e7e48c09faea2ec9faec17be09245 Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Fri, 16 Sep 2022 13:40:35 -0300 Subject: [PATCH 19/22] Fix type comparison --- tests/cypress/support/global-hooks.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/cypress/support/global-hooks.js b/tests/cypress/support/global-hooks.js index 905594380e..33ba9426f9 100644 --- a/tests/cypress/support/global-hooks.js +++ b/tests/cypress/support/global-hooks.js @@ -27,7 +27,7 @@ before(() => { }); cy.wpCli('eval "echo (int) \\ElasticPress\\Utils\\is_epio();"').then((response) => { - window.isEpIo = response.stdout === 1; + window.isEpIo = response.stdout === '1'; }); }); From 85cacdbbe764b2c45f5a88493f69d596d1a96959 Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Fri, 16 Sep 2022 14:44:25 -0300 Subject: [PATCH 20/22] Prevent autosuggest from running on Instant Results search --- assets/js/autosuggest.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/assets/js/autosuggest.js b/assets/js/autosuggest.js index 463fcef3b1..067a6486c5 100644 --- a/assets/js/autosuggest.js +++ b/assets/js/autosuggest.js @@ -676,9 +676,10 @@ function init() { */ const prepareInputForAutosuggest = (input) => { /** - * Skip facet widget search fields. + * Skip facet widget search fields and instant results. */ - if (input.classList.contains('facet-search')) { + const ignoredClasses = ['facet-search', 'ep-search-input']; + if (ignoredClasses.some((className) => input.classList.contains(className))) { return; } From 487796e893bd43a60d2d83efa0d6b9fc8a602c3c Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Fri, 16 Sep 2022 14:44:51 -0300 Subject: [PATCH 21/22] Deactivate elasticpress-proxy by default + stop dbdump generation --- bin/setup-cypress-env.sh | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/bin/setup-cypress-env.sh b/bin/setup-cypress-env.sh index 600426cc60..7d056655ab 100755 --- a/bin/setup-cypress-env.sh +++ b/bin/setup-cypress-env.sh @@ -75,7 +75,7 @@ fi ./bin/wp-env-cli tests-wordpress "wp --allow-root import /var/www/html/wp-content/uploads/content-example.xml --authors=create" -./bin/wp-env-cli tests-wordpress "wp --allow-root plugin deactivate woocommerce" +./bin/wp-env-cli tests-wordpress "wp --allow-root plugin deactivate woocommerce elasticpress-proxy" ./bin/wp-env-cli tests-wordpress "wp --allow-root plugin activate debug-bar debug-bar-elasticpress wordpress-importer --network" @@ -87,7 +87,5 @@ fi ./bin/wp-env-cli tests-wordpress "wp --allow-root user meta update admin edit_post_per_page 5" # Generate a SQL file that can be imported later to make things faster -SQL_FILENAME=./bin/$(date +'%F-%H-%M').sql -./bin/wp-env-cli tests-wordpress "wp --allow-root db export -" > $SQL_FILENAME - -exit 0 +# SQL_FILENAME=./bin/$(date +'%F-%H-%M').sql +# npm --silent run env run tests-cli "wp db export -" > $SQL_FILENAME From a2c09069e4faa8a4a7fcd203f536103f9506511a Mon Sep 17 00:00:00 2001 From: Felipe Elia Date: Fri, 16 Sep 2022 14:45:35 -0300 Subject: [PATCH 22/22] Wait for request --- .../integration/features/instant-results.spec.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/tests/cypress/integration/features/instant-results.spec.js b/tests/cypress/integration/features/instant-results.spec.js index bcbd1a29e5..841e9b64c0 100644 --- a/tests/cypress/integration/features/instant-results.spec.js +++ b/tests/cypress/integration/features/instant-results.spec.js @@ -25,7 +25,7 @@ describe('Instant Results Feature', () => { before(() => { createSearchWidget(); - // Create a sample post and index + // Create some sample posts cy.publishPost({ title: 'Blog post', content: 'This is a sample Blog post.', @@ -34,7 +34,6 @@ describe('Instant Results Feature', () => { title: 'Test Post', content: 'This is a sample test post.', }); - cy.wpCli('elasticpress index --setup --yes'); }); after(() => { @@ -50,7 +49,7 @@ describe('Instant Results Feature', () => { } cy.login(); - cy.deactivatePlugin('elasticpress-proxy', 'dashboard'); + cy.deactivatePlugin('elasticpress-proxy'); cy.visitAdminPage('admin.php?page=elasticpress'); cy.get('.ep-feature-instant-results .settings-button').click(); cy.get('.requirements-status-notice').should( @@ -127,13 +126,15 @@ describe('Instant Results Feature', () => { // Show the modal in the same state after a reload cy.reload(); cy.wait('@apiRequest'); - cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'blog'); + cy.get('@searchModal').should('be.visible').should('contain.text', 'blog'); // Update the results when search term is changed - cy.get('#ep-instant-results .ep-search-input') + cy.get('@searchModal') + .find('.ep-search-input') .clearThenType('test') .then(() => { - cy.get('.ep-search-modal').should('be.visible').should('contain.text', 'test'); + cy.wait('@apiRequest'); + cy.get('@searchModal').should('be.visible').should('contain.text', 'test'); cy.url().should('include', 'search=test'); });