Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Cu 86bznypcf notifications end to end testing #287

Open
wants to merge 24 commits into
base: dev
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
24 commits
Select commit Hold shift + click to select a range
4ab535f
create end-to-end test for Dashboard,add tsconfig.build.json, updated…
NyashaMuusha Jul 22, 2024
d0db719
updated dependencies
NyashaMuusha Jul 22, 2024
91dad36
removed example
NyashaMuusha Jul 23, 2024
989a4cb
updated dependencies
NyashaMuusha Jul 23, 2024
b72acd7
added id to page header
NyashaMuusha Jul 23, 2024
af741cf
added notification worklist tests
NyashaMuusha Jul 23, 2024
51698cc
fetch config api call
NyashaMuusha Jul 23, 2024
8e376ad
refactored fetch notifications
NyashaMuusha Jul 24, 2024
e5a5e1d
Merge remote-tracking branch 'upstream/dev' into CU-86bznypcf_Notific…
NyashaMuusha Jul 24, 2024
047eb29
updated config file
NyashaMuusha Jul 25, 2024
7d57c07
updated dependencies
NyashaMuusha Jul 25, 2024
b0d53a2
updated tsconfig file
NyashaMuusha Jul 25, 2024
c4a5a6d
added mock data
NyashaMuusha Jul 25, 2024
7e212e1
added id to data grid container, updated tests in notifications
NyashaMuusha Jul 25, 2024
930df4a
Merge branch 'dev' into CU-86bznypcf_Notifications-End-To-End-Testing
NyashaMuusha Jul 25, 2024
b6a6476
Merge branch 'dev' into CU-86bznypcf_Notifications-End-To-End-Testing
NyashaMuusha Jul 26, 2024
0bf10b6
Merge remote-tracking branch 'upstream/CU-86bznvd1v_Dashboard-End-To-…
NyashaMuusha Jul 26, 2024
f6ce941
updated notification automation test
NyashaMuusha Jul 26, 2024
ccd2df1
Merge remote-tracking branch 'upstream/CU-86bznypcf_Notifications-End…
NyashaMuusha Jul 26, 2024
0bcb57c
updated notification filter tests
NyashaMuusha Jul 29, 2024
d547f89
CU-86bznyq73 - Browse-End-To-End-Testing
NyashaMuusha Jul 29, 2024
67b2966
Merge branch 'dev' into CU-86bznypcf_Notifications-End-To-End-Testing
NyashaMuusha Jul 29, 2024
c14e8a2
Merge branch 'dev' into CU-86bznypcf_Notifications-End-To-End-Testing
NyashaMuusha Jul 29, 2024
f77c89c
updated imports
NyashaMuusha Aug 8, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions JeMPI_Apps/JeMPI_UI/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { defineConfig } from "cypress";

export default defineConfig({
projectId: '35adzy',
e2e: {
baseUrl:'http://localhost:3001/',
defaultCommandTimeout: 10000,
setupNodeEvents(on, config) {
// implement node event listeners here
},
},

component: {
devServer: {
framework: "create-react-app",
bundler: "webpack",
},
},
});
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)
})
})
})
84 changes: 84 additions & 0 deletions JeMPI_Apps/JeMPI_UI/cypress/e2e/dashboard.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
describe('Dashboard Component', () => {
beforeEach(() => {
cy.visit('/')
})

it('should display the dashboard tabs', () => {
cy.get('[aria-label="dashboard tabs"]').should('be.visible')
})

it('should navigate through tabs', () => {
// Check initial tab (Confusion Matrix)
cy.get('[id="dashboard-tab-0"]').click()
cy.get('#dashboard-tabpanel-0').should('be.visible')

// Switch to M & U Values tab
cy.get('[id="dashboard-tab-1"]').click()
cy.get('#dashboard-tabpanel-1').should('be.visible')
cy.get('#dashboard-tabpanel-0').should('not.be.visible')

// Switch to Import Process Status tab
cy.get('[id="dashboard-tab-2"]').click()
cy.get('#dashboard-tabpanel-2').should('be.visible')
cy.get('#dashboard-tabpanel-1').should('not.be.visible')
})

it('should display widgets in Confusion Matrix tab', () => {
cy.get('[id="dashboard-tab-0"]').click()
cy.get('#dashboard-tabpanel-0').within(() => {
cy.get('fieldset legend').contains('Records').should('be.visible')
cy.get('fieldset legend').contains('Notifications').should('be.visible')
cy.get('legend').contains('Confusion Matrix').should('be.visible')
})
})

it('should display M & U widget in M & U Values tab', () => {
cy.get('[id="dashboard-tab-1"]').click()
cy.get('#dashboard-tabpanel-1').within(() => {
cy.get('legend').contains('M & U Values').should('be.visible')
})
})

it('should render correctly with no data', () => {
// Mock the useDashboardData hook to return no data
cy.intercept('GET', '/api/dashboard-data', {
body: {
data: {
dashboardData: {}
}
}
})

// 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')
cy.get('fieldset legend').contains('Notifications').should('be.visible')
cy.get('legend').contains('Confusion Matrix').should('be.visible')
})
})

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 => {
res.setDelay(1000)
})
})
cy.visit('/')
cy.get('[id="dashboard-tab-0"]').click()
})

it('should handle API errors', () => {
// Mock the useDashboardData hook to return an error
cy.intercept('GET', '/api/dashboard-data', {
statusCode: 500,
body: { error: 'Internal Server Error' }
})
cy.visit('/')
cy.get('[id="dashboard-tab-0"]').click()
})
})
75 changes: 75 additions & 0 deletions JeMPI_Apps/JeMPI_UI/cypress/e2e/notifications.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,75 @@
describe('Notifications', () => {
beforeEach(() => {
cy.visit('/notifications')
})

describe('Page Header', () => {
it('should display the page header', () => {
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')
})

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

it('should display the states dropdown', () => {
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 })
})

it('should allow selecting an option', () => {
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')
})
})

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

it('should display the pagination', () => {
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)
})
})
})
Loading