2023-12-05 22:06:24 +01:00
|
|
|
const UNSUBSCRIBE_SURVEY_ID = '018b6e13-590c-0000-decb-c727a2b3f462'
|
|
|
|
|
2023-11-02 21:34:45 +01:00
|
|
|
describe('Billing', () => {
|
|
|
|
beforeEach(() => {
|
2024-05-30 14:25:02 +02:00
|
|
|
cy.intercept('/api/billing/', { fixture: 'api/billing/billing.json' })
|
2023-11-02 21:34:45 +01:00
|
|
|
|
|
|
|
cy.visit('/organization/billing')
|
|
|
|
})
|
|
|
|
|
2023-11-09 22:25:20 +01:00
|
|
|
it('Show and submit unsubscribe survey', () => {
|
2024-05-30 14:25:02 +02:00
|
|
|
cy.intercept('/api/billing/deactivate?products=product_analytics', {
|
|
|
|
fixture: 'api/billing/billing-unsubscribed-product-analytics.json',
|
2023-11-09 22:25:20 +01:00
|
|
|
}).as('unsubscribeProductAnalytics')
|
2023-11-16 01:04:48 +01:00
|
|
|
|
2023-11-02 21:34:45 +01:00
|
|
|
cy.get('[data-attr=more-button]').first().click()
|
|
|
|
cy.contains('.LemonButton', 'Unsubscribe').click()
|
2024-03-19 05:19:26 +01:00
|
|
|
cy.get('.LemonModal h3').should('contain', 'Why are you unsubscribing from Product analytics?')
|
2023-11-16 01:04:48 +01:00
|
|
|
cy.get('[data-attr=unsubscribe-reason-survey-textarea]').type('Product analytics')
|
2023-11-02 21:34:45 +01:00
|
|
|
cy.contains('.LemonModal .LemonButton', 'Unsubscribe').click()
|
|
|
|
|
2024-03-11 12:48:55 +01:00
|
|
|
cy.window().then((win) => {
|
|
|
|
const events = (win as any)._cypress_posthog_captures
|
|
|
|
const matchingEvents = events.filter((event) => event.event === 'survey sent')
|
2023-12-05 22:06:24 +01:00
|
|
|
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')
|
|
|
|
})
|
2024-03-11 12:48:55 +01:00
|
|
|
|
2023-11-09 22:25:20 +01:00
|
|
|
cy.get('.LemonModal').should('not.exist')
|
|
|
|
cy.wait(['@unsubscribeProductAnalytics'])
|
2023-11-02 21:34:45 +01:00
|
|
|
})
|
|
|
|
|
|
|
|
it('Unsubscribe survey text area maintains unique state between product types', () => {
|
|
|
|
cy.get('[data-attr=more-button]').first().click()
|
|
|
|
cy.contains('.LemonButton', 'Unsubscribe').click()
|
2024-03-19 05:19:26 +01:00
|
|
|
cy.get('.LemonModal h3').should('contain', 'Why are you unsubscribing from Product analytics?')
|
2023-11-02 21:34:45 +01:00
|
|
|
|
|
|
|
cy.get('[data-attr=unsubscribe-reason-survey-textarea]').type('Product analytics')
|
|
|
|
cy.contains('.LemonModal .LemonButton', 'Cancel').click()
|
|
|
|
|
|
|
|
cy.get('[data-attr=more-button]').eq(1).click()
|
|
|
|
cy.contains('.LemonButton', 'Unsubscribe').click()
|
2024-02-12 15:11:41 +01:00
|
|
|
cy.get('.LemonModal h3').should('contain', 'Why are you unsubscribing from Session replay?')
|
2023-11-02 21:34:45 +01:00
|
|
|
cy.get('[data-attr=unsubscribe-reason-survey-textarea]').type('Session replay')
|
|
|
|
cy.contains('.LemonModal .LemonButton', 'Cancel').click()
|
|
|
|
|
|
|
|
cy.get('[data-attr=more-button]').first().click()
|
|
|
|
cy.contains('.LemonButton', 'Unsubscribe').click()
|
|
|
|
cy.get('[data-attr=unsubscribe-reason-survey-textarea]').should('have.value', 'Product analytics')
|
|
|
|
})
|
|
|
|
})
|