Files
PaperClipAI/ui/src/components/new-agent/AgentProviderConnection.test.tsx
T
DottaandPaperclip 6fab9e8659 fix(apps): key Antigravity connector to antigravity with Antigravity branding and logo (#23012)
## Thinking Path

> - Paperclip is the open source app people use to manage AI agents for
work
> - The Connectors catalog and `/apps/connect` setup page let people
connect AI model providers for their agents
> - The Antigravity model-provider connector still used the `google`
slug, the generic Google "G" icon, and "Google" headings and sign-in
copy on `/apps/connect?source=google`
> - Showing "Google" with the generic Google icon on the Antigravity
connection flow makes it easy to confuse with Google Workspace
connectors and hides the Antigravity product identity
> - This pull request moves the catalog slug to `antigravity`, adds the
official Antigravity vector logo, redirects legacy `source=google` and
`source=google-ai` links to `source=antigravity`, and updates the
Connect page copy and icons to Antigravity while preserving the
underlying `google` AI provider storage contract
> - The benefit is that people see clear Antigravity branding, logo, and
URL routing throughout the Antigravity connection flow without breaking
saved accounts or existing links

## Linked Issues or Issue Description

**What existing behavior does this improve?**
Connector routing, branding, and logo presentation for Antigravity on
the Connectors catalog and `/apps/connect` setup page.

**Subsystem affected**
Shared app definitions (`packages/shared`), app brand assets
(`ui/public/brands/apps`), and UI connection setup pages and components
(`ui/src/pages/apps`, `ui/src/components`).

**Current behavior**
The Antigravity model-provider connector uses `?source=google`, displays
the generic Google logo, and shows "Connect Google", "Google", and "Sign
in to Google" on the Connect page.

**Proposed behavior**
The Antigravity connector keys to `?source=antigravity`, displays the
Antigravity logo, and shows "Connect Antigravity", "Antigravity", and
"Sign in to Antigravity" on the Connect page. Legacy links using
`?source=google` or `?source=google-ai` redirect to
`?source=antigravity` while preserving other query parameters.

**Reason and benefit**
This matches the existing `github` -> `github-copilot` catalog
separation pattern: stored `google` AI connections and Gemini API key
compatibility remain unchanged, while the user-facing catalog entry, URL
key, logo, and Connect page copy consistently reflect Antigravity.

**Breaking changes**
None. The underlying `google` AI provider identifier, credential
storage, and grants do not change, and legacy `source=google` /
`source=google-ai` deep links redirect automatically to
`source=antigravity`.

## What Changed

- Added the official transparent Antigravity vector mark at
`ui/public/brands/apps/antigravity.svg` and registered `antigravity` in
`ui/public/brands/apps/manifest.json` (keeping `google` with
`catalogVisible: false` for Google Workspace branding).
- Mapped `aiConnectionCatalogSlug("google")` to `"antigravity"` and
updated `aiProviderSetupPreset` so `antigravity`, `google`, and
`google-ai` all resolve to `{ provider: "google", label: "Antigravity"
}`.
- Replaced `packages/shared/src/app-definitions/google.json` with
`packages/shared/src/app-definitions/antigravity.json`, added
`scripts/app-definition-overrides/antigravity.json`, updated
`scripts/ingest-app-definitions.mjs`,
`packages/shared/src/app-definitions.ts`, and
`packages/shared/src/app-definitions.generated.ts`, and resynced
`tests/runner-e2e/source-sdk-public-inputs.json`.
- Updated `ui/src/pages/apps/app-connect-policy.ts` and
`ui/src/pages/apps/AppsConnect.tsx` to admit and redirect legacy
`source=google` and `source=google-ai` links to `source=antigravity`
while preserving query parameters.
- Updated `AdapterMark`, `AiProviderSetup`, `AgentProviderConnection`,
`AdapterLoginChrome`, `AiConnectionCredentialStep`, `AiConnectionField`,
`ai-connections/model.ts`, and
`ui/storybook/prototypes/AiConnectorPages.tsx` to show Antigravity
branding and `/brands/apps/antigravity.svg`.
- Updated existing unit tests and added
`ui/src/pages/apps/AppsConnect.test.tsx` covering legacy URL redirects
and Antigravity Connect page rendering.

## Verification

- `pnpm --filter @paperclipai/shared build` — passed.
- `node scripts/check-app-brand-assets.mjs` — passed (`Validated 114
brand identities`).
- `pnpm exec vitest run packages/shared/src/` — 120 test files passed.
- `pnpm exec vitest run ui/src/` — 575 test files (7,178 tests) passed;
`pnpm exec vitest run ui/src/pages/apps/AppsConnect.test.tsx` — 3/3
passed.
- `pnpm --filter @paperclipai/server exec vitest run
src/__tests__/ai-connections.test.ts
src/__tests__/connection-intents-service.test.ts` — 208/208 passed.
- `pnpm --filter @paperclipai/shared typecheck && pnpm --filter
@paperclipai/ui typecheck && pnpm --filter @paperclipai/server
typecheck` — passed.
- `node --test scripts/app-definition-overrides.test.mjs
scripts/app-brand-validation.test.mjs scripts/check-test-budget.test.mjs
scripts/storybook-catalog.test.mjs` — passed.
- `node tests/runner-e2e/source-sdk-public-inputs.mjs $(git rev-parse
HEAD) --check` — passed (`changed: false`).

## Risks

- Low risk. The stored AI provider enum (`google`) and database/API
contracts stay unchanged; `aiConnectionSourceSlug` maps previously
stored `google` connections to the `antigravity` catalog entry
automatically.
- Legacy bookmarks or deep links to `/apps/connect?source=google` or
`?source=google-ai` redirect immediately to `?source=antigravity` with
existing query parameters preserved.

## Model Used

- Google Gemini (Antigravity agent with tool use and code execution).

## Checklist

- [x] I have included a thinking path that traces from project context
to this change
- [x] I have specified the model used (with version and capability
details)
- [x] I have checked ROADMAP.md and confirmed this PR does not duplicate
planned core work
- [x] I have searched GitHub for duplicate or related PRs and linked
them above
- [x] I have either (a) linked existing issues with `Fixes: #` / `Closes
#` / `Refs #` OR (b) described the issue in-PR following the relevant
issue template
- [x] I have not referenced internal/instance-local Paperclip issues or
links (only public GitHub `#NNN` / `github.com/paperclipai/paperclip`
URLs)
- [x] My branch name describes the change (e.g. `docs/...`, `fix/...`)
and contains no internal Paperclip ticket id or instance-derived details
- [x] I have run tests locally and they pass
- [x] I have added or updated tests where applicable
- [x] I have updated relevant documentation to reflect my changes
- [x] I have considered and documented any risks above
- [ ] All Paperclip CI gates are green
- [ ] Greptile is 5/5 with no open P2s, recommendations, or follow-ups
- [x] I will address all Greptile and reviewer comments before
requesting merge

Co-authored-by: Paperclip <noreply@paperclip.ing>
2026-11-26 02:25:12 +00:00

152 lines
5.7 KiB
TypeScript

// @vitest-environment jsdom
import { QueryClient, QueryClientProvider } from "@tanstack/react-query";
import { flushSync } from "react-dom";
import { createRoot, type Root } from "react-dom/client";
import { afterEach, beforeEach, describe, expect, it, vi } from "vitest";
import { AgentProviderConnection } from "./AgentProviderConnection";
const mocks = vi.hoisted(() => ({
healthGet: vi.fn(),
startLocalLogin: vi.fn(),
checkLocalLogin: vi.fn(),
submitLocalLoginCode: vi.fn(),
cancelLocalLogin: vi.fn(),
connectLocal: vi.fn(),
listConnections: vi.fn(),
}));
vi.mock("@/api/health", () => ({ healthApi: { get: mocks.healthGet } }));
vi.mock("@/api/ai-connections", () => ({
aiConnectionsApi: {
startLocalLogin: mocks.startLocalLogin,
checkLocalLogin: mocks.checkLocalLogin,
submitLocalLoginCode: mocks.submitLocalLoginCode,
cancelLocalLogin: mocks.cancelLocalLogin,
connectLocal: mocks.connectLocal,
list: mocks.listConnections,
create: vi.fn(),
loginResult: vi.fn(),
},
}));
vi.mock("@/api/agents", () => ({
agentsApi: { getAdapterAuthSignal: vi.fn().mockResolvedValue({ status: "absent" }) },
}));
vi.mock("../onboarding/SavedProviderKeySelect", () => ({
SavedProviderKeySelect: () => null,
useSavedProviderKeys: () => ({
options: [],
subscriptions: [],
loading: false,
error: false,
storedLogin: { data: undefined, isPending: false, isError: false, isFetching: false },
}),
}));
let root: Root;
let host: HTMLDivElement;
beforeEach(() => {
vi.resetAllMocks();
mocks.startLocalLogin.mockResolvedValue({ sessionId: "hosted-session-1", expiresAt: "2099-01-01T00:00:00Z" });
mocks.checkLocalLogin.mockResolvedValue({
status: "sign_in_required",
authorizationUrl: "https://accounts.google.com/o/oauth2/v2/auth?state=hosted-ui-state",
});
mocks.submitLocalLoginCode.mockResolvedValue({ ok: true });
mocks.cancelLocalLogin.mockResolvedValue({});
mocks.connectLocal.mockResolvedValue({ connectionId: "conn-1", grantId: "grant-1" });
mocks.listConnections.mockResolvedValue({ currentUserId: "u1", canManageConnections: true, connections: [] });
host = document.createElement("div");
document.body.append(host);
root = createRoot(host);
});
afterEach(() => {
flushSync(() => root.unmount());
host.remove();
});
function renderConnection(adapterType: "antigravity_runtime" | "claude_local" | "codex_local", localEnvironment: boolean) {
const client = new QueryClient({ defaultOptions: { queries: { retry: false } } });
const provider = adapterType === "antigravity_runtime" ? "google" : adapterType === "claude_local" ? "anthropic" : "openai";
flushSync(() => {
root.render(
<QueryClientProvider client={client}>
<AgentProviderConnection
companyId="company-1"
adapterType={adapterType}
environmentId="sandbox-env-1"
canLogin={false}
localEnvironment={localEnvironment}
onBack={() => {}}
onConnected={() => {}}
testConnection={async () => true}
managedAccount={{
intent: {
provider,
method: "subscription",
name: "Test Account",
ownership: "personal",
agentIds: [],
allAgents: true,
},
onComplete: () => {},
}}
/>
</QueryClientProvider>,
);
});
}
describe("AgentProviderConnection hosted Google sign-in gating", () => {
it("enables hosted Google redirect sign-in for antigravity_runtime on non-local environments", async () => {
mocks.healthGet.mockResolvedValue({
status: "ok",
deploymentMode: "authenticated",
deploymentExposure: "public",
localAiLoginSupported: false,
hostedGoogleAiLoginSupported: true,
});
renderConnection("antigravity_runtime", false);
await vi.waitFor(() => expect(mocks.startLocalLogin).toHaveBeenCalledTimes(1));
await vi.waitFor(() => expect(host.querySelector('input[aria-label="Antigravity redirect URL"]')).not.toBeNull());
expect(host.querySelector('a[href="https://accounts.google.com/o/oauth2/v2/auth?state=hosted-ui-state"]')).not.toBeNull();
expect(host.querySelector('img[src="/brands/apps/antigravity.svg"]')).not.toBeNull();
expect(host.textContent).toContain("Antigravity");
expect(host.textContent).toContain("Sign in to Antigravity");
expect(host.textContent).toContain("127.0.0.1");
});
it("still exposes the Antigravity redirect paste field when local login is also supported (remote private/trusted host)", async () => {
mocks.healthGet.mockResolvedValue({
status: "ok",
deploymentMode: "authenticated",
deploymentExposure: "private",
localAiLoginSupported: true,
hostedGoogleAiLoginSupported: true,
});
renderConnection("antigravity_runtime", true);
await vi.waitFor(() => expect(mocks.startLocalLogin).toHaveBeenCalledTimes(1));
await vi.waitFor(() => expect(host.querySelector('input[aria-label="Antigravity redirect URL"]')).not.toBeNull());
expect(host.textContent).toContain("another machine");
expect(host.textContent).toContain("127.0.0.1");
});
it.each(["claude_local", "codex_local"] as const)("keeps local login disabled for %s on hosted instances", async (adapterType) => {
mocks.healthGet.mockResolvedValue({
status: "ok",
deploymentMode: "authenticated",
deploymentExposure: "public",
localAiLoginSupported: false,
hostedGoogleAiLoginSupported: true,
});
renderConnection(adapterType, false);
await new Promise((resolve) => setTimeout(resolve, 25));
expect(mocks.startLocalLogin).not.toHaveBeenCalled();
expect(host.textContent).toContain("does not support browser sign-in");
});
});