Skip to content

Commit

Permalink
Merge pull request #1382 from bcgov/feat/daniel-add-compliance-report…
Browse files Browse the repository at this point in the history
…-cy-1344

feat: Add Report Creation Test
  • Loading branch information
dhaselhan authored Dec 6, 2024
2 parents da88e9f + 6232bf1 commit 5e0a115
Show file tree
Hide file tree
Showing 3 changed files with 73 additions and 1 deletion.
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
import { Given, When, Then } from '@badeball/cypress-cucumber-preprocessor'

const currentYear = new Date().getFullYear().toString()

Given('the supplier is on the login page', () => {
cy.clearAllCookies()
cy.clearAllLocalStorage()
cy.clearAllSessionStorage()
cy.visit('/')
cy.getByDataTest('login-container').should('exist')
})

When('the supplier logs in with valid credentials', () => {
cy.loginWith(
'becid',
Cypress.env('BCEID_TEST_USER'),
Cypress.env('BCEID_TEST_PASS')
)
cy.visit('/')
cy.getByDataTest('dashboard-container').should('exist')
})

When('the supplier navigates to the compliance reports page', () => {
cy.get('a[href="/compliance-reporting"]').click()
})

When('the supplier creates a new compliance report', () => {
cy.get('.MuiStack-root > :nth-child(1) > .MuiButtonBase-root').click()
// Select and click the current year button
cy.contains('.MuiList-root li', currentYear).click()
})

Then('the compliance report introduction is shown', () => {
// Assert the header
cy.get('[data-test="compliance-report-header"]')
.should('be.visible')
.and('have.text', `${currentYear} Compliance report - Original Report`)

// Assert the status
cy.get('[data-test="compliance-report-status"]')
.should('be.visible')
.and('have.text', 'Status: Draft')

// Assert the Introduction Header
cy.contains('div.MuiTypography-h5', 'Introduction')
.should('be.visible')
.and('have.text', 'Introduction')

// Assert the Welcome Message
cy.contains(
'h6',
'Welcome to the British Columbia Low Carbon Fuel Standard Portal'
)
.should('be.visible')
.and(
'have.text',
'Welcome to the British Columbia Low Carbon Fuel Standard Portal'
)
})
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
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
And the supplier creates a new compliance report
Then the compliance report introduction is shown
Original file line number Diff line number Diff line change
Expand Up @@ -180,14 +180,19 @@ export const EditViewComplianceReport = () => {
data={modalData}
/>
<BCBox pb={2}>
<Typography variant="h5" color="primary">
<Typography
data-test="compliance-report-header"
variant="h5"
color="primary"
>
{compliancePeriod + ' ' + t('report:complianceReport')} -{' '}
{reportData?.report.nickname}
</Typography>
<Typography
variant="h6"
color="primary"
style={{ marginLeft: '0.25rem' }}
data-test="compliance-report-status"
>
Status: {currentStatus}
</Typography>
Expand Down

0 comments on commit 5e0a115

Please sign in to comment.