diff --git a/dashboard/e2e/require-sso.spec.ts b/dashboard/e2e/require-sso.spec.ts index c299a4de..a390f218 100644 --- a/dashboard/e2e/require-sso.spec.ts +++ b/dashboard/e2e/require-sso.spec.ts @@ -1,9 +1,10 @@ import { expect, test, type Page, type Route } from "@playwright/test"; // Require single sign-on, with the team's Okta or its own Microsoft Entra -// tenant. Settings, Sign-in rules shows each provider, what turning it on -// needs, the recovery words before and after, who isn't linked and their -// one-time links. The sign-in screen, for a team that requires it, shows only +// tenant. Settings, Sign-in rules shows the state now, a provider to choose, +// what turning it on needs (each step done or not, and how to do it), why the +// button is off, the consequences once in the confirm, who isn't linked and +// their one-time links. The sign-in screen, for a team that requires it, shows only // that provider: no password form, and no owner's way around it. Every API // call is answered here; nothing reaches Okta, Microsoft or a real backend. @@ -177,17 +178,79 @@ for (const width of [1280, 390]) { test("each provider says what turning it on needs; only a ready one can be chosen", async ({ page }) => { await mock(page, { signedIn: true }); await page.goto("/settings/sign-in"); + await expect(page.getByTestId("require-sso-state")).toContainText("Off"); + // The readiest provider is chosen first; Okta is one step short. + await expect(page.getByTestId("sso-choose-microsoft")).toHaveAttribute("aria-checked", "true"); + await expect(page.getByTestId("sso-choose-okta")).toContainText("1 step left"); + await page.getByTestId("sso-choose-okta").click(); const okta = page.getByTestId("sso-option-okta"); await expect(page.getByTestId("require-sso-okta")).toBeDisabled(); await expect(okta.getByTestId("need-session-okta")).toHaveAttribute("data-ok", "no"); + await expect(okta.getByTestId("need-owner-okta")).toHaveAttribute("data-ok", "yes"); + await expect(page.getByTestId("require-sso-reason")).toHaveText("Finish the step above first."); + await page.getByTestId("sso-choose-microsoft").click(); await expect(page.getByTestId("require-sso-microsoft")).toBeEnabled(); - // Recovery is said next to the choice, before anything is turned on. + await expect(page.getByTestId("require-sso-reason")).toHaveCount(0); + // Recovery, keys and support access are folded into the details, said once. + await page.getByText("If Microsoft Entra is down, and other details").click(); await expect(page.getByTestId("sso-recovery-microsoft")).toContainText("nobody can sign in until it's fixed"); - await expect(page.getByTestId("require-sso-keys")).toContainText("Keys follow their maker"); - await expect(page.getByTestId("require-sso-support")).toContainText("read-only, never a session in your team"); + await expect(page.getByTestId("require-sso-keys")).toContainText("suspended, not deleted"); + await expect(page.getByTestId("require-sso-support")).toContainText("never a session in your team"); await noSidewaysScroll(page); }); + test("requirements unmet say why and keep the button off; met, it confirms with the consequences", async ({ page }) => { + const state = await mock(page, { + signedIn: true, + options: [ + { provider: "okta", name: "Okta", set_up: false, enabled: false, domains_verified: false, session_from_provider: false, is_owner: true }, + { provider: "microsoft", name: "Microsoft Entra", ...READY }, + ], + unlinked: [{ user_id: "ann", email: "ann@example.org", name: "Ann Lee", role: "member" }], + }); + await page.goto("/settings/sign-in"); + await page.getByTestId("sso-choose-okta").click(); + await expect(page.getByTestId("sso-choose-okta")).toContainText("3 steps left"); + await expect(page.getByTestId("need-on-okta")).toHaveAttribute("data-ok", "no"); + // Each open step says how to do it: setup is a link to the Okta section. + await expect(page.getByTestId("go-setup-okta")).toHaveText("Set up Okta"); + await expect(page.getByTestId("go-setup-okta")).toHaveAttribute("href", "#okta"); + await expect(page.getByTestId("need-session-okta")).toContainText("Once Okta is on, sign in with it"); + await expect(page.getByTestId("require-sso-okta")).toBeDisabled(); + await expect(page.getByTestId("require-sso-reason")).toHaveText("Finish the 3 steps above first."); + await noSidewaysScroll(page); + + await page.getByTestId("sso-choose-microsoft").click(); + await expect(page.getByTestId("require-sso-microsoft")).toBeEnabled(); + await expect(page.getByTestId("require-sso-reason")).toHaveCount(0); + await page.getByTestId("require-sso-microsoft").click(); + const dialog = page.getByTestId("require-sso-confirm"); + await expect(dialog).toContainText("Require Microsoft Entra for everyone on this team?"); + await expect(dialog.getByTestId("consequence-sessions")).toContainText("the owner's included"); + await expect(dialog.getByTestId("consequence-unlinked")).toContainText("Ann Lee hasn't linked Microsoft Entra"); + await expect(dialog.getByTestId("consequence-keys")).toContainText("nightly-ci"); + await expect(dialog.getByTestId("consequence-recovery")).toContainText("support verifies them out of band"); + await noSidewaysScroll(page); + // Cancel sends nothing. + await dialog.getByRole("button", { name: "Cancel" }).click(); + await expect(dialog).toHaveCount(0); + expect(state.puts).toEqual([]); + }); + + test("a member who isn't the owner is told why the button is off", async ({ page }) => { + await mock(page, { + signedIn: true, + options: [ + { provider: "okta", name: "Okta", ...READY, is_owner: false }, + { provider: "microsoft", name: "Microsoft Entra", ...READY, is_owner: false }, + ], + }); + await page.goto("/settings/sign-in"); + await expect(page.getByTestId("need-owner-okta")).toHaveAttribute("data-ok", "no"); + await expect(page.getByTestId("require-sso-okta")).toBeDisabled(); + await expect(page.getByTestId("require-sso-reason")).toHaveText("Only the owner can turn this on."); + }); + test("turning it on confirms the recovery and who isn't linked, then sends the provider", async ({ page }) => { const state = await mock(page, { signedIn: true, @@ -195,8 +258,8 @@ for (const width of [1280, 390]) { }); await page.goto("/settings/sign-in"); await page.getByTestId("require-sso-microsoft").click(); - const confirm = page.getByTestId("confirm-dialog"); - await expect(confirm).toContainText("Require single sign-on with Microsoft Entra for everyone on this team?"); + const confirm = page.getByTestId("require-sso-confirm"); + await expect(confirm).toContainText("Require Microsoft Entra for everyone on this team?"); await expect(confirm).toContainText("If Microsoft Entra is down or misconfigured, nobody can sign in until it's fixed."); await expect(confirm).toContainText("Ann Lee"); await expect(confirm).toContainText("the owner's included"); @@ -204,9 +267,10 @@ for (const width of [1280, 390]) { await expect(confirm).toContainText("These keys are suspended until their maker links Microsoft Entra: nightly-ci."); await expect(confirm).toContainText("stays ended if you turn this off later"); await noSidewaysScroll(page); - await page.getByRole("button", { name: "Require Microsoft Entra" }).click(); + await page.getByTestId("require-sso-confirm-yes").click(); await expect.poll(() => state.puts.at(-1)).toEqual({ require_sso: "microsoft", acknowledge_unlinked: true }); - await expect(page.getByTestId("require-sso-state")).toContainText("Required with Microsoft Entra"); + await expect(page.getByTestId("require-sso-state")).toContainText("Required: Microsoft Entra"); + await expect(page.getByTestId("suspended-keys-microsoft")).toContainText("nightly-ci"); await expect(page.getByTestId("sso-recovery")).toContainText("support verifies them out of band"); }); @@ -215,7 +279,7 @@ for (const width of [1280, 390]) { await page.goto("/settings/sign-in"); await expect(page.getByTestId("keys-unread")).toContainText("couldn't read the team's keys"); await page.getByTestId("require-sso-microsoft").click(); - const confirm = page.getByTestId("confirm-dialog"); + const confirm = page.getByTestId("require-sso-confirm"); await expect(confirm).toContainText("couldn't read the team's keys, so it can't say which would be suspended"); await expect(confirm).not.toContainText("These keys are suspended"); await noSidewaysScroll(page); diff --git a/dashboard/scripts/ui-lint.mjs b/dashboard/scripts/ui-lint.mjs index f0f1fc33..601b38ec 100644 --- a/dashboard/scripts/ui-lint.mjs +++ b/dashboard/scripts/ui-lint.mjs @@ -7,8 +7,10 @@ // // Errors (fail the run): // model-name a Claude model named in page text; names come from lib/models.ts -// brand "Coderhelm" anywhere in src; the product is "CoderHelm", as on the site, -// the logo, the repositories and the docs +// brand "Coderhelm" or "Coder Helm" anywhere in src or in the e2e specs and their +// mock data (what the screenshots show); the product is "CoderHelm", as on +// the site, the logo, the repositories and the docs. Words the server sends +// are shown through productWords() (settings/sign-in/require-sso.tsx) // jargon openspec, " pass", TOTP, HMAC, "Log Analyzer" in UI copy // unlabeled-input an ,