// Selfhost-only (browser): guards two pieces of user feedback about the // API-keys experience on a self-hosted instance — // // 1. the copy-API-key buttons work even on a plain-HTTP (non-secure) origin, // and // 2. the API keys page is reachable from the main sidebar. // // Selfhost is the right target for (1): a self-hosted console is typically // served over plain HTTP on a LAN host/IP — a NON-secure origin, where the // browser does not expose `navigator.clipboard`. There the copy buttons fall // back to `document.execCommand("copy")` (see @executor-js/react `lib/clipboard`). // The harness runs on http://localhost, which IS a secure context, so the copy // test drops `navigator.clipboard` to reproduce the real deployment and records // what the page copies through the fallback. import { randomBytes } from "node:crypto"; import { expect } from "@effect/vitest"; import { Effect } from "effect"; import { AccountHttpApi } from "@executor-js/api"; import { scenario } from "../src/scenario"; import { Api, Browser, Target } from "../src/services"; declare global { interface Window { // The copy test stashes the text the page copied (via the execCommand // fallback) here, so it can be read back out of the browser context. __e2eCopied?: Array; } } scenario( "API keys · the page is reachable from the main sidebar", {}, Effect.gen(function* () { const target = yield* Target; const browser = yield* Browser; const identity = yield* target.newIdentity(); yield* browser.session(identity, async ({ page, step }) => { await step("Land on the dashboard", async () => { await page.goto("/", { waitUntil: "networkidle" }); // The shared shell's main nav lists the workspace sections. await page.locator("nav").getByRole("link", { name: "Integrations" }).first().waitFor(); }); await step("The main sidebar links straight to API keys", async () => { // Feedback: "the api keys link should be in the main sidebar." Today the // link lives only in the account dropdown at the bottom of the sidebar // (a closed popover that isn't even mounted), so there is no API-keys // link in the main