Skip to content

Commit

Permalink
fix functional tests by disabling surveys
Browse files Browse the repository at this point in the history
  • Loading branch information
lucasheriques committed Jan 22, 2025
1 parent 5f55307 commit 55e84cd
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
8 changes: 4 additions & 4 deletions functional_tests/identify.test.ts
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import '../src/__tests__/helpers/mock-logger'

import 'regenerator-runtime/runtime'
import { waitFor } from '@testing-library/dom'
import { getRequests } from './mock-server'
import 'regenerator-runtime/runtime'
import { createPosthogInstance } from '../src/__tests__/helpers/posthog-instance'
import { PostHog } from '../src/posthog-core'
import { logger } from '../src/utils/logger'
import { uuidv7 } from '../src/uuidv7'
import { PostHog } from '../src/posthog-core'
import { getRequests } from './mock-server'

describe('FunctionalTests / Identify', () => {
let token: string
Expand All @@ -15,7 +15,7 @@ describe('FunctionalTests / Identify', () => {

beforeEach(async () => {
token = uuidv7()
posthog = await createPosthogInstance(token)
posthog = await createPosthogInstance(token, { disable_surveys: true })
anonymousId = posthog.get_distinct_id()
})

Expand Down
14 changes: 7 additions & 7 deletions src/posthog-surveys.ts
Original file line number Diff line number Diff line change
Expand Up @@ -161,6 +161,13 @@ export class PostHogSurveys {
return
}

const disableSurveys = this.instance.config.disable_surveys

if (disableSurveys) {
logger.info('Disabled. Not loading surveys.')
return
}

const phExtensions = assignableWindow?.__PosthogExtensions__

if (!phExtensions) {
Expand All @@ -170,13 +177,6 @@ export class PostHogSurveys {

const generateSurveys = phExtensions.generateSurveys

const disableSurveys = this.instance.config.disable_surveys

if (disableSurveys) {
logger.info('Disabled. Not loading surveys.')
return
}

if (!this._decideServerResponse) {
logger.warn('Decide not loaded yet. Not loading surveys.')
return
Expand Down

0 comments on commit 55e84cd

Please sign in to comment.