Skip to content

Commit

Permalink
Tests: Fix b0rked search e2e WooCommerce test (#4906)
Browse files Browse the repository at this point in the history
  • Loading branch information
rebeccahum authored Sep 28, 2023
1 parent 73d9dc1 commit d4acfcc
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 7 deletions.
8 changes: 4 additions & 4 deletions tests/search/e2e/integration/features/woocommerce.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -110,11 +110,11 @@ describe('WooCommerce Feature', { tags: '@slow' }, () => {
cy.get('.woocommerce-orders-table tbody tr').should('have.length', 1);

// VIP: Use Search Dev Tools instead of Debug Bar
// cy.searchDevToolsResponseOK('shop_order');
cy.searchDevToolsResponseOK('shop_order', 2);
cy.get('#vip-search-dev-tools-mount').click();
cy.get('h3.vip-h3').first().click();
cy.get('strong.vip-h4.wp_query').first().click();
cy.get('ol.wp_query.vip-collapse-ol').first().should('contain.text','orderby: "date"');
cy.get('h3.vip-h3').eq(2).click();
cy.get('strong.vip-h4.wp_query').eq(2).click();
cy.get('ol.wp_query.vip-collapse-ol').eq(2).should('contain.text','orderby: "date"');
cy.get('#vip-search-dev-tools-mount').click();

cy.logout();
Expand Down
7 changes: 4 additions & 3 deletions tests/search/e2e/support/commands.js
Original file line number Diff line number Diff line change
Expand Up @@ -461,11 +461,12 @@ Cypress.Commands.add('createUser', (userData) => {
});

// VIP: Check that Search Dev Tools returns a 200 status and a certain text in the response body
Cypress.Commands.add('searchDevToolsResponseOK', (bodyText) => {
// If there's more than one ES query, use the index to select the correct one
Cypress.Commands.add('searchDevToolsResponseOK', (bodyText, index = 0) => {
cy.get('#vip-search-dev-tools-mount').click();
cy.get('h3.vip-h3').first().should('contain.text','(200)');
cy.get('h3.vip-h3').eq( index ).should('contain.text','(200)');
if ( bodyText ) {
cy.get('.line-numbers').first().should('contain.text', bodyText);
cy.get('.line-numbers').eq( index ).should('contain.text', bodyText);
}
cy.get('#vip-search-dev-tools-mount').click();
});
Expand Down

0 comments on commit d4acfcc

Please sign in to comment.