From 8b8fdac79140e7deb1d97a0bf84cc592a73bf571 Mon Sep 17 00:00:00 2001 From: Daniel Haselhan Date: Mon, 9 Dec 2024 16:36:03 -0800 Subject: [PATCH] feat: Expand Compliance Report Test * Now include checking rounding on line 6, submitting the report, and checking the IDIR can see it --- .../ComplianceReport/ComplianceReport.test.js | 44 ++++++++++++++++++- .../ComplianceReportManagement.feature | 17 +++++-- .../e2e/Pages/User/UserCreation.test.js | 42 +++++++++--------- frontend/cypress/e2e/accessibility.cy.js | 2 +- frontend/cypress/e2e/add__edit_org.cy.js | 2 +- frontend/cypress/e2e/disclaimer_banner.cy.js | 4 +- frontend/cypress/e2e/organization.cy.js | 2 +- frontend/cypress/e2e/user_flow.cy.js | 10 ++--- 8 files changed, 87 insertions(+), 36 deletions(-) diff --git a/frontend/cypress/e2e/Pages/ComplianceReport/ComplianceReport.test.js b/frontend/cypress/e2e/Pages/ComplianceReport/ComplianceReport.test.js index e175c8f20..8e92fff86 100644 --- a/frontend/cypress/e2e/Pages/ComplianceReport/ComplianceReport.test.js +++ b/frontend/cypress/e2e/Pages/ComplianceReport/ComplianceReport.test.js @@ -2,7 +2,7 @@ import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor' const currentYear = new Date().getFullYear().toString() -Given('the supplier is on the login page', () => { +Given('the user is on the login page', () => { cy.clearAllCookies() cy.clearAllLocalStorage() cy.clearAllSessionStorage() @@ -20,7 +20,7 @@ When('the supplier logs in with valid credentials', () => { cy.getByDataTest('dashboard-container').should('exist') }) -When('the supplier navigates to the compliance reports page', () => { +When('they navigate to the compliance reports page', () => { cy.get('a[href="/compliance-reporting"]').click() }) @@ -140,3 +140,43 @@ Then('the compliance report summary includes the quantity', () => { .should('be.visible') .and('have.text', '500') }) + +When('the supplier fills out line 6', () => { + cy.get( + '[data-test="renewable-summary"] > .MuiTable-root > .MuiTableBody-root > :nth-child(6) > :nth-child(3)' + ) + .find('input') + .type('50{enter}') + .blur() +}) + +Then('it should round the amount to 25', () => { + cy.get( + '[data-test="renewable-summary"] > .MuiTable-root > .MuiTableBody-root > :nth-child(6) > :nth-child(3)' + ) + .find('input') + .should('be.visible') + .and('have.value', '25') +}) + +When('the supplier accepts the agreement', () => { + cy.get('#signing-authority-declaration').click() +}) + +When('the supplier submits the report', () => { + cy.contains('button', 'Submit report').click() + cy.get('#modal-btn-submit-report').click() + cy.wait(2000) +}) + +Then('the status should change to Submitted', () => { + cy.get('[data-test="compliance-report-status"]') + .should('be.visible') + .and('have.text', 'Status: Submitted') +}) + +Then('they see the previously submitted report', () => { + cy.get('.ag-column-first > a > .MuiBox-root') + .should('be.visible') + .and('have.text', currentYear) +}) diff --git a/frontend/cypress/e2e/Pages/ComplianceReport/ComplianceReportManagement.feature b/frontend/cypress/e2e/Pages/ComplianceReport/ComplianceReportManagement.feature index a0e9c1975..501cf3790 100644 --- a/frontend/cypress/e2e/Pages/ComplianceReport/ComplianceReportManagement.feature +++ b/frontend/cypress/e2e/Pages/ComplianceReport/ComplianceReportManagement.feature @@ -1,12 +1,23 @@ Feature: Compliance Report Management Scenario: Supplier saves a draft compliance report - Given the supplier is on the login page - When the supplier logs in with valid credentials - And the supplier navigates to the compliance reports page + Given the user is on the login page + And the supplier logs in with valid credentials + And they navigate to the compliance reports page And the supplier creates a new compliance report Then the compliance report introduction is shown When the supplier navigates to the fuel supply page And the supplier enters a valid fuel supply row And saves and returns to the report Then the compliance report summary includes the quantity + When the supplier fills out line 6 + Then it should round the amount to 25 + When the supplier accepts the agreement + And the supplier submits the report + Then the status should change to Submitted + + Scenario: Analyst logs in to review a compliance report + Given the user is on the login page + And the analyst logs in with valid credentials + And they navigate to the compliance reports page + Then they see the previously submitted report \ No newline at end of file diff --git a/frontend/cypress/e2e/Pages/User/UserCreation.test.js b/frontend/cypress/e2e/Pages/User/UserCreation.test.js index bf9b8ff25..079dd77a6 100644 --- a/frontend/cypress/e2e/Pages/User/UserCreation.test.js +++ b/frontend/cypress/e2e/Pages/User/UserCreation.test.js @@ -25,39 +25,39 @@ When('the IDIR user logs in with valid credentials', () => { }) When('the IDIR user navigates to the user creation page', () => { - cy.get('a[href="/admin"]').click() - cy.url().should('include', '/admin/users') - cy.contains('New user').click() - cy.url().should('include', '/admin/users/add-user') + cy.get('a[href="/admin"]').click() + cy.url().should('include', '/admin/users') + cy.contains('New user').click() + cy.url().should('include', '/admin/users/add-user') }) When('the IDIR user fills out the form with valid data', () => { - cy.get('input[id="firstName"]').type('John') - cy.get('input[id="lastName"]').type('Doe') - cy.get('input[id="jobTitle"]').type('Senior Analyst') - cy.get('input[id="userName"]').type('johndoe') - cy.get('input[id="keycloakEmail"]').type('john.doe@example.com') - cy.get('input[id="phone"]').type('1234567890') - cy.get('input[id="mobilePhone"]').type('0987654321') + cy.get('input[id="firstName"]').type('John') + cy.get('input[id="lastName"]').type('Doe') + cy.get('input[id="jobTitle"]').type('Senior Analyst') + cy.get('input[id="userName"]').type('johndoe') + cy.get('input[id="keycloakEmail"]').type('john.doe@example.com') + cy.get('input[id="phone"]').type('1234567890') + cy.get('input[id="mobilePhone"]').type('0987654321') - // Select the Analyst role - cy.get('input[type="radio"][value="analyst"]').check() + // Select the Analyst role + cy.get('input[type="radio"][value="analyst"]').check() }) When('the IDIR user submits the form', () => { - cy.get('button[data-test="saveUser"]').click() + cy.get('button[data-test="saveUser"]').click() }) Then('a success message is displayed', () => { - cy.get("[data-test='alert-box'] .MuiBox-root").should( - 'contain', - 'User has been successfully saved.' - ) + cy.get("[data-test='alert-box'] .MuiBox-root").should( + 'contain', + 'User has been successfully saved.' + ) }) Then('the new user appears in the user list', () => { - cy.visit('/admin/users') - cy.contains('a', Cypress.env('john.doe@example.com')).should('be.visible') + cy.visit('/admin/users') + cy.contains('a', Cypress.env('john.doe@example.com')).should('be.visible') }) // Test for validation error @@ -75,7 +75,7 @@ When('the IDIR user fills out the form with invalid data', () => { }) Then('an error message is displayed for validation', () => { - cy.get('#userName-helper-text').should('contain', 'User name is required') + cy.get('#userName-helper-text').should('contain', 'User name is required') }) // Cleanup after the test diff --git a/frontend/cypress/e2e/accessibility.cy.js b/frontend/cypress/e2e/accessibility.cy.js index 4c44b2543..44147beff 100644 --- a/frontend/cypress/e2e/accessibility.cy.js +++ b/frontend/cypress/e2e/accessibility.cy.js @@ -18,7 +18,7 @@ describe('Accessibility Tests for LCFS', () => { it('Should have no accessibility violations in the navigation bar', () => { cy.visit('/') cy.injectAxe() - cy.login( + cy.loginWith( 'idir', Cypress.env('IDIR_TEST_USER'), Cypress.env('IDIR_TEST_PASS') diff --git a/frontend/cypress/e2e/add__edit_org.cy.js b/frontend/cypress/e2e/add__edit_org.cy.js index 1cd1e136e..1a714ee3f 100644 --- a/frontend/cypress/e2e/add__edit_org.cy.js +++ b/frontend/cypress/e2e/add__edit_org.cy.js @@ -6,7 +6,7 @@ describe('Add Organization Test Suite', () => { beforeEach(() => { - cy.login( + cy.loginWith( 'idir', Cypress.env('IDIR_TEST_USER'), Cypress.env('IDIR_TEST_PASS') diff --git a/frontend/cypress/e2e/disclaimer_banner.cy.js b/frontend/cypress/e2e/disclaimer_banner.cy.js index 363cc207a..ded9a66a4 100644 --- a/frontend/cypress/e2e/disclaimer_banner.cy.js +++ b/frontend/cypress/e2e/disclaimer_banner.cy.js @@ -5,7 +5,7 @@ describe('Disclaimer Banner Visibility Test Suite', () => { context('BCeID User', () => { beforeEach(() => { - cy.login( + cy.loginWith( 'bceid', Cypress.env('BCEID_TEST_USER'), Cypress.env('BCEID_TEST_PASS') @@ -29,7 +29,7 @@ describe('Disclaimer Banner Visibility Test Suite', () => { context('IDIR User', () => { beforeEach(() => { - cy.login( + cy.loginWith( 'idir', Cypress.env('IDIR_TEST_USER'), Cypress.env('IDIR_TEST_PASS') diff --git a/frontend/cypress/e2e/organization.cy.js b/frontend/cypress/e2e/organization.cy.js index 4ca2e7f38..2ac742e9b 100644 --- a/frontend/cypress/e2e/organization.cy.js +++ b/frontend/cypress/e2e/organization.cy.js @@ -5,7 +5,7 @@ describe('Organization Test Suite', () => { beforeEach(() => { // Login and visit the page - cy.login( + cy.loginWith( 'idir', Cypress.env('IDIR_TEST_USER'), Cypress.env('IDIR_TEST_PASS') diff --git a/frontend/cypress/e2e/user_flow.cy.js b/frontend/cypress/e2e/user_flow.cy.js index e99dde6be..233823650 100644 --- a/frontend/cypress/e2e/user_flow.cy.js +++ b/frontend/cypress/e2e/user_flow.cy.js @@ -28,12 +28,12 @@ describe('User Login Test Suite', () => { describe('IDIR Login Flow', () => { it('fails login with wrong IDIR user credentials', () => { - cy.login('idir', 'wrong_username', 'wrong_password') + cy.loginWith('idir', 'wrong_username', 'wrong_password') cy.getByDataTest('main-layout-navbar').should('not.exist') }) it('completes login with IDIR user credentials', () => { - cy.login( + cy.loginWith( 'idir', Cypress.env('IDIR_TEST_USER'), Cypress.env('IDIR_TEST_PASS') @@ -42,7 +42,7 @@ describe('User Login Test Suite', () => { }) it('executes logout functionality for IDIR user', () => { - cy.login( + cy.loginWith( 'idir', Cypress.env('IDIR_TEST_USER'), Cypress.env('IDIR_TEST_PASS') @@ -53,12 +53,12 @@ describe('User Login Test Suite', () => { describe('BCeID Login Flow', () => { it('fails login with wrong BCeID user credentials', () => { - cy.login('bceid', 'wrong_username', 'wrong_password') + cy.loginWith('bceid', 'wrong_username', 'wrong_password') cy.getByDataTest('main-layout-navbar').should('not.exist') }) it('completes login with BCeID user credentials', () => { - cy.login( + cy.loginWith( 'bceid', Cypress.env('BCEID_TEST_USER'), Cypress.env('BCEID_TEST_PASS')