Skip to content

Commit

Permalink
Merge pull request #3053 from 10up/fix-intermittent-tests-fails
Browse files Browse the repository at this point in the history
Fix Cypress intermittent tests fails
  • Loading branch information
felipeelia authored Oct 11, 2022
2 parents a10c114 + cc5e26b commit 2b7e1a4
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 0 deletions.
16 changes: 16 additions & 0 deletions tests/cypress/integration/features/facets.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down
7 changes: 7 additions & 0 deletions tests/cypress/integration/features/woocommerce.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -143,6 +143,13 @@ describe('WooCommerce Feature', () => {
// ensure order is placed.
cy.url().should('include', '/checkout/order-received');

/**
* Give Elasticsearch some time to process the new posts.
*
*/
// 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);
Expand Down

0 comments on commit 2b7e1a4

Please sign in to comment.