-
Notifications
You must be signed in to change notification settings - Fork 5k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
chore: Move user's analytics consent to the backend (#6505)
- Loading branch information
Showing
20 changed files
with
219 additions
and
65 deletions.
There are no files selected for viewing
45 changes: 45 additions & 0 deletions
45
frontend/__tests__/components/features/analytics/analytics-consent-form-modal.test.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import userEvent from "@testing-library/user-event"; | ||
import { describe, expect, it, vi } from "vitest"; | ||
import { render, screen } from "@testing-library/react"; | ||
import { QueryClient, QueryClientProvider } from "@tanstack/react-query"; | ||
import { AnalyticsConsentFormModal } from "#/components/features/analytics/analytics-consent-form-modal"; | ||
import OpenHands from "#/api/open-hands"; | ||
import { SettingsProvider } from "#/context/settings-context"; | ||
import { AuthProvider } from "#/context/auth-context"; | ||
|
||
describe("AnalyticsConsentFormModal", () => { | ||
it("should call saveUserSettings with default settings on confirm reset settings", async () => { | ||
const user = userEvent.setup(); | ||
const onCloseMock = vi.fn(); | ||
const saveUserSettingsSpy = vi.spyOn(OpenHands, "saveSettings"); | ||
|
||
render(<AnalyticsConsentFormModal onClose={onCloseMock} />, { | ||
wrapper: ({ children }) => ( | ||
<AuthProvider> | ||
<QueryClientProvider client={new QueryClient()}> | ||
<SettingsProvider>{children}</SettingsProvider> | ||
</QueryClientProvider> | ||
</AuthProvider> | ||
), | ||
}); | ||
|
||
const confirmButton = screen.getByTestId("confirm-preferences"); | ||
await user.click(confirmButton); | ||
|
||
expect(saveUserSettingsSpy).toHaveBeenCalledWith({ | ||
user_consents_to_analytics: true, | ||
agent: "CodeActAgent", | ||
confirmation_mode: false, | ||
enable_default_condenser: false, | ||
github_token: undefined, | ||
language: "en", | ||
llm_api_key: undefined, | ||
llm_base_url: "", | ||
llm_model: "anthropic/claude-3-5-sonnet-20241022", | ||
remote_runtime_resource_factor: 1, | ||
security_analyzer: "", | ||
unset_github_token: undefined, | ||
}); | ||
expect(onCloseMock).toHaveBeenCalled(); | ||
}); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.