Skip to content

Commit

Permalink
Merge branch 'master' into feat/flag-db-operations-validation
Browse files Browse the repository at this point in the history
  • Loading branch information
dmarticus committed Aug 6, 2024
2 parents f741a94 + 4107195 commit e853ae9
Show file tree
Hide file tree
Showing 418 changed files with 7,325 additions and 3,834 deletions.
70 changes: 57 additions & 13 deletions cypress/e2e/alerts.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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({
Expand All @@ -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
Expand All @@ -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')
})
})
4 changes: 2 additions & 2 deletions cypress/e2e/billing.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,8 @@ describe('Billing', () => {
expect(matchingEvent.properties.$survey_id).to.equal(UNSUBSCRIBE_SURVEY_ID)
expect(matchingEvent.properties.$survey_response).to.equal('Product analytics')
expect(matchingEvent.properties.$survey_response_1).to.equal('product_analytics')
expect(matchingEvent.properties.$survey_reasons.length).to.equal(1)
expect(matchingEvent.properties.$survey_reasons[0]).to.equal('Too expensive')
expect(matchingEvent.properties.$survey_response_2.length).to.equal(1)
expect(matchingEvent.properties.$survey_response_2[0]).to.equal('Too expensive')
})

cy.get('.LemonModal').should('not.exist')
Expand Down
Original file line number Diff line number Diff line change
@@ -1,8 +1,11 @@
import 'cypress-network-idle'

import { urls } from 'scenes/urls'

describe('insights date picker', () => {
beforeEach(() => {
cy.visit(urls.insightNew())
cy.waitForNetworkIdle(300)
})

it('Can set the date filter and show the right grouping interval', () => {
Expand Down
2 changes: 1 addition & 1 deletion ee/billing/test/test_quota_limiting.py
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,7 @@ def test_quota_limit_feature_flag_not_on(self, patch_feature_enabled, patch_capt
self.organization.save()

time.sleep(1)
with self.assertNumQueries(2):
with self.assertNumQueries(3):
quota_limited_orgs, quota_limiting_suspended_orgs = update_all_org_billing_quotas()
# Shouldn't be called due to lazy evaluation of the conditional
patch_feature_enabled.assert_not_called()
Expand Down
Loading

0 comments on commit e853ae9

Please sign in to comment.