From be8439660ecfca8c673be08630efbb32e826732a Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Mon, 10 Oct 2022 13:43:34 +0500 Subject: [PATCH 1/3] Fix intermittent tests fails --- tests/cypress/integration/features/woocommerce.spec.js | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/tests/cypress/integration/features/woocommerce.spec.js b/tests/cypress/integration/features/woocommerce.spec.js index 22713fcb0e..86ec82eafa 100644 --- a/tests/cypress/integration/features/woocommerce.spec.js +++ b/tests/cypress/integration/features/woocommerce.spec.js @@ -143,6 +143,14 @@ describe('WooCommerce Feature', () => { // ensure order is placed. cy.url().should('include', '/checkout/order-received'); + /** + * Give Elasticsearch some time to process the new posts. + * + * @todo instead of waiting for an arbitrary time, we should ensure the posts were processed OR retry the next block. + */ + // eslint-disable-next-line cypress/no-unnecessary-waiting + cy.wait(2000); + // ensure order is visible to user. cy.visit('my-account/orders'); cy.get('.woocommerce-orders-table tbody tr').should('have.length', 1); From b17d70f52910f81d07addced74ef8ec7525b458c Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Tue, 11 Oct 2022 13:28:03 +0500 Subject: [PATCH 2/3] Minor change --- tests/cypress/integration/features/woocommerce.spec.js | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/cypress/integration/features/woocommerce.spec.js b/tests/cypress/integration/features/woocommerce.spec.js index 86ec82eafa..64668e18f4 100644 --- a/tests/cypress/integration/features/woocommerce.spec.js +++ b/tests/cypress/integration/features/woocommerce.spec.js @@ -146,7 +146,6 @@ describe('WooCommerce Feature', () => { /** * Give Elasticsearch some time to process the new posts. * - * @todo instead of waiting for an arbitrary time, we should ensure the posts were processed OR retry the next block. */ // eslint-disable-next-line cypress/no-unnecessary-waiting cy.wait(2000); From ca2c87ff27b9786672cf66431cb2a34549ac7321 Mon Sep 17 00:00:00 2001 From: Burhan Nasir Date: Tue, 11 Oct 2022 16:43:58 +0500 Subject: [PATCH 3/3] Cherry-pick facet tests fix --- .../cypress/integration/features/facets.spec.js | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/tests/cypress/integration/features/facets.spec.js b/tests/cypress/integration/features/facets.spec.js index c72ed8cd98..04abf65df0 100644 --- a/tests/cypress/integration/features/facets.spec.js +++ b/tests/cypress/integration/features/facets.spec.js @@ -51,7 +51,13 @@ describe('Facets Feature', () => { cy.openBlockSettingsSidebar(); cy.get('.block-editor-block-inspector select').select('post_tag'); cy.get('.block-editor-block-inspector input[type="radio"][value="name"]').click(); + + // Make sure it waits for the correct request. + cy.intercept('/wp-json/elasticpress/v1/facets/block-preview*orderby=name&order=asc*').as( + 'blockPreview1', + ); cy.get('.block-editor-block-inspector input[type="radio"][value="asc"]').click(); + cy.wait('@blockPreview1'); /** * Verify the block has the expected output in the editor based on the @@ -321,7 +327,12 @@ describe('Facets Feature', () => { cy.get('.block-editor-block-inspector input[type="text"]').clearThenType( 'Search Meta 1', ); + + cy.intercept( + '/wp-json/elasticpress/v1/facets/meta/block-preview*facet=meta_field_1*', + ).as('blockPreview1'); cy.get('.block-editor-block-inspector select').select('meta_field_1'); + cy.wait('@blockPreview1'); /** * Verify that the blocks are inserted into the editor, and contain the @@ -345,7 +356,12 @@ describe('Facets Feature', () => { ); cy.get('.block-editor-block-inspector select').select('meta_field_2'); cy.get('.block-editor-block-inspector input[type="radio"][value="name"]').click(); + + cy.intercept( + '/wp-json/elasticpress/v1/facets/meta/block-preview*orderby=name&order=asc*', + ).as('blockPreview2'); cy.get('.block-editor-block-inspector input[type="radio"][value="asc"]').click(); + cy.wait('@blockPreview2'); /** * Verify the block has the expected output in the editor based on the