Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 10 additions & 2 deletions dashboard/e2e/hybrid.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ function status(s: State) {
{ id: "slack_notifications", name: "Slack and Teams notifications", mode: "direct", through_coderhelm: "", stays_with_you: "", uses_coderhelm: false },
{ id: "mcp_apps", name: "Figma, Linear, Sentry, Sanity and other sign-in apps", mode: "direct", through_coderhelm: "", stays_with_you: "", uses_coderhelm: false },
{ id: "slack_commands", name: "Slack and Teams commands", mode: "unavailable", through_coderhelm: "", stays_with_you: "", reason: "CoderHelm has no shared Slack or Teams app: each team connects its own app's signing secret in Plugins settings, so there is nothing to relay. That keeps working the same way on a hybrid install.", uses_coderhelm: false },
{ id: "github_sign_in", name: "Sign in with GitHub", mode: "unavailable", through_coderhelm: "", stays_with_you: "", reason: "Signing people in to your install with GitHub needs your own GitHub App: a hosted app's sign-in would hand CoderHelm your people's identities. Use email sign-in, or Google with your own domain.", uses_coderhelm: false },
{ id: "github_sign_in", name: "Sign in with GitHub", mode: "included", through_coderhelm: "Without a GitHub OAuth client of your own, GitHub's sign-in page is CoderHelm's GitHub App: CoderHelm passes GitHub's one-time code to your install, exchanges it when your install asks (with a secret only your install holds), and revokes the token at GitHub seconds later. It stores neither and doesn't ask GitHub who signed in.", stays_with_you: "Who signs in: your install asks GitHub itself whose account it is, then applies its own rules (team members and invites, two-factor). CoderHelm can't start a session on your install or choose who signs in.", reason: "", uses_coderhelm: false },
],
sharing: s.sharing,
checks,
Expand Down Expand Up @@ -319,7 +319,15 @@ test("other apps: each choice sends only that tool; direct and unavailable say s
await expect(page.getByTestId("hybrid-integration-slack_notifications")).toContainText("Works from your install, no app needed");
await expect(page.getByTestId("hybrid-integration-mcp_apps")).toContainText("Works from your install, no app needed");
await expect(page.getByTestId("hybrid-integration-slack_commands")).toContainText("Not available");
await expect(page.getByTestId("hybrid-integration-github_sign_in")).toContainText("needs your own GitHub App");
// Sign in with GitHub works through Coderhelm's app: on, nothing to choose,
// and the card says the install decides who signs in.
const signIn = page.getByTestId("hybrid-integration-github_sign_in");
await expect(signIn).toHaveAttribute("data-mode", "included");
await expect(signIn).toContainText("On through Coderhelm's app");
await expect(signIn).toContainText("your install asks GitHub itself whose account it is");
await expect(signIn).not.toContainText("Google");
await expect(signIn).not.toContainText("Not available");
await expect(signIn.getByRole("button")).toHaveCount(0);
// GitHub has its own row above, so it isn't listed again.
await expect(page.getByTestId("hybrid-integration-github")).toHaveCount(0);
});
Expand Down
24 changes: 19 additions & 5 deletions dashboard/e2e/sign-in-methods.spec.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,11 @@
import { expect, test, type Page, type Route } from "@playwright/test";

// The sign-in screen shows only the ways in that work on this deployment, as
// the API's GET /auth/methods says. A self-hosted install on Coderhelm's
// GitHub App (hybrid) has no GitHub OAuth client of its own, so it offers no
// GitHub button: before this, the button sent people to GitHub with an empty
// client_id and GitHub answered 404. Every API call is answered here.
// the API's GET /auth/methods says. A self-hosted install offers GitHub with
// an OAuth client of its own, or on Coderhelm's GitHub App (hybrid) once it is
// registered: the same /auth/github then goes through Coderhelm's app and the
// install checks the account itself. An install with neither shows no GitHub
// button. Every API call is answered here.

type Methods = { password: boolean; google: boolean; github: boolean };

Expand Down Expand Up @@ -41,7 +42,7 @@ async function mockApi(page: Page, opts: { selfHosted: boolean; methods: Methods
const github = (page: Page) => page.getByRole("link", { name: "Continue with GitHub" });
const google = (page: Page) => page.getByRole("link", { name: "Continue with Google" });

test("hybrid install with no GitHub client: email and password only, no GitHub button and no 'or'", async ({ page }) => {
test("self-hosted install with no way to GitHub: email and password only, no GitHub button and no 'or'", async ({ page }) => {
const { calls } = await mockApi(page, { selfHosted: true, methods: { password: true, google: false, github: false } });
await page.goto("/");
await expect(page.getByLabel("Email")).toBeVisible();
Expand All @@ -62,6 +63,19 @@ test("self-hosted install with its own GitHub client: the GitHub button goes to
await expect(page.getByText("or", { exact: true })).toBeVisible();
});

test("hybrid install registered with Coderhelm: GitHub is offered and starts at the install's own /auth/github", async ({ page }) => {
const { calls } = await mockApi(page, { selfHosted: true, methods: { password: true, google: false, github: true } });
await page.goto("/");
await expect.poll(() => calls.includes("/auth/methods")).toBe(true);
await expect(github(page)).toBeVisible();
// The install's API starts the trip (it then goes through Coderhelm's app),
// never a Coderhelm address in the page itself.
await expect(github(page)).toHaveAttribute("href", "/auth/github");
await expect(github(page)).not.toHaveAttribute("href", /coderhelm\.com/);
await expect(google(page)).toHaveCount(0);
await expect(page.getByLabel("Email")).toBeVisible();
});

test("self-hosted install whose API has no method list yet: no GitHub button", async ({ page }) => {
await mockApi(page, { selfHosted: true, methods: "missing" });
await page.goto("/");
Expand Down
6 changes: 4 additions & 2 deletions dashboard/src/components/hybrid-section.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -666,15 +666,17 @@ function IntegrationItem({ i, hybrid, s }: { i: HybridIntegration } & RowProps)
/>
) : i.mode === "direct" ? (
<Chip tone="success">Works from your install, no app needed</Chip>
) : i.mode === "included" ? (
<Chip tone="success">On through Coderhelm&apos;s app</Chip>
) : (
<Chip tone="muted">Not available</Chip>
)}
</div>
{notOffered && <p className="mt-1 text-sm text-zinc-400">Use your own {i.name} app for now.</p>}
{i.mode === "hosted" && !notOffered && (i.through_coderhelm || i.stays_with_you) && (
{(i.mode === "hosted" || i.mode === "included") && !notOffered && (i.through_coderhelm || i.stays_with_you) && (
<dl className="mt-2 grid min-w-0 gap-x-4 gap-y-1 text-sm sm:grid-cols-2">
{i.through_coderhelm && (
<div className={`min-w-0 ${value === "coderhelm" ? "" : "opacity-60"}`}>
<div className={`min-w-0 ${value === "coderhelm" || i.mode === "included" ? "" : "opacity-60"}`}>
<dt className="text-zinc-300">Through Coderhelm</dt>
<dd className="text-zinc-400">{i.through_coderhelm}</dd>
</div>
Expand Down
6 changes: 4 additions & 2 deletions dashboard/src/hooks/use-sign-in-methods.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,10 @@ import { isSelfHosted } from "@/lib/runtime-config";
// The sign-in methods that work on this deployment, from the API
// (`GET /auth/methods`): the sign-in screen shows these and no others, so it
// never offers a button that ends on someone else's error page. A
// self-hosted install has GitHub only with an OAuth client of its own; an
// install on Coderhelm's GitHub App (hybrid) has none.
// self-hosted install has GitHub with an OAuth client of its own, or, on
// Coderhelm's GitHub App (hybrid), once it is registered with Coderhelm: the
// same /auth/github then goes through Coderhelm's app and the install still
// decides who signs in.
//
// Until the API answers, and when it can't (an older gateway), the hosted
// service keeps Google and GitHub and a self-hosted install shows email and
Expand Down
2 changes: 1 addition & 1 deletion dashboard/src/lib/api.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4574,7 +4574,7 @@ export interface HybridGithubLink {
export interface HybridIntegration {
id: HybridIntegrationId;
name: string;
mode: "hosted" | "direct" | "unavailable";
mode: "hosted" | "direct" | "included" | "unavailable";
through_coderhelm: string;
stays_with_you: string;
reason?: string;
Expand Down
Loading