From 1a7b021ce0bdc6eae589c9dbb39be8bb7bd23eb3 Mon Sep 17 00:00:00 2001 From: ddjnw1yu Date: Mon, 13 Nov 2023 09:58:21 +1300 Subject: [PATCH 1/9] add keyword search test --- cypress/e2e/finddata.cy.js | 51 ++++++++++++++++++++++++++++++++------ 1 file changed, 43 insertions(+), 8 deletions(-) diff --git a/cypress/e2e/finddata.cy.js b/cypress/e2e/finddata.cy.js index 72b0ce10..29b37272 100644 --- a/cypress/e2e/finddata.cy.js +++ b/cypress/e2e/finddata.cy.js @@ -1,9 +1,44 @@ -describe('Find Data page', () => { - it('Go to dataset', () => { - cy.visit('') - cy.get('.mobile-navigation > :nth-child(1) > :nth-child(1) > a').click() - cy.url().should('include', '/data?type=dataset') - cy.get(':nth-child(1) > .el-table_1_column_2 > .cell > :nth-child(1) > a').click() - cy.url().should('include', '/datasets/') +const categories = ["dataset"] +// const categories = ["dataset", "model", "simulation", "projects"] + +const keywords = ["Spine", "neck"] + +categories.forEach(category => { + + describe(`Find Data in ${category}`, { testIsolation: false }, function () { + before(function () { + cy.visit(`/data?type=${category}`); + }); + + const searchInput = keywords.join(',') + it(`Keyword Search - ${searchInput}`, function () { + cy.get('.el-input__inner').type(searchInput); + cy.get('.btn-clear-search > .svg-icon').should('be.visible') + cy.get('.search-text').click(); + cy.url({ decode: true }).should('include', searchInput) + + cy.intercept('POST', '**/query?**').as('keywordSearchResult') + cy.wait('@keywordSearchResult'); + + cy.get(':nth-child(1) > p').then($p => { + const noResult = $p.text().includes('\n 0 Results | Showing') + if (noResult) { + this.skip() + } else { + const regex = new RegExp(`${keywords.join('|')}`, 'i') + cy.get('.table-wrap').within(() => { + cy.get('b').contains(regex) + }) + } + }) + cy.get('.btn-clear-search > .svg-icon').click() + cy.get('.el-input__inner').should('have.attr', 'placeholder', 'Enter search criteria'); + }) + + /* + There are situations that dataset cards do not show the (highlighted) keywords + Just in case this happens for all the displayed dataset cards, extra tests may need to be added + cy.get(':nth-child(1) > .el-table_1_column_2 > .cell').contains(regex); + */ }) -}) +}) \ No newline at end of file From 96da5b1c04c259eb8625da2952645c31e703ce72 Mon Sep 17 00:00:00 2001 From: ddjnw1yu Date: Mon, 13 Nov 2023 16:58:29 +1300 Subject: [PATCH 2/9] ignore uncaught exception --- cypress/support/commands.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 698b01a4..b7b3328c 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -34,4 +34,10 @@ // visit(originalFn: CommandOriginalFn, url: string, options: Partial): Chainable // } // } -// } \ No newline at end of file +// } + +Cypress.on('uncaught:exception', (err, runnable) => { + // returning false here prevents Cypress from + // failing the test + return false +}) \ No newline at end of file From a4eceb07652323dc2535fd0344e67e2301748af9 Mon Sep 17 00:00:00 2001 From: ddjnw1yu Date: Mon, 13 Nov 2023 16:58:36 +1300 Subject: [PATCH 3/9] add single faceted browse search test --- cypress/e2e/finddata.cy.js | 72 ++++++++++++++++++++++++++++++++------ 1 file changed, 62 insertions(+), 10 deletions(-) diff --git a/cypress/e2e/finddata.cy.js b/cypress/e2e/finddata.cy.js index 29b37272..c3580539 100644 --- a/cypress/e2e/finddata.cy.js +++ b/cypress/e2e/finddata.cy.js @@ -1,8 +1,10 @@ -const categories = ["dataset"] -// const categories = ["dataset", "model", "simulation", "projects"] +// const categories = ["dataset"] +const categories = ["dataset", "model", "simulation", "projects"] const keywords = ["Spine", "neck"] +const singleFacet = "Human" + categories.forEach(category => { describe(`Find Data in ${category}`, { testIsolation: false }, function () { @@ -15,7 +17,7 @@ categories.forEach(category => { cy.get('.el-input__inner').type(searchInput); cy.get('.btn-clear-search > .svg-icon').should('be.visible') cy.get('.search-text').click(); - cy.url({ decode: true }).should('include', searchInput) + cy.url({ decode: true }).should('contain', searchInput) cy.intercept('POST', '**/query?**').as('keywordSearchResult') cy.wait('@keywordSearchResult'); @@ -23,8 +25,9 @@ categories.forEach(category => { cy.get(':nth-child(1) > p').then($p => { const noResult = $p.text().includes('\n 0 Results | Showing') if (noResult) { - this.skip() + cy.get('.el-table__empty-text').should('exist') } else { + cy.get('.el-table__empty-text').should('not.exist') const regex = new RegExp(`${keywords.join('|')}`, 'i') cy.get('.table-wrap').within(() => { cy.get('b').contains(regex) @@ -33,12 +36,61 @@ categories.forEach(category => { }) cy.get('.btn-clear-search > .svg-icon').click() cy.get('.el-input__inner').should('have.attr', 'placeholder', 'Enter search criteria'); - }) - /* - There are situations that dataset cards do not show the (highlighted) keywords - Just in case this happens for all the displayed dataset cards, extra tests may need to be added - cy.get(':nth-child(1) > .el-table_1_column_2 > .cell').contains(regex); - */ + // // There are situations that dataset cards do not show the (highlighted) keywords + // // Just in case this happens for all the displayed dataset cards, extra tests may need to be added + // cy.get(':nth-child(1) > .el-table_1_column_2 > .cell').contains(regex); + }) + it(`Faceted Browse Search - ${singleFacet}`, function () { + // let facetCategory + cy.get('.no-facets').should('contain', 'No filters applied'); + cy.get('.label-content-container').should('not.be.visible'); + cy.get('.expand-all-container > .el-link > .el-link--inner').click(); + cy.get('.label-content-container').should('be.visible'); + cy.get('.label-content-container').then(($label) => { + const facetExistInFilter = $label.find('span.capitalize').text().toLocaleLowerCase().includes(singleFacet.toLocaleLowerCase()); + if (facetExistInFilter) { + // cy.wrap($label).contains(singleFacet).parents('.sparc-design-system-component-dropdown-multiselect').within(() => { + // cy.get('.label-title').then($el => { + // facetCategory = $el.text() + // }) + // }) + const regex = new RegExp(singleFacet, 'i') + cy.wrap($label).contains(regex).click() + cy.url({ decode: true }).should('contain', 'selectedFacetIds') + cy.get('.el-tag__close').click(); + cy.get('.no-facets').should('contain', 'No filters applied'); + cy.wrap($label).contains(regex).click() + cy.url({ decode: true }).should('contain', 'selectedFacetIds') + cy.get('.tags-container > .flex > .el-link > .el-link--inner').click(); + cy.get('.no-facets').should('contain', 'No filters applied'); + cy.wrap($label).contains(regex).click() + cy.url({ decode: true }).should('contain', 'selectedFacetIds') + cy.get('.el-card__body').should('have.length', 1) + cy.get('.el-card__body > .capitalize').contains(regex); + } else { + this.skip() + } + }) + cy.get(':nth-child(1) > p').then($p => { + const noResult = $p.text().includes('\n 0 Results | Showing') + if (noResult) { + cy.get('.el-table__empty-text').should('exist') + } else { + cy.get('.el-table__empty-text').should('not.exist') + cy.get('.table-wrap').then(($content) => { + const facetFoundInCard = $content.text().includes(singleFacet) + if (facetFoundInCard) { + cy.wrap($content).should('contain', singleFacet) + } else { + this.skip() + // cy.get(':nth-child(1) > .el-table_1_column_2 > .cell > :nth-child(1) > a').click(); + // cy.wait(5000) + // cy.get('.dataset-description-info').contains(singleFacet); + } + }) + } + }) + }); }) }) \ No newline at end of file From 413294551641a5d4dc40531bdd26a5c9eab5c4fe Mon Sep 17 00:00:00 2001 From: ddjnw1yu Date: Tue, 14 Nov 2023 10:15:30 +1300 Subject: [PATCH 4/9] fix test issue with ANATOMICAL STRUCTURE facet --- cypress/e2e/finddata.cy.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/cypress/e2e/finddata.cy.js b/cypress/e2e/finddata.cy.js index c3580539..6fe4ca43 100644 --- a/cypress/e2e/finddata.cy.js +++ b/cypress/e2e/finddata.cy.js @@ -1,5 +1,5 @@ -// const categories = ["dataset"] -const categories = ["dataset", "model", "simulation", "projects"] +const categories = ["dataset"] +// const categories = ["dataset", "model", "simulation", "projects"] const keywords = ["Spine", "neck"] @@ -14,6 +14,7 @@ categories.forEach(category => { const searchInput = keywords.join(',') it(`Keyword Search - ${searchInput}`, function () { + cy.get('.el-input__inner').should('have.attr', 'placeholder', 'Enter search criteria'); cy.get('.el-input__inner').type(searchInput); cy.get('.btn-clear-search > .svg-icon').should('be.visible') cy.get('.search-text').click(); @@ -35,7 +36,6 @@ categories.forEach(category => { } }) cy.get('.btn-clear-search > .svg-icon').click() - cy.get('.el-input__inner').should('have.attr', 'placeholder', 'Enter search criteria'); // // There are situations that dataset cards do not show the (highlighted) keywords // // Just in case this happens for all the displayed dataset cards, extra tests may need to be added @@ -58,15 +58,15 @@ categories.forEach(category => { const regex = new RegExp(singleFacet, 'i') cy.wrap($label).contains(regex).click() cy.url({ decode: true }).should('contain', 'selectedFacetIds') - cy.get('.el-tag__close').click(); + cy.get('.el-tag__close').eq(0).click(); cy.get('.no-facets').should('contain', 'No filters applied'); cy.wrap($label).contains(regex).click() cy.url({ decode: true }).should('contain', 'selectedFacetIds') cy.get('.tags-container > .flex > .el-link > .el-link--inner').click(); - cy.get('.no-facets').should('contain', 'No filters applied'); + // // "No filters applied" will not appear after click "reset all" in Cypress. BUG? + // cy.get('.no-facets').should('contain', 'No filters applied'); cy.wrap($label).contains(regex).click() cy.url({ decode: true }).should('contain', 'selectedFacetIds') - cy.get('.el-card__body').should('have.length', 1) cy.get('.el-card__body > .capitalize').contains(regex); } else { this.skip() From c890581c04974133d538a4c077968b66a8504ede Mon Sep 17 00:00:00 2001 From: ddjnw1yu Date: Tue, 14 Nov 2023 12:51:32 +1300 Subject: [PATCH 5/9] add all page features test --- cypress/e2e/finddata.cy.js | 99 ++++++++++++++++++++++---------------- 1 file changed, 58 insertions(+), 41 deletions(-) diff --git a/cypress/e2e/finddata.cy.js b/cypress/e2e/finddata.cy.js index 6fe4ca43..ac9bf7b3 100644 --- a/cypress/e2e/finddata.cy.js +++ b/cypress/e2e/finddata.cy.js @@ -1,5 +1,5 @@ -const categories = ["dataset"] -// const categories = ["dataset", "model", "simulation", "projects"] +// const categories = ["dataset"] +const categories = ["dataset", "model", "simulation", "projects"] const keywords = ["Spine", "neck"] @@ -9,21 +9,39 @@ categories.forEach(category => { describe(`Find Data in ${category}`, { testIsolation: false }, function () { before(function () { - cy.visit(`/data?type=${category}`); - }); + cy.visit(`/data?type=${category}`) + }) + it('All Page Features', function () { + cy.get('.label1 > .el-dropdown > .filter-dropdown').then(($dropdown) => { + // const defaultOrder = $dropdown.text().includes('Published (desc)') + // if (defaultOrder) { + cy.wrap($dropdown).click() + cy.contains('Z-A').click() + // } + cy.wrap($dropdown).should('contain', 'Z-A') + }) + cy.get('[role="tooltip"]').should('not.be.visible') + cy.get('.purple-fill').click() + cy.get('[role="tooltip"]').should('be.visible') + cy.get('[role="tooltip"]').should('contain', 'How do filters work?') + cy.get(':nth-child(1) > p > .el-dropdown > .filter-dropdown').click() + // Two dropdown-menu exist in the page, can not locate the specific element, force click is require + cy.get('.el-dropdown-menu > .el-dropdown-menu__item').contains('20').click({ force: true }) + cy.get('.el-table__row').should('have.length', 20) + }) const searchInput = keywords.join(',') it(`Keyword Search - ${searchInput}`, function () { - cy.get('.el-input__inner').should('have.attr', 'placeholder', 'Enter search criteria'); - cy.get('.el-input__inner').type(searchInput); + cy.get('.el-input__inner').should('have.attr', 'placeholder', 'Enter search criteria') + cy.get('.el-input__inner').type(searchInput) cy.get('.btn-clear-search > .svg-icon').should('be.visible') - cy.get('.search-text').click(); + cy.get('.search-text').click() cy.url({ decode: true }).should('contain', searchInput) cy.intercept('POST', '**/query?**').as('keywordSearchResult') - cy.wait('@keywordSearchResult'); + cy.wait('@keywordSearchResult') - cy.get(':nth-child(1) > p').then($p => { + cy.get(':nth-child(1) > p').then(($p) => { const noResult = $p.text().includes('\n 0 Results | Showing') if (noResult) { cy.get('.el-table__empty-text').should('exist') @@ -36,61 +54,60 @@ categories.forEach(category => { } }) cy.get('.btn-clear-search > .svg-icon').click() - // // There are situations that dataset cards do not show the (highlighted) keywords // // Just in case this happens for all the displayed dataset cards, extra tests may need to be added - // cy.get(':nth-child(1) > .el-table_1_column_2 > .cell').contains(regex); + // cy.get(':nth-child(1) > .el-table_1_column_2 > .cell').contains(regex) }) it(`Faceted Browse Search - ${singleFacet}`, function () { // let facetCategory - cy.get('.no-facets').should('contain', 'No filters applied'); - cy.get('.label-content-container').should('not.be.visible'); - cy.get('.expand-all-container > .el-link > .el-link--inner').click(); - cy.get('.label-content-container').should('be.visible'); + cy.get('.no-facets').should('contain', 'No filters applied') + cy.get('.label-content-container').should('not.be.visible') + cy.get('.expand-all-container > .el-link > .el-link--inner').click() + cy.get('.label-content-container').should('be.visible') cy.get('.label-content-container').then(($label) => { - const facetExistInFilter = $label.find('span.capitalize').text().toLocaleLowerCase().includes(singleFacet.toLocaleLowerCase()); + const facetExistInFilter = $label.find('span.capitalize').text().toLocaleLowerCase().includes(singleFacet.toLocaleLowerCase()) if (facetExistInFilter) { // cy.wrap($label).contains(singleFacet).parents('.sparc-design-system-component-dropdown-multiselect').within(() => { - // cy.get('.label-title').then($el => { + // cy.get('.label-title').then(($el) => { // facetCategory = $el.text() // }) // }) const regex = new RegExp(singleFacet, 'i') cy.wrap($label).contains(regex).click() cy.url({ decode: true }).should('contain', 'selectedFacetIds') - cy.get('.el-tag__close').eq(0).click(); - cy.get('.no-facets').should('contain', 'No filters applied'); + cy.get('.el-tag__close').eq(0).click() + cy.get('.no-facets').should('contain', 'No filters applied') cy.wrap($label).contains(regex).click() cy.url({ decode: true }).should('contain', 'selectedFacetIds') - cy.get('.tags-container > .flex > .el-link > .el-link--inner').click(); + cy.get('.tags-container > .flex > .el-link > .el-link--inner').click() // // "No filters applied" will not appear after click "reset all" in Cypress. BUG? - // cy.get('.no-facets').should('contain', 'No filters applied'); + // cy.get('.no-facets').should('contain', 'No filters applied') cy.wrap($label).contains(regex).click() cy.url({ decode: true }).should('contain', 'selectedFacetIds') - cy.get('.el-card__body > .capitalize').contains(regex); - } else { - this.skip() - } - }) - cy.get(':nth-child(1) > p').then($p => { - const noResult = $p.text().includes('\n 0 Results | Showing') - if (noResult) { - cy.get('.el-table__empty-text').should('exist') - } else { - cy.get('.el-table__empty-text').should('not.exist') - cy.get('.table-wrap').then(($content) => { - const facetFoundInCard = $content.text().includes(singleFacet) - if (facetFoundInCard) { - cy.wrap($content).should('contain', singleFacet) + cy.get('.el-card__body > .capitalize').contains(regex) + cy.get(':nth-child(1) > p').then(($p) => { + const noResult = $p.text().includes('\n 0 Results | Showing') + if (noResult) { + cy.get('.el-table__empty-text').should('exist') } else { - this.skip() - // cy.get(':nth-child(1) > .el-table_1_column_2 > .cell > :nth-child(1) > a').click(); - // cy.wait(5000) - // cy.get('.dataset-description-info').contains(singleFacet); + cy.get('.el-table__empty-text').should('not.exist') + cy.get('.table-wrap').then(($content) => { + const facetFoundInCard = $content.text().includes(singleFacet) + if (facetFoundInCard) { + cy.wrap($content).should('contain', singleFacet) + } else { + this.skip() + // cy.get(':nth-child(1) > .el-table_1_column_2 > .cell > :nth-child(1) > a').click() + // cy.wait(5000) + // cy.get('.dataset-description-info').contains(singleFacet) + } + }) } }) + } else { + this.skip() } }) - }); + }) }) }) \ No newline at end of file From b7032310e8b93a8f5e858c772f302e1a1c7ce638 Mon Sep 17 00:00:00 2001 From: ddjnw1yu Date: Tue, 14 Nov 2023 16:06:18 +1300 Subject: [PATCH 6/9] Add multiple facets test --- cypress/e2e/finddata.cy.js | 58 ++++++++++++++++++++++++++++++-------- 1 file changed, 47 insertions(+), 11 deletions(-) diff --git a/cypress/e2e/finddata.cy.js b/cypress/e2e/finddata.cy.js index ac9bf7b3..861ef220 100644 --- a/cypress/e2e/finddata.cy.js +++ b/cypress/e2e/finddata.cy.js @@ -5,6 +5,8 @@ const keywords = ["Spine", "neck"] const singleFacet = "Human" +const multipleFacets = ["Human", "Organ"] + categories.forEach(category => { describe(`Find Data in ${category}`, { testIsolation: false }, function () { @@ -14,11 +16,8 @@ categories.forEach(category => { it('All Page Features', function () { cy.get('.label1 > .el-dropdown > .filter-dropdown').then(($dropdown) => { - // const defaultOrder = $dropdown.text().includes('Published (desc)') - // if (defaultOrder) { cy.wrap($dropdown).click() cy.contains('Z-A').click() - // } cy.wrap($dropdown).should('contain', 'Z-A') }) cy.get('[role="tooltip"]').should('not.be.visible') @@ -26,8 +25,7 @@ categories.forEach(category => { cy.get('[role="tooltip"]').should('be.visible') cy.get('[role="tooltip"]').should('contain', 'How do filters work?') cy.get(':nth-child(1) > p > .el-dropdown > .filter-dropdown').click() - // Two dropdown-menu exist in the page, can not locate the specific element, force click is require - cy.get('.el-dropdown-menu > .el-dropdown-menu__item').contains('20').click({ force: true }) + cy.get('.el-dropdown-menu > .el-dropdown-menu__item:visible').contains('20').click() cy.get('.el-table__row').should('have.length', 20) }) const searchInput = keywords.join(',') @@ -47,7 +45,7 @@ categories.forEach(category => { cy.get('.el-table__empty-text').should('exist') } else { cy.get('.el-table__empty-text').should('not.exist') - const regex = new RegExp(`${keywords.join('|')}`, 'i') + const regex = new RegExp(keywords.join('|'), 'i') cy.get('.table-wrap').within(() => { cy.get('b').contains(regex) }) @@ -58,15 +56,15 @@ categories.forEach(category => { // // Just in case this happens for all the displayed dataset cards, extra tests may need to be added // cy.get(':nth-child(1) > .el-table_1_column_2 > .cell').contains(regex) }) - it(`Faceted Browse Search - ${singleFacet}`, function () { + it(`Single Faceted Browse Search - ${singleFacet}`, function () { // let facetCategory cy.get('.no-facets').should('contain', 'No filters applied') cy.get('.label-content-container').should('not.be.visible') cy.get('.expand-all-container > .el-link > .el-link--inner').click() cy.get('.label-content-container').should('be.visible') cy.get('.label-content-container').then(($label) => { - const facetExistInFilter = $label.find('span.capitalize').text().toLocaleLowerCase().includes(singleFacet.toLocaleLowerCase()) - if (facetExistInFilter) { + const singleFacetExist = $label.find('span.capitalize:visible').text().toLowerCase().includes(singleFacet.toLowerCase()) + if (singleFacetExist) { // cy.wrap($label).contains(singleFacet).parents('.sparc-design-system-component-dropdown-multiselect').within(() => { // cy.get('.label-title').then(($el) => { // facetCategory = $el.text() @@ -74,11 +72,9 @@ categories.forEach(category => { // }) const regex = new RegExp(singleFacet, 'i') cy.wrap($label).contains(regex).click() - cy.url({ decode: true }).should('contain', 'selectedFacetIds') cy.get('.el-tag__close').eq(0).click() cy.get('.no-facets').should('contain', 'No filters applied') cy.wrap($label).contains(regex).click() - cy.url({ decode: true }).should('contain', 'selectedFacetIds') cy.get('.tags-container > .flex > .el-link > .el-link--inner').click() // // "No filters applied" will not appear after click "reset all" in Cypress. BUG? // cy.get('.no-facets').should('contain', 'No filters applied') @@ -108,6 +104,46 @@ categories.forEach(category => { this.skip() } }) + cy.get('.tags-container > .flex > .el-link > .el-link--inner').click() + }) + it(`Multiple Faceted Browse Search - ${multipleFacets}`, function () { + cy.get('.expand-all-container > .el-link > .el-link--inner').click() + cy.get('.label-content-container').then(($label) => { + let multipleFacetsExist = true + multipleFacets.forEach((facet) => { + multipleFacetsExist = multipleFacetsExist && $label.find('span.capitalize:visible').text().toLowerCase().includes(facet.toLowerCase()) + }) + if (multipleFacetsExist) { + multipleFacets.forEach((facet) => { + const singleRegex = new RegExp(`^${facet}$`, 'i') + cy.wrap($label).contains(singleRegex).click() + }) + const multipleRegex = new RegExp(multipleFacets.join('|'), 'i') + cy.get('.el-card__body > .capitalize').contains(multipleRegex) + cy.get(':nth-child(1) > p').then(($p) => { + const noResult = $p.text().includes('\n 0 Results | Showing') + if (noResult) { + cy.get('.el-table__empty-text').should('exist') + } else { + cy.get('.el-table__empty-text').should('not.exist') + cy.get('.table-wrap').then(($content) => { + let facetsExistInCard = true + multipleFacets.forEach((facet) => { + facetsExistInCard = facetsExistInCard || $content.text().toLowerCase().includes(facet.toLowerCase()) + }) + if (facetsExistInCard) { + cy.wrap($content).contains(multipleRegex) + } else { + this.skip() + } + }) + } + }) + } else { + this.skip() + } + }) + cy.get('.tags-container > .flex > .el-link > .el-link--inner').click() }) }) }) \ No newline at end of file From f4b594ddef79c6266cf97f47a6748ef061a7a241 Mon Sep 17 00:00:00 2001 From: ddjnw1yu Date: Tue, 14 Nov 2023 17:03:21 +1300 Subject: [PATCH 7/9] update keyword search test --- cypress/e2e/finddata.cy.js | 59 ++++++++++++++++++++++---------------- 1 file changed, 35 insertions(+), 24 deletions(-) diff --git a/cypress/e2e/finddata.cy.js b/cypress/e2e/finddata.cy.js index 861ef220..36b3ccc0 100644 --- a/cypress/e2e/finddata.cy.js +++ b/cypress/e2e/finddata.cy.js @@ -7,7 +7,7 @@ const singleFacet = "Human" const multipleFacets = ["Human", "Organ"] -categories.forEach(category => { +categories.forEach((category) => { describe(`Find Data in ${category}`, { testIsolation: false }, function () { before(function () { @@ -28,33 +28,44 @@ categories.forEach(category => { cy.get('.el-dropdown-menu > .el-dropdown-menu__item:visible').contains('20').click() cy.get('.el-table__row').should('have.length', 20) }) - const searchInput = keywords.join(',') - it(`Keyword Search - ${searchInput}`, function () { - cy.get('.el-input__inner').should('have.attr', 'placeholder', 'Enter search criteria') - cy.get('.el-input__inner').type(searchInput) - cy.get('.btn-clear-search > .svg-icon').should('be.visible') - cy.get('.search-text').click() - cy.url({ decode: true }).should('contain', searchInput) + keywords.forEach((keyword) => { + it(`Keyword Search - ${keyword}`, function () { + cy.get('.el-input__inner').should('have.attr', 'placeholder', 'Enter search criteria') + cy.get('.el-input__inner').clear() + cy.get('.el-input__inner').type(keyword) + cy.get('.btn-clear-search > .svg-icon').should('be.visible') + cy.get('.search-text').click() + cy.url({ decode: true }).should('contain', keyword) - cy.intercept('POST', '**/query?**').as('keywordSearchResult') - cy.wait('@keywordSearchResult') - - cy.get(':nth-child(1) > p').then(($p) => { - const noResult = $p.text().includes('\n 0 Results | Showing') - if (noResult) { - cy.get('.el-table__empty-text').should('exist') + if (category === "projects") { + cy.wait(500) } else { - cy.get('.el-table__empty-text').should('not.exist') - const regex = new RegExp(keywords.join('|'), 'i') - cy.get('.table-wrap').within(() => { - cy.get('b').contains(regex) - }) + cy.intercept('POST', '**/query?**').as('keywordSearchResult') + cy.wait('@keywordSearchResult') } + + cy.get(':nth-child(1) > p').then(($p) => { + const noResult = $p.text().includes('\n 0 Results | Showing') + if (noResult) { + cy.get('.el-table__empty-text').should('exist') + } else { + cy.get('.el-table__empty-text').should('not.exist') + cy.get('.table-wrap').then(($content) => { + const keywordExist = $content.text().toLowerCase().includes(keyword.toLowerCase()) + if (keywordExist) { + const regex = new RegExp(keyword, 'i') + cy.get('b').contains(regex) + } else { + cy.get('b').should('not.exist') + } + }) + } + }) + cy.get('.btn-clear-search > .svg-icon').click() + // // There are situations that dataset cards do not show the (highlighted) keywords + // // Just in case this happens for all the displayed dataset cards, extra tests may need to be added + // cy.get(':nth-child(1) > .el-table_1_column_2 > .cell').contains(regex) }) - cy.get('.btn-clear-search > .svg-icon').click() - // // There are situations that dataset cards do not show the (highlighted) keywords - // // Just in case this happens for all the displayed dataset cards, extra tests may need to be added - // cy.get(':nth-child(1) > .el-table_1_column_2 > .cell').contains(regex) }) it(`Single Faceted Browse Search - ${singleFacet}`, function () { // let facetCategory From e72ca0f810ade6c42748c83e9413b7a7f5ecce99 Mon Sep 17 00:00:00 2001 From: ddjnw1yu Date: Wed, 15 Nov 2023 14:25:07 +1300 Subject: [PATCH 8/9] add comments and small tests --- cypress/e2e/finddata.cy.js | 104 ++++++++++++++++++++++--------------- 1 file changed, 62 insertions(+), 42 deletions(-) diff --git a/cypress/e2e/finddata.cy.js b/cypress/e2e/finddata.cy.js index 36b3ccc0..bde321fd 100644 --- a/cypress/e2e/finddata.cy.js +++ b/cypress/e2e/finddata.cy.js @@ -1,11 +1,11 @@ -// const categories = ["dataset"] -const categories = ["dataset", "model", "simulation", "projects"] +// const categories = ['dataset'] +const categories = ['dataset', 'model', 'simulation', 'projects'] -const keywords = ["Spine", "neck"] +const keywords = ['Spine', 'neck'] -const singleFacet = "Human" +const singleFacet = 'Male' -const multipleFacets = ["Human", "Organ"] +const multipleFacets = ['Human', 'Organ'] categories.forEach((category) => { @@ -15,15 +15,28 @@ categories.forEach((category) => { }) it('All Page Features', function () { + // Sort dropdown function testing + // Test whether the sort function can be triggered and text can be shown cy.get('.label1 > .el-dropdown > .filter-dropdown').then(($dropdown) => { cy.wrap($dropdown).click() cy.contains('Z-A').click() cy.wrap($dropdown).should('contain', 'Z-A') }) + // Tooltips showup testing + // Test whether content will be displayed cy.get('[role="tooltip"]').should('not.be.visible') cy.get('.purple-fill').click() cy.get('[role="tooltip"]').should('be.visible') - cy.get('[role="tooltip"]').should('contain', 'How do filters work?') + cy.get('[role="tooltip"] > .el-popover__title').should('contain', 'How do filters work?') + cy.get('.label-header > :nth-child(1) > .label-title').then(($label) => { + const tooltipExist = $label.text().includes('Availability') + if (tooltipExist) { + cy.get('.el-tooltip').click() + cy.get('[role="tooltip"]:visible').should('contain', 'SPARC') + } + }) + // Dataset show testing + // Test whether the number of displayed datasets can be changed cy.get(':nth-child(1) > p > .el-dropdown > .filter-dropdown').click() cy.get('.el-dropdown-menu > .el-dropdown-menu__item:visible').contains('20').click() cy.get('.el-table__row').should('have.length', 20) @@ -31,30 +44,21 @@ categories.forEach((category) => { keywords.forEach((keyword) => { it(`Keyword Search - ${keyword}`, function () { cy.get('.el-input__inner').should('have.attr', 'placeholder', 'Enter search criteria') - cy.get('.el-input__inner').clear() - cy.get('.el-input__inner').type(keyword) + cy.get('.el-input__inner').clear().type(keyword) cy.get('.btn-clear-search > .svg-icon').should('be.visible') cy.get('.search-text').click() cy.url({ decode: true }).should('contain', keyword) - - if (category === "projects") { - cy.wait(500) - } else { - cy.intercept('POST', '**/query?**').as('keywordSearchResult') - cy.wait('@keywordSearchResult') - } - + cy.wait(500) cy.get(':nth-child(1) > p').then(($p) => { const noResult = $p.text().includes('\n 0 Results | Showing') if (noResult) { cy.get('.el-table__empty-text').should('exist') } else { cy.get('.el-table__empty-text').should('not.exist') - cy.get('.table-wrap').then(($content) => { - const keywordExist = $content.text().toLowerCase().includes(keyword.toLowerCase()) + cy.get('.table-wrap').then(($table) => { + const keywordExist = $table.text().toLowerCase().includes(keyword.toLowerCase()) if (keywordExist) { - const regex = new RegExp(keyword, 'i') - cy.get('b').contains(regex) + cy.get('b').contains(new RegExp(keyword, 'i')).should('exist') } else { cy.get('b').should('not.exist') } @@ -64,14 +68,19 @@ categories.forEach((category) => { cy.get('.btn-clear-search > .svg-icon').click() // // There are situations that dataset cards do not show the (highlighted) keywords // // Just in case this happens for all the displayed dataset cards, extra tests may need to be added - // cy.get(':nth-child(1) > .el-table_1_column_2 > .cell').contains(regex) + // cy.get('') }) }) it(`Single Faceted Browse Search - ${singleFacet}`, function () { // let facetCategory cy.get('.no-facets').should('contain', 'No filters applied') - cy.get('.label-content-container').should('not.be.visible') + // Expand all cy.get('.expand-all-container > .el-link > .el-link--inner').click() + if (category !== 'projects') { + // This action is used to expand all parent facets in ANATOMICAL STRUCTURE + // Avoid error when using child facets as test facets + cy.get('.el-tree-node__expand-icon.el-icon-caret-right:visible').not('.is-leaf').click({ multiple: true }) + } cy.get('.label-content-container').should('be.visible') cy.get('.label-content-container').then(($label) => { const singleFacetExist = $label.find('span.capitalize:visible').text().toLowerCase().includes(singleFacet.toLowerCase()) @@ -81,29 +90,22 @@ categories.forEach((category) => { // facetCategory = $el.text() // }) // }) - const regex = new RegExp(singleFacet, 'i') - cy.wrap($label).contains(regex).click() - cy.get('.el-tag__close').eq(0).click() - cy.get('.no-facets').should('contain', 'No filters applied') - cy.wrap($label).contains(regex).click() - cy.get('.tags-container > .flex > .el-link > .el-link--inner').click() - // // "No filters applied" will not appear after click "reset all" in Cypress. BUG? - // cy.get('.no-facets').should('contain', 'No filters applied') + const regex = new RegExp(`(^| )${singleFacet}`, 'i') cy.wrap($label).contains(regex).click() cy.url({ decode: true }).should('contain', 'selectedFacetIds') - cy.get('.el-card__body > .capitalize').contains(regex) + cy.get('.el-card__body > .capitalize').contains(regex).should('have.length', 1) cy.get(':nth-child(1) > p').then(($p) => { const noResult = $p.text().includes('\n 0 Results | Showing') if (noResult) { cy.get('.el-table__empty-text').should('exist') } else { cy.get('.el-table__empty-text').should('not.exist') - cy.get('.table-wrap').then(($content) => { - const facetFoundInCard = $content.text().includes(singleFacet) + cy.get('.table-wrap').then(($table) => { + const facetFoundInCard = $table.text().includes(singleFacet) if (facetFoundInCard) { - cy.wrap($content).should('contain', singleFacet) + cy.wrap($table).should('contain', singleFacet) } else { - this.skip() + cy.wrap($table).should('not.contain', singleFacet) // cy.get(':nth-child(1) > .el-table_1_column_2 > .cell > :nth-child(1) > a').click() // cy.wait(5000) // cy.get('.dataset-description-info').contains(singleFacet) @@ -111,11 +113,25 @@ categories.forEach((category) => { }) } }) + // Uncheck + cy.get('.el-card__body > .capitalize').contains(regex).should('have.length', 1) + cy.wrap($label).contains(regex).click() + cy.get('.no-facets').should('contain', 'No filters applied') + // Close tag + cy.wrap($label).contains(regex).click() + cy.get('.el-card__body > .capitalize').contains(regex).should('have.length', 1) + cy.get('.el-tag__close').eq(0).click() + cy.get('.no-facets').should('contain', 'No filters applied') + // Reset all + cy.wrap($label).contains(regex).click() + cy.get('.tags-container > .flex > .el-link > .el-link--inner').click() + cy.get('.el-card__body > .capitalize').should('not.exist') + // // 'No filters applied' sometimes will not appear after click 'reset all' in Cypress. BUG or Cypress issue? + // cy.get('.no-facets').should('contain', 'No filters applied') } else { this.skip() } }) - cy.get('.tags-container > .flex > .el-link > .el-link--inner').click() }) it(`Multiple Faceted Browse Search - ${multipleFacets}`, function () { cy.get('.expand-all-container > .el-link > .el-link--inner').click() @@ -126,11 +142,11 @@ categories.forEach((category) => { }) if (multipleFacetsExist) { multipleFacets.forEach((facet) => { - const singleRegex = new RegExp(`^${facet}$`, 'i') - cy.wrap($label).contains(singleRegex).click() + cy.wrap($label).contains(new RegExp(`^${facet}`, 'i')).click() }) const multipleRegex = new RegExp(multipleFacets.join('|'), 'i') - cy.get('.el-card__body > .capitalize').contains(multipleRegex) + cy.get('.el-card__body > .capitalize:visible').should('have.length.above', 1) + cy.get('.el-card__body > .capitalize:visible').contains(multipleRegex).should('exist') cy.get(':nth-child(1) > p').then(($p) => { const noResult = $p.text().includes('\n 0 Results | Showing') if (noResult) { @@ -143,18 +159,22 @@ categories.forEach((category) => { facetsExistInCard = facetsExistInCard || $content.text().toLowerCase().includes(facet.toLowerCase()) }) if (facetsExistInCard) { - cy.wrap($content).contains(multipleRegex) + cy.wrap($content).contains(multipleRegex).should('exist') } else { - this.skip() + cy.wrap($content).contains(multipleRegex).should('not.exist') } }) } }) + multipleFacets.forEach((facet) => { + cy.get('.el-card__body > .capitalize').contains(new RegExp(` ${facet} `, 'i')).within(() => { + cy.get('.el-tag__close').click() + }) + }) } else { this.skip() } }) - cy.get('.tags-container > .flex > .el-link > .el-link--inner').click() }) }) }) \ No newline at end of file From 9e83c492bf7864c943431fb9d6db3510e3dee8da Mon Sep 17 00:00:00 2001 From: ddjnw1yu Date: Wed, 15 Nov 2023 16:12:25 +1300 Subject: [PATCH 9/9] add comment for possible issues --- cypress/e2e/finddata.cy.js | 20 +++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/cypress/e2e/finddata.cy.js b/cypress/e2e/finddata.cy.js index bde321fd..0f530f19 100644 --- a/cypress/e2e/finddata.cy.js +++ b/cypress/e2e/finddata.cy.js @@ -66,8 +66,8 @@ categories.forEach((category) => { } }) cy.get('.btn-clear-search > .svg-icon').click() - // // There are situations that dataset cards do not show the (highlighted) keywords - // // Just in case this happens for all the displayed dataset cards, extra tests may need to be added + // *** There are situations that dataset cards do not show the (highlighted) keywords + // *** Just in case this happens for all the displayed dataset cards, extra tests may need to be added // cy.get('') }) }) @@ -76,12 +76,14 @@ categories.forEach((category) => { cy.get('.no-facets').should('contain', 'No filters applied') // Expand all cy.get('.expand-all-container > .el-link > .el-link--inner').click() + cy.get('.label-content-container').should('be.visible') + cy.get('.label-content-container').should('have.length.above', 0) if (category !== 'projects') { - // This action is used to expand all parent facets in ANATOMICAL STRUCTURE - // Avoid error when using child facets as test facets + // *** This action is used to expand all parent facets in ANATOMICAL STRUCTURE + // *** Avoid error when using child facets as test facets + // *** Need to think of a solution to open the specific parent facet, instead of open all cy.get('.el-tree-node__expand-icon.el-icon-caret-right:visible').not('.is-leaf').click({ multiple: true }) } - cy.get('.label-content-container').should('be.visible') cy.get('.label-content-container').then(($label) => { const singleFacetExist = $label.find('span.capitalize:visible').text().toLowerCase().includes(singleFacet.toLowerCase()) if (singleFacetExist) { @@ -125,9 +127,10 @@ categories.forEach((category) => { // Reset all cy.wrap($label).contains(regex).click() cy.get('.tags-container > .flex > .el-link > .el-link--inner').click() - cy.get('.el-card__body > .capitalize').should('not.exist') - // // 'No filters applied' sometimes will not appear after click 'reset all' in Cypress. BUG or Cypress issue? + // *** 'No filters applied' sometimes will not appear after click 'reset all' in Cypress. BUG or Cypress issue? // cy.get('.no-facets').should('contain', 'No filters applied') + // *** There is a bug with reset all function. + // cy.get('.el-card__body > .capitalize').should('not.exist') } else { this.skip() } @@ -135,6 +138,9 @@ categories.forEach((category) => { }) it(`Multiple Faceted Browse Search - ${multipleFacets}`, function () { cy.get('.expand-all-container > .el-link > .el-link--inner').click() + if (category !== 'projects') { + cy.get('.el-tree-node__expand-icon.el-icon-caret-right:visible').not('.is-leaf').click({ multiple: true }) + } cy.get('.label-content-container').then(($label) => { let multipleFacetsExist = true multipleFacets.forEach((facet) => {