Skip to content

Commit

Permalink
cy wait 500
Browse files Browse the repository at this point in the history
  • Loading branch information
dgboss committed Nov 10, 2023
1 parent f64c267 commit 37544a8
Showing 1 changed file with 16 additions and 78 deletions.
94 changes: 16 additions & 78 deletions web/cypress/e2e/fire-behaviour-advisory-calculator-page.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,23 +24,14 @@ describe('FireBAT Calculator Page', () => {
wind_speed: parseFloat(windSpeed)
})
}).as('calculateResults')

visitAndAddRow()

cy.wait('@getStations')

cy.setFBAGrassCurePercentage(grassCure, 1)

cy.setFBAWindSpeed(windSpeed, 1)

cy.wait(500)

cy.selectFBAStationInDropdown(stationCode, 1)

cy.selectFBAFuelTypeInDropdown(fuelType.friendlyName, 1)

cy.wait('@calculateResults')

cy.rowCountShouldBe(1)
cy.url().should('contain', `s=${stationCode}&f=${fuelType.name.toLowerCase()}&c=${grassCure}&w=${windSpeed}`)
})
Expand All @@ -59,14 +50,11 @@ describe('FireBAT Calculator Page', () => {
describe('Dropdowns', () => {
it('Can select station if successfully received stations', () => {
cy.intercept('GET', 'api/stations/*', { fixture: 'weather-stations.json' }).as('getStations')

visitAndAddRow()

cy.wait('@getStations')
cy.wait(500)
const stationCode = 322
cy.wait(500)
cy.selectFBAStationInDropdown(stationCode, 1)

cy.rowCountShouldBe(1)
cy.url().should('contain', `s=${stationCode}`)
})
Expand All @@ -76,10 +64,9 @@ describe('FireBAT Calculator Page', () => {
visitAndAddRow()

cy.wait('@getStations')
cy.wait(500)
const fuelType = FuelTypes.get()['c1']
cy.wait(500)
cy.selectFBAFuelTypeInDropdown(fuelType.friendlyName, 1)

cy.rowCountShouldBe(1)
cy.url().should('contain', `f=${fuelType.name.toLowerCase()}`)
})
Expand All @@ -97,33 +84,25 @@ describe('FireBAT Calculator Page', () => {
crown_base_height: fuelType.crown_base_height
})
}).as('calculateResults')

visitAndAddRow()

cy.wait('@getStations')
cy.wait(500)
cy.selectFBAStationInDropdown(stationCode, 1)

cy.selectFBAFuelTypeInDropdown(fuelType.friendlyName, 1)

cy.rowCountShouldBe(1)
cy.url().should('contain', `s=${stationCode}&f=${fuelType.name.toLowerCase()}`)

cy.wait('@calculateResults')
})
it('Does not call backend when station and grass fuel type are set without grass cure percentage', () => {
cy.intercept('GET', 'api/stations/*', { fixture: 'weather-stations.json' }).as('getStations')
cy.intercept('POST', 'api/fba-calc/stations', _ => {
throw new Error('API request made without grass cure percentage set')
})

visitAndAddRow()

cy.wait('@getStations')
cy.wait(500)
const stationCode = 322
cy.wait(500)
cy.selectFBAStationInDropdown(stationCode, 1)

cy.selectFBAFuelTypeInDropdown(FuelTypes.get()['o1a'].friendlyName, 1)
cy.getByTestId(`fuel-type-dropdown-fba-1`).find('input').clear()
cy.selectFBAFuelTypeInDropdown(FuelTypes.get()['o1b'].friendlyName, 1)
Expand All @@ -142,73 +121,45 @@ describe('FireBAT Calculator Page', () => {
it('Disables remove row(s) button when table is empty', () => {
cy.intercept('GET', 'api/stations/*', { fixture: 'weather-stations.json' }).as('getStations')
cy.visit(FIRE_BEHAVIOR_CALC_ROUTE)

cy.getByTestId('remove-rows').should('have.class', 'Mui-disabled')
})

it('Enables remove row(s) button when table is not empty', () => {
cy.intercept('GET', 'api/stations/*', { fixture: 'weather-stations.json' }).as('getStations')

visitAndAddRow()

cy.wait('@getStations')

cy.getByTestId('fba-table-body').children().should('have.length', 1)

const stationCode = 322
cy.wait(500)
cy.selectFBAStationInDropdown(stationCode, 1)

cy.getByTestId('remove-rows').should('not.have.class', 'Mui-disabled')
})

it('Rows can be added and removed', () => {
cy.intercept('GET', 'api/stations/*', { fixture: 'weather-stations.json' }).as('getStations')

visitAndAddRow()

cy.wait('@getStations').then(interception => {
expect(interception.response.body.type).to.equal('FeatureCollection')
})

cy.getByTestId('fba-table-body').children().should('have.length', 1)

const stationCode = 322
cy.wait(500)
cy.selectFBAStationInDropdown(stationCode, 1)

cy.rowCountShouldBe(1)
cy.url().should('contain', `s=${stationCode}`)

cy.getByTestId('select-all').click()

cy.getByTestId('remove-rows').click()

cy.getByTestId('fba-instructions').should('be.visible')

cy.url().should('not.contain', `s=${stationCode}`)
})
it('Specific rows can be removed', () => {
cy.intercept('GET', 'api/stations/*', { fixture: 'weather-stations.json' }).as('getStations')

visitAndAddRow()

cy.wait('@getStations').then(interception => {
expect(interception.response.body.type).to.equal('FeatureCollection')
})

cy.getByTestId('fba-table-body').children().should('have.length', 1)

cy.wait('@getStations')
const stationCode = 322
cy.wait(500)
cy.selectFBAStationInDropdown(stationCode, 1)

cy.rowCountShouldBe(1)
cy.url().should('contain', `s=${stationCode}`)

cy.setSelectedRow()

cy.getByTestId('remove-rows').click()

cy.getByTestId('fba-instructions').should('be.visible')

cy.url().should('not.contain', `s=${stationCode}`)
})
})
Expand All @@ -217,10 +168,8 @@ describe('FireBAT Calculator Page', () => {
it('Disables the Export button when 0 rows are selected', () => {
cy.intercept('GET', 'api/stations/*', { fixture: 'weather-stations.json' }).as('getStations')
visitAndAddRow()
cy.wait('@getStations').then(interception => {
expect(interception.response.body.type).to.equal('FeatureCollection')
})
cy.getByTestId('fba-table-body').children().should('have.length', 1)
cy.wait('@getStations')
cy.wait(500)
cy.selectFBAStationInDropdown(322, 1)
cy.selectFBAFuelTypeInDropdown('C3', 1)
cy.getByTestId('export').should('be.visible')
Expand All @@ -230,10 +179,8 @@ describe('FireBAT Calculator Page', () => {
it('Enables the Export button once 1 or more rows are selected', () => {
cy.intercept('GET', 'api/stations/*', { fixture: 'weather-stations.json' }).as('getStations')
visitAndAddRow()
cy.wait('@getStations').then(interception => {
expect(interception.response.body.type).to.equal('FeatureCollection')
})
cy.getByTestId('fba-table-body').children().should('have.length', 1)
cy.wait('@getStations')
cy.wait(500)
cy.selectFBAStationInDropdown(322, 1)
cy.selectFBAFuelTypeInDropdown('C4', 1)
cy.getByTestId('select-all').click()
Expand All @@ -245,7 +192,6 @@ describe('FireBAT Calculator Page', () => {
it('Disables the Filter Columns dialog open button when 0 rows are in table', () => {
cy.intercept('GET', 'api/stations/*', { fixture: 'weather-stations.json' }).as('getStations')
cy.visit(FIRE_BEHAVIOR_CALC_ROUTE)

cy.getByTestId('filter-columns-btn').should('be.disabled')
})

Expand All @@ -254,18 +200,12 @@ describe('FireBAT Calculator Page', () => {
cy.intercept('POST', 'api/fba-calc/stations', {
fixture: 'fba-calc/322_209_response.json'
}).as('calculateResults')

visitAndAddRow()

cy.wait('@getStations').then(interception => {
expect(interception.response.body.type).to.equal('FeatureCollection')
})
cy.getByTestId('fba-table-body').children().should('have.length', 1)
cy.wait('@getStations')
cy.wait(500)
cy.selectFBAStationInDropdown(322, 1)
cy.selectFBAFuelTypeInDropdown('C4', 1)

cy.wait('@calculateResults')

cy.getByTestId('filter-columns-btn').should('be.enabled')
})

Expand All @@ -274,16 +214,14 @@ describe('FireBAT Calculator Page', () => {
cy.intercept('POST', 'api/fba-calc/stations', {
fixture: 'fba-calc/322_209_response.json'
}).as('calculateResults')

visitAndAddRow()
cy.wait('@getStations').then(interception => {
expect(interception.response.body.type).to.equal('FeatureCollection')
})
cy.getByTestId('fba-table-body').children().should('have.length', 1)
cy.wait('@getStations')
cy.wait(500)
cy.selectFBAStationInDropdown(322, 1)
cy.selectFBAFuelTypeInDropdown('C4', 1)

cy.getByTestId('add-row').click()
cy.wait(500)
cy.selectFBAStationInDropdown(209, 2)
cy.selectFBAFuelTypeInDropdown('C1', 2)

Expand Down

0 comments on commit 37544a8

Please sign in to comment.