From b4b0050de81a2d009fbaa8b1f8df94e54311e7e5 Mon Sep 17 00:00:00 2001 From: Paul D'Ambra Date: Fri, 14 Jun 2024 13:56:23 +0100 Subject: [PATCH] chore: add clarifying test (#1246) * chore: add clarifying test * but not distracted by my sandwich * ignore new cypress file --- .gitignore | 1 + cypress/e2e/opting-out.cy.ts | 33 +++++++++++++++++++++++++++++++++ 2 files changed, 34 insertions(+) diff --git a/.gitignore b/.gitignore index a99639586..6f9a2cca0 100644 --- a/.gitignore +++ b/.gitignore @@ -28,3 +28,4 @@ test-result.json yarn-error.log stats.html .eslintcache +cypress/downloads/downloads.html \ No newline at end of file diff --git a/cypress/e2e/opting-out.cy.ts b/cypress/e2e/opting-out.cy.ts index 4b8f369cf..a37c6e15c 100644 --- a/cypress/e2e/opting-out.cy.ts +++ b/cypress/e2e/opting-out.cy.ts @@ -112,6 +112,39 @@ describe('opting out', () => { pollPhCaptures('$snapshot').then(assertThatRecordingStarted) }) + it('can start recording when starting disabled', () => { + cy.posthogInit({ disable_session_recording: true }) + + assertWhetherPostHogRequestsWereCalled({ + '@recorder': false, + '@decide': true, + '@session-recording': false, + }) + + cy.get('[data-cy-input]') + .type('hello posthog!') + .then(() => { + cy.phCaptures().then((captures) => { + expect(captures || []).to.deep.equal(['$pageview']) + }) + }) + + cy.resetPhCaptures() + cy.posthog().invoke('startSessionRecording') + + assertWhetherPostHogRequestsWereCalled({ + '@recorder': true, + '@decide': true, + // no call to session-recording yet + }) + + cy.get('[data-cy-input]') + .type('hello posthog!') + .then(() => { + pollPhCaptures('$snapshot').then(assertThatRecordingStarted) + }) + }) + it('can override sampling when starting session recording', () => { cy.intercept('POST', '/decide/*', { autocapture_opt_out: true,