mirror of
https://github.com/farion1231/cc-switch.git
synced 2026-11-20 07:52:52 +08:00
2baa686218
DeepSeek Harness serves the signed-in account's models through its bundled account plugin, so nothing has to be written into a profile. Mirror the Kimi Code flow on top of that: - The add dialog offers "DeepSeek official sign-in" in the account-login group; it shows a short explanation and a button that opens the Auth Center at the DeepSeek Harness section instead of creating a provider. - When signed in, an official account card (name, Official chip, balance, expired hint) leads the "Added" section and counts toward its total. The card is derived from the shared sign-in status rather than stored as a provider row, so it never enters the DSH write path or cloud sync, and it follows sign-in/sign-out in the Auth Center immediately. Edit and remove stay disabled with a hint to sign out in the Auth Center.
93 lines
2.7 KiB
TypeScript
93 lines
2.7 KiB
TypeScript
import { fireEvent, render, screen } from "@testing-library/react";
|
|
import { QueryClientProvider } from "@tanstack/react-query";
|
|
import { beforeAll, beforeEach, describe, expect, it, vi } from "vitest";
|
|
import { AddProviderDialog } from "@/components/providers/AddProviderDialog";
|
|
import { dshApi, type DshAccountStatus } from "@/lib/api/dsh";
|
|
import { createTestQueryClient } from "../utils/testQueryClient";
|
|
|
|
vi.mock("@/lib/api/dsh", () => ({
|
|
dshApi: {
|
|
accountStatus: vi.fn(),
|
|
accountSignOut: vi.fn(),
|
|
loginStart: vi.fn(),
|
|
loginPoll: vi.fn(),
|
|
loginCancel: vi.fn(),
|
|
},
|
|
}));
|
|
vi.mock("@/components/providers/forms/CopilotAuthSection", () => ({
|
|
CopilotAuthSection: () => null,
|
|
}));
|
|
vi.mock("@/components/providers/forms/CodexOAuthSection", () => ({
|
|
CodexOAuthSection: () => null,
|
|
}));
|
|
vi.mock("@/components/providers/forms/XaiOAuthSection", () => ({
|
|
XaiOAuthSection: () => null,
|
|
}));
|
|
vi.mock("@/components/providers/forms/AgyOAuthSection", () => ({
|
|
AgyOAuthSection: () => null,
|
|
}));
|
|
vi.mock("@/components/providers/KimiAccountLogin", () => ({
|
|
KimiAccountLogin: () => null,
|
|
}));
|
|
vi.mock("@/components/JsonEditor", () => ({
|
|
default: () => null,
|
|
}));
|
|
|
|
beforeAll(() => {
|
|
Element.prototype.scrollIntoView ??= vi.fn();
|
|
window.matchMedia ??= vi.fn().mockReturnValue({
|
|
matches: false,
|
|
addEventListener: vi.fn(),
|
|
removeEventListener: vi.fn(),
|
|
});
|
|
});
|
|
|
|
const signedOut: DshAccountStatus = {
|
|
signedIn: false,
|
|
expired: false,
|
|
issuer: null,
|
|
profile: null,
|
|
wallets: [],
|
|
bonusWallets: [],
|
|
usageUrl: null,
|
|
topUpUrl: null,
|
|
error: null,
|
|
};
|
|
|
|
describe("DeepSeek account entry in the DeepSeek Harness add-provider dialog", () => {
|
|
beforeEach(() => {
|
|
vi.mocked(dshApi.accountStatus).mockResolvedValue(signedOut);
|
|
});
|
|
|
|
it("directs official sign-in to Auth Center without provider fields or an add footer", async () => {
|
|
const onSubmit = vi.fn();
|
|
render(
|
|
<QueryClientProvider client={createTestQueryClient()}>
|
|
<AddProviderDialog
|
|
open
|
|
appId="dsh"
|
|
onOpenChange={vi.fn()}
|
|
onSubmit={onSubmit}
|
|
/>
|
|
</QueryClientProvider>,
|
|
);
|
|
|
|
fireEvent.click(
|
|
await screen.findByRole("button", { name: "dsh.account.presetName" }),
|
|
);
|
|
const manage = await screen.findByRole("button", {
|
|
name: "dsh.account.manageAccounts",
|
|
});
|
|
expect(
|
|
screen.queryByRole("button", { name: "common.add" }),
|
|
).not.toBeInTheDocument();
|
|
expect(screen.queryByLabelText("API Key")).not.toBeInTheDocument();
|
|
|
|
fireEvent.click(manage);
|
|
expect(
|
|
await screen.findByRole("region", { name: "DeepSeek Harness" }),
|
|
).toBeInTheDocument();
|
|
expect(onSubmit).not.toHaveBeenCalled();
|
|
});
|
|
});
|