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 19 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
18 changes: 18 additions & 0 deletions JeMPI_Apps/JeMPI_UI/cypress.config.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
import { defineConfig } from "cypress";

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

component: {
devServer: {
framework: "create-react-app",
bundler: "webpack",
},
},
});
85 changes: 85 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,85 @@
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()
})
})
8 changes: 8 additions & 0 deletions JeMPI_Apps/JeMPI_UI/cypress/e2e/mock_notifications.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
describe('it mocks fetch notifications',()=>{
it.only('checks api call', () => {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Remove it.only to ensure all tests are executed.

The it.only method is often used for debugging or during implementation. It should be removed before deploying to production to ensure that all tests are executed.

- it.only('checks api call', () => {
+ it('checks api call', () => {
Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
it.only('checks api call', () => {
it('checks api call', () => {
Tools
Biome

[error] 2-2: Don't focus the test.

The 'only' method is often used for debugging or during implementation. It should be removed before deploying to production.
Consider removing 'only' to ensure all tests are executed.
Unsafe fix: Remove focus from test.

(lint/suspicious/noFocusedTests)

cy.populateData()
cy.wait('@fetchNotifications') // wait for the intercept to finish
cy.get('[data-cy=item-list]').should('contain', 'Bob Smith');
})

})
71 changes: 71 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,71 @@
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.get('#start-date-filter').should('be.visible');
});

it('should display the end date filter', () => {
cy.get('#end-date-filter').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.get('.MuiDataGrid-root').should('be.visible');
});

it('should display the pagination', () => {
cy.get('.MuiPagination-root').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