diff --git a/cypress.config.js b/cypress.config.js index ae7f8780..50ae23f3 100644 --- a/cypress.config.js +++ b/cypress.config.js @@ -4,7 +4,7 @@ require('dotenv').config(); module.exports = defineConfig({ defaultCommandTimeout: 5000, experimentalMemoryManagement: true, - numTestsKeptInMemory: 1, + numTestsKeptInMemory: 0, e2e: { baseUrl: process.env.ROOT_URL ? process.env.ROOT_URL : 'http://localhost:3000', experimentalStudio: true, diff --git a/cypress/e2e/datasets.cy.js b/cypress/e2e/datasets.cy.js index 6a99b437..a021eadf 100644 --- a/cypress/e2e/datasets.cy.js +++ b/cypress/e2e/datasets.cy.js @@ -3,6 +3,7 @@ describe("Dataset 127", function () { cy.visit("/datasets/127?type=dataset") }); it("Landing page", function () { + cy.get('.dataset-image').should('have.attr', 'src').and('include', 'https://assets.discover.pennsieve.io/') // Hover over author cy.get(':nth-child(2) > .contributor-item').should('be.visible').trigger('mouseenter', { eventConstructor: 'MouseEvent' }) @@ -10,29 +11,35 @@ describe("Dataset 127", function () { //only one visible popover cy.get('.orcid-popover:visible').should('have.length', 1) - /* Click on the DOI */ - //cy.get('.dataset-information-box > :nth-child(2) > a > u').click() - //cy.url().should('include', '/datasets/127?type=dataset') - //Check Get Dataset directs to files tab - cy.get('.button-container > :nth-child(1) > span').click() + cy.contains('.button-container span', 'Get Dataset').click() cy.get('.nuxt-link-exact-active').should('have.text', ' Files '); cy.get('[style=""] > .heading2.mb-8').should('have.text', 'Download Dataset').and('be.visible') //Checkt Cite Dataset direccts to Cite tab - cy.get('.button-container > .secondary > span').click() + cy.contains('.button-container span', 'Cite Dataset').click() cy.get('.nuxt-link-exact-active').should('have.text', ' Cite '); cy.get('.citation-details > .heading2').should('have.text', '\n Dataset Citation\n ').and('be.visible') + cy.get('.dataset-information-box > :nth-child(2) > a').should('have.attr', 'href').and('include', 'doi.org').then((href) => { + cy.request(href).then((resp) => { + expect(resp.status).to.eq(200); + expect(resp.body).to.include('datasets/127/version'); + }) + }); }); it("Landing page author search", function () { - cy.get(':nth-child(2) > .contributor-list > li > .el-tooltip > .tooltip-item > a > u').click(); - cy.url().should('include', '/data?type=dataset&search=') + cy.get(':nth-child(2) > .contributor-list > li > .el-tooltip > .tooltip-item > a').each($el => { + cy.wrap($el).should('have.attr', 'href').and('include', '/data?type='); + }); }); it("Landing page doi version", function () { - cy.get('.dataset-information-box > .active-link').click(); - cy.get('.el-col-push-1 > a > u').click(); - //the doi should resolve back to sparc.science - cy.origin('https://sparc.science', () => { - cy.url().should('include', '/datasets/127/version') + cy.get('.dataset-information-box > div').contains('View other versions').click(); + //Check if each link + cy.get('.el-col-push-1 > a').each(($link) => { + cy.wrap($link).should('have.attr', 'href').and('include', 'doi.org').then((href) => { + cy.request(href).then((resp) => { + cy.request(href).its('body').should('include', '/datasets/127/version'); + }); + }); }) }); it("Landing page project page", function () { @@ -42,6 +49,134 @@ describe("Dataset 127", function () { cy.url().should('include', '/projects/') }); it("Abstract Tab", function () { - //Extend test with Cypress Studio + cy.contains('#datasetDetailsTabsContainer .style1', ' Abstract ').click(); + cy.get('.nuxt-link-exact-active').should('have.text', ' Abstract '); + cy.get(':nth-child(1) > :nth-child(1) > strong').contains('Study Purpose:'); + cy.get('.dataset-description-info > :nth-child(1) > :nth-child(2) > strong').contains('Data Collection:'); + cy.get(':nth-child(1) > :nth-child(3) > strong').contains('Primary Conclusion:'); + cy.get('.experimental-design-section-text-column').contains('Protocol Links: '); + //cy.get('.experimental-design-container .link2').should('have.attr', 'href').and('include', 'https://doi.org/') + //The following regular expression should capture space and letters + cy.get('.dataset-description-info').contains(/Experimental Approach: *(.+)/); + cy.get('.dataset-description-info').contains('Subject Information:'); + cy.get('.dataset-description-info').contains(/Anatomical structure: *(.+)/); + cy.get('.dataset-description-info').contains(/Species: *(.+)/); + cy.get('.dataset-description-info').contains(/Sex: *(.+)/); + cy.get('.dataset-description-info').contains(/Number of samples: *(.+)/); + cy.get('.dataset-description-info').contains(/Keywords: *(.+)/); + cy.contains('.dataset-description-info a', 'Download Metadata file').should('have.attr', 'href').and('include', 'metadata').then((href) => { + cy.request(href).then((resp) => { + expect(resp.status).to.eq(200) + }) + }) + }); + it("About Tab", function () { + cy.contains('#datasetDetailsTabsContainer .style1', ' About ').click(); + cy.get('.nuxt-link-exact-active').should('have.text', ' About '); + cy.get('.dataset-about-info').contains(/Title: *(.+)/); + cy.get('.dataset-about-info').contains(/First Published: *(.+)/); + cy.get('.dataset-about-info').contains(/Last Published: *(.+)/); + cy.get('.dataset-about-info').contains(/Contact Author: *(.+)/); + cy.get('.dataset-about-info').contains(/Award[(]s[)]: (.+)/); + cy.get('.dataset-about-info').contains(/Funding Program[(]s[)]: *(.+)/); + cy.get('.dataset-about-info').contains(/Associated project[(]s[)]: *(.+)/); + cy.get('.dataset-about-info').contains(/Institution[(]s[)]: *(.+)/); + cy.get('.dataset-about-info').contains(/Associated project[(]s[)]: *(.+)/); + cy.get('.dataset-about-info').contains(/Version (.+) Revision (.+): *(.+)/); + cy.get('.dataset-about-info').contains(/Dataset DOI: *(.+)/); + cy.get('.about-section-container > :nth-child(2) > :nth-child(2) > a').should('have.attr', 'href').and('include', 'mailto'); + //Match award link to associated project + cy.get(':nth-child(11) > :nth-child(2) > a').invoke('attr', 'href').then(value => { + cy.get(':nth-child(8) > :nth-child(2) > a').should('have.attr', 'href', value); + }); + //match author to contributors + cy.get('.about-section-container > :nth-child(2) > :nth-child(1)').invoke('text').then(value => { + cy.get('.similar-datasets-container').contains(value); + }) + }); + it("Cite Tab", function () { + cy.contains('#datasetDetailsTabsContainer .style1', ' Cite ').click(); + cy.get('.nuxt-link-exact-active').should('have.text', ' Cite '); + cy.get('.dataset-information-box > :nth-child(2) > a > u').invoke('text').then(value => { + const expectedLink = 'https://citation.crosscite.org/?doi=' + value; + cy.get('.citation-details > p > a').should('have.attr', 'href', expectedLink); + }) + }); + it("Files Tab", function () { + //First check if there is a Files tab + cy.get('#datasetDetailsTabsContainer .style1').then(($tab) => { + if ($tab.text().includes(' Files ')) { + cy.contains('#datasetDetailsTabsContainer .style1', ' Files ').click(); + cy.get('.nuxt-link-exact-active').should('have.text', ' Files '); + cy.get('[style=""] > .heading2.mb-8').should('have.text', 'Download Dataset'); + cy.get('.left-column > :nth-child(1) > div > .label4').should('have.text', 'Option 1 - Direct download: '); + cy.get('.aws-download-column > :nth-child(1) > .label4').should('have.text', 'Option 2 - AWS download: '); + cy.get('.left-column > :nth-child(1) > a > .el-button > span').should('be.visible'); + cy.get('.left-column > :nth-child(1) > a > .el-button').should('be.enabled'); + //Find the download file button + cy.contains('.content .body1 .el-table__fixed-body-wrapper .el-table__row', ' dataset_description.xlsx ').should('have.length', 1).as('datasetDescription'); + cy.get('@datasetDescription').find('.el-table_1_column_5').should('have.length', 1).as('icons'); + cy.get('@icons').find('form[id=zipForm]').should('have.length', 1); + //there should be 4 icons, one for each action + cy.get('@icons').find('svg').should('have.length', 4); + //Check get share links + cy.get('@icons').find(':nth-child(4)').click({force: true}); + cy.get('.el-message').should('be.visible'); + //Check oSPARC link + cy.get('@icons').find(':nth-child(3) > .el-tooltip > .svg-icon').click({force: true}); + cy.get('.files-table-table .el-dialog .svg-icon').click(); + } else { + this.skip(); + } + }); + }); + it("Gallery Tab", function () { + cy.contains('#datasetDetailsTabsContainer .style1', ' Gallery ').click(); + cy.get('.content > .full-size').then(($content) => { + cy.wait(500); + const gallery = $content.find('.gallery-container'); + //console.log($content, gallery) + if (gallery && gallery.length) { + cy.wrap(gallery).find('.sparc-design-system-pagination').as('pagination'); + cy.get('@pagination').find('li.number').should('have.length.least', 1); + cy.wrap(gallery).find('.el-card').should('have.length.least', 1).each($card => { + cy.wrap($card).contains('span', ' View '); + //Need to test newly opened viewers + }); + } else { + cy.wrap($content).contains(' This dataset does not contain gallery items '); + } + }); + }); + it("References Tab", function () { + //First check if reference tab is present + cy.get('#datasetDetailsTabsContainer .style1').then(($tab) => { + if ($tab.text().includes(' References ')) { + cy.contains('#datasetDetailsTabsContainer .style1', ' References ').click(); + cy.get('.nuxt-link-exact-active').should('have.text', ' References '); + cy.get('.dataset-references .heading2').contains('Associated Publications for this Dataset'); + cy.get('.dataset-references .citation-container').each(el => { + cy.wrap(el).find('div > a').should('have.attr', 'href').and('include', 'doi.org'); + cy.wrap(el).find('.copy-button').click(); + cy.get('.el-message').should('be.visible'); + }); + } else { + this.skip(); + } + }); + }); + it("Versions Tab", function () { + //First check if version tab is present + cy.get('#datasetDetailsTabsContainer .style1').then(($tab) => { + if ($tab.text().includes(' Versions ')) { + cy.contains('#datasetDetailsTabsContainer .style1', ' Versions ').click(); + cy.get('.nuxt-link-exact-active').should('have.text', ' Versions '); + cy.get('.table-rows .el-col-push-1 > a').each($el => { + cy.wrap($el).should('have.attr', 'href').and('include', 'doi.org').then((href) => { + cy.request(href).its('body').should('include', '/datasets/127/version'); + }) + }); + } + }); }); -}); \ No newline at end of file +});