Skip to content

Commit

Permalink
chore: longer timeout on insight and dashboard cypress tests (#27159)
Browse files Browse the repository at this point in the history
  • Loading branch information
pauldambra authored Jan 2, 2025
1 parent 2a06229 commit 0db2211
Show file tree
Hide file tree
Showing 7 changed files with 38 additions and 30 deletions.
1 change: 0 additions & 1 deletion .github/workflows/ci-e2e.yml
Original file line number Diff line number Diff line change
Expand Up @@ -229,7 +229,6 @@ jobs:
uses: cypress-io/github-action@v6
with:
config-file: cypress.e2e.config.ts
config: retries=2
spec: ${{ matrix.chunk }}
install: false
# We were seeing suprising crashes in headless mode
Expand Down
6 changes: 3 additions & 3 deletions cypress.e2e.config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,8 @@ const checkFileDownloaded = async (filename: string, timeout: number, delayMs =

export default defineConfig({
video: false,
defaultCommandTimeout: 20000,
requestTimeout: 8000,
defaultCommandTimeout: 40000,
requestTimeout: 16000,
pageLoadTimeout: 80000,
projectId: 'twojfp',
viewportWidth: 1200,
Expand All @@ -34,7 +34,7 @@ export default defineConfig({
// cypress default is 'top' this means sometimes the element is underneath the top navbar
// not what a human would do... so, set it to center to avoid this weird behavior
scrollBehavior: 'center',
retries: { runMode: 2 },
retries: { runMode: 3 },
e2e: {
// We've imported your old cypress plugins here.
// You may want to clean this up later by importing these.
Expand Down
58 changes: 32 additions & 26 deletions cypress/e2e/billing.cy.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,33 +7,39 @@ describe('Billing', () => {
cy.visit('/organization/billing')
})

it('Show and submit unsubscribe survey', () => {
cy.intercept('/api/billing/deactivate?products=product_analytics', {
fixture: 'api/billing/billing-unsubscribed-product-analytics.json',
}).as('unsubscribeProductAnalytics')
it(
'Show and submit unsubscribe survey',
{
retries: 4,
},
() => {
cy.intercept('/api/billing/deactivate?products=product_analytics', {
fixture: 'api/billing/billing-unsubscribed-product-analytics.json',
}).as('unsubscribeProductAnalytics')

cy.get('[data-attr=more-button]').first().click()
cy.contains('.LemonButton', 'Unsubscribe').click()
cy.get('.LemonModal h3').should('contain', 'Unsubscribe from Product analytics')
cy.get('[data-attr=unsubscribe-reason-too-expensive]').click()
cy.get('[data-attr=unsubscribe-reason-survey-textarea]').type('Product analytics')
cy.contains('.LemonModal .LemonButton', 'Unsubscribe').click()

cy.window().then((win) => {
const events = (win as any)._cypress_posthog_captures
const matchingEvents = events.filter((event) => event.event === 'survey sent')
expect(matchingEvents.length).to.equal(1)
const matchingEvent = matchingEvents[0]
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_response_2.length).to.equal(1)
expect(matchingEvent.properties.$survey_response_2[0]).to.equal('Too expensive')
})

cy.get('.LemonModal').should('not.exist')
cy.wait(['@unsubscribeProductAnalytics'])
})
cy.get('[data-attr=more-button]').first().click()
cy.contains('.LemonButton', 'Unsubscribe').click()
cy.get('.LemonModal h3').should('contain', 'Unsubscribe from Product analytics')
cy.get('[data-attr=unsubscribe-reason-too-expensive]').click()
cy.get('[data-attr=unsubscribe-reason-survey-textarea]').type('Product analytics')
cy.contains('.LemonModal .LemonButton', 'Unsubscribe').click()

cy.window().then((win) => {
const events = (win as any)._cypress_posthog_captures
const matchingEvents = events.filter((event) => event.event === 'survey sent')
expect(matchingEvents.length).to.equal(1)
const matchingEvent = matchingEvents[0]
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_response_2.length).to.equal(1)
expect(matchingEvent.properties.$survey_response_2[0]).to.equal('Too expensive')
})

cy.get('.LemonModal').should('not.exist')
cy.wait(['@unsubscribeProductAnalytics'])
}
)

it('Unsubscribe survey text area maintains unique state between product types', () => {
cy.get('[data-attr=more-button]').first().click()
Expand Down
File renamed without changes.
File renamed without changes.
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,15 @@ describe('ReloadInsight component', () => {
})

it('saves the query to the URL and localStorage, and reloads it when prompted', () => {
cy.intercept('POST', /api\/environments\/\d+\/query\//).as('loadNewQueryInsight')

// Visit the new insight creation page
cy.visit('/insights/new')

cy.wait(2000)

cy.get('[data-attr="math-selector-0"]').click({ force: true })
cy.wait('@loadNewQueryInsight')
cy.get('[data-attr="math-dau-0"]').click({ force: true })

// Check that the 'draft-query' item is stored in localStorage
Expand Down
File renamed without changes.

0 comments on commit 0db2211

Please sign in to comment.