From f692e7a5deb31f54715f84d75f5acc7662402f28 Mon Sep 17 00:00:00 2001 From: Louise Davies Date: Tue, 22 Aug 2023 13:42:44 +0100 Subject: [PATCH] Improve download e2e tests - Add tests for bugs I found - Fix linting errors - Improve test efficiency - Lint cypress code in CI --- .../cypress/e2e/adminDownloadStatus.cy.ts | 265 ++++++------------ .../cypress/e2e/downloadCart.cy.ts | 9 +- .../cypress/e2e/downloadConfirmation.cy.ts | 62 ++-- .../cypress/e2e/downloadStatus.cy.ts | 244 +++++++--------- .../cypress/e2e/downloadTab.cy.ts | 6 +- packages/datagateway-download/package.json | 4 +- 6 files changed, 230 insertions(+), 360 deletions(-) diff --git a/packages/datagateway-download/cypress/e2e/adminDownloadStatus.cy.ts b/packages/datagateway-download/cypress/e2e/adminDownloadStatus.cy.ts index b0321b978..e59734e2f 100644 --- a/packages/datagateway-download/cypress/e2e/adminDownloadStatus.cy.ts +++ b/packages/datagateway-download/cypress/e2e/adminDownloadStatus.cy.ts @@ -1,14 +1,10 @@ describe('Admin Download Status', () => { - before(() => { - // Ensure the downloads are cleared before running tests. - cy.login({ username: 'root', password: 'pw', mechanism: 'simple' }); - - // Seed the initial downloads. - cy.clearDownloads(); - }); - beforeEach(() => { - cy.intercept('GET', '**/getPercentageComplete**'); + // set the viewport larger so all columns display nicely + // and sort indicators aren't covered + cy.viewport(1920, 1080); + + cy.intercept('GET', '**/getPercentageComplete**', '100'); cy.intercept('GET', '**/topcat/admin/downloads**').as( 'fetchAdminDownloads' ); @@ -25,11 +21,6 @@ describe('Admin Download Status', () => { }); }); - it('should load correctly and display admin download status table', () => { - cy.title().should('equal', 'DataGateway Download'); - cy.get('#datagateway-download').should('be.visible'); - }); - it('should refresh the table when clicking the refresh downloads button', () => { cy.get('[aria-label="Refresh download status table"]').should('exist'); @@ -52,177 +43,103 @@ describe('Admin Download Status', () => { }); }); - describe('should be able to sort download items by', () => { - it('ascending order', () => { - // Table is sorted by Requested Date by default. To keep working test, we will remove all sorts on the table beforehand - cy.get('.react-draggable') - .eq(7) - .trigger('mousedown') - .trigger('mousemove', { clientX: 800 }) - .trigger('mouseup'); - cy.contains('[role="button"]', 'Requested Date').click(); - - cy.get('.react-draggable') - .eq(4) - .trigger('mousedown') - .trigger('mousemove', { clientX: 600 }) - .trigger('mouseup'); - cy.contains('[role="button"]', 'Access Method').click(); - - cy.get('[aria-sort="ascending"]').should('exist'); - cy.get('.MuiTableSortLabel-iconDirectionAsc').should('be.visible'); - cy.get('[aria-rowindex="1"] [aria-colindex="5"]').should( - 'have.text', - 'globus' - ); - }); + it('should be able to sort by all sort directions on single and multiple columns', () => { + // remove default sort + cy.contains('[role="button"]', 'Requested Date').click(); - it('descending order', () => { - // Table is sorted by Requested Date by default. To keep working test, we will remove all sorts on the table beforehand - cy.get('.react-draggable') - .eq(7) - .trigger('mousedown') - .trigger('mousemove', { clientX: 800 }) - .trigger('mouseup'); - cy.contains('[role="button"]', 'Requested Date').click(); - - cy.get('.react-draggable') - .eq(4) - .trigger('mousedown') - .trigger('mousemove', { clientX: 600 }) - .trigger('mouseup'); - cy.contains('[role="button"]', 'Access Method').click(); - cy.contains('[role="button"]', 'Access Method').click(); - - cy.get('[aria-sort="descending"]').should('exist'); - cy.get('.MuiTableSortLabel-iconDirectionDesc').should( - 'not.have.css', - 'opacity', - '0' - ); - cy.get('[aria-rowindex="1"] [aria-colindex="5"]').should( - 'have.text', - 'https' - ); - }); + // ascending order + cy.contains('[role="button"]', 'Access Method') + .as('accessMethodSortButton') + .click(); - it('no order', () => { - // Table is sorted by Requested Date by default. To keep working test, we will remove all sorts on the table beforehand - cy.get('.react-draggable') - .eq(7) - .trigger('mousedown') - .trigger('mousemove', { clientX: 800 }) - .trigger('mouseup'); - cy.contains('[role="button"]', 'Requested Date').click(); - - cy.get('.react-draggable') - .eq(3) - .trigger('mousedown') - .trigger('mousemove', { clientX: 500 }) - .trigger('mouseup'); - cy.contains('[role="button"]', 'Prepared ID').click(); - cy.contains('[role="button"]', 'Prepared ID').click(); - cy.contains('[role="button"]', 'Prepared ID').click(); - - cy.get('[aria-sort="ascending"]').should('not.exist'); - cy.get('.MuiTableSortLabel-iconDirectionDesc').should('not.exist'); - cy.get('.MuiTableSortLabel-iconDirectionAsc').should( - 'have.css', - 'opacity', - '0' - ); - cy.get('[aria-rowindex="1"] [aria-colindex="4"]').should( - ($preparedId) => { - expect($preparedId[0].textContent).match( - /[0-9a-zA-Z]{8}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{4}-[0-9a-zA-Z]{12}/ - ); - } - ); - }); + cy.get('[aria-sort="ascending"]').should('exist'); + cy.get('.MuiTableSortLabel-iconDirectionAsc').should('be.visible'); + cy.get('[aria-rowindex="1"] [aria-colindex="5"]').should( + 'have.text', + 'globus' + ); - it('multiple columns', () => { - // Table is sorted by Requested Date by default. To keep working test, we will remove all sorts on the table beforehand - cy.get('.react-draggable') - .eq(7) - .trigger('mousedown') - .trigger('mousemove', { clientX: 800 }) - .trigger('mouseup'); - cy.contains('[role="button"]', 'Requested Date').click(); - - cy.get('.react-draggable') - .eq(4) - .trigger('mousedown') - .trigger('mousemove', { clientX: 550 }) - .trigger('mouseup'); - cy.contains('[role="button"]', 'Access Method').click(); - - cy.get('.react-draggable') - .eq(2) - .trigger('mousedown') - .trigger('mousemove', { clientX: 400 }) - .trigger('mouseup'); - cy.contains('[role="button"]', 'Username').click(); - - cy.get('[aria-rowindex="1"] [aria-colindex="5"]').should( - 'have.text', - 'globus' - ); - }); - }); + // descending order + cy.get('@accessMethodSortButton').click(); - describe('should be able to filter download items by', () => { - it('text', () => { - cy.get('[aria-label="Filter by Availability"]') - .first() - .type('Available', { force: true }); + cy.get('[aria-sort="descending"]').should('exist'); + cy.get('.MuiTableSortLabel-iconDirectionDesc').should( + 'not.have.css', + 'opacity', + '0' + ); + cy.get('[aria-rowindex="1"] [aria-colindex="5"]').should( + 'have.text', + 'https' + ); - cy.get('[aria-rowindex="1"] [aria-colindex="6"]').should( - 'have.text', - 'Available' - ); - }); + // no order + cy.get('@accessMethodSortButton').click(); - it('date between', () => { - const currDate = new Date(); + cy.get('[aria-sort="ascending"]').should('not.exist'); + cy.get('.MuiTableSortLabel-iconDirectionDesc').should('not.exist'); + cy.get('.MuiTableSortLabel-iconDirectionAsc').should( + 'have.css', + 'opacity', + '0' + ); + cy.get('[aria-rowindex="1"] [aria-colindex="5"]').should( + 'have.text', + 'https' + ); - cy.get('input[id="Requested Date filter from"]').type( - currDate.toISOString().slice(0, 10) - ); + // multiple columns + cy.contains('[role="button"]', 'Deleted').click(); + cy.contains('[role="button"]', 'Availability').click(); - cy.get('input[id="Requested Date filter to"]').type( - currDate.toISOString().slice(0, 10) - ); + cy.get('[aria-rowindex="2"] [aria-colindex="6"]').should( + 'have.text', + 'Available' + ); + cy.get('[aria-rowindex="3"] [aria-colindex="6"]').should( + 'have.text', + 'Expired' + ); + }); - cy.get('[aria-rowcount="0"]').should('not.exist'); + it('should be able to filter with both text & date filters on multiple columns', () => { + cy.get('[aria-rowcount]') + .invoke('attr', 'aria-rowcount') + .as('initialRowCount'); + const now = Date.now(); + // plus and minus 5 seconds from "now" + const fromDate = new Date(now - 5000); + const toDate = new Date(now + 5000); + + cy.get('input[id="Requested Date filter from"]').type( + fromDate.toLocaleString('sv') + ); + + cy.get('input[id="Requested Date filter to"]').type( + toDate.toLocaleString('sv') + ); + + cy.get('@initialRowCount').then((initialRowCount) => { + cy.get(`[aria-rowcount="${initialRowCount}"]`).should('not.exist'); }); + cy.get('[aria-rowcount="0"]').should('not.exist'); + + cy.get('[aria-rowcount]') + .invoke('attr', 'aria-rowcount') + .as('dateFilterRowCount'); + + cy.get('[aria-label="Filter by Availability"]') + .first() + .type('Available', { force: true }); + + cy.get('[aria-rowindex="1"] [aria-colindex="6"]').should( + 'have.text', + 'Available' + ); - it('multiple columns', () => { - cy.get('[role="columnheader"]').eq(4).as('accessColumn'); - cy.get('[role="columnheader"]').eq(5).as('availabilityColumn'); - - cy.get('.react-draggable') - .eq(4) - .trigger('mousedown') - .trigger('mousemove', { clientX: 500 }) - .trigger('mouseup'); - - cy.get('.react-draggable') - .eq(5) - .trigger('mousedown') - .trigger('mousemove', { clientX: 700 }) - .trigger('mouseup'); - - cy.get('[aria-label="Filter by Access Method') - .first() - .type('globus', { force: true }); - cy.get('[aria-label="Filter by Availability"]') - .first() - .type('restoring', { force: true }); - - cy.get('[aria-rowindex="1"] [aria-colindex="5"]').should( - 'have.text', - 'globus' - ); + cy.get('@dateFilterRowCount').then((dateFilterRowCount) => { + cy.get(`[aria-rowcount="${dateFilterRowCount}"]`).should('not.exist'); }); + cy.get('[aria-rowcount="0"]').should('not.exist'); }); }); diff --git a/packages/datagateway-download/cypress/e2e/downloadCart.cy.ts b/packages/datagateway-download/cypress/e2e/downloadCart.cy.ts index 6d9594417..2ca7ad9e9 100644 --- a/packages/datagateway-download/cypress/e2e/downloadCart.cy.ts +++ b/packages/datagateway-download/cypress/e2e/downloadCart.cy.ts @@ -21,13 +21,12 @@ describe('Download Cart', () => { // Ensure we can move away from the table and come back to it. cy.get('[aria-label="Download selection panel"]').should('exist'); // Wait for the downloads to be fetched before moving back to the cart. - cy.get('[aria-label="Downloads"]') - .should('exist') - .click() - .wait('@fetchDownloads'); + cy.get('[aria-label="Downloads"]').should('exist').click(); + cy.wait('@fetchDownloads'); cy.get('[aria-label="Download status panel"]').should('exist'); - cy.get('[aria-label="Selection').click().wait('@fetchCart'); + cy.get('[aria-label="Selection').click(); + cy.wait('@fetchCart'); cy.get('[aria-label="Download selection panel"]').should('exist'); cy.get('[aria-rowcount=59]', { timeout: 10000 }).should('exist'); diff --git a/packages/datagateway-download/cypress/e2e/downloadConfirmation.cy.ts b/packages/datagateway-download/cypress/e2e/downloadConfirmation.cy.ts index beb439c53..e04998fc0 100644 --- a/packages/datagateway-download/cypress/e2e/downloadConfirmation.cy.ts +++ b/packages/datagateway-download/cypress/e2e/downloadConfirmation.cy.ts @@ -27,7 +27,7 @@ describe('Download Confirmation', () => { cy.get('[aria-label="Download confirmation dialog"]').should('exist'); }); - it('should load correctly and display the confirmation dialog for the cart items', () => { + it('should load correctly and display the confirmation dialog for the cart items & let the dialog be closed', () => { // Show the correct download size of the cart items. cy.contains('Download Size: 3.12 GB').should('exist'); @@ -46,19 +46,12 @@ describe('Download Confirmation', () => { cy.contains('#download-table-hundred', '3 minutes, 57 seconds').should( 'exist' ); - }); - it('should prevent download requests with an invalid email address', () => { - // Enter in an invalid email address. - cy.get('#confirm-download-email').type('email.address'); + cy.get('[aria-label="Close download confirmation dialog"]').should('exist'); - // Ensure that the download button is disabled. - cy.get('#download-confirmation-download').should('be.disabled'); + cy.get('[aria-label="Close download confirmation dialog"]').click(); - // Complete the remainder of the email and ensure the email is not invalid anymore - // as the download button is enabled. - cy.get('#confirm-download-email').type('@test.com'); - cy.get('#download-confirmation-download').should('be.enabled'); + cy.get('[aria-label="Download confirmation dialog"]').should('not.exist'); }); it('should be able to submit a download request and start immediate download with default values (HTTPS)', () => { @@ -78,6 +71,13 @@ describe('Download Confirmation', () => { 'exist' ); cy.contains('#confirm-success-access-method', 'HTTPS').should('exist'); + + // Click on the download status link and expect the download + // status panel to have been displayed. + cy.contains('#download-confirmation-status-link', 'View My Downloads') + .should('exist') + .click(); + cy.get('[aria-label="Download status panel"]').should('exist'); }); it('should not be able to submit a download request with a disabled access method (Globus)', () => { @@ -114,7 +114,16 @@ describe('Download Confirmation', () => { cy.get('#confirm-download-name').type('test-file-name'); // Set email address. - cy.get('#confirm-download-email').type('test@email.com'); + // Enter in an invalid email address. + cy.get('#confirm-download-email').type('email.address'); + + // Ensure that the download button is disabled. + cy.get('#download-confirmation-download').should('be.disabled'); + + // Complete the remainder of the email and ensure the email is not invalid anymore + // as the download button is enabled. + cy.get('#confirm-download-email').type('@test.com'); + cy.get('#download-confirmation-download').should('be.enabled'); // Request download. cy.get('#download-confirmation-download').click(); @@ -129,30 +138,9 @@ describe('Download Confirmation', () => { 'exist' ); cy.contains('#confirm-success-access-method', 'HTTPS').should('exist'); - cy.contains('#confirm-success-email-address', 'test@email.com').should( - 'exist' - ); - }); - - // This needs to be implemented once the tab has been included into the code. - it('should be able to link to the downloads status tab upon successful download confirmation', () => { - cy.get('#download-confirmation-download').click(); - - cy.get('#download-confirmation-success').should('exist'); - - // Click on the download status link and expect the download - // status panel to have been displayed. - cy.contains('#download-confirmation-status-link', 'View My Downloads') - .should('exist') - .click(); - cy.get('[aria-label="Download status panel"]').should('exist'); - }); - - it('should be able to close the download confirmation dialog', () => { - cy.get('[aria-label="Close download confirmation dialog"]').should('exist'); - - cy.get('[aria-label="Close download confirmation dialog"]').click(); - - cy.get('[aria-label="Download confirmation dialog"]').should('not.exist'); + cy.contains( + '#confirm-success-email-address', + 'email.address@test.com' + ).should('exist'); }); }); diff --git a/packages/datagateway-download/cypress/e2e/downloadStatus.cy.ts b/packages/datagateway-download/cypress/e2e/downloadStatus.cy.ts index 890d02c58..72caccf45 100644 --- a/packages/datagateway-download/cypress/e2e/downloadStatus.cy.ts +++ b/packages/datagateway-download/cypress/e2e/downloadStatus.cy.ts @@ -10,7 +10,7 @@ describe('Download Status', () => { }); beforeEach(() => { - cy.intercept('GET', '**/getPercentageComplete**'); + cy.intercept('GET', '**/getPercentageComplete**', '100'); cy.intercept('GET', '**/topcat/user/downloads**').as('fetchDownloads'); cy.login(); @@ -21,19 +21,27 @@ describe('Download Status', () => { cy.visit('/download'); cy.get('[aria-label="Downloads"]').should('exist'); - cy.get('[aria-label="Downloads"]') - .click() - .then(() => { - cy.wait('@fetchDownloads'); - }); + cy.get('[aria-label="Downloads"]').click(); + cy.wait('@fetchDownloads'); }); }); - it('should load correctly and display download status table', () => { + it('should load correctly and display download status table & show correct info & links', () => { cy.title().should('equal', 'DataGateway Download'); cy.get('#datagateway-download').should('be.visible'); cy.get('[aria-label="Download status panel"]').should('exist'); + + cy.contains('[aria-colindex="1"]', 'test-file-1') + .should('be.visible') + .and('not.be.disabled'); + + // We are not clicking and proceeding to download the item in this test + // but instead checking that the link exists and it is possible to be clicked. + cy.get('a[aria-label="Download test-file-1"]').should('not.be.empty'); + cy.get('a[aria-label="Download test-file-1"]') + .should('have.prop', 'href') + .and('contain', 'getData'); }); it('should refresh the table when clicking the refresh downloads button', () => { @@ -61,155 +69,115 @@ describe('Download Status', () => { }); }); - describe('should be able to sort download items by', () => { - it('ascending order', () => { - // Table is sorted by Requested Date by default. To keep working test, we will remove all sorts on the table beforehand - cy.contains('[role="button"]', 'Requested Date').click(); + it('should be able to sort by all sort directions on single and multiple columns', () => { + // remove default sort + cy.contains('[role="button"]', 'Requested Date').click(); - cy.contains('[role="button"]', 'Download Name').click(); + // ascending + cy.contains('[role="button"]', 'Download Name') + .as('nameSortButton') + .click(); - cy.get('[aria-sort="ascending"]').should('exist'); - cy.get('.MuiTableSortLabel-iconDirectionAsc').should('be.visible'); + cy.get('[aria-sort="ascending"]').should('exist'); + cy.get('.MuiTableSortLabel-iconDirectionAsc').should('be.visible'); - cy.get('[aria-rowindex="1"] [aria-colindex="1"]').should( - 'have.text', - 'test-file-1' - ); - }); + cy.get('[aria-rowindex="1"] [aria-colindex="1"]').should( + 'have.text', + 'test-file-1' + ); - it('descending order', () => { - // Table is sorted by Requested Date by default. To keep working test, we will remove all sorts on the table beforehand - cy.contains('[role="button"]', 'Requested Date').click(); - - cy.contains('[role="button"]', 'Download Name').click(); - cy.contains('[role="button"]', 'Download Name').click(); - - cy.get('[aria-sort="descending"]').should('exist'); - cy.get('.MuiTableSortLabel-iconDirectionDesc').should( - 'not.have.css', - 'opacity', - '0' - ); - cy.get('[aria-rowindex="1"] [aria-colindex="1"]').should( - 'have.text', - 'test-file-4' - ); - - cy.get('[aria-rowindex="1"] [aria-colindex="3"]').should( - 'have.text', - 'Expired' - ); - }); + // descending + cy.get('@nameSortButton').click(); - it('no order', () => { - // Table is sorted by Requested Date by default. To keep working test, we will remove all sorts on the table beforehand - cy.contains('[role="button"]', 'Requested Date').click(); - - cy.contains('[role="button"]', 'Download Name').click(); - cy.contains('[role="button"]', 'Download Name').click(); - cy.contains('[role="button"]', 'Download Name').click(); - - cy.get('[aria-sort="ascending"]').should('not.exist'); - cy.get('.MuiTableSortLabel-iconDirectionDesc').should('not.exist'); - cy.get('.MuiTableSortLabel-iconDirectionAsc').should( - 'have.css', - 'opacity', - '0' - ); - cy.get('[aria-rowindex="1"] [aria-colindex="1"]').should( - 'have.text', - 'test-file-1' - ); - - cy.get('[aria-rowindex="1"] [aria-colindex="3"]').should( - 'have.text', - 'Available' - ); - }); + cy.get('[aria-sort="descending"]').should('exist'); + cy.get('.MuiTableSortLabel-iconDirectionDesc').should( + 'not.have.css', + 'opacity', + '0' + ); + cy.get('[aria-rowindex="1"] [aria-colindex="1"]').should( + 'have.text', + 'test-file-4' + ); - it('multiple columns', () => { - // Table is sorted by Requested Date by default. To keep working test, we will remove all sorts on the table beforehand - cy.contains('[role="button"]', 'Requested Date').click(); + cy.get('[aria-rowindex="1"] [aria-colindex="3"]').should( + 'have.text', + 'Expired' + ); - cy.contains('[role="button"]', 'Access Method').click(); - cy.contains('[role="button"]', 'Availability').click(); + // no order + cy.get('@nameSortButton').click(); - cy.get('[aria-rowindex="1"] [aria-colindex="1"]').should( - 'have.text', - 'test-file-4' - ); - }); + cy.get('[aria-sort="ascending"]').should('not.exist'); + cy.get('.MuiTableSortLabel-iconDirectionDesc').should('not.exist'); + cy.get('.MuiTableSortLabel-iconDirectionAsc').should( + 'have.css', + 'opacity', + '0' + ); + cy.get('[aria-rowindex="1"] [aria-colindex="1"]').should( + 'have.text', + 'test-file-1' + ); + + cy.get('[aria-rowindex="1"] [aria-colindex="3"]').should( + 'have.text', + 'Available' + ); + + // multiple columns + cy.contains('[role="button"]', 'Access Method').click(); + cy.contains('[role="button"]', 'Availability').click(); + + cy.get('[aria-rowindex="1"] [aria-colindex="1"]').should( + 'have.text', + 'test-file-4' + ); }); - describe('should be able to filter download items by', () => { - it('text', () => { - cy.get('[aria-label="Filter by Download Name"]').first().type('4'); + it('should be able to filter with both text & date filters on multiple columns', () => { + cy.get('input[id="Requested Date filter from"]').type( + '2020-01-31 00:00:00' + ); - cy.get('[aria-rowcount="1"]').should('exist'); + const date = new Date(); + date.setDate(1); + date.setMonth(date.getMonth() - 1); + // MUIv5 datetime pickers don't allow for time to be graphically selected + // This is because the relevant elements are elements with pointer-events: none + // Therefore, we settle for typing the date and time instead + cy.get('input[id="Requested Date filter to"]').type( + format(date, 'yyyy-MM-dd HH:mm:ss') + ); - cy.get('[aria-rowindex="1"] [aria-colindex="1"]').should( - 'have.text', - 'test-file-4' - ); - }); + // There should not be results for this time period. + cy.get('[aria-rowcount="0"]').should('exist'); - it('date between', () => { - cy.get('input[id="Requested Date filter from"]').type( - '2020-01-31 00:00:00' - ); - - const date = new Date(); - date.setDate(1); - date.setMonth(date.getMonth() - 1); - // MUIv5 datetime pickers don't allow for time to be graphically selected - // This is because the relevant elements are elements with pointer-events: none - // Therefore, we settle for typing the date and time instead - cy.get('input[id="Requested Date filter to"]').type( - format(date, 'yyyy-MM-dd HH:mm:ss') - ); - - // There should not be results for this time period. - cy.get('[aria-rowcount="0"]').should('exist'); - - const currDate = new Date(); - currDate.setHours(0, 0, 0, 0); - - cy.get('input[id="Requested Date filter from"]').clear(); - cy.get('input[id="Requested Date filter to"]').clear(); - cy.get('[aria-rowcount="4"]').should('exist'); - - cy.get('input[id="Requested Date filter from"]').type( - format(currDate, 'yyyy-MM-dd HH:mm:ss') - ); - - cy.get('[aria-rowcount="4"]').should('exist'); - - cy.get('[aria-rowindex="1"] [aria-colindex="4"]').should( - 'contain', - format(currDate, 'yyyy-MM-dd') - ); - }); + const currDate = new Date(); + currDate.setHours(0, 0, 0, 0); - it('multiple columns', () => { - cy.get('[aria-label="Filter by Access Method"]').first().type('globus'); + cy.get('input[id="Requested Date filter from"]').clear(); + cy.get('input[id="Requested Date filter to"]').clear(); + cy.get('[aria-rowcount="4"]').should('exist'); - cy.get('[aria-label="Filter by Availability"]').first().type('restoring'); + cy.get('input[id="Requested Date filter from"]').type( + format(currDate, 'yyyy-MM-dd HH:mm:ss') + ); - cy.get('[aria-rowcount="2"]').should('exist'); - }); - }); + cy.get('[aria-rowcount="4"]').should('exist'); - it('should have a download link for an item', () => { - cy.contains('[aria-colindex="1"]', 'test-file-1') - .should('be.visible') - .and('not.be.disabled'); + cy.get('[aria-rowindex="1"] [aria-colindex="5"]').should( + 'contain', + format(currDate, 'yyyy-MM-dd') + ); - // We are not clicking and proceeding to download the item in this test - // but instead checking that the link exists and it is possible to be clicked. - cy.get('a[aria-label="Download test-file-1"]').should('not.be.empty'); - cy.get('a[aria-label="Download test-file-1"]') - .should('have.prop', 'href') - .and('contain', 'getData'); + cy.get('[aria-label="Filter by Access Method"]').first().type('globus'); + + cy.get('[aria-rowcount="2"]').should('exist'); + + cy.get('[aria-label="Filter by Availability"]').first().type('restoring'); + + cy.get('[aria-rowcount="1"]').should('exist'); }); it('should be able to remove a download', () => { diff --git a/packages/datagateway-download/cypress/e2e/downloadTab.cy.ts b/packages/datagateway-download/cypress/e2e/downloadTab.cy.ts index cc85bad38..bfe3b7ca0 100644 --- a/packages/datagateway-download/cypress/e2e/downloadTab.cy.ts +++ b/packages/datagateway-download/cypress/e2e/downloadTab.cy.ts @@ -12,17 +12,15 @@ describe('Download Cart', () => { cy.clearDownloadCart(); }); - it('should load correctly and display selection panel', () => { + it('should display the selection tab on every page reload', () => { cy.title().should('equal', 'DataGateway Download'); cy.get('#datagateway-download').should('be.visible'); cy.get('[aria-label="Selection"]').should('exist'); cy.get('[aria-label="Downloads"]').should('exist'); cy.get('[aria-label="Download selection panel"]').should('be.visible'); cy.get('[aria-label="Download status panel"]').should('not.be.visible'); - }); - it('should display the selection tab on every page reload', () => { - cy.get('[aria-label="Downloads"]').should('exist').click(); + cy.get('[aria-label="Downloads"]').click(); cy.get('[aria-label="Download status panel"]').should('be.visible'); cy.get('[aria-label="Download selection panel"]').should('not.be.visible'); diff --git a/packages/datagateway-download/package.json b/packages/datagateway-download/package.json index 3179e51c1..0f72885b7 100644 --- a/packages/datagateway-download/package.json +++ b/packages/datagateway-download/package.json @@ -44,6 +44,7 @@ "typescript": "4.9.3" }, "devDependencies": { + "@babel/eslint-parser": "7.22.5", "@testing-library/jest-dom": "5.16.4", "@testing-library/react": "12.1.3", "@testing-library/react-hooks": "8.0.1", @@ -52,7 +53,6 @@ "@types/lodash.chunk": "4.2.6", "@typescript-eslint/eslint-plugin": "5.61.0", "@typescript-eslint/parser": "5.61.0", - "@babel/eslint-parser": "7.22.5", "cross-env": "7.0.3", "cypress": "11.2.0", "cypress-failed-log": "2.10.0", @@ -76,7 +76,7 @@ "e2e": "start-server-and-test e2e:serve http://localhost:3000 cy:run", "cy:open": "cypress open", "cy:run": "cypress run", - "lint:js": "eslint --ext=tsx --ext=ts --ext=js --ext=jsx --fix ./src && yarn build", + "lint:js": "eslint --ext=tsx --ext=ts --ext=js --ext=jsx --fix ./src ./cypress && yarn build", "eject": "react-scripts eject", "pre-commit": "lint-staged" },