|
2 | 2 |
|
3 | 3 | import React from "react" |
4 | 4 | import { render, screen, act, cleanup } from "@/utils/test-utils" |
5 | | -import posthog from "posthog-js" |
6 | 5 |
|
7 | 6 | import AppWithProviders from "../App" |
8 | 7 |
|
9 | | -// Mock posthog |
10 | | -vi.mock("posthog-js", () => ({ |
11 | | - default: { |
12 | | - onFeatureFlags: vi.fn(), |
13 | | - getFeatureFlag: vi.fn(), |
14 | | - }, |
15 | | -})) |
16 | | - |
17 | 8 | vi.mock("@src/utils/vscode", () => ({ |
18 | 9 | vscode: { |
19 | 10 | postMessage: vi.fn(), |
@@ -198,7 +189,6 @@ describe("App", () => { |
198 | 189 | shouldShowAnnouncement: false, |
199 | 190 | experiments: {}, |
200 | 191 | language: "en", |
201 | | - telemetrySetting: "enabled", |
202 | 192 | }) |
203 | 193 | }) |
204 | 194 |
|
@@ -348,54 +338,4 @@ describe("App", () => { |
348 | 338 | expect(chatView.getAttribute("data-hidden")).toBe("false") |
349 | 339 | expect(screen.queryByTestId("marketplace-view")).not.toBeInTheDocument() |
350 | 340 | }) |
351 | | - |
352 | | - describe("PostHog feature flag initialization", () => { |
353 | | - it("waits for state hydration before checking feature flags", () => { |
354 | | - mockUseExtensionState.mockReturnValue({ |
355 | | - didHydrateState: false, |
356 | | - showWelcome: false, |
357 | | - shouldShowAnnouncement: false, |
358 | | - experiments: {}, |
359 | | - language: "en", |
360 | | - telemetrySetting: "enabled", |
361 | | - }) |
362 | | - |
363 | | - render(<AppWithProviders />) |
364 | | - |
365 | | - // PostHog feature flag check should not be called before hydration |
366 | | - expect(posthog.onFeatureFlags).not.toHaveBeenCalled() |
367 | | - }) |
368 | | - |
369 | | - it("checks feature flags after state hydration when telemetry is enabled", () => { |
370 | | - mockUseExtensionState.mockReturnValue({ |
371 | | - didHydrateState: true, |
372 | | - showWelcome: false, |
373 | | - shouldShowAnnouncement: false, |
374 | | - experiments: {}, |
375 | | - language: "en", |
376 | | - telemetrySetting: "enabled", |
377 | | - }) |
378 | | - |
379 | | - render(<AppWithProviders />) |
380 | | - |
381 | | - // PostHog feature flag check should be called after hydration |
382 | | - expect(posthog.onFeatureFlags).toHaveBeenCalled() |
383 | | - }) |
384 | | - |
385 | | - it("does not check feature flags when telemetry is disabled", () => { |
386 | | - mockUseExtensionState.mockReturnValue({ |
387 | | - didHydrateState: true, |
388 | | - showWelcome: false, |
389 | | - shouldShowAnnouncement: false, |
390 | | - experiments: {}, |
391 | | - language: "en", |
392 | | - telemetrySetting: "disabled", |
393 | | - }) |
394 | | - |
395 | | - render(<AppWithProviders />) |
396 | | - |
397 | | - // PostHog feature flag check should not be called when telemetry is disabled |
398 | | - expect(posthog.onFeatureFlags).not.toHaveBeenCalled() |
399 | | - }) |
400 | | - }) |
401 | 341 | }) |
0 commit comments