-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: dashboard crashes if an item is missing type [TECH-588] (#1812)
One character fix in itemTypes.js The rest is support for new cypress tests that mock a request with missing or unrecognized item types. Look at view_errors.feature for a summary of what the new new cypress tests do. Some cypress changes are just moving functions to common so that all tests can access the function
- Loading branch information
1 parent
e732862
commit a200395
Showing
13 changed files
with
161 additions
and
48 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
import { When } from 'cypress-cucumber-preprocessor/steps' | ||
import { clickViewActionButton } from '../../../elements/viewDashboard' | ||
|
||
When('I click to preview the print layout', () => { | ||
clickViewActionButton('More') | ||
cy.get('[data-test="print-menu-item"]').click() | ||
cy.get('[data-test="print-layout-menu-item"]').click() | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
import { Then } from 'cypress-cucumber-preprocessor/steps' | ||
import { dashboards } from '../../../assets/backends/sierraLeone_236' | ||
|
||
Then('the print layout displays for {string} dashboard', title => { | ||
//check the url | ||
cy.location().should(loc => { | ||
expect(loc.hash).to.equal(`${dashboards[title].route}/printlayout`) | ||
}) | ||
|
||
//check for some elements | ||
cy.get('[data-test="print-layout-page"]').should('be.visible') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
69 changes: 69 additions & 0 deletions
69
cypress/integration/view/view_errors/dashboard_item_missing_type.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
import { Given, Then } from 'cypress-cucumber-preprocessor/steps' | ||
import { EXTENDED_TIMEOUT } from '../../../support/utils' | ||
import { | ||
dashboardChipSel, | ||
dashboardTitleSel, | ||
} from '../../../elements/viewDashboard' | ||
import { | ||
getDashboardItem, | ||
clickItemDeleteButton, | ||
} from '../../../elements/dashboardItem' | ||
|
||
const ITEM_1_UID = 'GaVhJpqABYX' | ||
const ITEM_2_UID = 'qXsjttMYuoZ' | ||
const ITEM_3_UID = 'Rwb3oXJ3bZ9' | ||
|
||
const interceptDashboardRequest = () => { | ||
cy.intercept(/dashboards\/iMnYyBfSxmM/, req => { | ||
req.reply(res => { | ||
// modify 3 items with different styles of "missing" type property | ||
res.body.dashboardItems.find( | ||
item => item.id === ITEM_1_UID | ||
).type = null | ||
|
||
const item = res.body.dashboardItems.find( | ||
item => item.id === ITEM_2_UID | ||
) | ||
|
||
delete item.type | ||
|
||
res.body.dashboardItems.find(item => item.id === ITEM_3_UID).type = | ||
'Unrecognized' | ||
|
||
res.send({ body: res.body }) | ||
}) | ||
}) | ||
} | ||
|
||
Given('I open the Delivery dashboard with items missing a type', () => { | ||
interceptDashboardRequest() | ||
cy.get(dashboardChipSel, EXTENDED_TIMEOUT).contains('Delivery').click() | ||
cy.get(dashboardTitleSel).should('be.visible').and('contain', 'Delivery') | ||
}) | ||
|
||
Then('the items missing type are displayed with a warning', () => { | ||
getDashboardItem(ITEM_1_UID) | ||
.scrollIntoView() | ||
.contains('The item type is missing') | ||
.should('be.visible') | ||
|
||
getDashboardItem(ITEM_2_UID) | ||
.scrollIntoView() | ||
.contains('The item type is missing') | ||
.should('be.visible') | ||
|
||
getDashboardItem(ITEM_3_UID) | ||
.scrollIntoView() | ||
.contains('Item type "Unrecognized" is not supported') | ||
.should('be.visible') | ||
}) | ||
|
||
Then('I can delete the items', () => { | ||
clickItemDeleteButton(ITEM_1_UID) | ||
clickItemDeleteButton(ITEM_2_UID) | ||
clickItemDeleteButton(ITEM_3_UID) | ||
|
||
getDashboardItem(ITEM_1_UID).should('not.exist') | ||
getDashboardItem(ITEM_2_UID).should('not.exist') | ||
getDashboardItem(ITEM_3_UID).should('not.exist') | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters