|
| 1 | +/// <reference types="cypress" /> |
| 2 | + |
| 3 | +describe('Browse Records', () => { |
| 4 | + beforeEach(() => { |
| 5 | + cy.visit( |
| 6 | + '/browse-records?isFetchingInteractions=false¶meters=%5B%5D&limit=25&offset=0&sortAsc=0&sortBy="auxDateCreated"' |
| 7 | + ) |
| 8 | + }) |
| 9 | + |
| 10 | + const openRecordDetails = () => { |
| 11 | + cy.get('.MuiDataGrid-row').first().dblclick() |
| 12 | + } |
| 13 | + |
| 14 | + describe('Page Header', () => { |
| 15 | + it('should display the page header', () => { |
| 16 | + cy.get('#page-header').contains('Browse Patients') |
| 17 | + }) |
| 18 | + }) |
| 19 | + |
| 20 | + describe('Filters', () => { |
| 21 | + beforeEach(() => { |
| 22 | + cy.get('#panel1a-header').click() |
| 23 | + cy.get('#panel1a-content').should('be.visible') |
| 24 | + }) |
| 25 | + |
| 26 | + it('should expand and collapse the filter accordion', () => { |
| 27 | + cy.get('#panel1a-header').click() |
| 28 | + cy.get('#panel1a-content').should('not.be.visible') |
| 29 | + |
| 30 | + cy.get('#panel1a-header').click() |
| 31 | + cy.get('#panel1a-content').should('be.visible') |
| 32 | + }) |
| 33 | + |
| 34 | + it('should display the start date filter', () => { |
| 35 | + cy.get( |
| 36 | + '#panel1a-content > div > div > div.MuiStack-root.css-uhybnf-MuiStack-root > div > div:nth-child(1) > div' |
| 37 | + ).should('be.visible') |
| 38 | + }) |
| 39 | + |
| 40 | + it('should display the end date filter', () => { |
| 41 | + cy.get( |
| 42 | + '#panel1a-content > div > div > div.MuiStack-root.css-uhybnf-MuiStack-root > div > div:nth-child(2) > div' |
| 43 | + ).should('be.visible') |
| 44 | + }) |
| 45 | + |
| 46 | + it('should toggle get interactions switch', () => { |
| 47 | + cy.get('#interactions-switch').click() |
| 48 | + cy.get( |
| 49 | + '#interactions-switch > span.MuiSwitch-root.MuiSwitch-sizeMedium.css-julti5-MuiSwitch-root > span.MuiButtonBase-root.MuiSwitch-switchBase.MuiSwitch-colorPrimary.Mui-checked.PrivateSwitchBase-root.MuiSwitch-switchBase.MuiSwitch-colorPrimary.Mui-checked.Mui-checked.css-byenzh-MuiButtonBase-root-MuiSwitch-switchBase > input' |
| 50 | + ).should('be.checked') |
| 51 | + }) |
| 52 | + }) |
| 53 | + |
| 54 | + describe('Search Results', () => { |
| 55 | + it('should display search results in the data grid', () => { |
| 56 | + cy.get('.MuiDataGrid-root').should('be.visible') |
| 57 | + cy.get('.MuiDataGrid-row').should('have.length.at.least', 1) |
| 58 | + }) |
| 59 | + |
| 60 | + it('should navigate to the record details page on row double-click', () => { |
| 61 | + cy.get('.MuiDataGrid-row').first().dblclick() |
| 62 | + cy.url().should('include', '/record-details/') |
| 63 | + }) |
| 64 | + }) |
| 65 | + describe('Record Details Page', () => { |
| 66 | + beforeEach(() => { |
| 67 | + cy.visit('/browse-records') |
| 68 | + openRecordDetails() |
| 69 | + }) |
| 70 | + |
| 71 | + it('It navigates to the record details page when a row is double-clicked', () => { |
| 72 | + cy.url().should('match', /\/record-details\/\w+/) |
| 73 | + }) |
| 74 | + |
| 75 | + it('It displays the records table', () => { |
| 76 | + cy.get('.MuiDataGrid-root').should('be.visible') |
| 77 | + }) |
| 78 | + |
| 79 | + it('It displays the audit trail table', () => { |
| 80 | + cy.get('.MuiDataGrid-root').eq(1).should('be.visible') |
| 81 | + }) |
| 82 | + it('It enables the edit button when a record is selected', () => { |
| 83 | + cy.get('.MuiDataGrid-row').first().click() |
| 84 | + cy.get('button').contains('Edit').should('be.enabled') |
| 85 | + }) |
| 86 | + |
| 87 | + it('It enables the save button when changes are made', () => { |
| 88 | + cy.get('.MuiDataGrid-row').first().click() |
| 89 | + cy.get('button').contains('Edit').click() |
| 90 | + cy.get('.MuiDataGrid-cell').first().dblclick() |
| 91 | + cy.get('button').contains('Save').should('be.enabled') |
| 92 | + }) |
| 93 | + |
| 94 | + it('It discards changes when the cancel button is clicked', () => { |
| 95 | + cy.get('.MuiDataGrid-row').first().click() |
| 96 | + cy.get('button').contains('Edit').click() |
| 97 | + cy.get('.MuiDataGrid-cell').first().dblclick() |
| 98 | + cy.get('button').contains('Cancel').click() |
| 99 | + cy.get('.MuiDataGrid-cell').first().should('not.contain', 'New value') |
| 100 | + }) |
| 101 | + |
| 102 | + it('It enables relink button on row double click', () => { |
| 103 | + openRecordDetails() |
| 104 | + cy.get('.MuiDataGrid-row').eq(1).dblclick() |
| 105 | + cy.get('button').contains('Relink') |
| 106 | + cy.get('button').contains('Relink').click() |
| 107 | + cy.contains('PATIENT LINKED TO GOLDEN RECORD').should('be.visible') |
| 108 | + cy.pause() |
| 109 | + }) |
| 110 | + }) |
| 111 | + |
| 112 | + describe('API Calls', () => { |
| 113 | + beforeEach(() => { |
| 114 | + cy.intercept('POST', '**/search', { fixture: 'searchResponse.json' }).as( |
| 115 | + 'searchQuery' |
| 116 | + ) |
| 117 | + cy.visit('/browse-records') |
| 118 | + }) |
| 119 | + |
| 120 | + it('It displays search results in the data grid', () => { |
| 121 | + cy.get('.MuiDataGrid-root').should('be.visible') |
| 122 | + cy.get('.MuiDataGrid-row').should('have.length.at.least', 1) |
| 123 | + }) |
| 124 | + }) |
| 125 | +}) |
0 commit comments