From 35d4847d713ca68fd38fa27892863e173d3e9a8c Mon Sep 17 00:00:00 2001 From: Li Yi Date: Tue, 30 Jan 2024 17:38:44 -0500 Subject: [PATCH] cypress leaving too quickly --- cypress/e2e/surveys.cy.ts | 5 +++-- src/extensions/surveys.tsx | 2 +- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cypress/e2e/surveys.cy.ts b/cypress/e2e/surveys.cy.ts index ef40abc32..116390b3b 100644 --- a/cypress/e2e/surveys.cy.ts +++ b/cypress/e2e/surveys.cy.ts @@ -581,11 +581,12 @@ describe('Surveys', () => { // first capture is $pageview cy.wait('@capture-assertion') cy.get('.PostHogSurvey123').shadow().find('.cancel-btn-wrapper').click() + cy.wait(500) cy.wait('@capture-assertion').then(async ({ request }) => { const captures = await getBase64EncodedPayload(request) expect(captures.map(({ event }) => event)).to.deep.equal([ - // 'survey shown', - // 'survey dismissed', + 'survey shown', + 'survey dismissed', '$pageleave', ]) }) diff --git a/src/extensions/surveys.tsx b/src/extensions/surveys.tsx index 81a3bda4a..28cabe601 100644 --- a/src/extensions/surveys.tsx +++ b/src/extensions/surveys.tsx @@ -230,7 +230,6 @@ export function Surveys({ posthog, survey, style }: { posthog: PostHog; survey: localStorage.setItem(`lastSeenSurveyDate`, new Date().toISOString()) window.addEventListener('PHSurveyClosed', () => { - localStorage.setItem(`seenSurvey_${survey.id}`, 'true') posthog.capture('survey dismissed', { $survey_name: survey.name, $survey_id: survey.id, @@ -240,6 +239,7 @@ export function Surveys({ posthog, survey, style }: { posthog: PostHog; survey: }, }) setShowSurveyQuestion(false) + localStorage.setItem(`seenSurvey_${survey.id}`, 'true') }) window.addEventListener('PHSurveySent', () => {