Skip to content

Commit

Permalink
feat: Expand Compliance Report Test
Browse files Browse the repository at this point in the history
* Now include checking rounding on line 6, submitting the report, and checking the IDIR can see it
  • Loading branch information
dhaselhan committed Dec 10, 2024
1 parent 1c422d3 commit 8b8fdac
Show file tree
Hide file tree
Showing 8 changed files with 87 additions and 36 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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()
})

Expand Down Expand Up @@ -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)
})
Original file line number Diff line number Diff line change
@@ -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
42 changes: 21 additions & 21 deletions frontend/cypress/e2e/Pages/User/UserCreation.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -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('[email protected]')
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('[email protected]')
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('[email protected]')).should('be.visible')
cy.visit('/admin/users')
cy.contains('a', Cypress.env('[email protected]')).should('be.visible')
})

// Test for validation error
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion frontend/cypress/e2e/accessibility.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion frontend/cypress/e2e/add__edit_org.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
4 changes: 2 additions & 2 deletions frontend/cypress/e2e/disclaimer_banner.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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')
Expand Down
2 changes: 1 addition & 1 deletion frontend/cypress/e2e/organization.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand Down
10 changes: 5 additions & 5 deletions frontend/cypress/e2e/user_flow.cy.js
Original file line number Diff line number Diff line change
Expand Up @@ -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')
Expand All @@ -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')
Expand All @@ -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')
Expand Down

0 comments on commit 8b8fdac

Please sign in to comment.