From 16230760ead36863578cd2eb63eae28fcd1e29bb Mon Sep 17 00:00:00 2001 From: Rodsy <89385857+Rodsy@users.noreply.github.com> Date: Thu, 21 Sep 2023 15:47:13 +0100 Subject: [PATCH] Tmma 461 expand cypress tests (#222) * user journey login, upload and delete, not including visualisation * user journey from login, upload and delete. no visulations * updated user journey test to include visualisation * updated file path for select file, renamed description of test, deleted unused test file and old visualiations test script --- cypress/integration/user-journey.js | 233 ++++++++++++++++++++++++++ cypress/integration/visualisations.js | 86 ---------- 2 files changed, 233 insertions(+), 86 deletions(-) create mode 100644 cypress/integration/user-journey.js delete mode 100644 cypress/integration/visualisations.js diff --git a/cypress/integration/user-journey.js b/cypress/integration/user-journey.js new file mode 100644 index 00000000..eafe8337 --- /dev/null +++ b/cypress/integration/user-journey.js @@ -0,0 +1,233 @@ +describe('User journey of login, upload abstracts, perform search, view, visualisation and then delete search.', () => { + + beforeEach(() => { + cy.visit('/'); + cy.viewport(1920, 1080) + }); + + it('Lets login, go to results page, check its empty then try to upload an abstract file', () => { + cy.visit('/logout'); + cy.visit('/'); + cy.get('#side-menu') + .contains('Login') + .click() + cy.get('title') + .invoke('text') + .should('equal', 'TeMMPo: Login') + + cy.get('#id_username').type(Cypress.env('CREDENTIALS_USR')); + cy.get('#id_password').type(Cypress.env('CREDENTIALS_PSW')); + cy.get('button[type=submit]').click() + + cy.get('title') + .invoke('text') + .should('equal', 'TeMMPo: My list') + + // goto results tab and check its empty + + cy.get('#side-menu') + .contains('Results') + .click() + + cy.get('.page-header') + .should('have.text', 'Results') + + cy.get('table') + .find('tr') + .eq(1) + .contains('No data available in table', { matchCase: false }) + + // lets go to the search page try to upload an ovid medline abstract file + + cy.get('.controls') + .find('a.btn.btn-default') + .contains('New search', { matchCase: false }) + .click() + + cy.get('title') + .invoke('text') + .should('equal', 'TeMMPo: Search') + + cy.get('.form-group') + .find('a.btn.btn-primary') + .eq(0) + .contains('Upload OVID MEDLINE® formatted abstracts', { matchCase: false }) + .click() + + // Goes to the ovid medline abstract file upload page + + cy.get('title') + .invoke('text') + .should('equal', 'TeMMPo: Search Ovid MEDLINE®') + + cy.get('input[type=file]') + .selectFile('tests/test-abstract-ovid-test-sample-5.txt') + + cy.get('#upload_button') + .contains('Upload', { matchCase: false }) + .click() + + // We should be on the Select exposure MeSH® terms page + + cy.get('title') + .invoke('text') + .should('equal', 'TeMMPo: Select exposure MeSH® terms') + + // Lets add some exposure terms in the textarea, click add, then move on to mediators + + cy.get('#term_names').type('Public Health Systems Research;Humans'); + + cy.contains('Add', { matchCase: false }) + .click() + + cy.contains('Save and move on to select mediators', { matchCase: false }) + .click() + + // We should be on the Select mediator MeSH® terms page + + cy.get('title') + .invoke('text') + .should('equal', 'TeMMPo: Select mediator MeSH® terms') + + // Lets add terms in the textarea, click add, then move on to outcomes + + cy.get('#term_names').type('Genetic Markers; Penetrance'); + + cy.contains('Add', { matchCase: false }) + .click() + + cy.contains('Save and move on to select outcomes', { matchCase: false }) + .click() + + // We should be on the Select outcome MeSH® terms page + + cy.get('title') + .invoke('text') + .should('equal', 'TeMMPo: Select outcome MeSH® terms') + + // Lets add outcome term in the textarea, click add, move on to genes + + cy.get('#term_names').type('Neoplasm Metastasis;Eryptosis'); + + cy.contains('Add', { matchCase: false }) + .click() + + cy.contains('Save and move on to select Genes and Filters', { matchCase: false }) + .click() + + // We should be on the Select genes and filter page + + cy.get('title') + .invoke('text') + .should('equal', 'TeMMPo: Select genes and filter') + + // click the button to continue and get some results + + cy.get('button.btn.btn-primary') + .contains('Search', { matchCase: false }) + .click() + + // We should be on the my list of Results page + + cy.get('title') + .invoke('text') + .should('equal', 'TeMMPo: My list') + + // get the table and check it has the uploaded text file listed + + cy.get('table') + .eq(0) + .find('tr') + .eq(1) + .should('not.be.empty') + + // now we are gonna wait a minute... + + cy.wait(60000) + + // reload the page + + cy.reload() + + // this is where we will do the visualiations... + + + // select sankey chart + + cy.get('tbody') + .contains('View Sankey diagram') + .click() + + + // check sankey chart contains human....etc + + cy.get('#sankey_multiple') + .should('include.text', 'Humans') + .and('include.text', 'Genetic Markers') + .and('include.text', 'Public Health Systems Research') + + + // go back to results tab + + cy.get('#side-menu') + .contains('Results') + .click() + + cy.get('.page-header') + .should('have.text', 'Results') + + // select bubble chart + + cy.get('tbody') + .contains('View bubble chart') + .click() + + // should contain Genetic Markers on the page + + cy.get('#bubble_chart') + .should('include.text', 'Genetic Markers') + + + // thats the end of visualiations test, now lets delete the file we uploaded... + + // goto results tab... + + cy.get('#side-menu') + .contains('Results') + .click() + + cy.get('.page-header') + .should('have.text', 'Results') + + // find and click the delete button + + cy.get('.controls') + .find('a.btn.btn-danger.btn-sm') + .contains('Delete', { matchCase: false }) + .click({force:true}) + + // now check we go the the delete search page + + cy.get('title') + .invoke('text') + .should('equal', 'TeMMPo: Delete search') + + // find the delete search button and click it + + cy.get('input.btn.btn-danger') + .contains('Delete search', { matchCase: false }) + .click({force:true}) + + // now were redirected to the results page with an alert saying Search results deleted + + cy.get('title') + .invoke('text') + .should('equal', 'TeMMPo: My list') + + cy.get('.info') + .contains('Search results deleted', { matchCase: false }) + + + }) + +}); \ No newline at end of file diff --git a/cypress/integration/visualisations.js b/cypress/integration/visualisations.js deleted file mode 100644 index c5e90af0..00000000 --- a/cypress/integration/visualisations.js +++ /dev/null @@ -1,86 +0,0 @@ -describe('Checking visualiations', () => { - - if (Cypress.config("baseUrl") != "https://py-web-t0.epi.bris.ac.uk") { - - it('Click login link, verify on the right page then try to login to admin', () => { - cy.visit('/logout'); - cy.visit('/'); - cy.get('#side-menu') - .contains('Login') - .click() - cy.get('title') - .invoke('text') - .should('equal', 'TeMMPo: Login') - - cy.get('#id_username').type(Cypress.env('CREDENTIALS_USR')); - cy.get('#id_password').type(Cypress.env('CREDENTIALS_PSW')); - cy.get('button[type=submit]').click() - - cy.get('title') - .invoke('text') - .should('equal', 'TeMMPo: My list') - - // goto resuts tab - - cy.get('#side-menu') - .contains('Results') - .click() - - cy.get('.page-header') - .should('have.text', 'Results') - - - // select sankey chart - - cy.get('tbody') - .contains('View Sankey diagram') - .click() - - - // check sankey chart contains human....etc - - cy.get('#sankey_multiple') - .should('include.text', 'Humans') - .and('include.text', 'Genetic Markers') - .and('include.text', 'Public Health Systems Research') - - - // go back to results tab - - cy.get('#side-menu') - .contains('Results') - .click() - - cy.get('.page-header') - .should('have.text', 'Results') - - // select bubble chart - - cy.get('tbody') - .contains('View bubble chart') - .click() - - // should contain Genetic Markers on the page - - cy.get('#bubble_chart') - .should('include.text', 'Genetic Markers') - - // Let's logout now - - cy.get('#side-menu') - .contains('Logout') - .click() - cy.get('title') - .invoke('text') - .should('equal', 'TeMMPo: Login') - - - }) - } - else - { - it.skip('Click login link, verify on the right page then try to login to admin', () => { - // NB: Disabled for the test instance, as fixtures were only manually added to demo and prod vs part of a data migration. - }) - } -}); \ No newline at end of file