From eda2a74dd9d17c03227c62d555827db4c8a429e3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bal=C3=A1zs=20Re=C3=A9?= Date: Wed, 28 Jun 2023 16:49:46 +0200 Subject: [PATCH] Add more acceptance tests --- acceptance/cypress/tests/search-blocks.cy.js | 433 ++++++++++++++++++ .../cypress/tests/search-document.cy.js | 166 +++++++ acceptance/cypress/tests/search-file.cy.js | 117 +++++ acceptance/cypress/tests/search-ui.cy.js | 212 +++++++++ 4 files changed, 928 insertions(+) create mode 100644 acceptance/cypress/tests/search-blocks.cy.js create mode 100644 acceptance/cypress/tests/search-document.cy.js create mode 100644 acceptance/cypress/tests/search-file.cy.js create mode 100644 acceptance/cypress/tests/search-ui.cy.js diff --git a/acceptance/cypress/tests/search-blocks.cy.js b/acceptance/cypress/tests/search-blocks.cy.js new file mode 100644 index 0000000..cf35ab0 --- /dev/null +++ b/acceptance/cypress/tests/search-blocks.cy.js @@ -0,0 +1,433 @@ +context('Search Acceptance Tests (Blocks)', () => { + beforeEach(() => { + // Docker compose setup requires host: solr-acceptance + cy.setRegistry('collective.solr.host', 'solr-acceptance'); + cy.setRegistry('collective.solr.active', true); + cy.setRegistry('collective.solr.use_tika', true); + cy.reindexSolr(); + }); + afterEach(() => { + cy.clearSolr(); + }); + + // Scenario: As anonymous user I can find a term in a text block + // Given a public document with the title 'Colorless Green Ideas' + // and a text block with the term 'mytextblock' + // and an anonymous user + // When I search for 'mytextblock' + // Then the search returns '1' results + // and the search results should include 'Colorless Green Ideas' + it('Find search term in Text Block', function () { + // GIVEN: a public document with the title 'Colorless Green Ideas' + // and a text block with the term 'mytextblock' + cy.createContent({ + contentType: 'Document', + contentId: 'colorless-green-ideas', + contentTitle: 'Colorless Green Ideas', + path: '', + blocks: { + '7f6bc7e0-970e-4f28-b06e-a2b22631c6e2': { + '@type': 'slate', + plaintext: 'mytextblock', + value: [ + { + children: [ + { + text: 'mytextblock', + }, + ], + type: 'p', + }, + ], + }, + 'cc97c959-7fdb-41ca-8edb-78653b717945': { + '@type': 'title', + }, + }, + blocksLayout: { + items: [ + 'cc97c959-7fdb-41ca-8edb-78653b717945', + '7f6bc7e0-970e-4f28-b06e-a2b22631c6e2', + ], + }, + }); + // the setWorkflow function does not set the workflow but instead is passed a workflow transition + // that then changes the workflow + cy.request({ + method: 'POST', + url: `http://localhost:55001/plone/colorless-green-ideas/@workflow/publish`, + headers: { + Accept: 'application/json', + }, + auth: { + user: 'admin', + pass: 'secret', + }, + }); + // and an anonymous user + cy.autologout(); + + // WHEN: I search for 'Colorless Green Ideas' + cy.visit('http://localhost:3000/search'); + cy.get('.searchinput').type('mytextblock'); + cy.get('.search-input button').click(); + // THEN: the search returns '1' results + cy.get('.total-bar .results').contains('1'); + // and the search results should include 'Colorless Green Ideas' + cy.get('#content-core').contains('Colorless Green Ideas'); + }); + + it('FInd search term in text block with background color ', () => { + cy.createContent({ + contentType: 'Document', + contentId: 'colorless-green-ideas', + contentTitle: 'Colorless Green Ideas', + path: '', + blocks: { + '36e5d4d2-7ec5-4ae5-86d9-10585e94c087': { + '@type': 'textPillWithStyle', + bg_color: '#ddeeff', + plaintext: 'My block', + useFullBackgroundContainer: true, + value: [ + { + children: [ + { + text: 'My block', + }, + ], + type: 'p', + }, + ], + }, + '762366a1-e323-43cf-9447-99e60cbef21f': { + '@type': 'title', + }, + }, + blocksLayout: { + items: [ + '762366a1-e323-43cf-9447-99e60cbef21f', + '36e5d4d2-7ec5-4ae5-86d9-10585e94c087', + ], + }, + }); + // the setWorkflow function does not set the workflow but instead is passed a workflow transition + // that then changes the workflow + cy.request({ + method: 'POST', + url: `http://localhost:55001/plone/colorless-green-ideas/@workflow/publish`, + headers: { + Accept: 'application/json', + }, + auth: { + user: 'admin', + pass: 'secret', + }, + }); + // and an anonymous user + cy.autologout(); + // WHEN: I search for 'My text block with background color' + cy.visit('http://localhost:3000/search'); + cy.get('.searchinput').type('My block'); + cy.get('.search-input button').click(); + // THEN: the search returns '1' results + cy.get('.total-bar .results').contains('1'); + // and the search results should include 'Colorless Green Ideas' + cy.get('#content-core').contains('Colorless Green Ideas'); + }); + + it('FInd search term in introduction block ', () => { + cy.createContent({ + contentType: 'Document', + contentId: 'colorless-green-ideas', + contentTitle: 'Colorless Green Ideas', + path: '', + blocks: { + '0994b803-483f-4799-b868-1b9f62d4b8cc': { + '@type': 'introduction', + about: { + 0: { + children: [ + { + text: '', + }, + ], + type: 'p', + }, + value: [ + { + children: [ + { + text: 'Introduction Blocks Thisis me', + }, + ], + type: 'p', + }, + ], + }, + academic: '', + building: '', + email: '', + firstname: '', + heading: 'Introduction Block', + image: '', + institute: '', + mobile: '', + name: '', + phone: '', + positions: '', + room: '', + salutation: '', + topics: { + 0: { + children: [ + { + text: '', + }, + ], + type: 'p', + }, + value: [ + { + children: [ + { + text: 'Introduction Block Topics', + }, + ], + type: 'p', + }, + ], + }, + }, + '56da4220-d429-4409-b6a4-2ab10145ac5f': { + '@type': 'slate', + plaintext: '', + value: [ + { + children: [ + { + text: '', + }, + ], + type: 'p', + }, + ], + }, + 'de772e4a-cda4-4d0f-88f6-135a802f08e0': { + '@type': 'title', + }, + }, + blocksLayout: { + items: [ + 'de772e4a-cda4-4d0f-88f6-135a802f08e0', + '0994b803-483f-4799-b868-1b9f62d4b8cc', + '56da4220-d429-4409-b6a4-2ab10145ac5f', + ], + }, + }); + cy.request({ + method: 'POST', + url: `http://localhost:55001/plone/colorless-green-ideas/@workflow/publish`, + headers: { + Accept: 'application/json', + }, + auth: { + user: 'admin', + pass: 'secret', + }, + }); + // and an anonymous user + cy.autologout(); + // WHEN: I search for 'Introduction Block' + cy.visit('http://localhost:3000/search'); + cy.get('.searchinput').type('Introduction Block'); + cy.get('.search-input button').click(); + // THEN: the search returns '1' results + cy.get('.total-bar .results').contains('1'); + // and the search results should include 'Colorless Green Ideas' + cy.get('#content-core').contains('Colorless Green Ideas'); + + //also check if we can find the 'topics' and 'thisis me' fields which are part of the block + cy.visit('http://localhost:3000/search'); + cy.get('.searchinput').type('Introduction Block Topics'); + cy.get('.search-input button').click(); + // THEN: the search returns '1' results + cy.get('.total-bar .results').contains('1'); + // and the search results should include 'Colorless Green Ideas' + cy.get('#content-core').contains('Colorless Green Ideas'); + + cy.visit('http://localhost:3000/search'); + cy.get('.searchinput').type('Introduction Block Thisis me'); + cy.get('.search-input button').click(); + // THEN: the search returns '1' results + cy.get('.total-bar .results').contains('1'); + // and the search results should include 'Colorless Green Ideas' + cy.get('#content-core').contains('Colorless Green Ideas'); + }); + + it('FInd search term in table block ', () => { + cy.createContent({ + contentType: 'Document', + contentId: 'colorless-green-ideas', + contentTitle: 'Colorless Green Ideas', + path: '', + blocks: { + '67a31986-383d-49c4-9e17-e2977de122d2': { + '@type': 'slateTable', + table: { + basic: false, + celled: true, + compact: false, + fixed: true, + inverted: false, + rows: [ + { + cells: [ + { + key: '6llm2', + type: 'header', + value: [ + { + children: [ + { + text: 'texxt inn column 1 row 1', + }, + ], + type: 'p', + }, + ], + }, + { + key: '2qlt4', + type: 'header', + value: [ + { + children: [ + { + text: 'texxt inn column 2 row 1', + }, + ], + type: 'p', + }, + ], + }, + ], + key: '1h7ev', + }, + { + cells: [ + { + key: 'dgkm2', + type: 'data', + value: [ + { + children: [ + { + text: 'texxt inn column 1 row 2', + }, + ], + type: 'p', + }, + ], + }, + { + key: '329lm', + type: 'data', + value: [ + { + children: [ + { + text: 'texxt inn column 2 row 2', + }, + ], + type: 'p', + }, + ], + }, + ], + key: 'bbl8h', + }, + ], + striped: false, + }, + }, + '762366a1-e323-43cf-9447-99e60cbef21f': { + '@type': 'title', + }, + }, + blocksLayout: { + items: [ + '762366a1-e323-43cf-9447-99e60cbef21f', + '67a31986-383d-49c4-9e17-e2977de122d2', + ], + }, + }); + cy.request({ + method: 'POST', + url: `http://localhost:55001/plone/colorless-green-ideas/@workflow/publish`, + headers: { + Accept: 'application/json', + }, + auth: { + user: 'admin', + pass: 'secret', + }, + }); + // and an anonymous user + cy.autologout(); + // WHEN: I search for 'text in column 2 row 2' + cy.visit('http://localhost:3000/search'); + cy.get('.searchinput').type('texxt inn column 2 row 2'); + cy.get('.search-input button').click(); + // THEN: the search returns '1' results + cy.get('.total-bar .results').contains('1'); + // and the search results should include 'Colorless Green Ideas' + cy.get('#content-core').contains('Colorless Green Ideas'); + }); + + it('Find search term in headline block ', () => { + cy.createContent({ + contentType: 'Document', + contentId: 'colorless-green-ideas', + contentTitle: 'Colorless Green Ideas', + path: '', + blocks: { + '45ee8ea9-1573-46f4-9ad5-f220bfab60ae': { + '@type': 'headline', + bg_color: null, + title: 'Headline Block', + }, + '762366a1-e323-43cf-9447-99e60cbef21f': { + '@type': 'title', + }, + }, + blocksLayout: { + items: [ + '762366a1-e323-43cf-9447-99e60cbef21f', + '45ee8ea9-1573-46f4-9ad5-f220bfab60ae', + ], + }, + }); + cy.request({ + method: 'POST', + url: `http://localhost:55001/plone/colorless-green-ideas/@workflow/publish`, + headers: { + Accept: 'application/json', + }, + auth: { + user: 'admin', + pass: 'secret', + }, + }); + // and an anonymous user + cy.autologout(); + // WHEN: I search for 'Headline Block' + cy.visit('http://localhost:3000/search'); + cy.get('.searchinput').type('Headline Block'); + cy.get('.search-input button').click(); + // THEN: the search returns '1' results + cy.get('.total-bar .results').contains('1'); + // and the search results should include 'Colorless Green Ideas' + cy.get('#content-core').contains('Colorless Green Ideas'); + }); +}); diff --git a/acceptance/cypress/tests/search-document.cy.js b/acceptance/cypress/tests/search-document.cy.js new file mode 100644 index 0000000..7da7e11 --- /dev/null +++ b/acceptance/cypress/tests/search-document.cy.js @@ -0,0 +1,166 @@ +context('Search Acceptance Tests (Document)', () => { + beforeEach(() => { + // Docker compose setup requires host: solr-acceptance + cy.setRegistry('collective.solr.host', 'solr-acceptance'); + cy.setRegistry('collective.solr.active', true); + cy.setRegistry('collective.solr.use_tika', true); + cy.reindexSolr(); + }); + afterEach(() => { + cy.clearSolr(); + }); + + // ========================================================================= + // DOCUMENT TITLE TERM SEARCH + // ========================================================================= + // + // Scenario: As anonymous user I can search for a document title + // + // Given a public document with the title 'Colorless' + // and an anonymous user + // When I search for 'Colorless' + // Then the search returns '1' results + // and the search results should include 'Colorless' + // + it('Page Title Search', function () { + // GIVEN: a public document with the title 'Colorless' + cy.createContent({ + contentType: 'Document', + contentId: 'colorless', + contentTitle: 'Colorless', + path: '', + }); + // cy.setWorkflow({ + // path: '/colorless-green-ideas', + // workflow_state: 'published', + // }); + cy.request({ + method: 'POST', + url: `http://localhost:55001/plone/colorless/@workflow/publish`, + headers: { + Accept: 'application/json', + }, + auth: { + user: 'admin', + pass: 'secret', + }, + }); + // and an anonymous user + cy.autologout(); + + // WHEN: I search for 'Colorless' + cy.visit('http://localhost:3000/search'); + cy.get('.searchinput').type('Colorless'); + cy.get('.search-input button').click(); + + // THEN: the search returns '1' results + cy.get('.total-bar .results').contains('1'); + // and the search results should include 'Colorless' + cy.get('#content-core').contains('Colorless'); + }); + + // ========================================================================= + // DOCUMENT DESCRIPTION TERM SEARCH + // ========================================================================= + // + // Scenario: As anonymous user I can search for a document description + // + // Given a public document with the title 'Colorless Green Ideas' + // and the description 'Sleep Furiously' + // and an anonymous user + // When I search for 'Sleep Furiously' + // Then the search returns '1' results + // and the search results should include 'Colorless Green Ideas' + // + it('Description Term Search', function () { + // Given a public document with the title 'Colorless Green Ideas' + // and the description 'Sleep Furiously' + cy.createContent({ + contentType: 'Document', + contentId: 'colorless-green-ideas', + contentTitle: 'Colorless Green Ideas', + contentDescription: 'Sleep Furiously', + path: '', + }); + // cy.setWorkflow({ + // path: '/colorless-green-ideas', + // workflow_state: 'published', + // }); + cy.request({ + method: 'POST', + url: `http://localhost:55001/plone/colorless-green-ideas/@workflow/publish`, + headers: { + Accept: 'application/json', + }, + auth: { + user: 'admin', + pass: 'secret', + }, + }); + // and an anonymous user + cy.autologout(); + + // WHEN: I search for 'Sleep Furiously' + cy.visit('http://localhost:3000/search'); + cy.get('.searchinput').type('Sleep Furiously'); + cy.get('.search-input button').click(); + + // THEN: the search returns '1' results + cy.get('.total-bar .results').contains('1'); + // and the search results should include 'Colorless Green Ideas' + cy.get('#content-core').contains('Colorless Green Ideas'); + }); + + // ========================================================================= + // DOCUMENT TAGS SEARCH + // ========================================================================= + // + // Scenario: As anonymous user I can search for a document tag + // + // Given a public document with the title 'Colorless Green Ideas' + // and the tag 'Furiously' + // and an anonymous user + // When I search for 'Furiously' + // Then the search returns '1' results + // and the search results should include 'Colorless Green Ideas' + // + it('Page Tag Search', function () { + // Given a public document with the title 'Colorless Green Ideas' + // and the tag 'Furiously' + cy.createContent({ + contentType: 'Document', + contentId: 'colorless-green-ideas', + contentTitle: 'Colorless Green Ideas', + contentSubjects: ['Furiously'], + path: '', + }); + // cy.setWorkflow({ + // path: '/colorless-green-ideas', + // workflow_state: 'published', + // }); + cy.request({ + method: 'POST', + url: `http://localhost:55001/plone/colorless-green-ideas/@workflow/publish`, + headers: { + Accept: 'application/json', + }, + auth: { + user: 'admin', + pass: 'secret', + }, + }); + + // and an anonymous user + cy.autologout(); + + // WHEN: I search for 'Sleep Furiously' + cy.visit('http://localhost:3000/search'); + cy.get('.searchinput').type('Furiously'); + cy.get('.search-input button').click(); + + // THEN: the search returns '1' results + cy.get('.total-bar .results').contains('1'); + // and the search results should include 'Colorless Green Ideas' + cy.get('#content-core').contains('Colorless Green Ideas'); + }); +}); diff --git a/acceptance/cypress/tests/search-file.cy.js b/acceptance/cypress/tests/search-file.cy.js new file mode 100644 index 0000000..8af1954 --- /dev/null +++ b/acceptance/cypress/tests/search-file.cy.js @@ -0,0 +1,117 @@ +context('Search Acceptance Tests (File)', () => { + beforeEach(() => { + // Docker compose setup requires host: solr-acceptance + cy.setRegistry('collective.solr.host', 'solr-acceptance'); + cy.setRegistry('collective.solr.active', true); + cy.setRegistry('collective.solr.use_tika', true); + cy.reindexSolr(); + }); + afterEach(() => { + cy.clearSolr(); + }); + // ========================================================================= + // FILE TITLE TERM SEARCH + // ========================================================================= + // + // Scenario: As anonymous user I can search for a file title + // + // Given a public file with the title 'Colorless Green Ideas' + // and an anonymous user + // When I search for 'Colorless Green Ideas' + // Then the search returns '1' results + // and the search results should include 'Colorless Green Ideas' + // + it('File Title Search', function () { + // GIVEN: a public file with the title 'Colorless Green Ideas' + cy.createContent({ + contentType: 'File', + contentId: 'colorless-green-ideas', + contentTitle: 'Colorless Green Ideas', + path: '', + }); + // and an anonymous user + cy.autologout(); + + // WHEN: I search for 'Colorless' + cy.visit('http://localhost:3000/search'); + cy.get('.searchinput').type('Colorless'); + cy.get('.search-input button').click(); + + // THEN: the search returns '1' results + cy.get('.total-bar .results').contains('1'); + // and the search results should include 'Colorless Green Ideas' + cy.get('#content-core').contains('Colorless Green Ideas'); + }); + + // ========================================================================= + // FILE DESCRIPTION TERM SEARCH + // ========================================================================= + // + // Scenario: As anonymous user I can search for a file description + // + // Given a public file with the title 'Colorless Green Ideas' and the description 'Sleep Furiously' + // and an anonymous user + // When I search for 'Sleep Furiously' + // Then the search returns '1' results + // and the search results should include 'Colorless Green Ideas' + // + it('File Description Search', function () { + // GIVEN: a public file with the title 'Colorless Green Ideas' + // and the description 'Sleep Furiously' + cy.createContent({ + contentType: 'File', + contentId: 'colorless-green-ideas', + contentTitle: 'Colorless Green Ideas', + path: '', + contentDescription: 'Sleep Furiously', + }); + // and an anonymous user + cy.autologout(); + + // WHEN: I search for 'Sleep Furiously' + cy.visit('http://localhost:3000/search'); + cy.get('.searchinput').type('Sleep Furiously'); + cy.get('.search-input button').click(); + + // THEN: the search returns '1' results + cy.get('.total-bar .results').contains('1'); + // and the search results should include 'Colorless Green Ideas' + cy.get('#content-core').contains('Colorless Green Ideas'); + }); + + // ========================================================================= + // FILE SUBJECTS (TAGS) SEARCH + // ========================================================================= + // + // Scenario: As anonymous user I can search for a file subject (tag) + // + // Given a public file with the title 'Colorless Green Ideas' and the subject (tag) 'Sleep Furiously' + // and an anonymous user + // When I search for 'Sleep Furiously' + // Then the search returns '1' results + // and the search results should include 'Colorless Green Ideas' + // + it('File Subjects (Tags) Search', function () { + // GIVEN: a public file with the title 'Colorless Green Ideas' + // and the subject (tag) 'Sleep Furiously' + cy.createContent({ + contentType: 'File', + contentId: 'colorless-green-ideas', + contentTitle: 'Colorless Green Ideas', + path: '', + contentSubjects: ['Furiously'], + }); + // and an anonymous user + cy.autologout(); + + // WHEN: I search for 'Sleep Furiously' + cy.visit('http://localhost:3000/search'); + cy.get('.searchinput').type('Furiously'); + cy.get('.search-input button').click(); + + // THEN: the search returns '1' results + cy.get('.total-bar .results').contains('1'); + // and the search results should include 'Colorless Green Ideas' + cy.get('#content-core').contains('Colorless Green Ideas'); + }); +}); diff --git a/acceptance/cypress/tests/search-ui.cy.js b/acceptance/cypress/tests/search-ui.cy.js new file mode 100644 index 0000000..c4cfca6 --- /dev/null +++ b/acceptance/cypress/tests/search-ui.cy.js @@ -0,0 +1,212 @@ +context('Search Acceptance Tests (UI)', () => { + beforeEach(() => { + // Docker compose setup requires host: solr-acceptance + cy.setRegistry('collective.solr.host', 'solr-acceptance'); + cy.setRegistry('collective.solr.active', true); + cy.setRegistry('collective.solr.use_tika', true); + cy.reindexSolr(); + // content + cy.createContent({ + contentType: 'Document', + contentId: 'alpha', + contentTitle: 'Alpha Beta Gaga Colorful', + path: '/', + }); + cy.request({ + method: 'POST', + url: `http://localhost:55001/plone/alpha/@workflow/publish`, + headers: { + Accept: 'application/json', + }, + auth: { + user: 'admin', + pass: 'secret', + }, + }); + cy.createContent({ + contentType: 'Document', + contentId: 'beta', + contentTitle: 'Beta Colorful', + path: '', + }); + cy.request({ + method: 'POST', + url: `http://localhost:55001/plone/beta/@workflow/publish`, + headers: { + Accept: 'application/json', + }, + auth: { + user: 'admin', + pass: 'secret', + }, + }); + cy.createContent({ + contentType: 'Document', + contentId: 'gamma', + contentTitle: 'Gamma Colorful', + path: '', + }); + cy.request({ + method: 'POST', + url: `http://localhost:55001/plone/gamma/@workflow/publish`, + headers: { + Accept: 'application/json', + }, + auth: { + user: 'admin', + pass: 'secret', + }, + }); + }); + afterEach(() => { + cy.clearSolr(); + }); + + it('sorting', function () { + cy.autologout(); + + cy.visit('http://localhost:3000/search'); + cy.get('.searchinput').type('colorful beta'); + cy.get('.search-input button').click(); + + cy.get('.total-bar .results').contains('3'); + + cy.get('.tileItem .summary').should(($div) => { + expect($div.get(0).innerText).to.eq('Beta Colorful'); + expect($div.get(1).innerText).to.eq('Alpha Beta Gaga Colorful'); + expect($div.get(2).innerText).to.eq('Gamma Colorful'); + }); + + cy.get('#sort_by .react-select__control').click(); + cy.contains('Alphabetically').click(); + + cy.get('.tileItem .summary').should(($div) => { + expect($div.get(0).innerText).to.eq('Alpha Beta Gaga Colorful'); + expect($div.get(1).innerText).to.eq('Beta Colorful'); + expect($div.get(2).innerText).to.eq('Gamma Colorful'); + }); + + cy.get('#sort_by .react-select__control').click(); + cy.contains('Date (newest first)').click(); + + cy.get('.tileItem .summary').should(($div) => { + expect($div.get(0).innerText).to.eq('Gamma Colorful'); + expect($div.get(1).innerText).to.eq('Beta Colorful'); + expect($div.get(2).innerText).to.eq('Alpha Beta Gaga Colorful'); + }); + }); + + it('batching', function () { + for (let i = 0; i < 50; i++) { + cy.createContent({ + contentType: 'Document', + contentId: `batched${i}`, + contentTitle: `One of a bunch ${i}`, + path: '', + }); + cy.request({ + method: 'POST', + url: `http://localhost:55001/plone/batched${i}/@workflow/publish`, + headers: { + Accept: 'application/json', + }, + auth: { + user: 'admin', + pass: 'secret', + }, + }); + } + + cy.autologout(); + + cy.visit('http://localhost:3000/search'); + cy.get('.searchinput').type('bunch'); + cy.get('.search-input button').click(); + + cy.get('#sort_by .react-select__control').click(); + cy.contains('Alphabetically').click(); + + cy.get('.total-bar .results').contains('50'); + + cy.get('.tileItem .summary').should(($div) => { + expect($div).to.have.length(25); + expect($div.get(0).innerText).to.eq('One of a bunch 0'); + expect($div.get(24).innerText).to.eq('One of a bunch 24'); + }); + + cy.get('.search-footer').contains('2').click(); + + cy.get('.tileItem .summary').should(($div) => { + expect($div).to.have.length(25); + expect($div.get(0).innerText).to.eq('One of a bunch 25'); + expect($div.get(24).innerText).to.eq('One of a bunch 49'); + }); + }); + + it('facets', function () { + cy.createContent({ + contentType: 'File', + contentId: 'file1', + contentTitle: 'Colorful beta file', + path: '', + }); + cy.autologout(); + + cy.visit('http://localhost:3000/search'); + cy.get('.searchinput').type('colorful beta'); + cy.get('.search-input button').click(); + + cy.get('.total-bar .results').contains('4'); + cy.get('.searchTab').eq(0).should('have.class', 'active'); + + cy.get('.searchTab').should(($div) => { + expect($div.get(0).innerText).to.eq('All4'); + expect($div.get(1).innerText).to.eq('Pages3'); + expect($div.get(2).innerText).to.eq('Events0'); + expect($div.get(3).innerText).to.eq('Images0'); + expect($div.get(4).innerText).to.eq('Files1'); + }); + + cy.get('.searchTab .searchCounter').should(($div) => { + expect($div.get(0).innerText).to.eq('4'); + expect($div.get(1).innerText).to.eq('3'); + expect($div.get(2).innerText).to.eq('0'); + expect($div.get(3).innerText).to.eq('0'); + expect($div.get(4).innerText).to.eq('1'); + }); + + cy.get('.searchTab').eq(1).click(); + cy.get('.searchTab').eq(1).should('have.class', 'active'); + cy.get('.total-bar .results').contains('3'); + + cy.get('.searchTab').eq(4).click(); + cy.get('.searchTab').eq(4).should('have.class', 'active'); + cy.get('.total-bar .results').contains('1'); + + cy.get('.searchTab').eq(0).click(); + cy.get('.searchTab').eq(0).should('have.class', 'active'); + cy.get('.total-bar .results').contains('4'); + + cy.get('.searchTab').eq(2).click(); + cy.get('.searchTab').eq(2).should('not.have.class', 'active'); + + cy.get('.searchTab').eq(3).click(); + cy.get('.searchTab').eq(3).should('not.have.class', 'active'); + }); + + /* + it('clear search', function () { + cy.autologout(); + + cy.visit('http://localhost:3000/search'); + cy.get('.searchinput').type('colorful beta'); + + cy.get('.search-input-wrapper .clear-icon').click(); + + cy.get('.search-input button').click(); + + cy.url().should('include', 'SearchableText=&'); + cy.get('.total-bar .results').eq(''); + }); +*/ +});