diff --git a/cypress/e2e/capture.cy.ts b/cypress/e2e/capture.cy.ts index f681657fe..816af49a2 100644 --- a/cypress/e2e/capture.cy.ts +++ b/cypress/e2e/capture.cy.ts @@ -209,8 +209,8 @@ describe('Event capture', () => { }) }) - describe('opting out of autocapture', () => { - it('captures pageviews, custom events', () => { + describe('when disabled', () => { + it('captures pageviews, custom events when autocapture disabled', () => { start({ options: { autocapture: false }, waitForDecide: false }) cy.wait(50) @@ -226,10 +226,8 @@ describe('Event capture', () => { expect(captures['event']).to.equal('$pageview') }) }) - }) - describe('opting out of pageviews', () => { - it('captures autocapture, custom events', () => { + it('captures autocapture, custom events when pageviews disabled', () => { start({ options: { capture_pageview: false } }) cy.get('[data-cy-custom-event-button]').click() @@ -239,35 +237,15 @@ describe('Event capture', () => { cy.phCaptures().should('include', '$autocapture') cy.phCaptures().should('include', 'custom-event') }) - }) - describe('user opts out after start', () => { - it('does not send any autocapture/custom events after that', () => { - start({}) - - cy.posthog().invoke('opt_out_capturing') + it('does not capture things when multiple disabled', () => { + start({ options: { capture_pageview: false, capture_pageleave: false, autocapture: false } }) cy.get('[data-cy-custom-event-button]').click() - cy.get('[data-cy-feature-flag-button]').click() cy.reload() - cy.phCaptures().should('deep.equal', ['$pageview']) - }) - - it('does not send session recording events', () => { - start({ - decideResponseOverrides: { - sessionRecording: { - endpoint: '/ses/', - }, - }, - }) - - cy.posthog().invoke('opt_out_capturing') - cy.resetPhCaptures() - - cy.get('[data-cy-custom-event-button]').click() - cy.phCaptures().should('deep.equal', []) + cy.phCaptures().should('have.length', 1) + cy.phCaptures().should('include', 'custom-event') }) }) diff --git a/cypress/e2e/opting-out.cy.ts b/cypress/e2e/opting-out.cy.ts index a37c6e15c..1131517b7 100644 --- a/cypress/e2e/opting-out.cy.ts +++ b/cypress/e2e/opting-out.cy.ts @@ -1,4 +1,5 @@ import { assertWhetherPostHogRequestsWereCalled, pollPhCaptures } from '../support/assertions' +import { start } from '../support/setup' function assertThatRecordingStarted() { cy.phCaptures({ full: true }).then((captures) => { @@ -188,4 +189,18 @@ describe('opting out', () => { pollPhCaptures('$snapshot').then(assertThatRecordingStarted) }) }) + + describe('user opts out after start', () => { + it('does not send any autocapture/custom events after that', () => { + start({}) + + cy.posthog().invoke('opt_out_capturing') + + cy.get('[data-cy-custom-event-button]').click() + cy.get('[data-cy-feature-flag-button]').click() + cy.reload() + + cy.phCaptures().should('deep.equal', ['$pageview']) + }) + }) })