Skip to content

Commit

Permalink
CU-86bznyq73 - Browse-End-To-End-Testing
Browse files Browse the repository at this point in the history
  • Loading branch information
NyashaMuusha committed Jul 29, 2024
1 parent 0bcb57c commit d547f89
Show file tree
Hide file tree
Showing 7 changed files with 1,152 additions and 61 deletions.
1 change: 1 addition & 0 deletions JeMPI_Apps/JeMPI_UI/cypress.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export default defineConfig({
projectId: '35adzy',
e2e: {
baseUrl:'http://localhost:3001/',
defaultCommandTimeout: 10000,
setupNodeEvents(on, config) {
// implement node event listeners here
},
Expand Down
125 changes: 125 additions & 0 deletions JeMPI_Apps/JeMPI_UI/cypress/e2e/browseRecords.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,125 @@
/// <reference types="cypress" />

describe('Browse Records', () => {
beforeEach(() => {
cy.visit(
'/browse-records?isFetchingInteractions=false&parameters=%5B%5D&limit=25&offset=0&sortAsc=0&sortBy="auxDateCreated"'
)
})

const openRecordDetails = () => {
cy.get('.MuiDataGrid-row').first().dblclick()
}

describe('Page Header', () => {
it('should display the page header', () => {
cy.get('#page-header').contains('Browse Patients')
})
})

describe('Filters', () => {
beforeEach(() => {
cy.get('#panel1a-header').click()
cy.get('#panel1a-content').should('be.visible')
})

it('should expand and collapse the filter accordion', () => {
cy.get('#panel1a-header').click()
cy.get('#panel1a-content').should('not.be.visible')

cy.get('#panel1a-header').click()
cy.get('#panel1a-content').should('be.visible')
})

it('should display the start date filter', () => {
cy.get(
'#panel1a-content > div > div > div.MuiStack-root.css-uhybnf-MuiStack-root > div > div:nth-child(1) > div'
).should('be.visible')
})

it('should display the end date filter', () => {
cy.get(
'#panel1a-content > div > div > div.MuiStack-root.css-uhybnf-MuiStack-root > div > div:nth-child(2) > div'
).should('be.visible')
})

it('should toggle get interactions switch', () => {
cy.get('#interactions-switch').click()
cy.get(
'#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'
).should('be.checked')
})
})

describe('Search Results', () => {
it('should display search results in the data grid', () => {
cy.get('.MuiDataGrid-root').should('be.visible')
cy.get('.MuiDataGrid-row').should('have.length.at.least', 1)
})

it('should navigate to the record details page on row double-click', () => {
cy.get('.MuiDataGrid-row').first().dblclick()
cy.url().should('include', '/record-details/')
})
})
describe('Record Details Page', () => {
beforeEach(() => {
cy.visit('/browse-records')
openRecordDetails()
})

it('It navigates to the record details page when a row is double-clicked', () => {
cy.url().should('match', /\/record-details\/\w+/)
})

it('It displays the records table', () => {
cy.get('.MuiDataGrid-root').should('be.visible')
})

it('It displays the audit trail table', () => {
cy.get('.MuiDataGrid-root').eq(1).should('be.visible')
})
it('It enables the edit button when a record is selected', () => {
cy.get('.MuiDataGrid-row').first().click()
cy.get('button').contains('Edit').should('be.enabled')
})

it('It enables the save button when changes are made', () => {
cy.get('.MuiDataGrid-row').first().click()
cy.get('button').contains('Edit').click()
cy.get('.MuiDataGrid-cell').first().dblclick()
cy.get('button').contains('Save').should('be.enabled')
})

it('It discards changes when the cancel button is clicked', () => {
cy.get('.MuiDataGrid-row').first().click()
cy.get('button').contains('Edit').click()
cy.get('.MuiDataGrid-cell').first().dblclick()
cy.get('button').contains('Cancel').click()
cy.get('.MuiDataGrid-cell').first().should('not.contain', 'New value')
})

it('It enables relink button on row double click', () => {
openRecordDetails()
cy.get('.MuiDataGrid-row').eq(1).dblclick()
cy.get('button').contains('Relink')
cy.get('button').contains('Relink').click()
cy.contains('PATIENT LINKED TO GOLDEN RECORD').should('be.visible')
cy.pause()
})
})

describe('API Calls', () => {
beforeEach(() => {
cy.intercept('POST', '**/search', { fixture: 'searchResponse.json' }).as(
'searchQuery'
)
cy.visit('/browse-records')
})

it('It displays search results in the data grid', () => {
cy.get('.MuiDataGrid-root').should('be.visible')
cy.get('.MuiDataGrid-row').should('have.length.at.least', 1)
})
})
})
9 changes: 4 additions & 5 deletions JeMPI_Apps/JeMPI_UI/cypress/e2e/dashboard.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ describe('Dashboard Component', () => {
})
})


it('should render correctly with no data', () => {
// Mock the useDashboardData hook to return no data
cy.intercept('GET', '/api/dashboard-data', {
Expand All @@ -49,11 +48,11 @@ describe('Dashboard Component', () => {
}
}
})

// Visit the page and click on the dashboard tab
cy.visit('/')
cy.get('[id="dashboard-tab-0"]').click()

// Verify that the page renders correctly with no data
cy.get('#dashboard-tabpanel-0').within(() => {
cy.get('fieldset legend').contains('Records').should('be.visible')
Expand All @@ -64,8 +63,8 @@ describe('Dashboard Component', () => {

it('should display loading state correctly', () => {
// Mock the useDashboardData hook to simulate loading state
cy.intercept('GET', '/api/dashboard-data', (req) => {
req.on('response', (res) => {
cy.intercept('GET', '/api/dashboard-data', req => {
req.on('response', res => {
res.setDelay(1000)
})
})
Expand Down
94 changes: 49 additions & 45 deletions JeMPI_Apps/JeMPI_UI/cypress/e2e/notifications.cy.ts
Original file line number Diff line number Diff line change
@@ -1,71 +1,75 @@
describe('Notifications', () => {
beforeEach(() => {
cy.visit('/notifications');
});
cy.visit('/notifications')
})

describe('Page Header', () => {
it('should display the page header', () => {
cy.get('#page-header').should('contain.text', 'Notification Worklist');
});
});
cy.get('#page-header').should('contain.text', 'Notification Worklist')
})
})

describe('Filters', () => {
it('should display the start date filter', () => {
cy.contains('Start Date').should('be.visible');
});
cy.contains('Start Date').should('be.visible')
})

it('should display the end date filter', () => {
cy.contains('End Date').should('be.visible');
});
cy.contains('End Date').should('be.visible')
})

it('should display the states dropdown', () => {
cy.get('#single-chip').click();
cy.contains('ALL').click();
});
cy.get('#single-chip').click()
cy.contains('ALL').click()
})

it('should have the correct default selected value', () => {
cy.get('#single-chip').click();
cy.contains('OPEN').click({ force: true });
});
cy.get('#single-chip').click()
cy.contains('OPEN').click({ force: true })
})

it('should allow selecting an option', () => {
cy.get('#single-chip').click();
cy.contains('ALL').click();
});
cy.get('#single-chip').click()
cy.contains('ALL').click()
})

it('should not allow multiple selections', () => {
cy.get('#single-chip').click();
cy.contains('ALL').click();
cy.get('#single-chip').click();
cy.contains('CLOSED').click();
cy.get('#single-chip').find('span.MuiChip-label').should('contain.text', 'CLOSED');
});
});
cy.get('#single-chip').click()
cy.contains('ALL').click()
cy.get('#single-chip').click()
cy.contains('CLOSED').click()
cy.get('#single-chip')
.find('span.MuiChip-label')
.should('contain.text', 'CLOSED')
})
})

describe('Data Grid', () => {
it('should display the data grid', () => {
cy.contains('OPEN').should('be.visible');
});
cy.contains('OPEN').should('be.visible')
})

it('should display the pagination', () => {
cy.contains('Rows per page:').should('be.visible');
});
});

cy.contains('Rows per page:').should('be.visible')
})
})

describe('API Calls', () => {
beforeEach(() => {
cy.intercept("POST", "http://localhost:50000/JeMPI/notifications", { fixture: "notifications.json" }).as('getNotifications');
cy.visit("/notifications");
});

it("It mocks API response", () => {
cy.get('#notification-container').should('be.visible');
cy.get('#notification-container .MuiDataGrid-main .MuiDataGrid-virtualScroller .MuiDataGrid-row').should('exist');
cy.get('#notification-container .MuiDataGrid-main .MuiDataGrid-virtualScroller .MuiDataGrid-row').should('have.length',25);
});
});

});


cy.intercept('POST', 'http://localhost:50000/JeMPI/notifications', {
fixture: 'notifications.json'
}).as('getNotifications')
cy.visit('/notifications')
})

it('It mocks API response', () => {
cy.get('#notification-container').should('be.visible')
cy.get(
'#notification-container .MuiDataGrid-main .MuiDataGrid-virtualScroller .MuiDataGrid-row'
).should('exist')
cy.get(
'#notification-container .MuiDataGrid-main .MuiDataGrid-virtualScroller .MuiDataGrid-row'
).should('have.length', 25)
})
})
})
Loading

0 comments on commit d547f89

Please sign in to comment.