From bca10eafc161991e496f58e263f91c0ff8fe06e5 Mon Sep 17 00:00:00 2001 From: iRohitSingh <61353484+iRohitSingh@users.noreply.github.com> Date: Fri, 2 Aug 2024 21:35:50 +0530 Subject: [PATCH] Add Cypress test for search block sort on property (#6224) Co-authored-by: Nilesh Co-authored-by: Steve Piercy --- .../tests/core/blocks/blocks-search.js | 110 ++++++++++++++++++ packages/volto/news/6226.bugfix | 1 + 2 files changed, 111 insertions(+) create mode 100644 packages/volto/news/6226.bugfix diff --git a/packages/volto/cypress/tests/core/blocks/blocks-search.js b/packages/volto/cypress/tests/core/blocks/blocks-search.js index 3867349870..6e355829ef 100644 --- a/packages/volto/cypress/tests/core/blocks/blocks-search.js +++ b/packages/volto/cypress/tests/core/blocks/blocks-search.js @@ -558,4 +558,114 @@ describe('Search Block Tests', () => { cy.get('#toolbar-save > .icon').click(); cy.wait(500); }); + it('Search block - test on select 1 sort on in listing criteria sort on', () => { + cy.visit('/'); + cy.get('#toolbar-add > .icon').click(); + cy.get('#toolbar-add-document').click(); + cy.getSlateTitle().focus().click().type('My Search Page'); + + // Add Search listing block + cy.addNewBlock('search'); + + // Add search query criteria + cy.get('#default-query-0-query .react-select__value-container').click(); + cy.get('#default-query-0-query .react-select__option') + .contains('Type') + .click(); + + cy.get('#default-query-0-query .fields:first-of-type > .field').click(); + cy.get( + '#default-query-0-query .fields:first-of-type > .field .react-select__option', + ) + .contains('Page') + .click(); + cy.get( + '#select-listingblock-sort-on > .react-select__control > .react-select__value-container', + ).click(); + cy.findByText('Effective date').click(); + cy.get('.field-wrapper-showSortOn .wrapper .ui label').click(); + //save page + cy.get('#toolbar-save').click(); + + // then we are able to see title and value + cy.get('span.sorted-label').should('have.text', 'Sorted onEffective date'); + cy.get('span.sorted-label-value').should('have.text', 'Effective date'); + // Verify the presence of Ascending button + cy.get('button[title="Ascending"]').should('be.visible'); + // Verify the presence of Descending button + cy.get('button[title="Descending"]').should('be.visible'); + }); + it('Search block - test on only one sort on option below.', () => { + cy.visit('/'); + cy.get('#toolbar-add > .icon').click(); + cy.get('#toolbar-add-document').click(); + cy.getSlateTitle().focus().click().type('My Search Page'); + + // Add Search listing block + cy.addNewBlock('search'); + cy.get('.field-wrapper-showSortOn .wrapper .ui label').click(); + cy.get( + '#field-sortOnOptions > .react-select__control > .react-select__value-container ', + ).click(); + cy.findByText('Effective date').click(); + //save page + cy.get('#toolbar-save').click(); + // then we are able to see label and sort option + cy.get('.sort-label').should('have.text', 'Sort on'); + cy.get('#select-search-sort-on').click(); + cy.findByText('Effective date').click({ force: true }); + cy.get( + 'div#select-search-sort-on.search-react-select-container.css-2b097c-container', + ).contains('Effective date'); + // Verify the presence of Ascending button + cy.get('button[title="Ascending"]').should('be.visible'); + // Verify the presence of Descending button + cy.get('button[title="Descending"]').should('be.visible'); + }); + it('Search block - test on select both listing sort on and sort on options', () => { + cy.visit('/'); + cy.get('#toolbar-add > .icon').click(); + cy.get('#toolbar-add-document').click(); + cy.getSlateTitle().focus().click().type('My Search Page'); + + // Add Search listing block + cy.addNewBlock('search'); + // Add search query criteria + cy.get('#default-query-0-query .react-select__value-container').click(); + cy.get('#default-query-0-query .react-select__option') + .contains('Type') + .click(); + + cy.get('#default-query-0-query .fields:first-of-type > .field').click(); + cy.get( + '#default-query-0-query .fields:first-of-type > .field .react-select__option', + ) + .contains('Page') + .click(); + cy.get( + '#select-listingblock-sort-on > .react-select__control > .react-select__value-container', + ).click(); + cy.findByText('Order in folder').click(); + // Add one sort on options below + cy.get('.field-wrapper-showSortOn .wrapper .ui label').click(); + cy.get('#field-sortOnOptions').click(); + cy.findByText('Effective date').click(); + // save page + cy.get('#toolbar-save').click(); + // then we are able to see label and sort option + cy.get('.sort-label').should('have.text', 'Sort on'); + cy.get('#select-search-sort-on').click(); + cy.findByText('Effective date').click({ force: true }); + cy.get( + 'div#select-search-sort-on.search-react-select-container.css-2b097c-container', + ).contains('Effective date'); + cy.get('#select-search-sort-on').click(); + cy.get( + 'div#select-search-sort-on.search-react-select-container.css-2b097c-container', + ).contains('Order in folder'); + // Verify the presence of Ascending button + cy.get('button[title="Ascending"]').should('be.visible'); + // Verify the presence of Descending button + cy.get('button[title="Descending"]').should('be.visible'); + }); }); diff --git a/packages/volto/news/6226.bugfix b/packages/volto/news/6226.bugfix new file mode 100644 index 0000000000..a571bd1d1e --- /dev/null +++ b/packages/volto/news/6226.bugfix @@ -0,0 +1 @@ +Add Cypress test for search block sort on property. @iRohitSingh