Skip to content

Commit d547f89

Browse files
committed
CU-86bznyq73 - Browse-End-To-End-Testing
1 parent 0bcb57c commit d547f89

File tree

7 files changed

+1152
-61
lines changed

7 files changed

+1152
-61
lines changed

JeMPI_Apps/JeMPI_UI/cypress.config.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ export default defineConfig({
44
projectId: '35adzy',
55
e2e: {
66
baseUrl:'http://localhost:3001/',
7+
defaultCommandTimeout: 10000,
78
setupNodeEvents(on, config) {
89
// implement node event listeners here
910
},
Lines changed: 125 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
1+
/// <reference types="cypress" />
2+
3+
describe('Browse Records', () => {
4+
beforeEach(() => {
5+
cy.visit(
6+
'/browse-records?isFetchingInteractions=false&parameters=%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+
})

JeMPI_Apps/JeMPI_UI/cypress/e2e/dashboard.cy.ts

Lines changed: 4 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ describe('Dashboard Component', () => {
3939
})
4040
})
4141

42-
4342
it('should render correctly with no data', () => {
4443
// Mock the useDashboardData hook to return no data
4544
cy.intercept('GET', '/api/dashboard-data', {
@@ -49,11 +48,11 @@ describe('Dashboard Component', () => {
4948
}
5049
}
5150
})
52-
51+
5352
// Visit the page and click on the dashboard tab
5453
cy.visit('/')
5554
cy.get('[id="dashboard-tab-0"]').click()
56-
55+
5756
// Verify that the page renders correctly with no data
5857
cy.get('#dashboard-tabpanel-0').within(() => {
5958
cy.get('fieldset legend').contains('Records').should('be.visible')
@@ -64,8 +63,8 @@ describe('Dashboard Component', () => {
6463

6564
it('should display loading state correctly', () => {
6665
// Mock the useDashboardData hook to simulate loading state
67-
cy.intercept('GET', '/api/dashboard-data', (req) => {
68-
req.on('response', (res) => {
66+
cy.intercept('GET', '/api/dashboard-data', req => {
67+
req.on('response', res => {
6968
res.setDelay(1000)
7069
})
7170
})
Lines changed: 49 additions & 45 deletions
Original file line numberDiff line numberDiff line change
@@ -1,71 +1,75 @@
11
describe('Notifications', () => {
22
beforeEach(() => {
3-
cy.visit('/notifications');
4-
});
3+
cy.visit('/notifications')
4+
})
55

66
describe('Page Header', () => {
77
it('should display the page header', () => {
8-
cy.get('#page-header').should('contain.text', 'Notification Worklist');
9-
});
10-
});
8+
cy.get('#page-header').should('contain.text', 'Notification Worklist')
9+
})
10+
})
1111

1212
describe('Filters', () => {
1313
it('should display the start date filter', () => {
14-
cy.contains('Start Date').should('be.visible');
15-
});
14+
cy.contains('Start Date').should('be.visible')
15+
})
1616

1717
it('should display the end date filter', () => {
18-
cy.contains('End Date').should('be.visible');
19-
});
18+
cy.contains('End Date').should('be.visible')
19+
})
2020

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

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

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

3636
it('should not allow multiple selections', () => {
37-
cy.get('#single-chip').click();
38-
cy.contains('ALL').click();
39-
cy.get('#single-chip').click();
40-
cy.contains('CLOSED').click();
41-
cy.get('#single-chip').find('span.MuiChip-label').should('contain.text', 'CLOSED');
42-
});
43-
});
37+
cy.get('#single-chip').click()
38+
cy.contains('ALL').click()
39+
cy.get('#single-chip').click()
40+
cy.contains('CLOSED').click()
41+
cy.get('#single-chip')
42+
.find('span.MuiChip-label')
43+
.should('contain.text', 'CLOSED')
44+
})
45+
})
4446

4547
describe('Data Grid', () => {
4648
it('should display the data grid', () => {
47-
cy.contains('OPEN').should('be.visible');
48-
});
49+
cy.contains('OPEN').should('be.visible')
50+
})
4951

5052
it('should display the pagination', () => {
51-
cy.contains('Rows per page:').should('be.visible');
52-
});
53-
});
54-
53+
cy.contains('Rows per page:').should('be.visible')
54+
})
55+
})
5556

5657
describe('API Calls', () => {
5758
beforeEach(() => {
58-
cy.intercept("POST", "http://localhost:50000/JeMPI/notifications", { fixture: "notifications.json" }).as('getNotifications');
59-
cy.visit("/notifications");
60-
});
61-
62-
it("It mocks API response", () => {
63-
cy.get('#notification-container').should('be.visible');
64-
cy.get('#notification-container .MuiDataGrid-main .MuiDataGrid-virtualScroller .MuiDataGrid-row').should('exist');
65-
cy.get('#notification-container .MuiDataGrid-main .MuiDataGrid-virtualScroller .MuiDataGrid-row').should('have.length',25);
66-
});
67-
});
68-
69-
});
70-
71-
59+
cy.intercept('POST', 'http://localhost:50000/JeMPI/notifications', {
60+
fixture: 'notifications.json'
61+
}).as('getNotifications')
62+
cy.visit('/notifications')
63+
})
64+
65+
it('It mocks API response', () => {
66+
cy.get('#notification-container').should('be.visible')
67+
cy.get(
68+
'#notification-container .MuiDataGrid-main .MuiDataGrid-virtualScroller .MuiDataGrid-row'
69+
).should('exist')
70+
cy.get(
71+
'#notification-container .MuiDataGrid-main .MuiDataGrid-virtualScroller .MuiDataGrid-row'
72+
).should('have.length', 25)
73+
})
74+
})
75+
})

0 commit comments

Comments
 (0)