-
Notifications
You must be signed in to change notification settings - Fork 1.4k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into feat/flag-db-operations-validation
- Loading branch information
Showing
418 changed files
with
7,325 additions
and
3,834 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,7 +2,7 @@ import { decideResponse } from '../fixtures/api/decide' | |
import { createInsight } from '../productAnalytics' | ||
|
||
describe('Alerts', () => { | ||
it('Should allow create and delete an alert', () => { | ||
beforeEach(() => { | ||
cy.intercept('**/decide/*', (req) => | ||
req.reply( | ||
decideResponse({ | ||
|
@@ -11,29 +11,45 @@ describe('Alerts', () => { | |
) | ||
) | ||
createInsight('insight') | ||
}) | ||
|
||
const createAlert = ( | ||
name: string = 'Alert name', | ||
email: string = '[email protected]', | ||
lowerThreshold: string = '100', | ||
upperThreshold: string = '200' | ||
): void => { | ||
cy.get('[data-attr=more-button]').click() | ||
// Alerts should be disabled for trends represented with graphs | ||
cy.get('[data-attr=disabled-alerts-button]').should('exist') | ||
cy.contains('Alerts').click() | ||
cy.contains('New alert').click() | ||
|
||
cy.get('[data-attr=alert-name]').clear().type(name) | ||
cy.get('[data-attr=alert-notification-targets').clear().type(email) | ||
cy.get('[data-attr=alert-lower-threshold').clear().type(lowerThreshold) | ||
cy.get('[data-attr=alert-upper-threshold').clear().type(upperThreshold) | ||
cy.contains('Create alert').click() | ||
cy.url().should('not.include', '/new') | ||
|
||
cy.get('[aria-label="close"]').click() | ||
} | ||
|
||
const setInsightDisplayTypeAndSave = (displayType: string): void => { | ||
// Only the Number representation supports alerts, so change the insight | ||
cy.get('[data-attr=insight-edit-button]').click() | ||
cy.get('[data-attr=chart-filter]').click() | ||
cy.contains('Number').click() | ||
cy.contains(displayType).click() | ||
cy.get('[data-attr=insight-save-button]').contains('Save').click() | ||
cy.url().should('not.include', '/edit') | ||
} | ||
|
||
it('Should allow create and delete an alert', () => { | ||
cy.get('[data-attr=more-button]').click() | ||
cy.contains('Alerts').click() | ||
cy.contains('New alert').click() | ||
// Alerts should be disabled for trends represented with graphs | ||
cy.get('[data-attr=disabled-alerts-button]').should('exist') | ||
|
||
cy.get('[data-attr=alert-name]').clear().type('Alert name') | ||
cy.get('[data-attr=alert-notification-targets').clear().type('[email protected]') | ||
cy.get('[data-attr=alert-lower-threshold').clear().type('100') | ||
cy.get('[data-attr=alert-upper-threshold').clear().type('200') | ||
cy.contains('Create alert').click() | ||
cy.url().should('not.include', '/new') | ||
setInsightDisplayTypeAndSave('Number') | ||
|
||
cy.get('[aria-label="close"]').click() | ||
createAlert() | ||
cy.reload() | ||
|
||
// Check the alert has the same values as when it was created | ||
|
@@ -50,4 +66,32 @@ describe('Alerts', () => { | |
cy.reload() | ||
cy.contains('Alert name').should('not.exist') | ||
}) | ||
|
||
it('Should warn about an alert deletion', () => { | ||
setInsightDisplayTypeAndSave('Number') | ||
|
||
createAlert('Alert to be deleted because of a changed insight') | ||
|
||
cy.get('[data-attr=insight-edit-button]').click() | ||
cy.get('[data-attr=chart-filter]').click() | ||
cy.contains('Line chart').click() | ||
|
||
cy.contains('the existing alerts will be deleted').should('exist') | ||
|
||
cy.get('[data-attr=chart-filter]').click() | ||
cy.contains('Number').click() | ||
|
||
// Assert that reverting the display type removes the banner | ||
cy.contains('the existing alerts will be deleted').should('not.exist') | ||
|
||
cy.get('[data-attr=insight-cancel-edit-button]').click() | ||
setInsightDisplayTypeAndSave('Line chart') | ||
setInsightDisplayTypeAndSave('Number') | ||
|
||
// Assert that saving an insight in an incompatible state removes alerts | ||
cy.get('[data-attr=more-button]').click() | ||
cy.contains('Alerts').click() | ||
cy.contains('Manage alerts').click() | ||
cy.contains('Alert to be deleted because of a changed insight').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
3 changes: 3 additions & 0 deletions
3
cypress/e2e/insights-date-picker.ts → cypress/e2e/insights-date-picker.cy.ts
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
Oops, something went wrong.