|
|
@@ -4,8 +4,9 @@ import { screen, waitFor, within } from "@testing-library/react";
|
|
|
import { renderWithProviders } from "test-utils";
|
|
|
import userEvent from "@testing-library/user-event";
|
|
|
import MainApp from "#/routes/_oh/route";
|
|
|
-import * as CaptureConsent from "#/utils/handle-capture-consent";
|
|
|
import i18n from "#/i18n";
|
|
|
+import * as CaptureConsent from "#/utils/handle-capture-consent";
|
|
|
+import OpenHands from "#/api/open-hands";
|
|
|
|
|
|
describe("frontend/routes/_oh", () => {
|
|
|
const RouteStub = createRoutesStub([{ Component: MainApp, path: "/" }]);
|
|
|
@@ -60,13 +61,20 @@ describe("frontend/routes/_oh", () => {
|
|
|
});
|
|
|
});
|
|
|
|
|
|
- it("should capture the user's consent", async () => {
|
|
|
+ it("should render and capture the user's consent if oss mode", async () => {
|
|
|
const user = userEvent.setup();
|
|
|
+ const getConfigSpy = vi.spyOn(OpenHands, "getConfig");
|
|
|
const handleCaptureConsentSpy = vi.spyOn(
|
|
|
CaptureConsent,
|
|
|
"handleCaptureConsent",
|
|
|
);
|
|
|
|
|
|
+ getConfigSpy.mockResolvedValue({
|
|
|
+ APP_MODE: "oss",
|
|
|
+ GITHUB_CLIENT_ID: "test-id",
|
|
|
+ POSTHOG_CLIENT_KEY: "test-key",
|
|
|
+ });
|
|
|
+
|
|
|
renderWithProviders(<RouteStub />);
|
|
|
|
|
|
// The user has not consented to tracking
|
|
|
@@ -87,6 +95,23 @@ describe("frontend/routes/_oh", () => {
|
|
|
).not.toBeInTheDocument();
|
|
|
});
|
|
|
|
|
|
+ it("should not render the user consent form if saas mode", async () => {
|
|
|
+ const getConfigSpy = vi.spyOn(OpenHands, "getConfig");
|
|
|
+ getConfigSpy.mockResolvedValue({
|
|
|
+ APP_MODE: "saas",
|
|
|
+ GITHUB_CLIENT_ID: "test-id",
|
|
|
+ POSTHOG_CLIENT_KEY: "test-key",
|
|
|
+ });
|
|
|
+
|
|
|
+ renderWithProviders(<RouteStub />);
|
|
|
+
|
|
|
+ await waitFor(() => {
|
|
|
+ expect(
|
|
|
+ screen.queryByTestId("user-capture-consent-form"),
|
|
|
+ ).not.toBeInTheDocument();
|
|
|
+ });
|
|
|
+ });
|
|
|
+
|
|
|
it("should not render the user consent form if the user has already made a decision", async () => {
|
|
|
localStorage.setItem("analytics-consent", "true");
|
|
|
renderWithProviders(<RouteStub />);
|