import { cleanup, fireEvent, render, screen, waitFor } from "@testing-library/react"; import { afterEach, describe, expect, it, vi } from "vitest"; import { useSettingsSaveContributor } from "@/components/settings/settings-save-provider"; import { GitLabIntegrationPage } from "./gitlab-settings"; import type { GitLabActionPresets, ReviewWatch } from "@/lib/types/gitlab"; const fetchGitLabStatusMock = vi.fn(); const setGitLabConfigMock = vi.fn(); const resetActionPresetsMock = vi.fn(); const updateActionPresetsMock = vi.fn(); const deleteReviewWatchMock = vi.fn(); const workspaceId = "workspace-1"; const defaultHost = "https://gitlab.com"; const credentialsContributorId = "gitlab-credentials"; const appState = { prompts: { items: [], loaded: true, loading: false }, gitlabReviewWatches: { items: [] as ReviewWatch[], loaded: false, loading: false }, gitlabIssueWatches: { items: [], loaded: false, loading: false }, gitlabActionPresets: { byWorkspaceId: {} as Record, loading: false, }, setGitLabReviewWatches: vi.fn(), setGitLabReviewWatchesLoading: vi.fn(), addGitLabReviewWatch: vi.fn(), updateGitLabReviewWatchInStore: vi.fn(), removeGitLabReviewWatch: vi.fn(), setGitLabIssueWatches: vi.fn(), setGitLabIssueWatchesLoading: vi.fn(), addGitLabIssueWatch: vi.fn(), updateGitLabIssueWatchInStore: vi.fn(), removeGitLabIssueWatch: vi.fn(), setGitLabActionPresets: vi.fn(), setGitLabActionPresetsLoading: vi.fn(), }; vi.mock("@/components/state-provider", () => ({ useAppStore: (selector: (value: typeof appState) => unknown) => selector(appState), })); vi.mock("@/components/integrations/workspace-scoped-section", () => ({ WorkspaceScopedSection: ({ children }: { children: (workspaceId: string) => React.ReactNode }) => children(workspaceId), })); vi.mock("@/components/toast-provider", () => ({ useToast: () => ({ toast: vi.fn() }), })); vi.mock("@/components/settings/settings-save-provider", () => ({ useSettingsSaveContributor: vi.fn(), SettingsSaveDirtyScope: ({ children }: { children: (isDirty: boolean) => React.ReactNode }) => children(false), })); vi.mock("@/components/settings/settings-prompt-editor", () => ({ SettingsPromptEditor: ({ value, onChange, ariaLabel, testId, }: { value: string; onChange: (value: string) => void; ariaLabel?: string; testId?: string; }) => (