mirror of
https://github.com/nightly-labs/openbot.git
synced 2026-12-04 02:20:34 +08:00
Remove low-signal tests and Storybook play functions, prefer E2E tests (#826)
* Remove low-signal unit tests and prefer E2E tests Delete test cases that cannot catch a real bug the CI E2E suite misses: copies of a stronger test, checks of constants or markup, checks of a mock's own return value, and implementation details. 65 cases in 43 files, including two whole files. Replace the mandatory-test list in AGENTS.md with E2E-first rules: no unit tests after the code, E2E tests with a repeatable artifact, and a failure-mode list in the PR body before an isolated test. * Keep tests minimal and add tests only for irreversible bugs * Remove Storybook play functions and unused test IDs CI only builds Storybook, so the 324 play functions never ran. Remove them, the helpers only they used, and 113 stories that looked the same as another story without their play function. Nothing reads the five renderer data-testid hooks now. Remove them and set the check:ui budget to zero. * Restore safety tests and remove stories that show only General Restore five deleted tests that guard data loss, agent isolation, a secret header, and the disabled updater. Delete stories that open on the General pane after their play functions were removed. Update the review rubric and the UI foundation doc to the new test rules. * Enforce the story and failure-mode test rules Add a Biome rule that rejects a story play function, with fixtures and a test. Add a "Failure modes" section to the PR template. Tell the reviewer to report a unit test that the section does not name. * Require tests for every database migration State in AGENTS.md and the test review rubric that a migration always needs tests, as src/backend/AGENTS.md already requires.
This commit is contained in:
@@ -9,6 +9,12 @@
|
||||
- [ ] Relevant manual smoke test completed, or not applicable
|
||||
- [ ] No credentials, private data, generated output, or real user files are included
|
||||
|
||||
## Failure modes
|
||||
|
||||
<!-- Remove this section unless the PR adds or changes a unit test. Write the list before the code: one line per way the system can fail, with the test that covers it. -->
|
||||
|
||||
-
|
||||
|
||||
## Risk and security impact
|
||||
|
||||
<!-- Note changes to permissions, IPC, filesystem access, persistence, browser behavior, or network access. Write "None" when not applicable. -->
|
||||
|
||||
@@ -27,12 +27,13 @@ Report a finding when the diff:
|
||||
- Mocks the unit under test, or stubs so much of the collaborator graph that the assertion can only
|
||||
observe the mocks. *Exception:* `electron`, `electron-updater`, and `node:` built-ins have no
|
||||
injectable seam and are exempt by policy.
|
||||
- Adds a unit test that no line of the PR body's "Failure modes" section names. `AGENTS.md` asks
|
||||
for that list before an isolated test; a test without one is a test written after the code.
|
||||
- Adds a new test *file* for a boundary an existing file already covers, or tests the same behaviour
|
||||
at both the component and the application level. `AGENTS.md` requires the lowest stable boundary,
|
||||
once.
|
||||
at both the component and the application level. `AGENTS.md` asks for one test, preferably E2E.
|
||||
|
||||
Do not report a missing test unless you can name the concrete regression it would catch, and do not
|
||||
ask for coverage of a mandatory boundary that the diff already covers elsewhere. A thin test at one
|
||||
of the seams `AGENTS.md` makes mandatory — the renderer-to-main trust boundary, the IPC contract,
|
||||
schema and migrations, persisted state, secrets, the provider process boundary, the Team API wire
|
||||
protocol, the updater — is not a finding for being thin.
|
||||
Do not report a missing test unless you can name the concrete regression it would catch, and that
|
||||
regression can lose user data, break a released protocol, weaken the trust boundary, or leak a
|
||||
secret. `AGENTS.md` does not ask for a regression test by default. A database migration is the
|
||||
exception: it always needs tests, and `contracts-and-migrations.md` lists them. A thin test at one of those
|
||||
seams is not a finding for being thin.
|
||||
|
||||
@@ -146,20 +146,27 @@ risks since the last release.
|
||||
|
||||
## Tests
|
||||
|
||||
- Prefer an existing test. Add a test only for a user or caller consequence; add a file only for a
|
||||
new boundary. Skip assertions already enforced by TypeScript, Biome, or `check:ui`.
|
||||
- Tests are mandatory for changes to the renderer-to-main boundary, IPC contracts, database schema
|
||||
and migrations, persisted state, secrets, provider processes, Team API wire protocols, and the
|
||||
updater. Test once at the lowest stable boundary.
|
||||
- Keep tests minimal. Do not add a regression test by default. Add a test only when a bug can lose
|
||||
user data, break a released protocol, weaken the trust boundary, or leak a secret, or when the
|
||||
same bug came back.
|
||||
- A database migration always needs tests: data-preservation fixtures for every affected released
|
||||
schema, plus the failure and rollback cases that [src/backend/AGENTS.md](src/backend/AGENTS.md)
|
||||
lists.
|
||||
- Highly prefer E2E tests as the sole testing mechanism. Use them to verify complex features work.
|
||||
At the end of E2E tests, produce a verifiable and repeatable artifact, such as a JSON report or a
|
||||
screenshot under `.openbot-build/`.
|
||||
- If you must test a system in isolation, first write down all the ways it could fail, then write
|
||||
the code. Put the list in the PR body under "Failure modes": one line per failure, with the test
|
||||
that covers it.
|
||||
- Do not assert what TypeScript, Biome, or `check:ui` already enforce.
|
||||
- Wait for state, an event, or a promise, not elapsed time. A spy can provide the wait condition,
|
||||
such as `await waitFor(() => expect(send).toHaveBeenCalled())`; assert the user consequence after
|
||||
that wait. Do not remove synchronization because it uses a spy.
|
||||
- Assert behavior and data. Query accessible roles and names; use `toHaveFocus()` for focus.
|
||||
Do not assert markup, classes, layout, animation timing, or snapshots. Use exact text only for
|
||||
product contracts, error/security messages, serialized output, or localization keys.
|
||||
- Use Storybook for visual details. Do not add test IDs to avoid missing accessibility.
|
||||
Story play functions can use them; renderer `data-testid` use must stay within the existing
|
||||
`check:ui` budget of five. A new hook must replace an existing one.
|
||||
- Use Storybook for visual details only. Do not add story `play` functions: CI does not run them.
|
||||
Do not add `data-testid` hooks; `check:ui` allows none.
|
||||
- `*.test.ts` uses Node; `*.test.tsx` uses JSX and jsdom; `*.dom.test.ts` uses DOM without a
|
||||
component. Keep pure logic in Node tests.
|
||||
|
||||
|
||||
+1
-1
@@ -40,7 +40,7 @@ Type-only imports (`import type`) are erased by the compiler and stay allowed in
|
||||
## Pull requests
|
||||
|
||||
1. Create a branch from `main`.
|
||||
2. Add or update tests for behavior changes and reproduced bugs.
|
||||
2. Test behavior changes and reproduced bugs as [AGENTS.md, Tests](AGENTS.md#tests) describes.
|
||||
3. Run `bun run check`. Coding agents do not: see [AGENTS.md, Checks](AGENTS.md#checks).
|
||||
4. Describe user-visible changes, risks, and manual verification in the pull request.
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { DOWNLOAD_PLATFORM_ORDER, DOWNLOAD_PLATFORMS, detectDownloadPlatform } from "../src/lib/download-platforms";
|
||||
import { OPENBOT_DOWNLOAD_LINKS } from "../src/lib/landing-links";
|
||||
import { detectDownloadPlatform } from "../src/lib/download-platforms";
|
||||
|
||||
describe("download platforms", () => {
|
||||
it.each([
|
||||
@@ -16,16 +15,4 @@ describe("download platforms", () => {
|
||||
it("returns no platform for an unknown client", () => {
|
||||
expect(detectDownloadPlatform({ platform: "Unknown" })).toBeUndefined();
|
||||
});
|
||||
|
||||
it("offers a download for every platform it can detect", () => {
|
||||
for (const platform of DOWNLOAD_PLATFORM_ORDER) {
|
||||
const details = DOWNLOAD_PLATFORMS[platform];
|
||||
expect(details).toMatchObject({ available: true, status: "Available", href: OPENBOT_DOWNLOAD_LINKS[platform] });
|
||||
}
|
||||
});
|
||||
|
||||
it("describes the Linux download as an x64 AppImage", () => {
|
||||
expect(DOWNLOAD_PLATFORMS.linux.description).toBe("x64 · AppImage");
|
||||
expect(DOWNLOAD_PLATFORMS.linux.action).toBe("Download for Linux");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { renderToString } from "@solidjs/web";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { PricingSection } from "../src/components/landing/PricingSection";
|
||||
import { AppPreviewPage } from "../src/routes/app-preview.lazy";
|
||||
|
||||
describe("landing page", () => {
|
||||
@@ -10,12 +9,4 @@ describe("landing page", () => {
|
||||
expect(markup).toContain('aria-label="Loading OpenBot preview"');
|
||||
expect(markup).not.toContain('aria-label="Agent navigation"');
|
||||
});
|
||||
|
||||
it("states the price in the server-rendered markup", () => {
|
||||
const markup = renderToString(() => <PricingSection />);
|
||||
|
||||
expect(markup).toContain("What it costs");
|
||||
expect(markup).toContain("$0");
|
||||
expect(markup).toContain("OpenBot is free. No hidden fees. No locked features.");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -120,15 +120,6 @@ describe("plugin page", () => {
|
||||
}
|
||||
});
|
||||
|
||||
/* The one way off this page that is not the app or the site header, and the only navigable thing
|
||||
the article layout added. */
|
||||
it("leads back to the whole catalog", () => {
|
||||
const plugin = firstPlugin();
|
||||
renderPage(() => <PluginPage plugin={plugin} />);
|
||||
|
||||
expect(screen.getByRole("link", { name: "All plugins" })).toHaveAttribute("href", "/plugins");
|
||||
});
|
||||
|
||||
it("opens the listing in the app with a link built from the slug", () => {
|
||||
const plugin = firstPlugin();
|
||||
renderPage(() => <PluginPage plugin={plugin} />);
|
||||
|
||||
@@ -73,18 +73,6 @@ it("disables every feedback event immediately and restores the preference after
|
||||
expect(native.feedback).toHaveBeenCalledWith("notification", "success");
|
||||
});
|
||||
|
||||
it.each(["light", "medium", "heavy", "soft", "rigid"] as const)("plays the requested %s impact", async (style) => {
|
||||
await loadHapticsPreference();
|
||||
await haptics.impact(style);
|
||||
expect(native.feedback).toHaveBeenCalledWith("impact", style);
|
||||
});
|
||||
|
||||
it.each(["success", "warning", "error"] as const)("plays the requested %s notification", async (type) => {
|
||||
await loadHapticsPreference();
|
||||
await haptics.notification(type);
|
||||
expect(native.feedback).toHaveBeenCalledWith("notification", type);
|
||||
});
|
||||
|
||||
it("keeps feedback off on a read failure and permits saving a new preference", async () => {
|
||||
native.read.mockRejectedValueOnce(new Error("Storage unavailable"));
|
||||
await expect(loadHapticsPreference()).rejects.toThrow("Storage unavailable");
|
||||
|
||||
@@ -205,6 +205,10 @@
|
||||
"./tools/biome/anti-slop/rules/no-sleep-in-tests.grit"
|
||||
]
|
||||
},
|
||||
{
|
||||
"includes": ["**/*.stories.ts", "**/*.stories.tsx"],
|
||||
"plugins": ["./tools/ui-foundation/no-story-play.grit"]
|
||||
},
|
||||
{
|
||||
"includes": ["packages/ui/src/**/*.ts", "packages/ui/src/**/*.tsx"],
|
||||
"plugins": ["./tools/ui-foundation/no-desktop-preload.grit"],
|
||||
|
||||
@@ -152,11 +152,11 @@ Biome rejects these patterns in tests: `toHaveClass`, `toHaveStyle`, `getCompute
|
||||
`querySelector("svg" | "img")`, `document.activeElement`, snapshots, `*ByTestId` queries,
|
||||
assertions reached through CSS classes, an awaited bare `setTimeout`, and `it.only`.
|
||||
Use `toHaveFocus()` to name the element whose focus matters. Storybook stories are the place for
|
||||
visual checks and play functions.
|
||||
visual checks. Stories have no `play` functions: CI only builds Storybook, so a play function never
|
||||
ran. `tools/ui-foundation/no-story-play.grit` rejects a new one in any `*.stories.tsx` file.
|
||||
|
||||
GritQL cannot connect a test query to the product's `data-testid` attribute. `check:ui` checks the
|
||||
renderer attribute budget separately. The budget is five because existing story play functions
|
||||
use three of those hooks. It permits replacement, not growth.
|
||||
GritQL cannot connect a test query to the product's `data-testid` attribute. `check:ui` counts
|
||||
renderer `data-testid` attributes separately, with a budget of zero.
|
||||
|
||||
`check:ui` also detects CSS classes that no component, story, or HTML entry point names. This found
|
||||
about 1,400 lines of unused CSS. A dynamic `prefix-${value}` counts as a use only inside a class
|
||||
|
||||
@@ -19,7 +19,7 @@ Features — the `src/renderer/src/features/<domain>/` directories — import pr
|
||||
|
||||
Colours must come from the semantic `--openbot-*` variables. Text sizes, radii and animation durations use tokens. Hover applies only inside `@media (hover: hover) and (pointer: fine)`, pressable controls use `scale(0.97)`, and animations stay below 300 ms and respect `prefers-reduced-motion`.
|
||||
|
||||
`bun run check:ui` blocks native buttons and switches, hand-rolled dialogs/menus/tabs/listboxes, direct Kobalte/Lucide imports outside the UI layer, and colour literals along with untokenized text sizes, radii and transition durations. The check covers every renderer stylesheet as well as inline declarations in TSX; the only place a colour literal is allowed is the shared palette `packages/brand/src/tokens.css`. It also checks that the complex namespaces have not gone back to direct Kobalte aliases. Every migration budget is zero, except the `data-testid` budget, which stays at the five hooks already in the tree.
|
||||
`bun run check:ui` blocks native buttons and switches, hand-rolled dialogs/menus/tabs/listboxes, direct Kobalte/Lucide imports outside the UI layer, and colour literals along with untokenized text sizes, radii and transition durations. The check covers every renderer stylesheet as well as inline declarations in TSX; the only place a colour literal is allowed is the shared palette `packages/brand/src/tokens.css`. It also checks that the complex namespaces have not gone back to direct Kobalte aliases. Every migration budget is zero, including the `data-testid` budget.
|
||||
|
||||
## Verification
|
||||
|
||||
|
||||
@@ -23,9 +23,6 @@ function bodyPathAt(state: StateId, radii: number[]): string {
|
||||
return new BotEngine(RAYON, state, radii, null).sample(POSES[state]).bodyPath;
|
||||
}
|
||||
|
||||
/** States that draw their own body, so the silhouette they are given makes no difference. */
|
||||
const SHAPE_BLIND_STATES = ["orbit", "thinking", "burst", "egg"] as const satisfies readonly StateId[];
|
||||
|
||||
describe("shape-safe states", () => {
|
||||
it("lists exactly the states that keep the avatar's silhouette", () => {
|
||||
const fromCatalogue = STATES.filter((state) => state.baseBody).map((state) => state.id);
|
||||
@@ -36,12 +33,6 @@ describe("shape-safe states", () => {
|
||||
it.each(SHAPE_SAFE_STATES)("draws the chosen silhouette in %s", (state) => {
|
||||
expect(bodyPathAt(state, radiiOf("cercle"))).not.toEqual(bodyPathAt(state, radiiOf("triangle")));
|
||||
});
|
||||
|
||||
// The failing case this replaces, kept so the reason for the allowlist stays visible: these
|
||||
// states ignore the silhouette entirely, so two different agents render the same body.
|
||||
it.each(SHAPE_BLIND_STATES)("ignores the chosen silhouette in %s", (state) => {
|
||||
expect(bodyPathAt(state, radiiOf("cercle"))).toEqual(bodyPathAt(state, radiiOf("triangle")));
|
||||
});
|
||||
});
|
||||
|
||||
describe("avatarMoodPresentation", () => {
|
||||
@@ -58,8 +49,4 @@ describe("avatarMoodPresentation", () => {
|
||||
expect(STATES.find((state) => state.id === presentation.state)?.baseFace).toBe(true);
|
||||
}
|
||||
});
|
||||
|
||||
it("keeps breathing small enough to stay a scale rather than a shape change", () => {
|
||||
for (const mood of MOODS) expect(avatarMoodPresentation(mood).breathe).toBeLessThanOrEqual(0.06);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -25,16 +25,6 @@ describe("attachment file whitelist", () => {
|
||||
expect(isSupportedAttachmentName("no-extension")).toBe(false);
|
||||
});
|
||||
|
||||
it("accepts EML as a single attachment", () => {
|
||||
expect(isSupportedAttachmentName("message.eml")).toBe(true);
|
||||
expect(ATTACHMENT_FILE_ACCEPT).toContain(".eml");
|
||||
});
|
||||
|
||||
it.each(["recording.MP3", "Screen Recording.mov"])("accepts %s in the picker", (name) => {
|
||||
expect(isSupportedAttachmentName(name)).toBe(true);
|
||||
expect(ATTACHMENT_FILE_ACCEPT).toContain(`.${name.split(".").at(-1)?.toLowerCase()}`);
|
||||
});
|
||||
|
||||
it("offers media only when the selected host supports it, without hiding other files", () => {
|
||||
const legacy = supportedAttachmentExtensions({ eml: false, media: false });
|
||||
expect(legacy).not.toContain("mp3");
|
||||
|
||||
@@ -32,10 +32,6 @@ describe("translateFor", () => {
|
||||
expect(translateFor("fr")("provider.endpointCount", { count: 1 })).toBe("1 point de terminaison");
|
||||
expect(translateFor("fr")("provider.endpointCount", { count: 2 })).toBe("2 points de terminaison");
|
||||
});
|
||||
|
||||
it("fills a placeholder", () => {
|
||||
expect(translateFor("en")("startup.failedBody", { message: "Disk is full" })).toContain("Disk is full");
|
||||
});
|
||||
});
|
||||
|
||||
describe("createTranslate", () => {
|
||||
|
||||
@@ -458,7 +458,7 @@ export function AccountDock(props: AccountDockProps) {
|
||||
<span title={props.account.email}>{props.account.email}</span>
|
||||
<Show when={!props.remoteClient && props.appInfo}>
|
||||
{(info) => (
|
||||
<span class="sr-only" data-testid="app-version">
|
||||
<span class="sr-only">
|
||||
Version {info().version} · {info().platform}
|
||||
</span>
|
||||
)}
|
||||
@@ -517,7 +517,7 @@ export function AccountDock(props: AccountDockProps) {
|
||||
<span title={props.account.email}>{props.account.email}</span>
|
||||
<Show when={!props.remoteClient && props.appInfo}>
|
||||
{(info) => (
|
||||
<span class="sr-only" data-testid="app-version">
|
||||
<span class="sr-only">
|
||||
Version {info().version} · {info().platform}
|
||||
</span>
|
||||
)}
|
||||
|
||||
@@ -102,11 +102,6 @@ describe("routine schedule mapping", () => {
|
||||
expect(routineScheduleToDraft(saved)).toEqual(draft);
|
||||
});
|
||||
|
||||
it.each(cases)("keeps $name stable over a round trip", ({ draft }) => {
|
||||
const saved = routineScheduleFromDraft(draft);
|
||||
expect(routineScheduleFromDraft(routineScheduleToDraft(saved))).toEqual(saved);
|
||||
});
|
||||
|
||||
it("reads a window end that is not on the run minute as the last run", () => {
|
||||
const draft: RoutineScheduleDraft = {
|
||||
kind: "hourly",
|
||||
|
||||
@@ -204,7 +204,6 @@ export function SettingsDialogShell(props: SettingsDialogShellProps) {
|
||||
<Dialog.Overlay
|
||||
class="settings-modal-backdrop"
|
||||
data-motion={closing() ? "closing" : "open"}
|
||||
data-testid="settings-modal-backdrop"
|
||||
onPointerDown={(event) => {
|
||||
if (event.target === event.currentTarget) requestOpenChange(false);
|
||||
}}
|
||||
@@ -244,7 +243,6 @@ export function SettingsDialogShell(props: SettingsDialogShellProps) {
|
||||
class="settings-modal-scroll-frame"
|
||||
data-scroll-up={canScrollUp() ? "" : undefined}
|
||||
data-scroll-down={canScrollDown() ? "" : undefined}
|
||||
data-testid="settings-modal-scroll-frame"
|
||||
>
|
||||
<div ref={registerScrollElement} class="settings-modal-content" onScroll={updateScrollFades}>
|
||||
{props.children}
|
||||
|
||||
@@ -2,21 +2,6 @@ import { describe, expect, it } from "vitest";
|
||||
import { loadAgentRuntimeLock, parseAgentRuntimeLock } from "./agent-runtime-lock";
|
||||
|
||||
describe("agent runtime lock", () => {
|
||||
it("loads the pinned provider runtimes for every supported target", async () => {
|
||||
const lock = await loadAgentRuntimeLock();
|
||||
|
||||
expect(lock.codex.version).toBe("0.153.4");
|
||||
expect(lock.codex.artifacts["darwin-arm64"].assetSha256).toHaveLength(64);
|
||||
expect(lock.codex.artifacts["win32-x64"].assetSha256).toHaveLength(64);
|
||||
expect(lock.claude.sdkVersion).toBe("0.3.263");
|
||||
expect(lock.claude.version).toBe("2.1.263");
|
||||
expect(lock.claude.artifacts["darwin-arm64"].binarySha256).toHaveLength(64);
|
||||
expect(lock.claude.artifacts["win32-x64"].binarySha256).toHaveLength(64);
|
||||
expect(lock.grok.version).toBe("1.0.22");
|
||||
expect(lock.grok.artifacts["darwin-arm64"].assetSha256).toHaveLength(64);
|
||||
expect(lock.grok.artifacts["win32-x64"].assetSha256).toHaveLength(64);
|
||||
});
|
||||
|
||||
// The schema strips a key it does not name, so this is what proves the Linux artifacts survive.
|
||||
it("keeps the Linux artifact of every provider", async () => {
|
||||
const lock = await loadAgentRuntimeLock();
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
import type { Page } from "playwright-core";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { clickByRole, typeByRole } from "./tools";
|
||||
|
||||
function fakePage(calls: unknown[]): Page {
|
||||
return {
|
||||
getByRole: (role: string, options: { name: string; exact?: boolean }) => {
|
||||
calls.push([role, options]);
|
||||
return {
|
||||
click: async () => undefined,
|
||||
fill: async () => undefined,
|
||||
press: async () => undefined,
|
||||
};
|
||||
},
|
||||
// biome-ignore lint/nursery/noUnsafeTypeAssertion: fake implements only the locator surface under test.
|
||||
} as unknown as Page;
|
||||
}
|
||||
|
||||
describe("exact role matching", () => {
|
||||
it("forwards --exact to the role locator on click", async () => {
|
||||
const calls: unknown[] = [];
|
||||
await clickByRole(fakePage(calls), "button", "Settings", 1000, true);
|
||||
expect(calls).toEqual([["button", { name: "Settings", exact: true }]]);
|
||||
});
|
||||
|
||||
it("keeps substring matching unless --exact passes", async () => {
|
||||
const calls: unknown[] = [];
|
||||
await clickByRole(fakePage(calls), "button", "Settings", 1000);
|
||||
await typeByRole(fakePage(calls), "textbox", "Message", "hi", 1000, false);
|
||||
expect(calls).toEqual([
|
||||
["button", { name: "Settings", exact: false }],
|
||||
["textbox", { name: "Message", exact: false }],
|
||||
]);
|
||||
});
|
||||
});
|
||||
@@ -1,7 +1,6 @@
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
import {
|
||||
configureMobileConnectDevelopmentNetwork,
|
||||
configureSiteHostingDevelopmentEnvironment,
|
||||
createDevelopmentServiceSpec,
|
||||
createDevStackRecord,
|
||||
developmentEnvironmentForTarget,
|
||||
@@ -10,22 +9,11 @@ import {
|
||||
parseDevelopmentTarget,
|
||||
projectRoot,
|
||||
selectMobileConnectLanAddress,
|
||||
servicesForTarget,
|
||||
signalOwnedProcess,
|
||||
stopOwnedProcesses,
|
||||
} from "./dev-services";
|
||||
|
||||
describe("development service runner", () => {
|
||||
it("runs the normal API and app in a stable order", () => {
|
||||
expect(servicesForTarget("all")).toEqual(["api", "remote", "app"]);
|
||||
expect(servicesForTarget("app")).toEqual(["api", "remote", "app"]);
|
||||
});
|
||||
|
||||
it("starts a complete isolated two-client harness on demand", () => {
|
||||
expect(servicesForTarget("test-client")).toEqual(["api", "remote", "app", "test-client"]);
|
||||
expect(servicesForTarget("api")).toEqual(["api"]);
|
||||
});
|
||||
|
||||
it("seeds the app profile the start is about to create", () => {
|
||||
const missing = () => false;
|
||||
const specs = (environment: NodeJS.ProcessEnv) => [
|
||||
@@ -61,12 +49,6 @@ describe("development service runner", () => {
|
||||
expect(developmentEnvironmentForTarget("test-client", {}).OPENBOT_DEV_TEST_CLIENT_ENABLED).toBe("1");
|
||||
});
|
||||
|
||||
it("builds the API command without a shell command string", () => {
|
||||
const spec = createDevelopmentServiceSpec("api", {});
|
||||
expect(spec.executable).toBe(process.execPath);
|
||||
expect(spec.args).toEqual(["run", "--cwd", `${projectRoot}/apps/auth-api`, "dev"]);
|
||||
});
|
||||
|
||||
it("builds the local Signal command with the Auth API development keys", () => {
|
||||
const spec = createDevelopmentServiceSpec("remote", { REMOTE_SIGNAL_PORT: "3101" });
|
||||
|
||||
@@ -119,18 +101,6 @@ describe("development service runner", () => {
|
||||
expect(environment.ELECTRON_RUN_AS_NODE).toBe("1");
|
||||
});
|
||||
|
||||
it("enables hosted sites in the development environment", () => {
|
||||
const environment: NodeJS.ProcessEnv = {};
|
||||
|
||||
configureSiteHostingDevelopmentEnvironment(environment, 3_100);
|
||||
|
||||
expect(environment).toEqual({
|
||||
SITE_PUBLISH_ENABLED: "true",
|
||||
SITE_COOKIE_ISOLATION_READY: "true",
|
||||
SITE_LOCAL_ORIGIN: "http://openbot.localhost:3100",
|
||||
});
|
||||
});
|
||||
|
||||
it("advertises the preferred private LAN address for Mobile Connect development", () => {
|
||||
const interfaces = {
|
||||
utun3: [{ address: "10.8.0.2", family: "IPv4" as const, internal: false }],
|
||||
|
||||
@@ -12,17 +12,6 @@ import {
|
||||
import { pinRuntimeLockDocument } from "./pin-remote-desktop-runtime";
|
||||
|
||||
describe("native runtime lock", () => {
|
||||
it("loads pinned native dependencies", async () => {
|
||||
const lock = await loadNativeRuntimeLock();
|
||||
|
||||
expect(lock.remoteDesktop.sunshine.version).toBe("v2026.516.143833");
|
||||
expect(lock.remoteDesktop.moonlightWeb.version).toBe("v2.10.0");
|
||||
expect(lock.remoteDesktop.sunshine.sourceMode).toBe("upstream-with-patch");
|
||||
expect(lock.remoteDesktop.moonlightWeb.sourceMode).toBe("upstream-with-patch");
|
||||
expect(lock.remoteDesktop.sunshine.upstream.commit).toBe("14ffa6fdaa53f7b51512be2b3d24f3939695403c");
|
||||
expect(lock.remoteDesktop.moonlightWeb.upstream.commit).toBe("cd9d03cbf9a42b394f7b72a733a2f39cb5f0edd8");
|
||||
});
|
||||
|
||||
it("creates a source manifest for both GPL runtimes", async () => {
|
||||
const lock = await loadNativeRuntimeLock();
|
||||
const manifest = createRemoteDesktopSourceManifest(lock);
|
||||
|
||||
@@ -297,13 +297,6 @@ describe("NorbiAI reviewer selection", () => {
|
||||
);
|
||||
});
|
||||
|
||||
it("pins the cap to gpt-6-astra at low", () => {
|
||||
expect(job.env.CAPPED_MODEL).toBe("gpt-6-astra");
|
||||
expect(job.env.CAPPED_MODEL_EFFORT).toBe("low");
|
||||
// Capping a model that never reads the effort would cap nothing.
|
||||
expect(job.env.EFFORT_MODELS?.split(" ")).toContain(job.env.CAPPED_MODEL);
|
||||
});
|
||||
|
||||
// The effort only reaches gpt-6-astra: a chatgpt-web slug carries its own level. The list
|
||||
// is what that model accepts, less `max` and `ultra`, which are withheld on purpose — so
|
||||
// the assertion is exact rather than a subset check, and putting one back has to be a
|
||||
|
||||
@@ -79,13 +79,11 @@ describe("ui foundation check", () => {
|
||||
budget("untokenized font-size", 1),
|
||||
budget("untokenized border-radius", 1),
|
||||
budget("untokenized transition durations", 2),
|
||||
// Six against a budget of five, because a non-zero budget only reports once the tree
|
||||
// exceeds it: five in branches/TestHooks.tsx and the sixth in components/ui/Button.tsx.
|
||||
// That sixth is the whole reason this budget reads its own source join rather than the
|
||||
// one the composite scan uses - exempt components/ui and the count reads 5, meets the
|
||||
// budget and says nothing. The hook in Bad.test.tsx is the other side: count test files
|
||||
// and this reads 7.
|
||||
budget("data-testid hooks in renderer markup", 6, 5),
|
||||
// Six: five in branches/TestHooks.tsx and the sixth in components/ui/Button.tsx. That
|
||||
// sixth is why this budget reads its own source join rather than the one the composite
|
||||
// scan uses - exempt components/ui and the count reads 5. The hook in Bad.test.tsx is
|
||||
// the other side: count test files and this reads 7.
|
||||
budget("data-testid hooks in renderer markup", 6),
|
||||
].sort(),
|
||||
);
|
||||
});
|
||||
@@ -165,41 +163,65 @@ it("checks primitive adapters when the shared UI is outside the renderer", () =>
|
||||
expect(clean.failures).toEqual([]);
|
||||
});
|
||||
|
||||
it("rejects desktop preload access in shared UI while allowing browser APIs and documentation", () => {
|
||||
const workspace = mkdtempSync(resolve(tmpdir(), "ui-boundary-"));
|
||||
interface PluginDiagnostic {
|
||||
category: string;
|
||||
severity: string;
|
||||
message: string;
|
||||
location?: { start?: { line?: number } };
|
||||
}
|
||||
|
||||
/** Runs one GritQL plugin on one fixture file and returns only the plugin's diagnostics. */
|
||||
function pluginDiagnostics(plugin: string, fixture: string, extension: string): PluginDiagnostic[] {
|
||||
const workspace = mkdtempSync(resolve(tmpdir(), "ui-plugin-"));
|
||||
try {
|
||||
const plugin = resolve(import.meta.dirname, "../tools/ui-foundation/no-desktop-preload.grit");
|
||||
writeFileSync(
|
||||
resolve(workspace, "biome.json"),
|
||||
JSON.stringify({
|
||||
plugins: [plugin],
|
||||
plugins: [resolve(import.meta.dirname, "../tools/ui-foundation", plugin)],
|
||||
linter: { enabled: true, rules: { recommended: false } },
|
||||
formatter: { enabled: false },
|
||||
assist: { enabled: false },
|
||||
}),
|
||||
);
|
||||
for (const [sourceRoot, file, expected] of [
|
||||
[fixtureRenderer, "DesktopPreload.ts", 6],
|
||||
[fixtureRenderer, "OptionalPreload.ts", 1],
|
||||
[fixtureRenderer, "IndexedPreload.ts", 1],
|
||||
[cleanRenderer, "BrowserGlobals.ts", 0],
|
||||
] as const) {
|
||||
const target = resolve(workspace, "fixture.ts");
|
||||
writeFileSync(target, readFileSync(resolve(sourceRoot, "components/ui", file)));
|
||||
const result = spawnSync(
|
||||
resolve(import.meta.dirname, "../node_modules/.bin/biome"),
|
||||
["check", target, `--config-path=${workspace}`, "--reporter=json"],
|
||||
{ encoding: "utf8" },
|
||||
);
|
||||
const report: { diagnostics: { category: string; severity: string; message: string }[] } = JSON.parse(
|
||||
result.stdout,
|
||||
);
|
||||
const diagnostics = report.diagnostics.filter((item) => item.category === "plugin");
|
||||
expect(diagnostics.filter((item) => item.message.includes("errored"))).toEqual([]);
|
||||
expect(diagnostics).toHaveLength(expected);
|
||||
if (expected) expect(diagnostics[0]?.severity).toBe("error");
|
||||
}
|
||||
const target = resolve(workspace, `fixture.${extension}`);
|
||||
writeFileSync(target, readFileSync(fixture));
|
||||
const result = spawnSync(
|
||||
resolve(import.meta.dirname, "../node_modules/.bin/biome"),
|
||||
["check", target, `--config-path=${workspace}`, "--reporter=json"],
|
||||
{ encoding: "utf8" },
|
||||
);
|
||||
const report: { diagnostics: PluginDiagnostic[] } = JSON.parse(result.stdout);
|
||||
const diagnostics = report.diagnostics.filter((item) => item.category === "plugin");
|
||||
expect(diagnostics.filter((item) => item.message.includes("errored"))).toEqual([]);
|
||||
return diagnostics;
|
||||
} finally {
|
||||
rmSync(workspace, { recursive: true, force: true });
|
||||
}
|
||||
}
|
||||
|
||||
it("rejects desktop preload access in shared UI while allowing browser APIs and documentation", () => {
|
||||
for (const [sourceRoot, file, expected] of [
|
||||
[fixtureRenderer, "DesktopPreload.ts", 6],
|
||||
[fixtureRenderer, "OptionalPreload.ts", 1],
|
||||
[fixtureRenderer, "IndexedPreload.ts", 1],
|
||||
[cleanRenderer, "BrowserGlobals.ts", 0],
|
||||
] as const) {
|
||||
const diagnostics = pluginDiagnostics("no-desktop-preload.grit", resolve(sourceRoot, "components/ui", file), "ts");
|
||||
expect(diagnostics).toHaveLength(expected);
|
||||
if (expected) expect(diagnostics[0]?.severity).toBe("error");
|
||||
}
|
||||
});
|
||||
|
||||
it("rejects a story play function on each line its fixture marks, and nothing in a visual story", () => {
|
||||
const fixture = resolve(fixtureRenderer, "stories/Play.stories.tsx");
|
||||
const marked = readFileSync(fixture, "utf8")
|
||||
.split("\n")
|
||||
.flatMap((line, index) => (line.trimEnd().endsWith("// flag") ? [index + 1] : []));
|
||||
const flagged = pluginDiagnostics("no-story-play.grit", fixture, "tsx").map((item) => item.location?.start?.line);
|
||||
|
||||
expect(marked.length).toBeGreaterThan(0);
|
||||
expect(flagged).toEqual(marked);
|
||||
expect(pluginDiagnostics("no-story-play.grit", resolve(cleanRenderer, "stories/Visual.stories.tsx"), "tsx")).toEqual(
|
||||
[],
|
||||
);
|
||||
});
|
||||
|
||||
@@ -222,12 +222,9 @@ export function checkUiFoundation(
|
||||
const debtBudgets = [
|
||||
["hand-rolled composite ARIA roles", manualCompositeCount, 0],
|
||||
// Biome rejects the *ByTestId queries, but a GritQL rule cannot see a JSX attribute in
|
||||
// the product tree, so root AGENTS.md rules this out in prose alone. The five that exist
|
||||
// are not dead weight: three are read by play functions in src/renderer/stories, where
|
||||
// the test rules relax by design. So this freezes the count rather than demanding zero -
|
||||
// a new hook has to replace an old one, and the accessible-name route is the only way to
|
||||
// reach an element the sixth time.
|
||||
["data-testid hooks in renderer markup", matches(testHookSource, /data-testid\s*=/gu), 5],
|
||||
// the product tree, so this count is the only guard against a hook in markup. Reach an
|
||||
// element by its accessible name instead.
|
||||
["data-testid hooks in renderer markup", matches(testHookSource, /data-testid\s*=/gu), 0],
|
||||
["colour literals outside the palette", colorLiteralCount, 0],
|
||||
["untokenized font-size", matches(legacyStyles, /font-size:(?!\s*(?:var\(|inherit\b))\s*[^;]+/gu), 0],
|
||||
[
|
||||
|
||||
@@ -850,54 +850,6 @@ describe.sequential("AgentService: providers", () => {
|
||||
});
|
||||
});
|
||||
|
||||
// The same refresh asks one question of each thread: is a turn running on it. `readConversation`
|
||||
// answers that too, but it loads and parses every message of the thread to do it, so a settings
|
||||
// change would read the whole history of every agent on the main process and throw it away.
|
||||
it("does not read a conversation to find whether a thread is busy", async () => {
|
||||
const { store, mailbox } = stores(root);
|
||||
const client = new FakeAgentClient("codex", "CODEX_DONE", true, true);
|
||||
service = createTestService({
|
||||
store,
|
||||
mailbox,
|
||||
preferredProvider: "codex",
|
||||
clientFactory: () => client,
|
||||
});
|
||||
await service.initialize();
|
||||
await service.sendMessage({ agentId: "chief", text: "Start." });
|
||||
await waitFor(() => service?.listQueue("chief").deliveries.every((delivery) => delivery.status === "completed"));
|
||||
const firstSession = store.activeProviderSession("chief")?.externalSessionId;
|
||||
|
||||
const readConversation = vi.spyOn(store.database, "readConversation");
|
||||
const readActiveTurnId = vi.spyOn(store.database, "readActiveTurnId");
|
||||
service.saveMcpServer({
|
||||
config: {
|
||||
id: "",
|
||||
name: "Filesystem",
|
||||
transport: "stdio",
|
||||
enabled: true,
|
||||
command: "/bin/echo",
|
||||
args: ["ready"],
|
||||
env: [],
|
||||
envPassthrough: [],
|
||||
workingDirectory: "",
|
||||
url: "",
|
||||
headers: [],
|
||||
},
|
||||
});
|
||||
// The refresh did reach the question - otherwise the first expectation would pass on a path that
|
||||
// never ran - and it answered it from the thread row alone.
|
||||
expect(readActiveTurnId).toHaveBeenCalled();
|
||||
expect(readConversation).not.toHaveBeenCalled();
|
||||
readConversation.mockRestore();
|
||||
readActiveTurnId.mockRestore();
|
||||
|
||||
await service.sendMessage({ agentId: "chief", text: "Continue." });
|
||||
await waitFor(() =>
|
||||
service?.listQueue("chief").deliveries.every((delivery) => ["completed", "failed"].includes(delivery.status)),
|
||||
);
|
||||
expect(store.activeProviderSession("chief")?.externalSessionId).not.toBe(firstSession);
|
||||
});
|
||||
|
||||
// The queue keeps a failed delivery's reason in the database and shows it again in the app, so a
|
||||
// provider that rejects a start by quoting what it was sent would store the credential for good.
|
||||
it("keeps an MCP credential out of the reason a failed delivery keeps", async () => {
|
||||
|
||||
@@ -53,21 +53,9 @@ describe("applySiteIdentity", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("passes other hosts through with the same content", () => {
|
||||
expect(applySiteIdentity("https://accounts.google.com/", { "User-Agent": rawAgent })).toEqual({
|
||||
"User-Agent": rawAgent,
|
||||
});
|
||||
});
|
||||
|
||||
it("invents no header when none is sent", () => {
|
||||
expect(applySiteIdentity("https://web.whatsapp.com/", { Accept: "text/html" })).toEqual({
|
||||
Accept: "text/html",
|
||||
});
|
||||
});
|
||||
|
||||
it("never mutates the input record", () => {
|
||||
const input = { "user-agent": rawAgent };
|
||||
applySiteIdentity("https://web.whatsapp.com/", input);
|
||||
expect(input).toEqual({ "user-agent": rawAgent });
|
||||
});
|
||||
});
|
||||
|
||||
@@ -10,7 +10,6 @@ import {
|
||||
OPENCODE_PROFILE_CONFIG,
|
||||
type OpenCodeProviderOptions,
|
||||
openCodeConfigEnv,
|
||||
openCodeSignInMessage,
|
||||
} from "./opencode-config";
|
||||
|
||||
function provider(overrides: Partial<CustomProviderConfig> = {}): CustomProviderConfig {
|
||||
@@ -89,14 +88,6 @@ describe("mergeOpenCodeConfig", () => {
|
||||
expect(config?.permission).toEqual({ "*": "deny" });
|
||||
expect(config?.provider?.permission).toBeDefined();
|
||||
});
|
||||
|
||||
it("returns the base alone when there are no providers", () => {
|
||||
expect(mergeOpenCodeConfig(OPENCODE_PROFILE_CONFIG, [])).toEqual({ permission: { "*": "deny" } });
|
||||
});
|
||||
|
||||
it("returns null when there is nothing at all to say", () => {
|
||||
expect(mergeOpenCodeConfig({}, [])).toBeNull();
|
||||
});
|
||||
});
|
||||
|
||||
describe("openCodeConfigEnv", () => {
|
||||
@@ -123,17 +114,3 @@ describe("openCodeConfigEnv", () => {
|
||||
expect(openCodeConfigEnv({}, source)[OPENCODE_CONFIG_ENV]).toContain("studio-local");
|
||||
});
|
||||
});
|
||||
|
||||
describe("openCodeSignInMessage", () => {
|
||||
it("sends a plain OpenCode user to the Go key", () => {
|
||||
expect(openCodeSignInMessage(0)).toContain("OpenCode Go key");
|
||||
});
|
||||
|
||||
it("names the endpoint first when a custom provider is configured", () => {
|
||||
const message = openCodeSignInMessage(1);
|
||||
expect(message).toContain("base URL");
|
||||
expect(message).toContain("API key");
|
||||
// The Go key is still offered, but as the alternative rather than the instruction.
|
||||
expect(message.indexOf("base URL")).toBeLessThan(message.indexOf("OpenCode Go key"));
|
||||
});
|
||||
});
|
||||
|
||||
@@ -104,21 +104,6 @@ describe("approval automation store", () => {
|
||||
expect(automation.turboEnabled()).toBe(false);
|
||||
});
|
||||
|
||||
it("round trips a grant", async () => {
|
||||
const root = await temporaryRoot();
|
||||
const path = join(root, "automation.json");
|
||||
await writeApprovalAutomation(path, {
|
||||
turbo: true,
|
||||
defaultAutoApprove: false,
|
||||
autoApproveOverrides: { "agent-1": true },
|
||||
});
|
||||
await expect(readApprovalAutomation(path, [])).resolves.toEqual({
|
||||
turbo: true,
|
||||
defaultAutoApprove: false,
|
||||
autoApproveOverrides: { "agent-1": true },
|
||||
});
|
||||
});
|
||||
|
||||
it("leaves no temporary file behind", async () => {
|
||||
const root = await temporaryRoot();
|
||||
await writeApprovalAutomation(join(root, "automation.json"), {
|
||||
|
||||
@@ -252,24 +252,6 @@ describe("ComputerUseHighlightController", () => {
|
||||
expect(place).toHaveBeenCalledWith(windows[0], expect.objectContaining({ cursor: { x: 600, y: 500 } }));
|
||||
});
|
||||
|
||||
it("drops the overlay of a display that is unplugged", async () => {
|
||||
const displays = [
|
||||
{ id: 1, bounds: { x: 0, y: 0, width: 1512, height: 982 } },
|
||||
{ id: 2, bounds: { x: 1512, y: 0, width: 2560, height: 1080 } },
|
||||
];
|
||||
const { controller, windows } = controllerWith(
|
||||
[target(7, "Notes", { x: 100, y: 80, width: 900, height: 600 })],
|
||||
displays,
|
||||
);
|
||||
|
||||
await controller.refresh();
|
||||
displays.pop();
|
||||
await controller.refresh();
|
||||
|
||||
expect(windows[1]?.destroy).toHaveBeenCalledTimes(1);
|
||||
expect(windows[0]?.destroy).not.toHaveBeenCalled();
|
||||
});
|
||||
|
||||
it("hides the rim when no agent holds the desktop", async () => {
|
||||
const { controller, windows } = controllerWith([target(7, "Notes", { x: 0, y: 0, width: 800, height: 600 }), null]);
|
||||
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { applicationBundleName, applicationBundlePath, applicationIconName } from "./computer-use-permission-app";
|
||||
import { applicationBundlePath, applicationIconName } from "./computer-use-permission-app";
|
||||
|
||||
describe("applicationBundlePath", () => {
|
||||
it("finds the bundle a packaged executable sits inside", () => {
|
||||
@@ -25,12 +25,6 @@ describe("applicationBundlePath", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("applicationBundleName", () => {
|
||||
it("names the bundle as the list will show it", () => {
|
||||
expect(applicationBundleName("/Applications/OpenBot.app")).toBe("OpenBot");
|
||||
});
|
||||
});
|
||||
|
||||
describe("applicationIconName", () => {
|
||||
it("prefers the icon named after the bundle", () => {
|
||||
expect(applicationIconName("/Applications/OpenBot.app", ["document.icns", "openbot.icns", "en.lproj"])).toBe(
|
||||
|
||||
@@ -2,7 +2,7 @@ import { chmod, mkdir, mkdtemp, writeFile } from "node:fs/promises";
|
||||
import { tmpdir } from "node:os";
|
||||
import { join } from "node:path";
|
||||
import { beforeEach, describe, expect, it } from "vitest";
|
||||
import { type CuaDriverArtifactInput, isSupportedCuaDriverTarget, resolveCuaDriver } from "./cua-driver-artifact";
|
||||
import { type CuaDriverArtifactInput, resolveCuaDriver } from "./cua-driver-artifact";
|
||||
|
||||
let root: string;
|
||||
|
||||
@@ -150,12 +150,4 @@ describe("resolveCuaDriver", () => {
|
||||
await expect(resolveCuaDriver(input({ platform: "linux", architecture: "ppc64" }))).resolves.toBeNull();
|
||||
await expect(resolveCuaDriver(input({ platform: "freebsd", architecture: "x64" }))).resolves.toBeNull();
|
||||
});
|
||||
|
||||
it("names the three desktops as supported, and nothing else", () => {
|
||||
expect(isSupportedCuaDriverTarget("darwin", "arm64")).toBe(true);
|
||||
expect(isSupportedCuaDriverTarget("win32", "x64")).toBe(true);
|
||||
expect(isSupportedCuaDriverTarget("linux", "arm64")).toBe(true);
|
||||
expect(isSupportedCuaDriverTarget("linux", "ppc64")).toBe(false);
|
||||
expect(isSupportedCuaDriverTarget("freebsd", "x64")).toBe(false);
|
||||
});
|
||||
});
|
||||
|
||||
@@ -100,19 +100,6 @@ describe("CuaDriverRuntime", () => {
|
||||
expect(spawned[0]?.options.env.CUA_DRIVER_HOST_BUNDLE_ID).toBe("app.openbot.desktop");
|
||||
});
|
||||
|
||||
it("leaves the cursor to OpenBot on every display", async () => {
|
||||
class ActingTap extends CuaDriverActionTap {
|
||||
override lastPointer() {
|
||||
return { tool: "click", x: 600, y: 500, at: 0 };
|
||||
}
|
||||
}
|
||||
const { driver, spawned } = await runtime({ actionTap: new ActingTap() });
|
||||
await driver.start();
|
||||
|
||||
expect(spawned[0]?.args).toContain("--no-overlay");
|
||||
expect(driver.lastPointer(60_000)).toEqual({ tool: "click", x: 600, y: 500, at: 0 });
|
||||
});
|
||||
|
||||
it("makes neither call the driver makes to its own vendor, because OpenBot ships the driver and pins it", async () => {
|
||||
// Set in the inherited environment, which the daemon spawn copies first. OpenBot ships the
|
||||
// driver, so the analytics and the release check stay off whatever a process it inherits from
|
||||
@@ -444,19 +431,6 @@ describe("CuaDriverRuntime", () => {
|
||||
await granted.driver.stop();
|
||||
});
|
||||
|
||||
it("reports both grants as ready, and a missing one as setup still required", async () => {
|
||||
const granted = await runtime();
|
||||
await expect(granted.driver.state()).resolves.toMatchObject({ status: "ready" });
|
||||
|
||||
const partial = await runtime({
|
||||
readPermissions: async () => [
|
||||
{ id: "screen-recording", granted: true },
|
||||
{ id: "accessibility", granted: false },
|
||||
],
|
||||
});
|
||||
await expect(partial.driver.state()).resolves.toMatchObject({ status: "permissions-required" });
|
||||
});
|
||||
|
||||
// Windows names a pipe in a kernel namespace rather than a path on disk, so nothing is created,
|
||||
// nothing is unlinked, and the path-length rule that macOS and Linux need does not apply.
|
||||
it("serves on a named pipe on Windows, and measures no path", async () => {
|
||||
|
||||
@@ -18,7 +18,6 @@ import {
|
||||
DYNAMIC_ISLAND_COLLAPSE_SETTLE_MS,
|
||||
DynamicIslandWindowController,
|
||||
dynamicIslandNotchSizeForDisplay,
|
||||
dynamicIslandWindowBounds,
|
||||
requireDynamicIslandSender,
|
||||
} from "./dynamic-island-window";
|
||||
|
||||
@@ -120,15 +119,6 @@ describe("dynamic island window geometry", () => {
|
||||
).toBeUndefined();
|
||||
});
|
||||
|
||||
it("centers the overlay at each display top edge", () => {
|
||||
expect(dynamicIslandWindowBounds(display({ bounds: { x: 200, y: -20, width: 1512, height: 982 } }))).toEqual({
|
||||
x: 649,
|
||||
y: -20,
|
||||
width: 614,
|
||||
height: 380,
|
||||
});
|
||||
});
|
||||
|
||||
it("creates, updates, and removes one window per connected display", async () => {
|
||||
const root = await temporaryRoot();
|
||||
const windows: FakeWindow[] = [];
|
||||
|
||||
@@ -10,13 +10,6 @@ const { EXTERNAL_DESTINATIONS } = await import("./app-handlers");
|
||||
const { parseExternalDestination } = await import("./app-inputs");
|
||||
|
||||
describe("external destinations", () => {
|
||||
it("sends the OpenCode key request to the OpenCode sign-in page", () => {
|
||||
// The dialog says the key is optional and the free models need no account. A wrong address here
|
||||
// asks the user for a paid credential on a page OpenBot did not choose.
|
||||
expect(EXTERNAL_DESTINATIONS["opencode-auth"]).toBe("https://opencode.ai/auth");
|
||||
expect(EXTERNAL_DESTINATIONS["opencode-install"]).toBe("https://opencode.ai/docs/");
|
||||
});
|
||||
|
||||
it("sends the host owner to the macOS pane that grants screen recording", () => {
|
||||
// A member who is refused a remote screen cannot grant anything: this address is what the host
|
||||
// owner opens, and a wrong one leaves the desktop dark with no way to repair it.
|
||||
|
||||
@@ -26,7 +26,6 @@ const READY: ComputerUseState = {
|
||||
function bind(options: { show?: (permission: MacPermissionId) => Promise<void> } = {}) {
|
||||
const opened: string[] = [];
|
||||
const shown: MacPermissionId[] = [];
|
||||
const close = vi.fn();
|
||||
const startDrag = vi.fn(async (sender: { id: number }) => {
|
||||
if (sender.id !== 7) throw new Error("The Computer Use drag must start in the help window.");
|
||||
});
|
||||
@@ -37,7 +36,7 @@ function bind(options: { show?: (permission: MacPermissionId) => Promise<void> }
|
||||
shown.push(permission);
|
||||
await options.show?.(permission);
|
||||
},
|
||||
close,
|
||||
close: vi.fn(),
|
||||
permissionApp,
|
||||
startDrag,
|
||||
reveal,
|
||||
@@ -51,7 +50,7 @@ function bind(options: { show?: (permission: MacPermissionId) => Promise<void> }
|
||||
permissionHelp,
|
||||
});
|
||||
for (const [name, register] of Object.entries(endpoints)) register(name);
|
||||
return { opened, shown, close, startDrag, reveal, permissionApp };
|
||||
return { opened, shown, startDrag, reveal, permissionApp };
|
||||
}
|
||||
|
||||
describe("the Computer Use endpoints", () => {
|
||||
@@ -89,14 +88,6 @@ describe("the Computer Use endpoints", () => {
|
||||
expect(shown).toEqual([]);
|
||||
});
|
||||
|
||||
it("takes the steps away when the renderer is done with them", async () => {
|
||||
const { close } = bind();
|
||||
|
||||
await bound.get("closePermissionHelp")?.(APP_FRAME, undefined);
|
||||
|
||||
expect(close).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
// The card the user drags carries the bundle macOS holds responsible, which in a development
|
||||
// build is Electron and not OpenBot.
|
||||
it("names the application the System Settings list will show", async () => {
|
||||
|
||||
@@ -33,17 +33,6 @@ describe("setup store", () => {
|
||||
});
|
||||
});
|
||||
|
||||
it("persists and reads the preferred provider", async () => {
|
||||
const root = await temporaryRoot();
|
||||
const path = join(root, "openbot-setup-v2.json");
|
||||
await writeSetupState(path, { preferredProvider: "grok", preferredModel: null });
|
||||
await expect(readSetupState(path)).resolves.toEqual({
|
||||
completed: true,
|
||||
preferredProvider: "grok",
|
||||
preferredModel: null,
|
||||
});
|
||||
});
|
||||
|
||||
it("persists the preferred model without changing the file version", async () => {
|
||||
const root = await temporaryRoot();
|
||||
const path = join(root, "openbot-setup-v2.json");
|
||||
|
||||
@@ -32,14 +32,6 @@ describe("update preference store", () => {
|
||||
await expect(readUpdatePreference(path)).resolves.toEqual({ autoDownload: true });
|
||||
});
|
||||
|
||||
it("persists an opt-out atomically without leaving temporary files", async () => {
|
||||
const root = await temporaryRoot();
|
||||
const path = join(root, "update.json");
|
||||
await expect(writeUpdatePreference(path, false)).resolves.toEqual({ autoDownload: false });
|
||||
await expect(readUpdatePreference(path)).resolves.toEqual({ autoDownload: false });
|
||||
expect((await readdir(root)).filter((entry) => entry.endsWith(".tmp"))).toEqual([]);
|
||||
});
|
||||
|
||||
it("persists the last of several overlapping writes", async () => {
|
||||
const root = await temporaryRoot();
|
||||
const path = join(root, "update.json");
|
||||
|
||||
@@ -27,10 +27,7 @@ skills for the component patterns, not the imports.
|
||||
- `bun run check:ui` is the design-system guard for this directory: shared primitives over native
|
||||
controls, Kobalte and Lucide only inside `@openbot/ui`, and palette tokens instead of colour,
|
||||
size, radius and transition literals. The pre-commit hook runs it on each commit that stages
|
||||
code, so do not run it by hand — its budgets only ever go down. All of them sit at zero
|
||||
except the `data-testid` hook count, frozen at the five already in the tree;
|
||||
[check design notes](../../docs/development-checks.md#lint-and-ui-rules) say why that one is a
|
||||
ratchet instead of a ban.
|
||||
code, so do not run it by hand — its budgets only ever go down. All of them sit at zero.
|
||||
- Nothing here imports `src/main`, `src/backend` or `src/preload`. `biome.json` rejects it by path,
|
||||
so reaching past the IPC contract fails `bun run lint` rather than review.
|
||||
- Never verify UI with `dist/`, a packaged `.app`, a production build, or an ad-hoc preview — those
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { OtpInput, type OtpInputStatus } from "@openbot/ui/features/account/OtpInput";
|
||||
import { fireEvent, render, screen, within } from "@solidjs/testing-library";
|
||||
import { createSignal } from "solid-js";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
|
||||
function renderOtp(options: { value?: string; status?: OtpInputStatus } = {}) {
|
||||
@@ -94,24 +93,6 @@ describe("OtpInput", () => {
|
||||
expect(slots()[7]?.textContent).toBe("");
|
||||
});
|
||||
|
||||
it("resets its fixed slots when the controlled value is cleared", async () => {
|
||||
const onComplete = vi.fn();
|
||||
render(() => {
|
||||
const [value, setValue] = createSignal("ABCDEFGH");
|
||||
return (
|
||||
<>
|
||||
<OtpInput value={value()} onChange={setValue} onComplete={onComplete} />
|
||||
<button type="button" onClick={() => setValue("")}>
|
||||
Reset
|
||||
</button>
|
||||
</>
|
||||
);
|
||||
});
|
||||
|
||||
await fireEvent.click(screen.getByRole("button", { name: "Reset" }));
|
||||
expect(screen.getByRole("textbox", { name: "One-time code" })).toHaveValue("");
|
||||
});
|
||||
|
||||
it("announces the incorrect code and the verified result", () => {
|
||||
const errorView = renderOtp({ value: "ABCDEFGH", status: "error" });
|
||||
expect(screen.getByRole("alert")).toHaveTextContent("That code is incorrect");
|
||||
|
||||
@@ -2,9 +2,6 @@ import {
|
||||
accountUsageProviderRows,
|
||||
accountUsageRowLabel,
|
||||
accountUsageSummary,
|
||||
usageRemainingPercent,
|
||||
usageTone,
|
||||
usageWindowLabel,
|
||||
} from "@openbot/ui/features/account/account-usage-view";
|
||||
import { assert, describe, expect, it } from "vitest";
|
||||
|
||||
@@ -99,16 +96,4 @@ describe("account usage view", () => {
|
||||
expect(rows[0]).toMatchObject({ name: "Claude", remainingPercent: null });
|
||||
expect(rows[2]).toMatchObject({ name: "Grok", remainingPercent: null });
|
||||
});
|
||||
|
||||
it("labels common windows and remaining quota", () => {
|
||||
expect(usageRemainingPercent(41)).toBe(59);
|
||||
expect(usageTone(59)).toBe("neutral");
|
||||
expect(usageTone(29)).toBe("warning");
|
||||
expect(usageTone(9)).toBe("critical");
|
||||
expect(usageWindowLabel(10_080)).toBe("Weekly");
|
||||
expect(usageWindowLabel(43_200)).toBe("Monthly");
|
||||
expect(usageWindowLabel(300)).toBe("5-hour");
|
||||
expect(usageWindowLabel(1_440)).toBe("Daily");
|
||||
expect(usageWindowLabel(null)).toBe("Limit");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -20,21 +20,6 @@ function withAvatar(index: number, avatarUrl: string | null): AgentProfile {
|
||||
}
|
||||
|
||||
describe("AgentActivityIndicator", () => {
|
||||
it("shows the agent's custom avatar while it works", async () => {
|
||||
const agent = withAvatar(0, "openbot-avatar://agent/chief?v=image-1");
|
||||
const { container } = render(() => <AgentActivityIndicator agent={agent} label="Working on it…" />);
|
||||
|
||||
await screen.findByRole("status");
|
||||
expect(drawnAvatar(container)).toHaveAttribute("data-avatar", "image");
|
||||
});
|
||||
|
||||
it("keeps the generated avatar when the agent has no custom image", async () => {
|
||||
const { container } = render(() => <AgentActivityIndicator agent={withAvatar(0, null)} label="Working on it…" />);
|
||||
|
||||
await screen.findByRole("status");
|
||||
expect(drawnAvatar(container)).toHaveAttribute("data-avatar", "generated");
|
||||
});
|
||||
|
||||
it("follows the agent it is given, including an avatar that is removed", async () => {
|
||||
const [agent, setAgent] = createSignal(withAvatar(0, "openbot-avatar://agent/chief?v=image-1"));
|
||||
const { container } = render(() => <AgentActivityIndicator agent={agent()} label="Working on it…" />);
|
||||
|
||||
@@ -38,21 +38,4 @@ describe("ComposerErrorBanner", () => {
|
||||
await fireEvent.keyDown(screen.getByRole("alert"), { key: "Escape" });
|
||||
expect(onDismiss).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("does not confuse one chat's banner for another", () => {
|
||||
const onDismiss = vi.fn();
|
||||
const { unmount } = render(() => (
|
||||
<ComposerErrorBanner message="Chat A failure" conversationKey="local:agent-a" onDismiss={onDismiss} />
|
||||
));
|
||||
expect(screen.getByRole("alert")).toHaveAttribute("data-conversation-key", "local:agent-a");
|
||||
unmount();
|
||||
|
||||
render(() => (
|
||||
<ComposerErrorBanner message="Chat B failure" conversationKey="local:agent-b" onDismiss={onDismiss} />
|
||||
));
|
||||
const banner = screen.getByRole("alert");
|
||||
expect(banner).toHaveAttribute("data-conversation-key", "local:agent-b");
|
||||
expect(banner).toHaveTextContent("Chat B failure");
|
||||
expect(banner).not.toHaveTextContent("Chat A failure");
|
||||
});
|
||||
});
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
import { AttachmentCards } from "@openbot/ui/features/conversation/AttachmentCards";
|
||||
import {
|
||||
attachmentReferenceBadge,
|
||||
attachmentReferenceTone,
|
||||
} from "@openbot/ui/features/conversation/AttachmentReference";
|
||||
import { attachmentReferenceBadge } from "@openbot/ui/features/conversation/AttachmentReference";
|
||||
import { messageFileReferences } from "@openbot/ui/features/conversation/FileReference";
|
||||
import { fireEvent, render, screen } from "@solidjs/testing-library";
|
||||
import { describe, expect, it, vi } from "vitest";
|
||||
@@ -26,23 +23,6 @@ describe("attachmentReferenceBadge", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("attachmentReferenceTone", () => {
|
||||
it.each([
|
||||
["start-types.d.ts", "source"],
|
||||
["component.JSX", "script"],
|
||||
["index.html", "markup"],
|
||||
["styles.css", "style"],
|
||||
["budget.xlsx", "data"],
|
||||
["brief.PDF", "document"],
|
||||
["diagram.png", "media"],
|
||||
["Program.cs", "default"],
|
||||
["payload.unknown", "default"],
|
||||
["LICENSE", "default"],
|
||||
])("uses the expected file tone for %s", (name, tone) => {
|
||||
expect(attachmentReferenceTone(name)).toBe(tone);
|
||||
});
|
||||
});
|
||||
|
||||
describe("messageFileReferences", () => {
|
||||
const attachment = {
|
||||
id: "report",
|
||||
|
||||
@@ -96,24 +96,6 @@ describe("chat-scoped composer errors", () => {
|
||||
view.dispose();
|
||||
});
|
||||
|
||||
it("dismissed errors do not reappear on reconnect unless a new error occurs", () => {
|
||||
const first = setup(chatA.agentId);
|
||||
first.store.setComposerErrorForTarget(chatA, "Stale failure");
|
||||
expect(first.composerErrors()[keyA]).toBe("Stale failure");
|
||||
first.store.clearChatErrors(chatA);
|
||||
expect(first.composerErrors()[keyA]).toBeUndefined();
|
||||
first.dispose();
|
||||
|
||||
// Reconnect rebuilds the view from stable keyed state with the dismissed
|
||||
// entry gone: nothing reappears.
|
||||
const second = setup(chatA.agentId, { composer: {}, conversation: {} });
|
||||
expect(second.store.currentChatError()).toBeNull();
|
||||
|
||||
second.store.setComposerErrorForTarget(chatA, "New failure after reconnect");
|
||||
expect(second.composerErrors()[keyA]).toBe("New failure after reconnect");
|
||||
second.dispose();
|
||||
});
|
||||
|
||||
it("prefers the transient composer error but keeps the conversation error", () => {
|
||||
const view = setup(chatA.agentId, {
|
||||
composer: { [keyA]: "Composer failure" },
|
||||
|
||||
@@ -1173,7 +1173,7 @@ export function ServerSettingsModal(props: ServerSettingsModalProps) {
|
||||
</label>
|
||||
}
|
||||
>
|
||||
<ItemGroup class="settings-modal-card server-settings-members-list" data-testid="server-members-list">
|
||||
<ItemGroup class="settings-modal-card server-settings-members-list">
|
||||
<Show
|
||||
when={filteredMembers().length > 0}
|
||||
fallback={
|
||||
|
||||
@@ -1079,26 +1079,6 @@ describe("SettingsModal", () => {
|
||||
await waitFor(() => expect(value().turboMode).toBe(false));
|
||||
});
|
||||
|
||||
it("keeps Turbo available without per-agent approval controls", async () => {
|
||||
render(() => (
|
||||
<SettingsModal
|
||||
open
|
||||
onOpenChange={() => undefined}
|
||||
value={DEFAULT_GENERAL_SETTINGS}
|
||||
onValueChange={() => undefined}
|
||||
appInfo={null}
|
||||
updateStatus={idleUpdateStatus}
|
||||
onUpdateAction={async () => {}}
|
||||
account={account}
|
||||
onUpdateAccountName={async () => {}}
|
||||
onUpdateAccountAvatar={async () => {}}
|
||||
/>
|
||||
));
|
||||
|
||||
expect(await screen.findByRole("switch", { name: "Turbo mode" })).toBeEnabled();
|
||||
expect(screen.queryByRole("button", { name: "Revoke all" })).not.toBeInTheDocument();
|
||||
});
|
||||
|
||||
// The second way in, for the computer whose browser cannot finish the first one. What Settings
|
||||
// owns is the entry point and the dialog; the phase itself comes from main.
|
||||
it("opens the code sign-in from the ChatGPT row and shows the code to type", async () => {
|
||||
|
||||
@@ -737,27 +737,6 @@ describe("SkillsMarketplaceModal", () => {
|
||||
expect(screen.getByRole("button", { name: "View Standup Digest details" })).toBeInTheDocument();
|
||||
});
|
||||
|
||||
it("uses category and card skeletons while discover listings load", async () => {
|
||||
let resolvePage!: (page: MarketplaceSkillPage) => void;
|
||||
const pendingPage = new Promise<MarketplaceSkillPage>((resolve) => {
|
||||
resolvePage = resolve;
|
||||
});
|
||||
window.openbot.skills.list = vi.fn(() => pendingPage);
|
||||
|
||||
renderMarketplace({
|
||||
open: true,
|
||||
agents: [{ id: "writer", name: "Writer" }],
|
||||
activeAgentId: "writer",
|
||||
onOpenChange: () => undefined,
|
||||
});
|
||||
openSkillsTab();
|
||||
|
||||
expect(await screen.findByRole("status", { name: "Loading skills" })).toBeInTheDocument();
|
||||
|
||||
resolvePage({ skills: [], nextCursor: null });
|
||||
await waitFor(() => expect(screen.queryByRole("status", { name: "Loading skills" })).not.toBeInTheDocument());
|
||||
});
|
||||
|
||||
it("offers an update when a newer detail version arrives after the installed list was loaded", async () => {
|
||||
const installed: InstalledSkill[] = [
|
||||
{
|
||||
@@ -795,35 +774,6 @@ describe("SkillsMarketplaceModal", () => {
|
||||
expect(await screen.findByRole("button", { name: "Update skill" })).toBeEnabled();
|
||||
});
|
||||
|
||||
it("announces detail loading with its own live region", async () => {
|
||||
// SkillsMarketplaceModal.tsx:1445 is a second status region named
|
||||
// "Loading skill"; the listing skeleton at :1409 is "Loading skills" and
|
||||
// is covered separately, so detail loading needs its own assertion.
|
||||
const loadedDetail = await window.openbot.skills.get("release-notes");
|
||||
let resolveDetail!: (detail: typeof loadedDetail) => void;
|
||||
window.openbot.skills.get = vi.fn(
|
||||
() =>
|
||||
new Promise<typeof loadedDetail>((resolve) => {
|
||||
resolveDetail = resolve;
|
||||
}),
|
||||
);
|
||||
|
||||
renderMarketplace({
|
||||
open: true,
|
||||
agents: [{ id: "writer", name: "Writer" }],
|
||||
activeAgentId: "writer",
|
||||
onOpenChange: () => undefined,
|
||||
});
|
||||
openSkillsTab();
|
||||
const listing = await screen.findByRole("button", { name: "View Release Notes details" });
|
||||
listing.click();
|
||||
|
||||
expect(await screen.findByRole("status", { name: "Loading skill" })).toBeInTheDocument();
|
||||
|
||||
resolveDetail(loadedDetail);
|
||||
await screen.findByRole("region", { name: "Release Notes details" });
|
||||
});
|
||||
|
||||
it.each(["skills", "agents"] as const)("includes the account photo when submitting %s", async (kind) => {
|
||||
window.openbot.skills.choosePackage = vi.fn(async () => ({
|
||||
draftId: "draft",
|
||||
|
||||
@@ -233,12 +233,6 @@ describe("computeSidebarAgentStates", () => {
|
||||
expect(older.chief).toEqual({ kind: "unread", count: 1 });
|
||||
});
|
||||
|
||||
it("keeps a user turn on the working mark", () => {
|
||||
const states = computeSidebarAgentStates(input({ queues: { chief: queue("chief", "running") } }));
|
||||
|
||||
expect(states.chief).toEqual({ kind: "working" });
|
||||
});
|
||||
|
||||
it("lets an unread reply replace a finished routine", () => {
|
||||
const states = computeSidebarAgentStates(
|
||||
input({
|
||||
|
||||
@@ -30,23 +30,6 @@ describe("presentUpdateStatus", () => {
|
||||
expect(presentation.busy).toBe(busy);
|
||||
});
|
||||
|
||||
it("never leaves a phase waiting on preparation", () => {
|
||||
const phases: UpdateStatus["phase"][] = [
|
||||
"idle",
|
||||
"checking",
|
||||
"available",
|
||||
"downloading",
|
||||
"ready",
|
||||
"installing",
|
||||
"up-to-date",
|
||||
"error",
|
||||
"unsupported",
|
||||
];
|
||||
for (const phase of phases) {
|
||||
expect(presentUpdateStatus(status({ phase })).actionLabel).not.toMatch(/preparing/iu);
|
||||
}
|
||||
});
|
||||
|
||||
it.each([
|
||||
// A download is retryable in place. An install is not: shutdown preparation has already run, so
|
||||
// the message asks for a relaunch and the action falls back to checking rather than inviting a
|
||||
|
||||
@@ -13,20 +13,6 @@ describe("OpenBotPlayground", () => {
|
||||
vi.useRealTimers();
|
||||
});
|
||||
|
||||
it("returns host-wide usage and filters agent usage by provider", async () => {
|
||||
const mock = createMockOpenBot();
|
||||
|
||||
await expect(mock.api.agent.getUsage()).resolves.toMatchObject({
|
||||
limits: [{ id: "codex" }, { id: "claude" }, { id: "grok" }],
|
||||
});
|
||||
await expect(mock.api.agent.getUsage("chief")).resolves.toMatchObject({
|
||||
limits: [{ id: "codex", secondary: { usedPercent: 41 } }],
|
||||
});
|
||||
await expect(mock.api.agent.getUsage("research")).resolves.toMatchObject({
|
||||
limits: [{ id: "claude" }],
|
||||
});
|
||||
});
|
||||
|
||||
it("reports ready and accepts a same-origin start message only from its parent", async () => {
|
||||
vi.useFakeTimers();
|
||||
const frames = new Map<number, FrameRequestCallback>();
|
||||
|
||||
@@ -1,65 +0,0 @@
|
||||
import type { SidebarLayoutSnapshot } from "@openbot/contracts/ipc";
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { applySidebarLayoutAction } from "./mock-sidebar-layout";
|
||||
|
||||
const layout: SidebarLayoutSnapshot = {
|
||||
revision: 3,
|
||||
sections: [
|
||||
{ id: "s1", name: "First" },
|
||||
{ id: "s2", name: "Second" },
|
||||
],
|
||||
order: ["s1", "s2"],
|
||||
agentAssignments: { "bot-1": "s1" },
|
||||
agentOrder: ["bot-1"],
|
||||
};
|
||||
|
||||
describe("mock sidebar layout", () => {
|
||||
it("bumps the revision on every action without mutating the input", () => {
|
||||
const next = applySidebarLayoutAction(layout, { type: "rename", sectionId: "s1", name: "Renamed" });
|
||||
expect(next.revision).toBe(4);
|
||||
expect(next.sections[0]?.name).toBe("Renamed");
|
||||
expect(layout.revision).toBe(3);
|
||||
expect(layout.sections[0]?.name).toBe("First");
|
||||
});
|
||||
|
||||
it("creates sections and optionally assigns the new agent", () => {
|
||||
const next = applySidebarLayoutAction(layout, { type: "create", name: " Third ", agentId: "bot-2" });
|
||||
expect(next.sections).toHaveLength(3);
|
||||
const created = next.sections[2];
|
||||
expect(created?.name).toBe("Third");
|
||||
expect(next.order).toEqual(["s1", "s2", created?.id]);
|
||||
expect(next.agentAssignments["bot-2"]).toBe(created?.id);
|
||||
});
|
||||
|
||||
it("deletes sections and drops their assignments", () => {
|
||||
const next = applySidebarLayoutAction(layout, { type: "delete", sectionId: "s1" });
|
||||
expect(next.sections.map((section) => section.id)).toEqual(["s2"]);
|
||||
expect(next.order).toEqual(["s2"]);
|
||||
expect(next.agentAssignments).toEqual({});
|
||||
});
|
||||
|
||||
it("moves sections within bounds and ignores out-of-range moves", () => {
|
||||
const moved = applySidebarLayoutAction(layout, { type: "move", sectionId: "s1", direction: "down" });
|
||||
expect(moved.order).toEqual(["s2", "s1"]);
|
||||
const stayed = applySidebarLayoutAction(layout, { type: "move", sectionId: "s1", direction: "up" });
|
||||
expect(stayed.order).toEqual(["s1", "s2"]);
|
||||
});
|
||||
|
||||
it("orders agents and assigns or unassigns sections", () => {
|
||||
const ordered = applySidebarLayoutAction(layout, {
|
||||
type: "move-agent",
|
||||
agentId: "bot-2",
|
||||
sectionId: "s2",
|
||||
beforeAgentId: "bot-1",
|
||||
});
|
||||
expect(ordered.agentOrder).toEqual(["bot-2", "bot-1"]);
|
||||
expect(ordered.agentAssignments["bot-2"]).toBe("s2");
|
||||
const unassigned = applySidebarLayoutAction(ordered, {
|
||||
type: "assign",
|
||||
agentId: "bot-1",
|
||||
sectionId: null,
|
||||
});
|
||||
expect(unassigned.agentAssignments["bot-1"]).toBeUndefined();
|
||||
expect(unassigned.agentOrder).toContain("bot-1");
|
||||
});
|
||||
});
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { CentralAuthState } from "@openbot/contracts/ipc";
|
||||
import { AccountLogin } from "@openbot/ui/features/account/AccountLogin";
|
||||
import { createSignal } from "solid-js";
|
||||
import { expect, fn } from "storybook/test";
|
||||
import { fn } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
|
||||
const signedOut: CentralAuthState = { status: "signed_out" };
|
||||
@@ -91,47 +91,10 @@ export const Interactive: Story = {
|
||||
},
|
||||
};
|
||||
|
||||
export const HappyPath: Story = {
|
||||
render: (storyArgs) => {
|
||||
const [state, setState] = createSignal(storyArgs.state);
|
||||
return (
|
||||
<AccountLogin
|
||||
{...storyArgs}
|
||||
state={state()}
|
||||
onRequestEmailCode={async (email) => {
|
||||
setState(codeSentState({ email }));
|
||||
}}
|
||||
onVerifyEmailCode={async () => {
|
||||
setState({
|
||||
status: "signed_in",
|
||||
user: { id: "story-user", email: "person@example.com", name: null, avatarUrl: null },
|
||||
});
|
||||
}}
|
||||
/>
|
||||
);
|
||||
},
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.type(canvas.getByLabelText("Email"), "Person@Example.com");
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Send sign-in code" }));
|
||||
await expect(canvas.getByRole("heading", { name: "Check your inbox" })).toBeInTheDocument();
|
||||
await expect(canvas.getByText(/person@example.com/)).toBeInTheDocument();
|
||||
await userEvent.type(canvas.getByRole("textbox", { name: "One-time code" }), "ABCDEFGH");
|
||||
await expect(canvas.getByText("Verified. Opening OpenBot…")).toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
|
||||
export const SendingCode: Story = {
|
||||
args: { state: { status: "signing_in" } },
|
||||
};
|
||||
|
||||
export const InvalidEmail: Story = {
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.type(canvas.getByLabelText("Email"), "not-an-email");
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Send sign-in code" }));
|
||||
await expect(canvas.getByRole("alert")).toHaveTextContent("Enter a valid email address.");
|
||||
},
|
||||
};
|
||||
|
||||
export const CodeSent: Story = {
|
||||
args: { state: codeSentState() },
|
||||
};
|
||||
|
||||
@@ -3,7 +3,7 @@ import {
|
||||
type AccountUsageProviderRow,
|
||||
accountUsageProviderRows,
|
||||
} from "@openbot/ui/features/account/account-usage-view";
|
||||
import { expect, fn, within } from "storybook/test";
|
||||
import { fn } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
|
||||
const mixedRows = accountUsageProviderRows({
|
||||
@@ -57,16 +57,7 @@ const meta = {
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof meta>;
|
||||
|
||||
export const ConnectedProviders: Story = {
|
||||
play: async ({ canvasElement }) => {
|
||||
const canvas = within(canvasElement);
|
||||
await expect(canvas.getByRole("heading", { name: "Usage" })).toBeInTheDocument();
|
||||
await expect(canvas.getByText("ChatGPT")).toBeInTheDocument();
|
||||
await expect(canvas.getByText("Claude")).toBeInTheDocument();
|
||||
await expect(canvas.getByText("Grok")).toBeInTheDocument();
|
||||
await expect(canvas.getByText("0% left")).toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
export const ConnectedProviders: Story = {};
|
||||
|
||||
export const OneProvider: Story = {
|
||||
args: { rows: oneProviderRows },
|
||||
|
||||
@@ -3,7 +3,7 @@ import { Blocks, Download, HardDrive, Monitor, Settings, Tabs, UsersRound } from
|
||||
import { AgentImportView } from "@openbot/ui/features/import/AgentImportView";
|
||||
import { SettingsDialogShell } from "@openbot/ui/features/settings/SettingsDialogShell";
|
||||
import { createSignal } from "solid-js";
|
||||
import { expect, fn, userEvent, within } from "storybook/test";
|
||||
import { fn } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
import { AGENT_IMPORT_PREVIEW, AGENT_IMPORT_SKILL, AGENT_IMPORT_WARNINGS } from "./agent-import-fixtures";
|
||||
import { FILES_NOW } from "./files-fixtures";
|
||||
@@ -56,23 +56,13 @@ function Stage(props: { args: ViewArgs; narrow?: boolean }) {
|
||||
export const Intro: Story = {
|
||||
name: "Import: Steps",
|
||||
render: () => <Stage args={viewArgs()} />,
|
||||
play: async ({ canvas }) => {
|
||||
await expect(canvas.getByRole("button", { name: "Open the export agent" })).toBeVisible();
|
||||
await expect(canvas.getByRole("button", { name: /^Choose export file/u })).toBeEnabled();
|
||||
},
|
||||
};
|
||||
|
||||
export const SetUpYourself: Story = {
|
||||
name: "Import: Set up the skill yourself",
|
||||
render: () => {
|
||||
const [setup, setSetup] = createSignal<ViewArgs["setup"]>("agent");
|
||||
const onSaveExportSkill = fn();
|
||||
return <Stage args={viewArgs({ setup: setup(), onSetupChange: setSetup, onSaveExportSkill })} />;
|
||||
},
|
||||
play: async ({ canvas }) => {
|
||||
await userEvent.click(canvas.getByRole("tab", { name: "Set it up yourself" }));
|
||||
await expect(canvas.getByRole("button", { name: "Copy" })).toBeEnabled();
|
||||
await expect(canvas.getByRole("button", { name: /^Save file/u })).toBeVisible();
|
||||
return <Stage args={viewArgs({ setup: setup(), onSetupChange: setSetup })} />;
|
||||
},
|
||||
};
|
||||
|
||||
@@ -94,21 +84,7 @@ export const OpenFailed: Story = {
|
||||
|
||||
export const Review: Story = {
|
||||
name: "Import: Review",
|
||||
render: () => {
|
||||
const onImport = fn();
|
||||
return <Stage args={viewArgs({ phase: "review", preview: AGENT_IMPORT_PREVIEW, onImport })} />;
|
||||
},
|
||||
play: async ({ canvas }) => {
|
||||
await expect(canvas.getByRole("button", { name: "Import 3 agents and 2 channels" })).toBeEnabled();
|
||||
await userEvent.click(canvas.getByRole("checkbox", { name: "Import Sales Outbound" }));
|
||||
await userEvent.click(canvas.getByRole("checkbox", { name: "Import Research" }));
|
||||
await expect(canvas.getByText("1 of 3 selected")).toBeVisible();
|
||||
// A channel keeps the members that stay selected, and needs one of them.
|
||||
await expect(canvas.getByRole("checkbox", { name: "Import Pipeline review" })).toBeDisabled();
|
||||
await expect(canvas.getByText("Select at least one of its agents to import it.")).toBeVisible();
|
||||
await expect(canvas.getByText("Imports without Research, Sales Outbound.")).toBeVisible();
|
||||
await expect(canvas.getByRole("button", { name: "Import 1 agent and 1 channel" })).toBeEnabled();
|
||||
},
|
||||
render: () => <Stage args={viewArgs({ phase: "review", preview: AGENT_IMPORT_PREVIEW })} />,
|
||||
};
|
||||
|
||||
export const ReviewWithWarnings: Story = {
|
||||
@@ -131,9 +107,6 @@ export const Importing: Story = {
|
||||
export const Done: Story = {
|
||||
name: "Import: Done",
|
||||
render: () => <Stage args={viewArgs({ phase: "done", result: RESULT })} />,
|
||||
play: async ({ canvas }) => {
|
||||
await expect(canvas.getByRole("button", { name: `Open ${STORY_AGENT_SUMMARIES[0]?.name}` })).toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
export const PartlyDone: Story = {
|
||||
@@ -206,10 +179,6 @@ function ServerSettingsStage(props: { args: ViewArgs }) {
|
||||
export const InServerSettings: Story = {
|
||||
name: "Import: Server settings",
|
||||
render: () => <ServerSettingsStage args={viewArgs()} />,
|
||||
play: async () => {
|
||||
const dialog = await within(document.body).findByRole("dialog", { name: "Import" });
|
||||
await expect(within(dialog).getByRole("tab", { name: "Import" })).toHaveAttribute("aria-selected", "true");
|
||||
},
|
||||
};
|
||||
|
||||
export const ReviewInServerSettings: Story = {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { AgentMemory } from "@openbot/contracts/ipc";
|
||||
import { onCleanup } from "solid-js";
|
||||
import { expect, fireEvent, fn, waitFor, within } from "storybook/test";
|
||||
import { fn } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
import AgentSettingsPanel from "../src/features/conversation/AgentSettingsPanel";
|
||||
import { STORY_AGENT, STORY_AGENT_STATUS, STORY_MODELS } from "./fixtures";
|
||||
@@ -117,118 +117,12 @@ type Story = StoryObj<typeof meta>;
|
||||
|
||||
export const SettingsRow: Story = {
|
||||
render: () => <AgentMemoriesStory memories={chiefMemories} />,
|
||||
play: async ({ canvas }) => {
|
||||
await waitFor(() => expect(canvas.getByRole("button", { name: /Memories/ })).toHaveTextContent("3 saved"));
|
||||
},
|
||||
};
|
||||
|
||||
export const OpenModal: Story = {
|
||||
render: () => <AgentMemoriesStory memories={chiefMemories} />,
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(await canvas.findByRole("button", { name: /Memories/ }));
|
||||
const body = within(document.body);
|
||||
const dialog = await body.findByRole("dialog", { name: "Memories" });
|
||||
await expect(dialog).toBeVisible();
|
||||
await expect(body.getAllByText("Learned automatically", { exact: false })[0]).toBeVisible();
|
||||
await expect(body.getByText("Added manually", { exact: false })).toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
export const AddComposer: Story = {
|
||||
render: () => <AgentMemoriesStory memories={chiefMemories} />,
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(await canvas.findByRole("button", { name: /Memories/ }));
|
||||
const body = within(document.body);
|
||||
await userEvent.click(await body.findByRole("button", { name: "Add memory" }));
|
||||
const input = body.getByRole("textbox", { name: "New memory" });
|
||||
await expect(input).toHaveFocus();
|
||||
await userEvent.type(input, "Prefers concise weekly summaries.");
|
||||
await expect(body.getByRole("button", { name: "Save memory" })).toHaveAttribute("data-variant", "default");
|
||||
},
|
||||
};
|
||||
|
||||
export const Editing: Story = {
|
||||
render: () => <AgentMemoriesStory memories={chiefMemories} />,
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(await canvas.findByRole("button", { name: /Memories/ }));
|
||||
const body = within(document.body);
|
||||
const firstMemory = await body.findByRole("button", { name: /Edit memory: The user prefers/ });
|
||||
firstMemory.focus();
|
||||
await userEvent.keyboard("{Enter}");
|
||||
await expect(body.getByRole("textbox", { name: "Edit memory" })).toHaveFocus();
|
||||
await expect(body.getByRole("button", { name: "Save" })).toHaveAttribute("data-variant", "default");
|
||||
},
|
||||
};
|
||||
|
||||
export const DeleteAction: Story = {
|
||||
render: () => <AgentMemoriesStory memories={chiefMemories} />,
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(await canvas.findByRole("button", { name: /Memories/ }));
|
||||
const body = within(document.body);
|
||||
const [deleteButton] = await body.findAllByRole("button", { name: "Delete memory" });
|
||||
if (!deleteButton) throw new Error("The first memory has no delete button.");
|
||||
await userEvent.click(deleteButton);
|
||||
await waitFor(() =>
|
||||
expect(body.queryByText("The user prefers short progress updates with the result first.")).toBeNull(),
|
||||
);
|
||||
await expect(body.queryByRole("dialog", { name: "Delete this memory?" })).toBeNull();
|
||||
},
|
||||
};
|
||||
|
||||
export const ClearConfirmation: Story = {
|
||||
render: () => <AgentMemoriesStory memories={chiefMemories} />,
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(await canvas.findByRole("button", { name: /Memories/ }));
|
||||
const body = within(document.body);
|
||||
await userEvent.click(await body.findByRole("button", { name: "Clear all memories" }));
|
||||
await expect(await body.findByRole("alertdialog", { name: "Clear all memories?" })).toBeVisible();
|
||||
await expect(document.querySelector(".agent-memories-modal")).toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
export const FullList: Story = {
|
||||
render: () => <AgentMemoriesStory memories={fullMemoryList} />,
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(await canvas.findByRole("button", { name: /Memories/ }));
|
||||
const body = within(document.body);
|
||||
const list = await body.findByRole("list");
|
||||
await expect(await body.findByText("Durable working preference 64", { exact: false })).toBeInTheDocument();
|
||||
await expect(body.getByText("64 saved", { exact: false })).toBeVisible();
|
||||
await waitFor(() => expect(list).toHaveClass("scroll-fade-bottom"));
|
||||
await expect(list).not.toHaveClass("scroll-fade-top");
|
||||
},
|
||||
};
|
||||
|
||||
export const FullListMiddle: Story = {
|
||||
render: () => <AgentMemoriesStory memories={fullMemoryList} />,
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(await canvas.findByRole("button", { name: /Memories/ }));
|
||||
const list = await within(document.body).findByRole("list");
|
||||
await waitFor(() => expect(list.scrollHeight).toBeGreaterThan(list.clientHeight));
|
||||
list.scrollTop = Math.round((list.scrollHeight - list.clientHeight) / 2);
|
||||
await fireEvent.scroll(list);
|
||||
await waitFor(() => expect(list).toHaveClass("scroll-fade-top", "scroll-fade-bottom"));
|
||||
},
|
||||
};
|
||||
|
||||
export const FullListBottom: Story = {
|
||||
render: () => <AgentMemoriesStory memories={fullMemoryList} />,
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(await canvas.findByRole("button", { name: /Memories/ }));
|
||||
const list = await within(document.body).findByRole("list");
|
||||
await waitFor(() => expect(list.scrollHeight).toBeGreaterThan(list.clientHeight));
|
||||
list.scrollTop = list.scrollHeight - list.clientHeight;
|
||||
await fireEvent.scroll(list);
|
||||
await waitFor(() => expect(list).toHaveClass("scroll-fade-top"));
|
||||
await expect(list).not.toHaveClass("scroll-fade-bottom");
|
||||
},
|
||||
};
|
||||
|
||||
export const EmptyState: Story = {
|
||||
render: () => <AgentMemoriesStory memories={[]} />,
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(await canvas.findByRole("button", { name: /Memories/ }));
|
||||
const body = within(document.body);
|
||||
await expect(await body.findByText("This agent has no saved memories yet.")).toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { Routine, RoutineRun } from "@openbot/contracts/ipc";
|
||||
import { onCleanup } from "solid-js";
|
||||
import { expect, fn, waitFor, within } from "storybook/test";
|
||||
import { fn } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
import { AgentRoutinesSettings } from "../src/features/conversation/AgentRoutinesSettings";
|
||||
import AgentSettingsPanel from "../src/features/conversation/AgentSettingsPanel";
|
||||
@@ -132,56 +132,10 @@ type Story = StoryObj<typeof meta>;
|
||||
|
||||
export const RoutineList: Story = {
|
||||
render: () => <RoutinesStory />,
|
||||
play: async ({ canvas }) => {
|
||||
await expect(await canvas.findByRole("button", { name: /Morning brief/ })).toHaveTextContent("Weekdays at");
|
||||
},
|
||||
};
|
||||
|
||||
export const RoutineEditor: Story = {
|
||||
render: () => <RoutinesStory />,
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(await canvas.findByRole("button", { name: /Morning brief/ }));
|
||||
await expect(canvas.getByRole("heading", { name: "Routine" })).toBeVisible();
|
||||
await expect(canvas.getByDisplayValue("Morning brief")).toBeVisible();
|
||||
await expect(canvas.getByRole("button", { name: "Test run" })).toBeEnabled();
|
||||
await expect(canvas.queryByRole("button", { name: "Add another" })).not.toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
|
||||
export const EmptyDraft: Story = {
|
||||
render: () => <RoutinesStory routines={[]} />,
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(await canvas.findByRole("button", { name: "Create Routine" }));
|
||||
await expect(canvas.getByPlaceholderText("Morning brief")).toHaveValue("");
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Back to Routines" }));
|
||||
await expect(canvas.getByText("No routines yet.")).toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
export const UnsavedChangesConfirmation: Story = {
|
||||
render: () => <RoutinesStory />,
|
||||
play: async ({ canvas, canvasElement, userEvent }) => {
|
||||
await userEvent.click(await canvas.findByRole("button", { name: /Morning brief/ }));
|
||||
await userEvent.clear(canvas.getByRole("textbox", { name: "Name" }));
|
||||
await userEvent.type(canvas.getByRole("textbox", { name: "Name" }), "Changed morning brief");
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Back to Routines" }));
|
||||
const body = within(canvasElement.ownerDocument.body);
|
||||
await expect(await body.findByRole("alertdialog")).toHaveAccessibleName("Discard changes?");
|
||||
await expect(body.getByRole("button", { name: "Keep editing" })).toBeInTheDocument();
|
||||
await expect(body.getByRole("button", { name: "Discard changes" })).toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
|
||||
export const OpenTimePicker: Story = {
|
||||
render: () => <RoutinesStory />,
|
||||
play: async ({ canvas, canvasElement, userEvent }) => {
|
||||
await userEvent.click(await canvas.findByRole("button", { name: /Morning brief/ }));
|
||||
await expect(canvas.getByRole("button", { name: "Days: Weekdays" })).toBeVisible();
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Time: 7 AM" }));
|
||||
const body = within(canvasElement.ownerDocument.body);
|
||||
await expect(await body.findByRole("textbox", { name: "Time hour" })).toHaveValue("7");
|
||||
await expect(body.getByRole("textbox", { name: "Time minute" })).toHaveValue("00");
|
||||
},
|
||||
};
|
||||
|
||||
const runStatuses: RoutineRun["status"][] = [
|
||||
@@ -214,47 +168,11 @@ export const RunHistoryStatuses: Story = {
|
||||
}))}
|
||||
/>
|
||||
),
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(await canvas.findByRole("button", { name: /Morning brief/ }));
|
||||
for (const status of runStatuses) {
|
||||
const label = status === "needs-attention" ? "Needs attention" : `${status[0]?.toUpperCase()}${status.slice(1)}`;
|
||||
await expect(await canvas.findByRole("img", { name: label })).toBeVisible();
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export const FullSidePanel: Story = {
|
||||
render: () => <FullSettingsPanelStory />,
|
||||
parameters: { layout: "fullscreen" },
|
||||
play: async ({ canvas }) => {
|
||||
await waitFor(() => expect(canvas.getByRole("button", { name: /Routines/ })).toHaveTextContent("2 configured"));
|
||||
await expect(canvas.getByLabelText("Agent name")).toHaveValue("Chief");
|
||||
await expect(canvas.getByRole("switch", { name: "Notifications" })).toBeChecked();
|
||||
},
|
||||
};
|
||||
|
||||
export const FullSidePanelRoutines: Story = {
|
||||
render: () => <FullSettingsPanelStory />,
|
||||
parameters: { layout: "fullscreen" },
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(await canvas.findByRole("button", { name: /Routines/ }));
|
||||
await expect(canvas.queryByRole("button", { name: "Edit agent avatar" })).not.toBeInTheDocument();
|
||||
await expect(await canvas.findByRole("button", { name: /Morning brief/ })).toHaveTextContent("Weekdays at");
|
||||
await expect(canvas.getByRole("button", { name: /Weekly planning/ })).toHaveTextContent("Paused");
|
||||
},
|
||||
};
|
||||
|
||||
export const FullSidePanelRoutineEditor: Story = {
|
||||
render: () => <FullSettingsPanelStory />,
|
||||
parameters: { layout: "fullscreen" },
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(await canvas.findByRole("button", { name: /Routines/ }));
|
||||
await userEvent.click(await canvas.findByRole("button", { name: /Morning brief/ }));
|
||||
await expect(canvas.getByDisplayValue("Morning brief")).toBeVisible();
|
||||
await expect(canvas.getByRole("button", { name: "Test run" })).toBeEnabled();
|
||||
await expect(await canvas.findByRole("img", { name: "Succeeded" })).toBeVisible();
|
||||
await expect(canvas.getByRole("img", { name: "Needs attention" })).toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
function storyRun(id: string, status: RoutineRun["status"], kind: RoutineRun["kind"], hoursAgo: number): RoutineRun {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { InstalledSkill } from "@openbot/contracts/ipc";
|
||||
import { onCleanup } from "solid-js";
|
||||
import { expect, fn, waitFor, within } from "storybook/test";
|
||||
import { fn } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
import AgentSettingsPanel from "../src/features/conversation/AgentSettingsPanel";
|
||||
import { STORY_AGENT, STORY_AGENT_STATUS, STORY_INSTALLED_SKILLS, STORY_MODELS } from "./fixtures";
|
||||
@@ -10,53 +10,14 @@ const storyAgent = STORY_AGENT;
|
||||
|
||||
function AgentSkillsStory(props: {
|
||||
skills: InstalledSkill[];
|
||||
localState?: "empty" | "error" | "loading" | "update";
|
||||
detailState?: "long" | "error" | "loading" | "reduced-motion";
|
||||
skillsMode?: "mutable" | "readonly" | "hidden";
|
||||
onAddFromMarketplace?: (agentId: string) => void;
|
||||
}) {
|
||||
const previousApi = window.openbot;
|
||||
const mock = createMockOpenBot({ installedSkills: { chief: props.skills } });
|
||||
if (props.localState === "empty") mock.api.skills.localList = async () => [];
|
||||
if (props.localState === "error")
|
||||
mock.api.skills.localList = async () => {
|
||||
throw new Error("Unavailable");
|
||||
};
|
||||
if (props.localState === "loading") mock.api.skills.localList = async () => new Promise(() => undefined);
|
||||
if (props.localState === "update")
|
||||
void mock.api.skills.localRevise({
|
||||
agentId: "chief",
|
||||
skillId: "local-skill-11111111-1111-4111-8111-111111111111",
|
||||
expectedRevision: 1,
|
||||
sourcePath: "draft",
|
||||
});
|
||||
const getDetail = mock.api.skills.get;
|
||||
mock.api.skills.get = async (id) => {
|
||||
if (props.detailState === "error") throw new Error("Could not load skill details.");
|
||||
if (props.detailState === "loading") return new Promise(() => undefined);
|
||||
const detail = await getDetail(id);
|
||||
return props.detailState === "long"
|
||||
? {
|
||||
...detail,
|
||||
name: "Release notes for a large project with many teams and services",
|
||||
examplePrompt:
|
||||
"Review the latest commits, group them by service, explain the impact on users, and include the steps needed for an upgrade. ".repeat(
|
||||
5,
|
||||
),
|
||||
instructions:
|
||||
"## What this skill does\n\nSummarize changes and explain their impact.\n\n## How it works\n\n" +
|
||||
"- Read the commits and check the linked issues.\n".repeat(20),
|
||||
}
|
||||
: detail;
|
||||
};
|
||||
const matchMedia = window.matchMedia;
|
||||
if (props.detailState === "reduced-motion")
|
||||
window.matchMedia = (query) =>
|
||||
matchMedia.call(window, query === "(prefers-reduced-motion: reduce)" ? "all" : query);
|
||||
window.openbot = mock.api;
|
||||
|
||||
onCleanup(() => {
|
||||
window.matchMedia = matchMedia;
|
||||
mock.dispose();
|
||||
window.openbot = previousApi;
|
||||
});
|
||||
@@ -128,227 +89,12 @@ export const SettingsRow: Story = {
|
||||
render: () => (
|
||||
<AgentSkillsStory skills={STORY_INSTALLED_SKILLS.chief ?? []} onAddFromMarketplace={addFromMarketplace} />
|
||||
),
|
||||
play: async ({ canvas }) => {
|
||||
await waitFor(() => expect(canvas.getByRole("button", { name: /Skills/ })).toHaveTextContent("3 assigned"));
|
||||
},
|
||||
};
|
||||
|
||||
export const OpenModal: Story = {
|
||||
render: () => (
|
||||
<AgentSkillsStory skills={STORY_INSTALLED_SKILLS.chief ?? []} onAddFromMarketplace={addFromMarketplace} />
|
||||
),
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(await canvas.findByRole("button", { name: /Skills/ }));
|
||||
const dialog = await within(document.body).findByRole("dialog", { name: "Skills" });
|
||||
await expect(dialog).toBeVisible();
|
||||
await expect(within(dialog).queryByText("Managed")).toBeNull();
|
||||
await expect(within(dialog).queryByText("openbot-site-hosting")).toBeNull();
|
||||
await expect(within(dialog).getByText("Release notes")).toBeVisible();
|
||||
await expect(within(dialog).getByRole("button", { name: "Update Source check" })).toBeVisible();
|
||||
await expect(within(dialog).getByRole("switch", { name: "Enable Release notes" })).toBeChecked();
|
||||
},
|
||||
};
|
||||
|
||||
export const OpenDetail: Story = {
|
||||
render: () => (
|
||||
<AgentSkillsStory skills={STORY_INSTALLED_SKILLS.chief ?? []} onAddFromMarketplace={addFromMarketplace} />
|
||||
),
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(await canvas.findByRole("button", { name: /Skills/ }));
|
||||
const body = within(document.body);
|
||||
await userEvent.click(await body.findByRole("button", { name: /^Inbox triage/ }));
|
||||
const dialog = await body.findByRole("dialog", { name: "Inbox triage" });
|
||||
await expect(dialog).toBeVisible();
|
||||
await expect(within(dialog).getByRole("button", { name: "Skills" })).toBeVisible();
|
||||
await expect(await within(dialog).findByText(/Sorts a morning inbox/)).toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
export const EmptyState: Story = {
|
||||
render: () => <AgentSkillsStory skills={[]} onAddFromMarketplace={addFromMarketplace} />,
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(await canvas.findByRole("button", { name: /Skills/ }));
|
||||
const dialog = await within(document.body).findByRole("dialog", { name: "Skills" });
|
||||
await expect(dialog).toBeVisible();
|
||||
await expect(within(dialog).getByText("This agent has no assigned skills yet.")).toBeVisible();
|
||||
await expect(within(dialog).getAllByRole("button", { name: "Add from marketplace" }).length).toBeGreaterThan(0);
|
||||
},
|
||||
};
|
||||
|
||||
export const RemoteReadOnly: Story = {
|
||||
render: () => <AgentSkillsStory skills={STORY_INSTALLED_SKILLS.research ?? []} skillsMode="readonly" />,
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(await canvas.findByRole("button", { name: /Skills/ }));
|
||||
const body = within(document.body);
|
||||
await expect(await body.findByText("Skills for this agent are managed on the host.")).toBeVisible();
|
||||
await expect(body.queryByRole("button", { name: "Add from marketplace" })).toBeNull();
|
||||
await expect(body.queryByRole("switch")).toBeNull();
|
||||
},
|
||||
};
|
||||
|
||||
export const RemoteLocalDetail: Story = {
|
||||
render: () => (
|
||||
<AgentSkillsStory
|
||||
skills={[
|
||||
{
|
||||
skillId: "local-skill-11111111-1111-4111-8111-111111111111",
|
||||
slug: "weekly-summary",
|
||||
name: "Weekly summary",
|
||||
installedVersion: 1,
|
||||
availableVersion: 1,
|
||||
state: "installed",
|
||||
},
|
||||
]}
|
||||
skillsMode="readonly"
|
||||
/>
|
||||
),
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(await canvas.findByRole("button", { name: /Skills/ }));
|
||||
const body = within(document.body);
|
||||
await userEvent.click(await body.findByRole("button", { name: /^Weekly summary/ }));
|
||||
await expect(
|
||||
await body.findByText("This local skill is stored on the host. Open its details on that computer."),
|
||||
).toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
export const RemoveConfirm: Story = {
|
||||
render: () => (
|
||||
<AgentSkillsStory skills={STORY_INSTALLED_SKILLS.chief ?? []} onAddFromMarketplace={addFromMarketplace} />
|
||||
),
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(await canvas.findByRole("button", { name: /Skills/ }));
|
||||
const body = within(document.body);
|
||||
await userEvent.click(await body.findByRole("button", { name: "More for Inbox triage" }));
|
||||
await userEvent.click(await body.findByRole("menuitem", { name: "Uninstall" }));
|
||||
await expect(await body.findByRole("alertdialog", { name: "Remove this skill?" })).toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
export const AuthorExample: Story = {
|
||||
render: () => <AgentSkillsStory skills={STORY_INSTALLED_SKILLS.chief ?? []} />,
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(await canvas.findByRole("button", { name: /Skills/ }));
|
||||
const body = within(document.body);
|
||||
await userEvent.click(await body.findByRole("button", { name: /^Release notes/ }));
|
||||
await expect(await body.findByText(/Turn the latest commits/)).toBeVisible();
|
||||
await expect(await body.findByRole("button", { name: "Try skill" })).toBeEnabled();
|
||||
},
|
||||
};
|
||||
|
||||
export const DisabledDetail: Story = {
|
||||
render: () => (
|
||||
<AgentSkillsStory skills={(STORY_INSTALLED_SKILLS.chief ?? []).map((skill) => ({ ...skill, enabled: false }))} />
|
||||
),
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(await canvas.findByRole("button", { name: /Skills/ }));
|
||||
const body = within(document.body);
|
||||
await userEvent.click(await body.findByRole("button", { name: /^Release notes/ }));
|
||||
await expect(await body.findByRole("button", { name: "Try skill" })).toBeEnabled();
|
||||
},
|
||||
};
|
||||
|
||||
export const LongDetail: Story = {
|
||||
...OpenDetail,
|
||||
render: () => <AgentSkillsStory skills={STORY_INSTALLED_SKILLS.chief ?? []} detailState="long" />,
|
||||
};
|
||||
export const ReducedMotion: Story = {
|
||||
...OpenDetail,
|
||||
render: () => <AgentSkillsStory skills={STORY_INSTALLED_SKILLS.chief ?? []} detailState="reduced-motion" />,
|
||||
play: async (context) => {
|
||||
await OpenDetail.play?.(context);
|
||||
await expect(window.matchMedia("(prefers-reduced-motion: reduce)").matches).toBe(true);
|
||||
await expect(document.querySelector(".skill-preview-gradient canvas")).toBeNull();
|
||||
},
|
||||
};
|
||||
export const DetailError: Story = {
|
||||
render: () => <AgentSkillsStory skills={STORY_INSTALLED_SKILLS.chief ?? []} detailState="error" />,
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(await canvas.findByRole("button", { name: /Skills/ }));
|
||||
const body = within(document.body);
|
||||
await userEvent.click(await body.findByRole("button", { name: /^Release notes/ }));
|
||||
await expect(await body.findByRole("alert")).toHaveTextContent("Could not load skill details.");
|
||||
},
|
||||
};
|
||||
export const DetailLoading: Story = {
|
||||
render: () => <AgentSkillsStory skills={STORY_INSTALLED_SKILLS.chief ?? []} detailState="loading" />,
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(await canvas.findByRole("button", { name: /Skills/ }));
|
||||
const body = within(document.body);
|
||||
await userEvent.click(await body.findByRole("button", { name: /^Release notes/ }));
|
||||
await expect(await body.findByText("Loading details…")).toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
export const LocalLibrary: Story = {
|
||||
render: () => <AgentSkillsStory skills={STORY_INSTALLED_SKILLS.chief ?? []} />,
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(await canvas.findByRole("button", { name: /Skills/ }));
|
||||
const body = within(document.body);
|
||||
await userEvent.click(await body.findByRole("tab", { name: "Local" }));
|
||||
await expect(await body.findByRole("button", { name: /Weekly summary/ })).toBeVisible();
|
||||
},
|
||||
};
|
||||
export const LocalLibraryDetail: Story = {
|
||||
...LocalLibrary,
|
||||
play: async (context) => {
|
||||
await LocalLibrary.play?.(context);
|
||||
const body = within(document.body);
|
||||
await context.userEvent.click(await body.findByRole("button", { name: /Weekly summary/ }));
|
||||
await expect(await body.findByRole("button", { name: "Add skill" })).toBeEnabled();
|
||||
},
|
||||
};
|
||||
export const LocalLibraryEmpty: Story = {
|
||||
render: () => <AgentSkillsStory skills={[]} localState="empty" />,
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(await canvas.findByRole("button", { name: /Skills/ }));
|
||||
const body = within(document.body);
|
||||
await userEvent.click(await body.findByRole("tab", { name: "Local" }));
|
||||
await expect(await body.findByText("No local skills yet.")).toBeVisible();
|
||||
},
|
||||
};
|
||||
export const LocalLibraryError: Story = {
|
||||
...LocalLibraryEmpty,
|
||||
render: () => <AgentSkillsStory skills={[]} localState="error" />,
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(await canvas.findByRole("button", { name: /Skills/ }));
|
||||
const body = within(document.body);
|
||||
await userEvent.click(await body.findByRole("tab", { name: "Local" }));
|
||||
await expect(await body.findByRole("button", { name: "Retry" })).toBeVisible();
|
||||
},
|
||||
};
|
||||
export const LocalLibraryLoading: Story = {
|
||||
...LocalLibraryEmpty,
|
||||
render: () => <AgentSkillsStory skills={[]} localState="loading" />,
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(await canvas.findByRole("button", { name: /Skills/ }));
|
||||
const body = within(document.body);
|
||||
await userEvent.click(await body.findByRole("tab", { name: "Local" }));
|
||||
await expect(await body.findByRole("status")).toHaveTextContent("Loading local skills");
|
||||
},
|
||||
};
|
||||
|
||||
export const LocalLibraryUpdate: Story = {
|
||||
render: () => (
|
||||
<AgentSkillsStory
|
||||
localState="update"
|
||||
skills={[
|
||||
{
|
||||
skillId: "local-skill-11111111-1111-4111-8111-111111111111",
|
||||
slug: "weekly-summary",
|
||||
name: "Weekly summary",
|
||||
installedVersion: 1,
|
||||
availableVersion: 2,
|
||||
enabled: false,
|
||||
origin: "local",
|
||||
state: "update-available",
|
||||
},
|
||||
]}
|
||||
/>
|
||||
),
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(await canvas.findByRole("button", { name: /Skills/ }));
|
||||
const body = within(document.body);
|
||||
await expect(await body.findByRole("button", { name: "Update Weekly summary" })).toBeEnabled();
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { onCleanup } from "solid-js";
|
||||
import { expect, fireEvent, waitFor, within } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
import { App } from "../src/App";
|
||||
import type { MockOpenBotOptions } from "../src/preview/mock-openbot";
|
||||
@@ -33,261 +32,20 @@ function SidebarStatePlayground(props: { compact: boolean; options?: MockOpenBot
|
||||
|
||||
export const Playground: Story = {
|
||||
render: () => <OpenBotPlayground />,
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await expect(canvas.getByRole("navigation", { name: "Chat list" })).toBeInTheDocument();
|
||||
await expect(canvas.findByRole("heading", { name: "Agents" })).resolves.toBeInTheDocument();
|
||||
|
||||
const editor = canvas.getByRole("textbox", { name: "Message Chief" });
|
||||
await userEvent.click(editor);
|
||||
editor.textContent = "Show me the next step";
|
||||
await fireEvent.input(editor);
|
||||
await expect(editor).toHaveTextContent("Show me the next step");
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Send message" }));
|
||||
await expect(
|
||||
canvas.findByText("Show me the next step", undefined, { timeout: 3_000 }),
|
||||
).resolves.toBeInTheDocument();
|
||||
|
||||
await expect(
|
||||
canvas.findByText(/Mock reply from Chief: I received/, undefined, { timeout: 3_000 }),
|
||||
).resolves.toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
|
||||
export const SettingsTyping: Story = {
|
||||
render: () => <OpenBotPlayground />,
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await canvas.findByRole("heading", { name: "Chief" });
|
||||
await userEvent.click(canvas.getByRole("button", { name: "View agent settings" }));
|
||||
|
||||
const name = canvas.getByRole("textbox", { name: "Agent name" });
|
||||
await userEvent.clear(name);
|
||||
await userEvent.type(name, "Rapid name editing");
|
||||
await expect(name).toHaveValue("Rapid name editing");
|
||||
await expect(name).toHaveFocus();
|
||||
const title = canvas.getByRole("textbox", { name: "Agent title" });
|
||||
await userEvent.clear(title);
|
||||
await userEvent.type(title, "Every character remains");
|
||||
const description = canvas.getByRole("textbox", { name: "Agent instructions" });
|
||||
await userEvent.clear(description);
|
||||
await userEvent.type(description, "Drafts survive reactive profile updates.");
|
||||
|
||||
await expect(canvas.getByRole("textbox", { name: "Agent name" })).toHaveValue("Rapid name editing");
|
||||
await expect(canvas.getByRole("textbox", { name: "Agent title" })).toHaveValue("Every character remains");
|
||||
await expect(canvas.getByRole("textbox", { name: "Agent instructions" })).toHaveValue(
|
||||
"Drafts survive reactive profile updates.",
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
export const CommandSearch: Story = {
|
||||
render: () => <OpenBotPlayground />,
|
||||
play: async ({ canvas, canvasElement, userEvent }) => {
|
||||
await canvas.findByRole("heading", { name: "Chief" });
|
||||
await fireEvent.keyDown(window, { key: "k", metaKey: true });
|
||||
const page = within(canvasElement.ownerDocument.body);
|
||||
const dialog = await page.findByRole("dialog", { name: "Search OpenBot" });
|
||||
const input = page.getByRole("combobox", { name: "Search OpenBot" });
|
||||
await expect(dialog).toBeVisible();
|
||||
await expect(input).toHaveFocus();
|
||||
|
||||
await userEvent.click(page.getByRole("tab", { name: "Messages" }));
|
||||
await userEvent.type(input, "milestone");
|
||||
await expect(page.findByRole("option", { name: /launch milestones/i })).resolves.toBeInTheDocument();
|
||||
|
||||
await userEvent.clear(input);
|
||||
await userEvent.click(page.getByRole("tab", { name: "Agents" }));
|
||||
await userEvent.type(input, "research");
|
||||
await expect(page.findByRole("option", { name: /Research/ })).resolves.toBeInTheDocument();
|
||||
|
||||
await userEvent.clear(input);
|
||||
await userEvent.click(page.getByRole("tab", { name: "All" }));
|
||||
},
|
||||
};
|
||||
|
||||
type PlayContext = Parameters<NonNullable<Story["play"]>>[0];
|
||||
|
||||
/*
|
||||
* The expanded sidebar is a precondition, not a detail: the compact rail hides the new-chat button
|
||||
* from the accessibility tree, so a channel story must pin the sidebar open rather than inherit
|
||||
* whatever width the last visitor left in local storage.
|
||||
*/
|
||||
function ChannelPlayground() {
|
||||
return <SidebarStatePlayground compact={false} />;
|
||||
}
|
||||
|
||||
async function openNewChannelDialog(context: PlayContext): Promise<HTMLElement> {
|
||||
const body = within(context.canvasElement.ownerDocument.body);
|
||||
await context.canvas.findByRole("heading", { name: "Chief" });
|
||||
const expandSidebar = context.canvas.queryByRole("button", { name: "Expand sidebar" });
|
||||
if (expandSidebar) await context.userEvent.click(expandSidebar);
|
||||
await context.userEvent.click(context.canvas.getByRole("button", { name: "New agent or channel" }));
|
||||
await context.userEvent.click(await body.findByRole("menuitem", { name: "New channel" }));
|
||||
return await body.findByRole("dialog", { name: "New channel" });
|
||||
}
|
||||
|
||||
export const NewChannel: Story = {
|
||||
render: () => <ChannelPlayground />,
|
||||
play: async (context) => {
|
||||
const dialog = await openNewChannelDialog(context);
|
||||
await expect(within(dialog).getByRole("searchbox", { name: "Search agents" })).toBeVisible();
|
||||
await expect(within(dialog).getByRole("button", { name: "Create" })).toBeDisabled();
|
||||
},
|
||||
};
|
||||
|
||||
export const NewChannelWithMembers: Story = {
|
||||
render: () => <ChannelPlayground />,
|
||||
play: async (context) => {
|
||||
const dialog = await openNewChannelDialog(context);
|
||||
const field = within(dialog);
|
||||
const userEvent = context.userEvent;
|
||||
await userEvent.type(field.getByRole("textbox", { name: "Channel name" }), "Project Falcon");
|
||||
await userEvent.click(field.getByRole("checkbox", { name: /Chief/ }));
|
||||
await userEvent.click(field.getByRole("checkbox", { name: /Research/ }));
|
||||
await expect(field.getByRole("checkbox", { name: /Chief/ })).toBeChecked();
|
||||
await expect(field.getByRole("checkbox", { name: /Research/ })).toBeChecked();
|
||||
await expect(field.getByRole("button", { name: "Create" })).toBeEnabled();
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* The channel after it exists: a sidebar row with a preview line, and the chat itself, which reuses
|
||||
* the agent chat's header, message column and composer. Creation runs through the dialog because the
|
||||
* preview mock seeds no channel of its own.
|
||||
*/
|
||||
export const Channel: Story = {
|
||||
render: () => <ChannelPlayground />,
|
||||
play: async (context) => {
|
||||
const dialog = await openNewChannelDialog(context);
|
||||
const field = within(dialog);
|
||||
const userEvent = context.userEvent;
|
||||
await userEvent.type(field.getByRole("textbox", { name: "Channel name" }), "Project Falcon");
|
||||
await userEvent.click(field.getByRole("checkbox", { name: /Chief/ }));
|
||||
await userEvent.click(field.getByRole("checkbox", { name: /Research/ }));
|
||||
await userEvent.click(field.getByRole("button", { name: "Create" }));
|
||||
|
||||
const chat = await context.canvas.findByRole("main", { name: "Channel conversation" });
|
||||
const composer = within(chat).getByRole("textbox", { name: "Message to channel" });
|
||||
composer.textContent = "Let's align on the launch milestones before Friday.";
|
||||
await fireEvent.input(composer);
|
||||
await userEvent.click(within(chat).getByRole("button", { name: "Send message" }));
|
||||
|
||||
await expect(within(chat).findByRole("article", { name: "Message from You" })).resolves.toBeInTheDocument();
|
||||
// A request that names no recipient is routed by the lead, and the lead posts its choice as an
|
||||
// activity row rather than a message. So the newest row of the channel, and the sidebar line
|
||||
// that previews it, is the dispatch rather than the request.
|
||||
await expect(within(chat).findByLabelText("Assigned to Chief")).resolves.toBeInTheDocument();
|
||||
expect(within(chat).queryByRole("article", { name: "Message from Chief" })).not.toBeInTheDocument();
|
||||
await waitFor(() =>
|
||||
expect(context.canvas.getByRole("button", { name: /^Project Falcon\./ })).toHaveAccessibleName(
|
||||
"Project Falcon. Assigned to Chief.",
|
||||
),
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
export const AccountMenu: Story = {
|
||||
render: () => <SidebarStatePlayground compact={false} />,
|
||||
play: async ({ canvas, canvasElement, userEvent }) => {
|
||||
await canvas.findByRole("heading", { name: "Chief" });
|
||||
const trigger = await canvas.findByRole("button", { name: "Open account actions" });
|
||||
const usageTrigger = await canvas.findByRole("button", { name: /^Usage,/ });
|
||||
const settingsTrigger = await canvas.findByRole("button", { name: "Settings" });
|
||||
const dock = canvasElement.querySelector<HTMLElement>(".account-dock");
|
||||
const rail = canvasElement.querySelector<HTMLElement>(".server-rail");
|
||||
const sidebar = canvasElement.querySelector<HTMLElement>(".sidebar");
|
||||
if (!dock || !rail || !sidebar) throw new Error("The combined account dock is incomplete.");
|
||||
|
||||
await waitFor(() => {
|
||||
const dockWidth = dock.getBoundingClientRect().width;
|
||||
const navigationWidth = rail.getBoundingClientRect().width + sidebar.getBoundingClientRect().width;
|
||||
expect(Math.abs(dockWidth - navigationWidth)).toBeLessThan(1);
|
||||
});
|
||||
|
||||
await userEvent.click(usageTrigger);
|
||||
const usagePopover = await within(canvasElement.ownerDocument.body).findByRole("dialog", {
|
||||
name: "Usage",
|
||||
});
|
||||
await expect(within(usagePopover).getByRole("button", { name: "Refresh" })).toBeInTheDocument();
|
||||
await userEvent.keyboard("{Escape}");
|
||||
await waitFor(() => expect(usageTrigger).toHaveFocus());
|
||||
|
||||
await userEvent.click(trigger);
|
||||
const popover = await within(canvasElement.ownerDocument.body).findByRole("dialog", {
|
||||
name: "Account actions",
|
||||
});
|
||||
await expect(within(popover).getByRole("button", { name: "Marketplace" })).toBeInTheDocument();
|
||||
await expect(within(popover).getByRole("button", { name: "Providers & permissions" })).toBeInTheDocument();
|
||||
await expect(within(popover).getByRole("button", { name: "Send feedback" })).toBeInTheDocument();
|
||||
await expect(within(popover).getByRole("button", { name: "Message" })).toBeInTheDocument();
|
||||
await expect(within(popover).getByRole("button", { name: "Sign out" })).toBeInTheDocument();
|
||||
await expect(within(popover).queryByRole("button", { name: "Settings" })).not.toBeInTheDocument();
|
||||
|
||||
await userEvent.keyboard("{Escape}");
|
||||
await waitFor(() =>
|
||||
expect(
|
||||
within(canvasElement.ownerDocument.body).queryByRole("dialog", { name: "Account actions" }),
|
||||
).not.toBeInTheDocument(),
|
||||
);
|
||||
await waitFor(() => expect(trigger).toHaveFocus());
|
||||
|
||||
await userEvent.keyboard("{Enter}");
|
||||
await within(canvasElement.ownerDocument.body).findByRole("dialog", { name: "Account actions" });
|
||||
await userEvent.click(canvas.getByRole("main", { name: "Conversation" }));
|
||||
await waitFor(() =>
|
||||
expect(
|
||||
within(canvasElement.ownerDocument.body).queryByRole("dialog", { name: "Account actions" }),
|
||||
).not.toBeInTheDocument(),
|
||||
);
|
||||
|
||||
await userEvent.click(settingsTrigger);
|
||||
await within(canvasElement.ownerDocument.body).findByRole("dialog", { name: "General" });
|
||||
},
|
||||
};
|
||||
|
||||
export const CompactAccountMenu: Story = {
|
||||
render: () => <SidebarStatePlayground compact={true} />,
|
||||
play: async ({ canvas, canvasElement, userEvent }) => {
|
||||
await canvas.findByRole("heading", { name: "Chief" });
|
||||
const trigger = await canvas.findByRole("button", { name: "Open account menu" });
|
||||
const dock = canvasElement.querySelector<HTMLElement>(".account-dock");
|
||||
const rail = canvasElement.querySelector<HTMLElement>(".server-rail");
|
||||
const sidebar = canvasElement.querySelector<HTMLElement>(".sidebar");
|
||||
if (!dock || !rail || !sidebar) throw new Error("The compact account dock is incomplete.");
|
||||
|
||||
await waitFor(() => {
|
||||
expect(dock).toHaveClass("account-dock-compact");
|
||||
const dockWidth = dock.getBoundingClientRect().width;
|
||||
const navigationWidth = rail.getBoundingClientRect().width + sidebar.getBoundingClientRect().width;
|
||||
expect(Math.abs(dockWidth - navigationWidth)).toBeLessThan(1);
|
||||
});
|
||||
|
||||
await userEvent.click(trigger);
|
||||
const popover = await within(canvasElement.ownerDocument.body).findByRole("dialog", {
|
||||
name: "Account actions",
|
||||
});
|
||||
await expect(within(popover).getByRole("button", { name: "Marketplace" })).toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
|
||||
export const LinuxAccountMenu: Story = {
|
||||
render: () => (
|
||||
<SidebarStatePlayground compact={false} options={{ appInfo: { ...STORY_APP_INFO, platform: "linux" } }} />
|
||||
),
|
||||
play: async ({ canvas, canvasElement, userEvent }) => {
|
||||
await canvas.findByRole("heading", { name: "Chief" });
|
||||
const dock = canvasElement.querySelector<HTMLElement>(".account-dock");
|
||||
const sidebar = canvasElement.querySelector<HTMLElement>(".sidebar");
|
||||
if (!dock || !sidebar) throw new Error("The Linux account dock is incomplete.");
|
||||
await expect(canvasElement.querySelector(".server-rail")).not.toBeInTheDocument();
|
||||
await expect(dock).not.toHaveClass("account-dock-with-server-rail");
|
||||
await expect(Math.abs(dock.getBoundingClientRect().width - sidebar.getBoundingClientRect().width)).toBeLessThan(1);
|
||||
|
||||
await userEvent.click(await canvas.findByRole("button", { name: "Open account menu" }));
|
||||
const popover = await within(canvasElement.ownerDocument.body).findByRole("dialog", {
|
||||
name: "Account actions",
|
||||
});
|
||||
await expect(within(popover).getByRole("button", { name: "Marketplace" })).toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
|
||||
export const LongAccountEmail: Story = {
|
||||
@@ -307,17 +65,6 @@ export const LongAccountEmail: Story = {
|
||||
}}
|
||||
/>
|
||||
),
|
||||
play: async ({ canvas }) => {
|
||||
const trigger = await canvas.findByRole("button", { name: "Open account actions" });
|
||||
const accountName = trigger.querySelector<HTMLElement>("strong");
|
||||
const accountEmail = trigger.querySelector<HTMLElement>(".account-dock-copy > span:not(.sr-only)");
|
||||
if (!accountName) throw new Error("The account name is missing from the dock.");
|
||||
if (!accountEmail) throw new Error("The account email is missing from the dock.");
|
||||
await expect(accountName).toHaveTextContent("Norbert Bodziony");
|
||||
await expect(accountEmail).toHaveTextContent("norbert.bodziony.with.a.very.long.workspace.profile@example.com");
|
||||
await expect(getComputedStyle(accountEmail).textOverflow).toBe("ellipsis");
|
||||
await expect(accountEmail.scrollWidth).toBeGreaterThan(accountEmail.clientWidth);
|
||||
},
|
||||
};
|
||||
|
||||
export const EmptyWorkspace: Story = {
|
||||
@@ -334,18 +81,6 @@ export const EmptyWorkspace: Story = {
|
||||
}}
|
||||
/>
|
||||
),
|
||||
play: async ({ canvas }) => {
|
||||
await expect(canvas.queryByRole("heading", { name: "People" })).not.toBeInTheDocument();
|
||||
await expect(canvas.queryByRole("button", { name: "OpenBot team server" })).not.toBeInTheDocument();
|
||||
await expect(canvas.getAllByRole("listitem")).toHaveLength(6);
|
||||
|
||||
const createButton = canvas.getByRole("button", { name: "Create agent" });
|
||||
await expect(createButton).toBeDisabled();
|
||||
const nameInput = canvas.getByRole("textbox", { name: "Name" });
|
||||
const purposeInput = canvas.getByRole("textbox", { name: "What should this agent help with?" });
|
||||
await expect(nameInput).toHaveValue("New agent");
|
||||
await expect(purposeInput).toHaveValue("");
|
||||
},
|
||||
};
|
||||
|
||||
export const IncompatibleRemoteHost: Story = {
|
||||
@@ -376,12 +111,6 @@ export const IncompatibleRemoteHost: Story = {
|
||||
}}
|
||||
/>
|
||||
),
|
||||
play: async ({ canvas }) => {
|
||||
await expect(canvas.findByRole("heading", { name: "Update OpenBot on OpenBot team" })).resolves.toBeInTheDocument();
|
||||
await expect(canvas.getByText("44.0.0")).toBeInTheDocument();
|
||||
await expect(canvas.getByText("42.0.0")).toBeInTheDocument();
|
||||
await expect(canvas.getByRole("button", { name: "Retry" })).toBeEnabled();
|
||||
},
|
||||
};
|
||||
|
||||
export const DifferentRemoteVersions: Story = {
|
||||
@@ -414,38 +143,12 @@ export const DifferentRemoteVersions: Story = {
|
||||
}}
|
||||
/>
|
||||
),
|
||||
play: async ({ canvas, canvasElement }) => {
|
||||
await expect(canvas.findByRole("heading", { name: "Chief" })).resolves.toBeInTheDocument();
|
||||
await expect(
|
||||
within(canvasElement.ownerDocument.body).findByText("Different OpenBot versions on OpenBot team"),
|
||||
).resolves.toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
|
||||
export const Onboarding: Story = {
|
||||
render: () => (
|
||||
<OpenBotPlayground options={{ setupState: { completed: false, preferredProvider: null, preferredModel: null } }} />
|
||||
),
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await expect(canvas.findByRole("heading", { name: "Meet OpenBot" })).resolves.toBeInTheDocument();
|
||||
await expect(canvas.getByRole("radiogroup", { name: "Default provider" })).toBeInTheDocument();
|
||||
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Next" }));
|
||||
await expect(
|
||||
canvas.findByRole("heading", { name: "OpenBot might control your computer" }),
|
||||
).resolves.toBeInTheDocument();
|
||||
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Back" }));
|
||||
await expect(canvas.findByRole("heading", { name: "Meet OpenBot" })).resolves.toBeInTheDocument();
|
||||
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Next" }));
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Next" }));
|
||||
await expect(canvas.findByRole("heading", { name: "Give each agent a job" })).resolves.toBeInTheDocument();
|
||||
await expect(canvas.getByRole("region", { name: "Example agent jobs" })).toBeInTheDocument();
|
||||
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Open OpenBot" }));
|
||||
await expect(canvas.findByRole("heading", { name: "Chief" })).resolves.toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
|
||||
export const SignedOut: Story = {
|
||||
@@ -467,65 +170,9 @@ export const AgentStarting: Story = {
|
||||
),
|
||||
};
|
||||
|
||||
export const HostUsage: Story = {
|
||||
render: () => <OpenBotPlayground />,
|
||||
play: async ({ canvas, canvasElement }) => {
|
||||
const server = await canvas.findByRole("button", { name: "Local server" });
|
||||
await fireEvent.contextMenu(server);
|
||||
const menu = within(canvasElement.ownerDocument.body);
|
||||
await fireEvent.pointerUp(await menu.findByRole("menuitem", { name: "Usage" }), { button: 0 });
|
||||
await expect(canvas.findByRole("region", { name: "Usage summary" })).resolves.toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
|
||||
export const SkillPreviewDraft: Story = {
|
||||
render: () => <OpenBotPlayground />,
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
const editor = await canvas.findByRole("textbox", { name: "Message Chief" });
|
||||
await userEvent.click(editor);
|
||||
editor.textContent = "Keep this draft";
|
||||
await fireEvent.input(editor);
|
||||
await userEvent.click(canvas.getByRole("button", { name: "View agent settings" }));
|
||||
await userEvent.click(await canvas.findByRole("button", { name: /Skills/ }));
|
||||
const body = within(document.body);
|
||||
await userEvent.click(await body.findByRole("button", { name: /^Release notes/ }));
|
||||
await userEvent.click(await body.findByRole("button", { name: "Try skill" }));
|
||||
await waitFor(() => expect(editor).toHaveFocus());
|
||||
await expect(editor).toHaveTextContent("Keep this draft");
|
||||
await expect(editor).toHaveTextContent("Release notes");
|
||||
await expect(editor).toHaveTextContent("Turn the latest commits");
|
||||
await expect(canvas.getByRole("button", { name: "Send message" })).toBeEnabled();
|
||||
},
|
||||
};
|
||||
|
||||
export const MarketplaceSkillPreviewDraft: Story = {
|
||||
render: () => <OpenBotPlayground />,
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
const chiefEditor = await canvas.findByRole("textbox", { name: "Message Chief" });
|
||||
chiefEditor.textContent = "Keep Chief's draft";
|
||||
await fireEvent.input(chiefEditor);
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Open Marketplace" }));
|
||||
const body = within(document.body);
|
||||
await userEvent.click(await body.findByRole("button", { name: "Skills" }));
|
||||
await userEvent.click(await body.findByRole("button", { name: "View Release notes details" }));
|
||||
await userEvent.selectOptions(body.getByRole("combobox", { name: "Install to" }), "research");
|
||||
await expect(body.getByRole("button", { name: "Try skill" })).toBeDisabled();
|
||||
await userEvent.click(await body.findByRole("button", { name: "Install skill" }));
|
||||
await waitFor(() => expect(body.getByRole("button", { name: "Try skill" })).toBeEnabled());
|
||||
await userEvent.click(body.getByRole("button", { name: "Try skill" }));
|
||||
const researchEditor = await canvas.findByRole("textbox", { name: "Message Research" });
|
||||
await waitFor(() => expect(researchEditor).toHaveFocus());
|
||||
await expect(researchEditor).toHaveTextContent("Turn the latest commits");
|
||||
await expect(canvas.queryByText(/^Mock reply from Research:/)).not.toBeInTheDocument();
|
||||
await userEvent.click(canvas.getByRole("button", { name: /^Chief, Chief of staff/ }));
|
||||
await expect(await canvas.findByRole("textbox", { name: "Message Chief" })).toHaveTextContent("Keep Chief's draft");
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* The signed-out provider in the real shell. `sign-in-required` is the only input: the notice, the
|
||||
* model picker's label and the suppressed usage chip all read that one field, so this story is the
|
||||
* check that they agree.
|
||||
* model picker's label and the suppressed usage chip all read that one field.
|
||||
*/
|
||||
export const ProviderSignInRequired: Story = {
|
||||
render: () => (
|
||||
@@ -548,13 +195,4 @@ export const ProviderSignInRequired: Story = {
|
||||
}}
|
||||
/>
|
||||
),
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await canvas.findByRole("heading", { name: "Chief" });
|
||||
const signIn = await canvas.findByRole("button", { name: "Sign in to ChatGPT" });
|
||||
await expect(canvas.getByText("Sign in required")).toBeInTheDocument();
|
||||
await expect(canvas.getByText("Sign in to ChatGPT to send messages.")).toBeInTheDocument();
|
||||
// The composer still takes a draft, so signing in never costs the user their message.
|
||||
await expect(canvas.getByRole("textbox", { name: /^Message / })).toBeInTheDocument();
|
||||
await userEvent.click(signIn);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { AgentApproval } from "@openbot/contracts/ipc";
|
||||
import { ApprovalCard } from "@openbot/ui/features/conversation/ConversationPrompts";
|
||||
import { fn, userEvent, within } from "storybook/test";
|
||||
import { fn } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
|
||||
const approval: AgentApproval = {
|
||||
@@ -84,23 +84,9 @@ export const Narrow: Story = {
|
||||
),
|
||||
],
|
||||
};
|
||||
export const Pending: Story = {
|
||||
args: { onApprove: fn(async () => true) },
|
||||
play: async ({ canvasElement }) => {
|
||||
const canvas = within(canvasElement);
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Allow" }));
|
||||
},
|
||||
};
|
||||
/** The three-button card: the agent runs on this computer, so the standing grant is the user's to give. */
|
||||
export const AlwaysAllow: Story = {
|
||||
args: { agentName: "Chief", onAlwaysAllow: fn(async () => false) },
|
||||
};
|
||||
/** The same card without that option, which is what a remote agent and a permissions request both show. */
|
||||
export const WithoutAlwaysAllow: Story = { args: { agentName: "Chief" } };
|
||||
export const AlwaysAllowConfirmation: Story = {
|
||||
args: { agentName: "Chief", onAlwaysAllow: fn(async () => false) },
|
||||
play: async ({ canvasElement }) => {
|
||||
const canvas = within(canvasElement);
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Always allow" }));
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { AttachmentCards, AttachmentDownloadAll } from "@openbot/ui/features/conversation/AttachmentCards";
|
||||
import { expect, fn, userEvent, within } from "storybook/test";
|
||||
import { fn } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
import { STORY_ATTACHMENTS } from "./fixtures";
|
||||
|
||||
@@ -50,31 +50,6 @@ export const Files: Story = {};
|
||||
export const SingleCompactFile: Story = {
|
||||
name: "Single compact file",
|
||||
args: { attachments: [compactFile] },
|
||||
play: async ({ canvas }) => {
|
||||
const preview = canvas.getByRole("button", { name: `Preview ${compactFile.name}` });
|
||||
const open = canvas.getByRole("button", { name: `Open ${compactFile.name}` });
|
||||
const visual = preview.querySelector<HTMLElement>(".attachment-file-visual");
|
||||
const copy = preview.querySelector<HTMLElement>(".attachment-file-copy");
|
||||
if (!visual || !copy) throw new Error("The attachment preview content is incomplete");
|
||||
|
||||
const previewBounds = preview.getBoundingClientRect();
|
||||
const visualBounds = visual.getBoundingClientRect();
|
||||
const copyBounds = copy.getBoundingClientRect();
|
||||
const openBounds = open.getBoundingClientRect();
|
||||
await expect(getComputedStyle(preview).justifyContent).toBe("flex-start");
|
||||
await expect(previewBounds.height).toBe(40);
|
||||
await expect(visual).toHaveAttribute("data-file-tone", "markup");
|
||||
await expect(visualBounds.left).toBe(previewBounds.left);
|
||||
await expect(copyBounds.left).toBeGreaterThan(visualBounds.right);
|
||||
await expect(openBounds.left).toBeGreaterThan(previewBounds.right);
|
||||
await expect(openBounds.width).toBe(40);
|
||||
await expect(openBounds.height).toBe(40);
|
||||
|
||||
open.focus();
|
||||
await expect(within(document.body).findByRole("tooltip")).resolves.toHaveTextContent("Open file");
|
||||
await userEvent.keyboard("{Escape}");
|
||||
await expect(within(document.body).queryByRole("tooltip")).not.toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
|
||||
export const NarrowLongNames: Story = {
|
||||
@@ -85,27 +60,6 @@ export const NarrowLongNames: Story = {
|
||||
<AttachmentCards {...storyArgs} />
|
||||
</div>
|
||||
),
|
||||
play: async ({ canvas }) => {
|
||||
const cards = canvas.getAllByRole("button", { name: /^(Preview|Open) /u });
|
||||
const names = canvas.getAllByText(/customer-import|quarterly-operating/u);
|
||||
const openButtons = canvas.getAllByRole("button", { name: /^Open /u });
|
||||
|
||||
await expect(cards).toHaveLength(4);
|
||||
await expect(openButtons).toHaveLength(2);
|
||||
for (const name of names) {
|
||||
await expect(name.scrollWidth).toBeGreaterThan(name.clientWidth);
|
||||
}
|
||||
for (const open of openButtons) {
|
||||
const bounds = open.getBoundingClientRect();
|
||||
await expect(bounds.width).toBe(40);
|
||||
await expect(bounds.height).toBe(40);
|
||||
}
|
||||
const [longFile] = longNamedFiles;
|
||||
if (!longFile) throw new Error("Long-named file fixtures are empty.");
|
||||
await expect(canvas.getByText(longFile.name).closest(".message-attachment")?.getBoundingClientRect().width).toBe(
|
||||
220,
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
export const Empty: Story = {
|
||||
@@ -120,17 +74,6 @@ export const WithDownloadAll: Story = {
|
||||
<AttachmentCards {...storyArgs} />
|
||||
</div>
|
||||
),
|
||||
play: async ({ canvas }) => {
|
||||
const download = canvas.getByRole("button", { name: "Download all as ZIP" });
|
||||
const [firstAttachment] = STORY_ATTACHMENTS;
|
||||
if (!firstAttachment) throw new Error("Story attachment fixtures are empty.");
|
||||
const firstCard = canvas.getByRole("button", { name: `Preview ${firstAttachment.name}` });
|
||||
const downloadBounds = download.getBoundingClientRect();
|
||||
const cardBounds = firstCard.getBoundingClientRect();
|
||||
|
||||
await expect(downloadBounds.bottom).toBeLessThanOrEqual(cardBounds.top);
|
||||
await expect(downloadBounds.width).toBeLessThan(cardBounds.width);
|
||||
},
|
||||
};
|
||||
|
||||
export const DownloadingZip: Story = {
|
||||
@@ -141,7 +84,4 @@ export const DownloadingZip: Story = {
|
||||
<AttachmentCards {...storyArgs} />
|
||||
</div>
|
||||
),
|
||||
play: async ({ canvas }) => {
|
||||
await expect(canvas.getByRole("button", { name: "Downloading ZIP…" })).toBeDisabled();
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import type { BrowserTakeoverRequest } from "@openbot/contracts/ipc";
|
||||
import { BrowserSecretCard } from "@openbot/ui/features/conversation/BrowserSecretCard";
|
||||
import { userEvent, within } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
import browserTakeoverPreviewUrl from "./assets/browser-takeover-preview.svg";
|
||||
|
||||
@@ -60,13 +59,6 @@ export const Narrow: Story = {
|
||||
),
|
||||
};
|
||||
|
||||
export const PartiallyFilled: Story = {
|
||||
play: async ({ canvasElement }) => {
|
||||
const canvas = within(canvasElement);
|
||||
await userEvent.type(canvas.getByLabelText("6-digit code"), "123");
|
||||
},
|
||||
};
|
||||
|
||||
export const TwelveDigitsNarrow: Story = {
|
||||
args: { request: { ...request, secret: { method: "otp", origin: "https://accounts.example.com", digits: 12 } } },
|
||||
render: Narrow.render,
|
||||
@@ -82,18 +74,8 @@ export const PreviewUnavailable: Story = {
|
||||
|
||||
export const SubmittingPassword: Story = {
|
||||
args: { ...Password.args, onRespond: () => new Promise<void>(() => {}) },
|
||||
play: async ({ canvasElement }) => {
|
||||
const canvas = within(canvasElement);
|
||||
await userEvent.type(canvas.getByLabelText("Password"), "example-password");
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Submit" }));
|
||||
},
|
||||
};
|
||||
|
||||
export const SubmittingCode: Story = {
|
||||
args: { onRespond: () => new Promise<void>(() => {}) },
|
||||
play: async ({ canvasElement }) => {
|
||||
const canvas = within(canvasElement);
|
||||
await userEvent.type(canvas.getByLabelText("6-digit code"), "123456");
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Submit" }));
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { BrowserPreview, BrowserTab } from "@openbot/contracts/ipc";
|
||||
import { BrowserTakeoverCard } from "@openbot/ui/features/conversation/ConversationPrompts";
|
||||
import { fn, userEvent, within } from "storybook/test";
|
||||
import { fn } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
import browserTakeoverPreviewUrl from "./assets/browser-takeover-preview.svg";
|
||||
|
||||
@@ -78,10 +78,3 @@ export const Cancelled: Story = {
|
||||
export const TabUnavailable: Story = {
|
||||
args: { tab: undefined, preview: null, previewStatus: "failed" },
|
||||
};
|
||||
|
||||
export const Submitting: Story = {
|
||||
play: async ({ canvasElement }) => {
|
||||
const canvas = within(canvasElement);
|
||||
await userEvent.click(canvas.getByRole("button", { name: "I’m done" }));
|
||||
},
|
||||
};
|
||||
|
||||
@@ -8,7 +8,7 @@ import { MessageActions } from "@openbot/ui/features/conversation/MessageRenderi
|
||||
import { UnreadMessagesDivider } from "@openbot/ui/features/conversation/UnreadMessages";
|
||||
import type { JSX } from "@solidjs/web";
|
||||
import { createStore, For, Show } from "solid-js";
|
||||
import { expect, fn, within } from "storybook/test";
|
||||
import { fn } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
import { requireFixture, STORY_AGENTS } from "./fixtures";
|
||||
|
||||
@@ -158,21 +158,6 @@ export const ChannelTranscriptWithSeveralAuthors: Story = {
|
||||
]}
|
||||
/>
|
||||
),
|
||||
play: async ({ canvas }) => {
|
||||
const chiefMessages = await canvas.findAllByRole("article", { name: `Message from ${chief.name}` });
|
||||
await expect(chiefMessages).toHaveLength(2);
|
||||
const [firstChiefMessage, secondChiefMessage] = chiefMessages;
|
||||
if (!firstChiefMessage || !secondChiefMessage) throw new Error("Chief messages are missing.");
|
||||
await expect(within(firstChiefMessage).getByText("11:12 PM")).toBeInTheDocument();
|
||||
await expect(within(secondChiefMessage).queryByText("11:13 PM")).not.toBeInTheDocument();
|
||||
const ownMessage = await canvas.findByRole("article", { name: "Message from You" });
|
||||
await expect(within(ownMessage).getByText("12:59 PM")).toBeInTheDocument();
|
||||
// The label after the colon shifts on every turn, the way it does in the agent chat, so the
|
||||
// announcement is matched on its subject.
|
||||
await expect(
|
||||
await canvas.findByRole("status", { name: new RegExp(`^${chief.name} and ${sales.name} are working: `) }),
|
||||
).toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
|
||||
/** One agent at work: the sentence has to read for a single name too. */
|
||||
|
||||
@@ -9,7 +9,7 @@ import {
|
||||
} from "@openbot/ui/components/SettingsPanel";
|
||||
import { ChannelMemberRow } from "@openbot/ui/features/channels/ChannelMemberRow";
|
||||
import { onCleanup } from "solid-js";
|
||||
import { expect, fn } from "storybook/test";
|
||||
import { fn } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
import { saveSettingsPanelWidth } from "../src/components/settings-panel-width";
|
||||
import AgentSettingsPanel from "../src/features/conversation/AgentSettingsPanel";
|
||||
@@ -139,10 +139,6 @@ type Story = StoryObj<typeof meta>;
|
||||
|
||||
export const ChannelSettings: Story = {
|
||||
render: () => <ChannelPanelStory title="Channel settings" body={() => <ChannelPanelBody />} />,
|
||||
play: async ({ canvas }) => {
|
||||
await expect(await canvas.findByRole("heading", { level: 2, name: "Channel settings" })).toBeInTheDocument();
|
||||
await expect(await canvas.findByRole("button", { name: /^Memories\s*0 saved$/ })).toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
|
||||
export const ChannelSettingsWithoutMembers: Story = {
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { CalendarClock } from "@openbot/ui";
|
||||
import { ChatActionCard, type ChatActionCardProps } from "@openbot/ui/features/conversation/ChatActionCard";
|
||||
import { expect, fn } from "storybook/test";
|
||||
import { fn } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
|
||||
/*
|
||||
@@ -33,37 +33,23 @@ const meta = {
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof meta>;
|
||||
|
||||
export const Note: Story = {
|
||||
play: async ({ args, canvas, userEvent }) => {
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Open routine Morning brief" }));
|
||||
await expect(args.onOpen).toHaveBeenCalledOnce();
|
||||
},
|
||||
};
|
||||
export const Note: Story = {};
|
||||
|
||||
export const Busy: Story = { args: { status: { kind: "busy", text: "Saving…" } } };
|
||||
|
||||
/** A change made from the card is done. */
|
||||
export const Done: Story = {
|
||||
args: { status: { kind: "done", text: "Saved" } },
|
||||
play: async ({ canvas }) => {
|
||||
await expect(canvas.getByRole("status")).toHaveTextContent("Saved");
|
||||
},
|
||||
};
|
||||
|
||||
export const ErrorStatus: Story = {
|
||||
name: "Error",
|
||||
args: { status: { kind: "error", text: "Could not save the schedule. Try again." } },
|
||||
play: async ({ canvas }) => {
|
||||
await expect(canvas.getByRole("alert")).toHaveTextContent("Could not save the schedule. Try again.");
|
||||
},
|
||||
};
|
||||
|
||||
/** The subject no longer exists: the title is struck through and Open is hidden. */
|
||||
export const Removed: Story = {
|
||||
args: { removed: true, status: { kind: "note", text: "This routine was deleted." } },
|
||||
play: async ({ canvas }) => {
|
||||
await expect(canvas.queryByRole("button", { name: /Open routine/ })).not.toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
|
||||
/** A variant can be the header and the footer only. */
|
||||
|
||||
@@ -2,7 +2,7 @@ import { Heading, Text } from "@openbot/ui";
|
||||
import type { AgentProfile, ChatActionMarkerModel } from "@openbot/ui/data";
|
||||
import { ChatActionMarker } from "@openbot/ui/features/conversation/ChatActionMarker";
|
||||
import { createSignal } from "solid-js";
|
||||
import { expect, fn } from "storybook/test";
|
||||
import { fn } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
import { AgentSkillsModal } from "../src/features/conversation/AgentSkillsModal";
|
||||
|
||||
@@ -103,13 +103,6 @@ export const AllStates: Story = {
|
||||
</section>
|
||||
</main>
|
||||
),
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
onOpenRoutine.mockClear();
|
||||
const [routineButton] = canvas.getAllByRole("button", { name: "Open routine Morning brief" });
|
||||
if (!routineButton) throw new Error("Routine button is missing.");
|
||||
await userEvent.click(routineButton);
|
||||
await expect(onOpenRoutine).toHaveBeenCalledWith({ routineId: "routine-1", name: "Morning brief" });
|
||||
},
|
||||
};
|
||||
|
||||
export const CompactAndUnavailable: Story = {
|
||||
@@ -170,9 +163,6 @@ export const AgentRecipientsMenu: Story = {
|
||||
</section>
|
||||
</main>
|
||||
),
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(canvas.getByRole("button", { name: /3 agents/ }));
|
||||
},
|
||||
};
|
||||
|
||||
export const ReducedMotion: Story = {
|
||||
@@ -220,10 +210,6 @@ export const RoutineRunSummary: Story = {
|
||||
</section>
|
||||
</main>
|
||||
),
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Show history for Morning brief" }));
|
||||
await expect(canvas.getByRole("list", { name: "Earlier routine states" })).toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
const timestamp = "2026-09-01T08:00:00.000Z";
|
||||
|
||||
@@ -20,7 +20,7 @@ import { ChoiceCard } from "@openbot/ui/features/conversation/ConversationPrompt
|
||||
import { MessageActions, MessageBody } from "@openbot/ui/features/conversation/MessageRendering";
|
||||
import type { JSX } from "@solidjs/web";
|
||||
import { createMemo, createSignal, Show } from "solid-js";
|
||||
import { expect, fn, waitFor, within } from "storybook/test";
|
||||
import { fn } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
import { toAgentMessage } from "../src/app-message-projection";
|
||||
import { STORY_AGENTS, STORY_ATTACHMENTS } from "./fixtures";
|
||||
@@ -388,34 +388,11 @@ export const MessageComposition: Story = {
|
||||
export const IntegratedMessages: Story = {
|
||||
name: "Integrated messages",
|
||||
render: () => <PrototypeThread />,
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
onPrototypeReply.mockClear();
|
||||
const message = canvas.getByLabelText("Assistant at 10:05");
|
||||
const toolbar = within(message).getByRole("toolbar", { name: "Agent message actions" });
|
||||
const addReaction = within(toolbar).getByRole("button", { name: "Add reaction" });
|
||||
addReaction.focus();
|
||||
await waitFor(() => expect(toolbar).toBeVisible());
|
||||
|
||||
await userEvent.click(addReaction);
|
||||
const picker = await within(message).findByRole("menu", { name: "Add reaction" });
|
||||
await userEvent.click(within(picker).getByRole("menuitemradio", { name: "React with 🎉" }));
|
||||
await expect(within(message).findByRole("button", { name: "Remove reaction 🎉" })).resolves.toBeVisible();
|
||||
|
||||
const reply = within(toolbar).getByRole("button", { name: "Reply to Agent message" });
|
||||
reply.focus();
|
||||
await waitFor(() => expect(toolbar).toBeVisible());
|
||||
await userEvent.keyboard("{Enter}");
|
||||
await expect(onPrototypeReply).toHaveBeenCalledTimes(1);
|
||||
},
|
||||
};
|
||||
|
||||
export const NarrowConversation: Story = {
|
||||
name: "Integrated messages narrow",
|
||||
render: () => <PrototypeThread narrow />,
|
||||
play: async ({ canvas }) => {
|
||||
const stage = canvas.getByRole("region", { name: "Integrated chat example" });
|
||||
await expect(stage.scrollWidth).toBeLessThanOrEqual(stage.clientWidth);
|
||||
},
|
||||
};
|
||||
|
||||
export const MessageDates: Story = {
|
||||
|
||||
@@ -3,7 +3,7 @@ import { serializeChatTagReference } from "@openbot/contracts/chat-tag-reference
|
||||
import type { DraftAttachment, InstalledSkill } from "@openbot/contracts/ipc";
|
||||
import { ComposerEditor } from "@openbot/ui/features/conversation/ComposerEditor";
|
||||
import { createSignal } from "solid-js";
|
||||
import { expect, fn, within } from "storybook/test";
|
||||
import { fn } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
import { STORY_AGENTS, STORY_MCP_SERVERS } from "./fixtures";
|
||||
|
||||
@@ -104,20 +104,6 @@ const longDescriptionSkill: InstalledSkill = {
|
||||
"Collects the timeline, the alerts and the chat around an incident, then writes the review the team reads the next morning, with the contributing causes, the repair work and the owner of each follow-up item.",
|
||||
};
|
||||
|
||||
/** Writes a picker trigger into the contenteditable and puts the caret after it. */
|
||||
function typePickerTrigger(editor: HTMLElement, trigger: string): void {
|
||||
editor.textContent = trigger;
|
||||
const textNode = editor.firstChild;
|
||||
if (!textNode) throw new Error("Composer editor did not create a text node");
|
||||
const selectionRange = document.createRange();
|
||||
selectionRange.setStart(textNode, textNode.textContent?.length ?? 0);
|
||||
selectionRange.collapse(true);
|
||||
const selection = window.getSelection();
|
||||
selection?.removeAllRanges();
|
||||
selection?.addRange(selectionRange);
|
||||
editor.dispatchEvent(new Event("input", { bubbles: true }));
|
||||
}
|
||||
|
||||
/**
|
||||
* The picker grows out of the top edge of the composer, so a picker story keeps empty room above
|
||||
* the composer. A compact composer holds the editor in the middle grid column, and the picker
|
||||
@@ -179,21 +165,6 @@ export const Disabled: Story = {
|
||||
|
||||
export const MentionPicker: Story = {
|
||||
render: (storyArgs) => composerFrame(storyArgs, { width: "480px" }),
|
||||
play: async ({ args: storyArgs, canvas, userEvent }) => {
|
||||
const editor = canvas.getByRole("textbox", { name: "Message Chief" });
|
||||
await userEvent.click(editor);
|
||||
typePickerTrigger(editor, "@");
|
||||
const picker = await within(document.body).findByRole("listbox", { name: "Insert mention" });
|
||||
await expect(picker).toBeInTheDocument();
|
||||
const research = within(document.body).getByRole("option", { name: "Research Agent" });
|
||||
const sales = within(document.body).getByRole("option", { name: "Sales Outbound Agent" });
|
||||
await expect(research).toHaveClass("mention-picker-option-active");
|
||||
await userEvent.keyboard("{ArrowDown}");
|
||||
await expect(sales).toHaveClass("mention-picker-option-active");
|
||||
await userEvent.keyboard("{Enter}");
|
||||
await expect(editor.querySelector('[data-mention-id="sales"]')).not.toBeNull();
|
||||
await expect(storyArgs.onSubmit).not.toHaveBeenCalled();
|
||||
},
|
||||
};
|
||||
|
||||
export const SkillPicker: Story = {
|
||||
@@ -201,18 +172,6 @@ export const SkillPicker: Story = {
|
||||
skills: installedSkills,
|
||||
},
|
||||
render: (storyArgs) => composerFrame(storyArgs, { width: "480px" }),
|
||||
play: async ({ args: storyArgs, canvas, userEvent }) => {
|
||||
const editor = canvas.getByRole("textbox", { name: "Message Chief" });
|
||||
await userEvent.click(editor);
|
||||
typePickerTrigger(editor, "$");
|
||||
const picker = await within(document.body).findByRole("listbox", { name: "Insert skill or MCP server" });
|
||||
await expect(picker).toBeInTheDocument();
|
||||
await expect(within(document.body).getByRole("option", { name: /^Release Notes/ })).toBeInTheDocument();
|
||||
await userEvent.keyboard("{Enter}");
|
||||
await expect(editor.querySelector('[data-skill-id="skill-release-notes"]')).not.toBeNull();
|
||||
await expect(editor).toHaveTextContent("Release Notes");
|
||||
await expect(storyArgs.onSubmit).not.toHaveBeenCalled();
|
||||
},
|
||||
};
|
||||
|
||||
export const McpServerPicker: Story = {
|
||||
@@ -221,15 +180,6 @@ export const McpServerPicker: Story = {
|
||||
mcpServers: STORY_MCP_SERVERS,
|
||||
},
|
||||
render: (storyArgs) => composerFrame(storyArgs, { width: "480px" }),
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
const editor = canvas.getByRole("textbox", { name: "Message Chief" });
|
||||
await userEvent.click(editor);
|
||||
typePickerTrigger(editor, "$Lin");
|
||||
const picker = await within(document.body).findByRole("listbox", { name: "Insert skill or MCP server" });
|
||||
await expect(within(picker).getByRole("option", { name: /^Linear MCP server/ })).toBeInTheDocument();
|
||||
await userEvent.keyboard("{Enter}");
|
||||
await expect(editor.querySelector('[data-mcp-id="mcp-linear"]')).not.toBeNull();
|
||||
},
|
||||
};
|
||||
|
||||
export const SkillPickerLongDescription: Story = {
|
||||
@@ -237,13 +187,6 @@ export const SkillPickerLongDescription: Story = {
|
||||
skills: [longDescriptionSkill, ...installedSkills],
|
||||
},
|
||||
render: (storyArgs) => composerFrame(storyArgs, { width: "480px" }),
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
const editor = canvas.getByRole("textbox", { name: "Message Chief" });
|
||||
await userEvent.click(editor);
|
||||
typePickerTrigger(editor, "$");
|
||||
const picker = await within(document.body).findByRole("listbox", { name: "Insert skill or MCP server" });
|
||||
await expect(within(picker).getByRole("option", { name: /^Incident Review/ })).toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
|
||||
export const CompactComposerPicker: Story = {
|
||||
@@ -251,13 +194,6 @@ export const CompactComposerPicker: Story = {
|
||||
skills: installedSkills,
|
||||
},
|
||||
render: (storyArgs) => composerFrame(storyArgs, { width: "360px", compact: true }),
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
const editor = canvas.getByRole("textbox", { name: "Message Chief" });
|
||||
await userEvent.click(editor);
|
||||
typePickerTrigger(editor, "$");
|
||||
const picker = await within(document.body).findByRole("listbox", { name: "Insert skill or MCP server" });
|
||||
await expect(within(picker).getByRole("option", { name: /^Site Hosting/ })).toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
|
||||
export const FileReferencePicker: Story = {
|
||||
@@ -266,46 +202,6 @@ export const FileReferencePicker: Story = {
|
||||
onOpenAttachment: fn(),
|
||||
},
|
||||
render: (storyArgs) => composerFrame(storyArgs, { width: "480px" }),
|
||||
play: async ({ args: storyArgs, canvas, userEvent }) => {
|
||||
const editor = canvas.getByRole("textbox", { name: "Message Chief" });
|
||||
await userEvent.click(editor);
|
||||
editor.textContent = "@start";
|
||||
const textNode = editor.firstChild;
|
||||
if (!textNode) throw new Error("Composer editor did not create a text node");
|
||||
const selectionRange = document.createRange();
|
||||
selectionRange.setStart(textNode, textNode.textContent?.length ?? 0);
|
||||
selectionRange.collapse(true);
|
||||
const selection = {
|
||||
anchorNode: textNode,
|
||||
anchorOffset: textNode.textContent?.length ?? 0,
|
||||
rangeCount: 1,
|
||||
getRangeAt: () => selectionRange,
|
||||
removeAllRanges: () => undefined,
|
||||
addRange: () => undefined,
|
||||
// biome-ignore lint/nursery/noUnsafeTypeAssertion: Storybook needs a minimal Selection double for contenteditable caret placement.
|
||||
} as unknown as Selection;
|
||||
const originalGetSelection = window.getSelection;
|
||||
Object.defineProperty(window, "getSelection", {
|
||||
configurable: true,
|
||||
value: () => selection,
|
||||
});
|
||||
try {
|
||||
editor.dispatchEvent(new Event("input", { bubbles: true }));
|
||||
const picker = await within(document.body).findByRole("listbox", { name: "Insert mention" });
|
||||
await expect(within(picker).getByRole("option", { name: "start-types.d.ts File" })).toBeInTheDocument();
|
||||
await userEvent.keyboard("{Enter}");
|
||||
const chip = editor.querySelector<HTMLElement>('[data-attachment-reference-id="draft-start-types"]');
|
||||
if (!chip) throw new Error("Composer editor did not insert the file reference");
|
||||
await expect(editor).toHaveTextContent("start-types.d.ts");
|
||||
await userEvent.click(chip);
|
||||
await expect(storyArgs.onOpenAttachment).toHaveBeenCalledWith(referencedFiles[0]);
|
||||
} finally {
|
||||
Object.defineProperty(window, "getSelection", {
|
||||
configurable: true,
|
||||
value: originalGetSelection,
|
||||
});
|
||||
}
|
||||
},
|
||||
};
|
||||
|
||||
export const WithFileReferences: Story = {
|
||||
@@ -335,21 +231,4 @@ export const LongFileReference: Story = {
|
||||
</div>
|
||||
</div>
|
||||
),
|
||||
play: async ({ args: storyArgs, canvas, userEvent }) => {
|
||||
const token = canvas.getByRole("button", {
|
||||
name: `Open attached file ${longReferencedFile.name}`,
|
||||
});
|
||||
const label = token.querySelector<HTMLElement>(".inline-file-reference-name");
|
||||
if (!label) throw new Error("The composer file reference label is missing");
|
||||
await expect(label.scrollWidth).toBeGreaterThan(label.clientWidth);
|
||||
|
||||
token.focus();
|
||||
await expect(within(document.body).findByRole("tooltip")).resolves.toHaveTextContent(longReferencedFile.name);
|
||||
await userEvent.keyboard("{Escape}");
|
||||
await expect(within(document.body).queryByRole("tooltip")).not.toBeInTheDocument();
|
||||
await userEvent.keyboard("{Enter}");
|
||||
await expect(storyArgs.onOpenAttachment).toHaveBeenCalledTimes(1);
|
||||
await userEvent.keyboard(" ");
|
||||
await expect(storyArgs.onOpenAttachment).toHaveBeenCalledTimes(2);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { ComposerErrorBanner } from "@openbot/ui/features/conversation/ComposerErrorBanner";
|
||||
import { ComposerUsageLimitNotice } from "@openbot/ui/features/conversation/ComposerNotice";
|
||||
import type { JSX } from "@solidjs/web";
|
||||
import { expect, fn } from "storybook/test";
|
||||
import { fn } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
|
||||
const meta = {
|
||||
@@ -35,11 +35,6 @@ export const ProviderError: Story = {
|
||||
<ComposerErrorBanner {...args} />
|
||||
</ComposerStack>
|
||||
),
|
||||
play: async ({ args, canvas, userEvent }) => {
|
||||
await expect(canvas.getByRole("alert")).toHaveTextContent("The model endpoint refused the request.");
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Dismiss error" }));
|
||||
await expect(args.onDismiss).toHaveBeenCalled();
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -57,9 +52,6 @@ export const DroppedTransport: Story = {
|
||||
<ComposerErrorBanner {...args} />
|
||||
</ComposerStack>
|
||||
),
|
||||
play: async ({ canvas }) => {
|
||||
await expect(canvas.getByRole("alert")).toHaveTextContent(/Connection refused/u);
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -96,8 +88,4 @@ export const BesideTheUsageLimit: Story = {
|
||||
<ComposerErrorBanner {...args} />
|
||||
</ComposerStack>
|
||||
),
|
||||
play: async ({ canvas }) => {
|
||||
await expect(canvas.getByText("Usage limit reached")).toBeInTheDocument();
|
||||
await expect(canvas.getByRole("alert")).toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ComposerSignInNotice, ComposerUsageLimitNotice } from "@openbot/ui/features/conversation/ComposerNotice";
|
||||
import type { JSX } from "@solidjs/web";
|
||||
import { expect, fn } from "storybook/test";
|
||||
import { fn } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
|
||||
const meta = {
|
||||
@@ -34,13 +34,6 @@ export const SignInRequired: Story = {
|
||||
<ComposerSignInNotice {...args} />
|
||||
</ComposerStack>
|
||||
),
|
||||
play: async ({ args, canvas, userEvent }) => {
|
||||
const signIn = canvas.getByRole("button", { name: "Sign in to ChatGPT" });
|
||||
await expect(canvas.getByText("Sign in required")).toBeInTheDocument();
|
||||
await expect(canvas.getByText("Sign in to ChatGPT to send messages.")).toBeInTheDocument();
|
||||
await userEvent.click(signIn);
|
||||
await expect(args.onSignIn).toHaveBeenCalledWith("codex");
|
||||
},
|
||||
};
|
||||
|
||||
export const ClaudeSignInRequired: Story = {
|
||||
@@ -50,9 +43,6 @@ export const ClaudeSignInRequired: Story = {
|
||||
<ComposerSignInNotice {...args} />
|
||||
</ComposerStack>
|
||||
),
|
||||
play: async ({ canvas }) => {
|
||||
await expect(canvas.getByText("Sign in to Claude to send messages.")).toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
|
||||
/** The provider already reports `connecting`, so the action cannot be pressed a second time. */
|
||||
@@ -63,31 +53,6 @@ export const SigningIn: Story = {
|
||||
<ComposerSignInNotice {...args} />
|
||||
</ComposerStack>
|
||||
),
|
||||
play: async ({ canvas }) => {
|
||||
await expect(canvas.getByRole("button", { name: "Sign in to ChatGPT" })).toBeDisabled();
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* The gap between the press and the provider reporting `connecting`: the button holds its own
|
||||
* pending state so a slow main process never looks like an unpressed button.
|
||||
*/
|
||||
export const StartingSignIn: Story = {
|
||||
args: {
|
||||
onSignIn: fn(async () => {
|
||||
await new Promise((resolve) => setTimeout(resolve, 60_000));
|
||||
}),
|
||||
},
|
||||
render: (args) => (
|
||||
<ComposerStack>
|
||||
<ComposerSignInNotice {...args} />
|
||||
</ComposerStack>
|
||||
),
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Sign in to ChatGPT" }));
|
||||
await expect(await canvas.findByRole("button", { name: "Sign in to ChatGPT" })).toBeDisabled();
|
||||
await expect(canvas.getByText("Signing in…")).toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -100,11 +65,6 @@ export const UsageLimitReached: Story = {
|
||||
<ComposerUsageLimitNotice provider="codex" resetsAt={USAGE_RESETS_AT} />
|
||||
</ComposerStack>
|
||||
),
|
||||
play: async ({ canvas }) => {
|
||||
await expect(canvas.getByText("Usage limit reached")).toBeInTheDocument();
|
||||
await expect(canvas.getByText(/You used all of your ChatGPT limit\. It resets /u)).toBeInTheDocument();
|
||||
await expect(canvas.queryByRole("button")).not.toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
|
||||
/** Some providers report a spent window with no reset time, so the card names the way out instead. */
|
||||
@@ -114,9 +74,4 @@ export const UsageLimitWithoutReset: Story = {
|
||||
<ComposerUsageLimitNotice provider="claude" resetsAt={null} />
|
||||
</ComposerStack>
|
||||
),
|
||||
play: async ({ canvas }) => {
|
||||
await expect(
|
||||
canvas.getByText("You used all of your Claude limit. Select a different model to continue."),
|
||||
).toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { Button, ConfirmDialog, type ConfirmDialogProps, Heading, UserAvatar } from "@openbot/ui";
|
||||
import { createSignal } from "solid-js";
|
||||
import { expect, fn, waitFor, within } from "storybook/test";
|
||||
import { fn } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
|
||||
type DemoProps = Omit<ConfirmDialogProps, "open" | "onCancel"> & {
|
||||
@@ -54,9 +54,6 @@ const meta = {
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof meta>;
|
||||
|
||||
const nextFrame = () =>
|
||||
new Promise<void>((resolve) => requestAnimationFrame(() => requestAnimationFrame(() => resolve())));
|
||||
|
||||
export const Destructive: Story = {};
|
||||
|
||||
export const WithAvatar: Story = {
|
||||
@@ -109,73 +106,4 @@ export const WithDetails: Story = {
|
||||
|
||||
export const KeyboardFlow: Story = {
|
||||
args: { initiallyOpen: false },
|
||||
play: async ({ args, canvas, userEvent }) => {
|
||||
const body = within(document.body);
|
||||
const trigger = canvas.getByRole("button", { name: "Delete folder" });
|
||||
const openDialog = async () => {
|
||||
await userEvent.click(trigger);
|
||||
const dialog = await body.findByRole("alertdialog", { name: "Delete Research?" });
|
||||
await waitFor(() => expect(within(dialog).getByRole("button", { name: "Delete" })).toHaveFocus());
|
||||
return dialog;
|
||||
};
|
||||
|
||||
const dialog = await openDialog();
|
||||
const confirm = within(dialog).getByRole("button", { name: "Delete" });
|
||||
const cancel = within(dialog).getByRole("button", { name: "Cancel" });
|
||||
await userEvent.tab({ shift: true });
|
||||
await expect(cancel).toHaveFocus();
|
||||
await userEvent.tab();
|
||||
await expect(confirm).toHaveFocus();
|
||||
await userEvent.tab({ shift: true });
|
||||
await userEvent.keyboard("{Enter}");
|
||||
await waitFor(() => expect(body.queryByRole("alertdialog")).not.toBeInTheDocument());
|
||||
await expect(args.onCancel).toHaveBeenCalledOnce();
|
||||
await nextFrame();
|
||||
await expect(trigger).toHaveFocus();
|
||||
|
||||
await openDialog();
|
||||
await userEvent.keyboard("{Escape}");
|
||||
await waitFor(() => expect(body.queryByRole("alertdialog")).not.toBeInTheDocument());
|
||||
await expect(args.onCancel).toHaveBeenCalledTimes(2);
|
||||
await expect(args.onConfirm).not.toHaveBeenCalled();
|
||||
|
||||
await openDialog();
|
||||
await userEvent.keyboard("{Enter}");
|
||||
await waitFor(() => expect(body.queryByRole("alertdialog")).not.toBeInTheDocument());
|
||||
await expect(args.onConfirm).toHaveBeenCalledOnce();
|
||||
await nextFrame();
|
||||
await expect(trigger).toHaveFocus();
|
||||
},
|
||||
};
|
||||
|
||||
let finishDelete: (() => void) | undefined;
|
||||
|
||||
export const AsyncConfirm: Story = {
|
||||
args: {
|
||||
initiallyOpen: false,
|
||||
onConfirm: fn(
|
||||
() =>
|
||||
new Promise<void>((resolve) => {
|
||||
finishDelete = resolve;
|
||||
}),
|
||||
),
|
||||
},
|
||||
play: async ({ args, canvas, userEvent }) => {
|
||||
const body = within(document.body);
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Delete folder" }));
|
||||
const dialog = await body.findByRole("alertdialog", { name: "Delete Research?" });
|
||||
await userEvent.click(within(dialog).getByRole("button", { name: "Delete" }));
|
||||
|
||||
const pending = await within(dialog).findByRole("button", { name: "Deleting…" });
|
||||
await expect(pending).toHaveAttribute("aria-busy", "true");
|
||||
await expect(pending).toBeDisabled();
|
||||
await expect(within(dialog).getByRole("button", { name: "Cancel" })).toBeDisabled();
|
||||
await userEvent.keyboard("{Escape}");
|
||||
await expect(dialog).toBeInTheDocument();
|
||||
await expect(args.onCancel).not.toHaveBeenCalled();
|
||||
|
||||
finishDelete?.();
|
||||
await waitFor(() => expect(body.queryByRole("alertdialog")).not.toBeInTheDocument());
|
||||
await expect(args.onConfirm).toHaveBeenCalledOnce();
|
||||
},
|
||||
};
|
||||
|
||||
@@ -11,7 +11,7 @@ import type { AgentMessage as RendererAgentMessage } from "@openbot/ui/data";
|
||||
import { BrowserTakeoverCard } from "@openbot/ui/features/conversation/ConversationPrompts";
|
||||
import { Portal } from "@solidjs/web";
|
||||
import { createEffect, createSignal, onCleanup, onSettled, type ParentProps, Show } from "solid-js";
|
||||
import { expect, fireEvent, fn, waitFor, within } from "storybook/test";
|
||||
import { fn } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
import { clipboardFiles } from "../../preload/clipboard-files";
|
||||
import { AuthProvider } from "../src/features/account/account-context";
|
||||
@@ -100,28 +100,6 @@ const unreadStoryMessages: RendererAgentMessage[] = [
|
||||
),
|
||||
];
|
||||
|
||||
/*
|
||||
* The pill that counts what arrived below the reader. The messages live in a signal, because the
|
||||
* count is a function of arrival: the play function has to append to a transcript the reader is
|
||||
* already scrolled away from.
|
||||
*/
|
||||
const newMessagePillHistory: RendererAgentMessage[] = unreadStoryMessages.map((message, index) => ({
|
||||
...message,
|
||||
id: `pill-history-${index + 1}`,
|
||||
}));
|
||||
|
||||
function newMessagePillArrival(index: number): RendererAgentMessage {
|
||||
return {
|
||||
id: `pill-arrival-${index}`,
|
||||
author: "agent",
|
||||
body: `Arrived while the reader was scrolled up (${index}). The pill above the composer counts this one.`,
|
||||
time: `09:${String(50 + index).padStart(2, "0")}`,
|
||||
kind: "text",
|
||||
};
|
||||
}
|
||||
|
||||
const [newMessagePillMessages, setNewMessagePillMessages] = createSignal<RendererAgentMessage[]>(newMessagePillHistory);
|
||||
|
||||
const imageGenerationMessages: RendererAgentMessage[] = [
|
||||
...messages,
|
||||
{
|
||||
@@ -1109,13 +1087,6 @@ export const ProviderSignInRequired: Story = {
|
||||
},
|
||||
onSignInProvider: fn(),
|
||||
},
|
||||
play: async ({ args, canvas, userEvent }) => {
|
||||
const signIn = await canvas.findByRole("button", { name: "Sign in to ChatGPT" });
|
||||
// The composer still takes a draft, so signing in never costs the user their message.
|
||||
await expect(canvas.getByRole("textbox", { name: "Message Chief" })).toBeInTheDocument();
|
||||
await userEvent.click(signIn);
|
||||
await expect(args.onSignInProvider).toHaveBeenCalledWith("codex");
|
||||
},
|
||||
};
|
||||
|
||||
/** The real composer with the plan window spent: the card states the reset and offers no button. */
|
||||
@@ -1132,11 +1103,6 @@ export const UsageLimitReached: Story = {
|
||||
],
|
||||
},
|
||||
},
|
||||
play: async ({ canvas }) => {
|
||||
await expect(await canvas.findByText("Usage limit reached")).toBeInTheDocument();
|
||||
// The composer still takes a draft, so the user can write while they wait for the reset.
|
||||
await expect(canvas.getByRole("textbox", { name: "Message Chief" })).toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -1153,28 +1119,6 @@ export const ProviderErrorBanner: Story = {
|
||||
conversationError="Falling back from WebSockets to HTTPS transport. stream disconnected before completion: Connection refused (os error 61)"
|
||||
/>
|
||||
),
|
||||
play: async ({ canvas }) => {
|
||||
const banner = await canvas.findByRole("alert");
|
||||
await expect(banner).toHaveTextContent(/Connection refused/u);
|
||||
// The composer still takes a draft, so the error never costs the user their message.
|
||||
await expect(canvas.getByRole("textbox", { name: "Message Chief" })).toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
|
||||
/** The same chat after the press: the banner goes, the composer keeps its place and its draft. */
|
||||
export const ProviderErrorDismissed: Story = {
|
||||
name: "Provider error dismissed",
|
||||
render: (storyArgs) => (
|
||||
<MockedConversation
|
||||
args={storyArgs}
|
||||
conversationError="Falling back from WebSockets to HTTPS transport. stream disconnected before completion: Connection refused (os error 61)"
|
||||
/>
|
||||
),
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(await canvas.findByRole("button", { name: "Dismiss error" }));
|
||||
await waitFor(() => expect(canvas.queryByRole("alert")).not.toBeInTheDocument());
|
||||
await expect(canvas.getByRole("textbox", { name: "Message Chief" })).toHaveFocus();
|
||||
},
|
||||
};
|
||||
|
||||
export const AllAgentMessageTypes: Story = {
|
||||
@@ -1189,11 +1133,6 @@ export const AllAgentMessageTypes: Story = {
|
||||
export const VoiceRecording: Story = {
|
||||
name: "Voice recording",
|
||||
render: (storyArgs) => <RecordingConversation args={storyArgs} />,
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Create prompt with voice" }));
|
||||
await expect(canvas.findByRole("group", { name: "Voice recording" })).resolves.toBeVisible();
|
||||
await expect(canvas.findByRole("button", { name: "Stop voice recording" })).resolves.toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
export const VoiceModelDownload: Story = {
|
||||
@@ -1201,44 +1140,6 @@ export const VoiceModelDownload: Story = {
|
||||
render: (storyArgs) => <MockedConversation args={storyArgs} voiceModelProgress={47} />,
|
||||
};
|
||||
|
||||
export const SearchConversation: Story = {
|
||||
name: "Search conversation",
|
||||
play: async ({ canvas, canvasElement, userEvent }) => {
|
||||
const storyWindow = canvasElement.ownerDocument.defaultView;
|
||||
if (!storyWindow) throw new Error("Story window is missing.");
|
||||
const searchReturnTarget = canvas.getByRole("button", { name: "View agent settings" });
|
||||
fireEvent.keyDown(searchReturnTarget, { key: "f", ctrlKey: true });
|
||||
|
||||
const search = await canvas.findByRole("search", { name: "Search conversation" });
|
||||
const input = canvas.getByRole("searchbox", { name: "Search messages" });
|
||||
await expect(search).toBeVisible();
|
||||
await waitFor(() => expect(input).toHaveFocus());
|
||||
await userEvent.type(input, "milestone");
|
||||
await expect(canvas.findByText("1/2")).resolves.toBeVisible();
|
||||
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Next match" }));
|
||||
await expect(canvas.findByText("2/2")).resolves.toBeVisible();
|
||||
await userEvent.keyboard("{Escape}");
|
||||
await expect(canvas.queryByRole("search", { name: "Search conversation" })).not.toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
|
||||
export const ComposerActionMenu: Story = {
|
||||
name: "Composer action menu",
|
||||
play: async ({ canvas, canvasElement, userEvent }) => {
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Add to prompt" }));
|
||||
const menu = await within(canvasElement.ownerDocument.body).findByRole("menu", { name: "Add to prompt" });
|
||||
await waitFor(() => expect(menu).toBeVisible());
|
||||
const attachImage = within(menu).getByRole("menuitem", { name: /Attach image/ });
|
||||
const useSkill = within(menu).getByRole("menuitem", { name: /Use a skill/ });
|
||||
const addContext = within(menu).getByRole("menuitem", { name: /Add context/ });
|
||||
await expect(menu).toHaveClass("ui-action-menu");
|
||||
await waitFor(() => expect(attachImage).toHaveFocus());
|
||||
await expect(useSkill).toHaveAttribute("data-disabled");
|
||||
await expect(addContext).toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
export const PastedImageInComposer: Story = {
|
||||
name: "Pasted image in composer",
|
||||
render: (storyArgs) => <MockedConversation args={storyArgs} initialAttachments={queuePreviewAttachments} />,
|
||||
@@ -1247,10 +1148,7 @@ export const PastedImageInComposer: Story = {
|
||||
export const MixedAttachmentsInNarrowComposer: Story = {
|
||||
name: "Mixed attachments in narrow composer",
|
||||
render: (storyArgs) => (
|
||||
<section
|
||||
data-testid="narrow-composer-attachments-sample"
|
||||
style={{ width: "360px", height: "820px", overflow: "hidden" }}
|
||||
>
|
||||
<section style={{ width: "360px", height: "820px", overflow: "hidden" }}>
|
||||
<MockedConversation args={storyArgs} initialAttachments={[...queuePreviewAttachments, storyAttachment]} />
|
||||
</section>
|
||||
),
|
||||
@@ -1289,60 +1187,6 @@ export const ScrollToLatest: Story = {
|
||||
unreadCount: 0,
|
||||
firstUnreadMessageId: null,
|
||||
},
|
||||
play: async ({ canvas, canvasElement }) => {
|
||||
const scrollElement = canvasElement.querySelector<HTMLElement>(".conversation-scroll");
|
||||
if (!scrollElement) throw new Error("Conversation scroll element is missing.");
|
||||
Object.defineProperties(scrollElement, {
|
||||
clientHeight: { configurable: true, value: 600 },
|
||||
scrollHeight: { configurable: true, value: 1_200 },
|
||||
});
|
||||
scrollElement.scrollTop = 0;
|
||||
scrollElement.dispatchEvent(new Event("scroll"));
|
||||
await expect(canvas.findByRole("button", { name: "Scroll to latest message" })).resolves.toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
export const NewMessagesPill: Story = {
|
||||
name: "New messages pill",
|
||||
args: {
|
||||
messages: newMessagePillHistory,
|
||||
unreadCount: 0,
|
||||
firstUnreadMessageId: null,
|
||||
},
|
||||
render: (storyArgs) => <MockedConversation args={storyArgs} messages={newMessagePillMessages()} />,
|
||||
play: async ({ canvas, canvasElement }) => {
|
||||
setNewMessagePillMessages(newMessagePillHistory);
|
||||
const scrollElement = canvasElement.querySelector<HTMLElement>(".conversation-scroll");
|
||||
if (!scrollElement) throw new Error("Conversation scroll element is missing.");
|
||||
Object.defineProperties(scrollElement, {
|
||||
clientHeight: { configurable: true, value: 600 },
|
||||
scrollHeight: { configurable: true, value: 1_200 },
|
||||
});
|
||||
scrollElement.scrollTop = 0;
|
||||
scrollElement.dispatchEvent(new Event("scroll"));
|
||||
await expect(canvas.findByRole("button", { name: "Scroll to latest message" })).resolves.toBeVisible();
|
||||
|
||||
setNewMessagePillMessages((current) => [...current, newMessagePillArrival(1)]);
|
||||
await expect(canvas.findByRole("button", { name: "Jump to 1 new message" })).resolves.toBeVisible();
|
||||
|
||||
setNewMessagePillMessages((current) => [...current, newMessagePillArrival(2), newMessagePillArrival(3)]);
|
||||
await expect(canvas.findByRole("button", { name: "Jump to 3 new messages" })).resolves.toBeVisible();
|
||||
|
||||
// The reader's own message is not news to them.
|
||||
setNewMessagePillMessages((current) => [
|
||||
...current,
|
||||
{ id: "pill-own-message", author: "you", body: "Reading up from here.", time: "09:54", kind: "text" },
|
||||
]);
|
||||
await expect(canvas.findByRole("button", { name: "Jump to 3 new messages" })).resolves.toBeVisible();
|
||||
|
||||
fireEvent.click(await canvas.findByRole("button", { name: "Dismiss new message count" }));
|
||||
await expect(canvas.findByRole("button", { name: "Scroll to latest message" })).resolves.toBeVisible();
|
||||
expect(scrollElement.scrollTop).toBe(0);
|
||||
|
||||
// A dismissed count comes back with the next arrival, from zero.
|
||||
setNewMessagePillMessages((current) => [...current, newMessagePillArrival(4)]);
|
||||
await expect(canvas.findByRole("button", { name: "Jump to 1 new message" })).resolves.toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
export const CitationsInChat: Story = {
|
||||
@@ -1364,13 +1208,6 @@ export const ImageGenerationCompletedInChat: Story = {
|
||||
activeTurnId: "turn-image-generation",
|
||||
presence: completedImageGenerationPresence,
|
||||
},
|
||||
play: async ({ canvas, canvasElement }) => {
|
||||
expect(canvas.queryByRole("status", { name: "Chief is working" })).not.toBeInTheDocument();
|
||||
await canvas.getByRole("button", { name: "Preview generated image" }).click();
|
||||
await expect(
|
||||
within(canvasElement.ownerDocument.body).findByRole("dialog", { name: "generated-image.png" }),
|
||||
).resolves.toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
|
||||
export const DataTableInChat: Story = {
|
||||
@@ -1378,19 +1215,6 @@ export const DataTableInChat: Story = {
|
||||
args: {
|
||||
messages: dataTableMessages,
|
||||
},
|
||||
play: async ({ canvas }) => {
|
||||
await expect(canvas.getByText("Compare the upcoming Premier League fixtures.")).toBeVisible();
|
||||
const table = canvas.getByRole("table");
|
||||
await expect(table).toBeVisible();
|
||||
await expect(canvas.getAllByRole("columnheader")).toHaveLength(5);
|
||||
const bubble = table.closest<HTMLElement>(".ui-bubble");
|
||||
const actions = canvas.getByRole("toolbar", { name: "Agent message actions" });
|
||||
if (!bubble) throw new Error("The data table message bubble is missing.");
|
||||
await expect(bubble).toHaveAttribute("data-variant", "muted");
|
||||
await expect(
|
||||
Math.abs(actions.getBoundingClientRect().bottom - bubble.getBoundingClientRect().bottom),
|
||||
).toBeLessThanOrEqual(2);
|
||||
},
|
||||
};
|
||||
|
||||
export const CodeBlockInChat: Story = {
|
||||
@@ -1398,17 +1222,6 @@ export const CodeBlockInChat: Story = {
|
||||
args: {
|
||||
messages: codeBlockMessages,
|
||||
},
|
||||
play: async ({ canvas, canvasElement }) => {
|
||||
await expect(canvas.getByRole("region", { name: "Shell code block" })).toBeVisible();
|
||||
const codeRow = canvasElement.querySelector<HTMLElement>(".virtual-chat-row:has(.message-code-block)");
|
||||
const followUp = canvas
|
||||
.getByText("The checks should complete before release.")
|
||||
.closest<HTMLElement>(".virtual-chat-row");
|
||||
if (!codeRow || !followUp) throw new Error("Code block chat rows are missing.");
|
||||
await waitFor(() =>
|
||||
expect(followUp.getBoundingClientRect().top).toBeGreaterThanOrEqual(codeRow.getBoundingClientRect().bottom),
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
export const MarkdownInChat: Story = {
|
||||
@@ -1416,20 +1229,6 @@ export const MarkdownInChat: Story = {
|
||||
args: {
|
||||
messages: markdownMessages,
|
||||
},
|
||||
play: async ({ canvas, canvasElement }) => {
|
||||
await expect(canvas.getByRole("heading", { level: 2, name: "Recommendation" })).toBeVisible();
|
||||
await expect(canvas.getByText("Kobalte").tagName).toBe("STRONG");
|
||||
await expect(canvas.getByRole("checkbox", { name: "Works with our design system" })).toBeChecked();
|
||||
await expect(canvas.queryByText("## Recommendation")).not.toBeInTheDocument();
|
||||
const markdownRow = canvasElement.querySelector<HTMLElement>(".virtual-chat-row:has(.message-markdown)");
|
||||
const followUp = canvas
|
||||
.getByText("I can prepare the migration checklist next.")
|
||||
.closest<HTMLElement>(".virtual-chat-row");
|
||||
if (!markdownRow || !followUp) throw new Error("Markdown chat rows are missing.");
|
||||
await waitFor(() =>
|
||||
expect(followUp.getBoundingClientRect().top).toBeGreaterThanOrEqual(markdownRow.getBoundingClientRect().bottom),
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
export const StreamingMarkdownInChat: Story = {
|
||||
@@ -1439,33 +1238,6 @@ export const StreamingMarkdownInChat: Story = {
|
||||
activeTurnId: "streaming-markdown",
|
||||
},
|
||||
render: (storyArgs) => <StreamingMarkdownConversation args={storyArgs} />,
|
||||
play: async ({ canvas, canvasElement }) => {
|
||||
await expect(canvas.getByRole("heading", { level: 2, name: "Live response" })).toBeVisible();
|
||||
const streamingRow = canvasElement.querySelector<HTMLElement>(
|
||||
'.virtual-chat-row:has([data-chat-search-message="streaming-markdown-agent"])',
|
||||
);
|
||||
if (!streamingRow) throw new Error("The streaming Markdown row is missing.");
|
||||
const initialHeight = streamingRow.getBoundingClientRect().height;
|
||||
|
||||
await expect(
|
||||
canvas.findByText("The streamed response is complete.", {}, { timeout: 2_000 }),
|
||||
).resolves.toBeVisible();
|
||||
await expect(canvas.getByText("Markdown renderer").tagName).toBe("STRONG");
|
||||
await expect(canvas.getByRole("region", { name: "TypeScript code block" })).toBeVisible();
|
||||
|
||||
const updatedRow = canvasElement.querySelector<HTMLElement>(
|
||||
'.virtual-chat-row:has([data-chat-search-message="streaming-markdown-agent"])',
|
||||
);
|
||||
const followUp = canvas
|
||||
.getByText("This message must stay below the growing response.")
|
||||
.closest<HTMLElement>(".virtual-chat-row");
|
||||
if (!updatedRow || !followUp) throw new Error("The streamed chat rows are missing.");
|
||||
expect(updatedRow).toBe(streamingRow);
|
||||
await waitFor(() => expect(updatedRow.getBoundingClientRect().height).toBeGreaterThan(initialHeight));
|
||||
await waitFor(() =>
|
||||
expect(followUp.getBoundingClientRect().top).toBeGreaterThanOrEqual(updatedRow.getBoundingClientRect().bottom),
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
export const ComparisonTableInChat: Story = {
|
||||
@@ -1473,11 +1245,6 @@ export const ComparisonTableInChat: Story = {
|
||||
args: {
|
||||
messages: comparisonTableMessages,
|
||||
},
|
||||
play: async ({ canvas }) => {
|
||||
await expect(canvas.getByText("Compare the Personal and Enterprise plans feature by feature.")).toBeVisible();
|
||||
await expect(canvas.getByRole("region", { name: "Comparison table" })).toBeVisible();
|
||||
await expect(canvas.getAllByRole("columnheader")).toHaveLength(3);
|
||||
},
|
||||
};
|
||||
|
||||
export const ImageGenerationUnavailableWithClaude: Story = {
|
||||
@@ -1545,11 +1312,6 @@ export const BrowserTakeover: Story = {
|
||||
messages: [],
|
||||
},
|
||||
render: (storyArgs) => <MockedConversation args={storyArgs} takeoverStateGallery />,
|
||||
play: async ({ canvas }) => {
|
||||
await expect(canvas.getByRole("region", { name: "Browser takeover" })).toBeVisible();
|
||||
await expect(canvas.getByRole("region", { name: "Browser takeover complete" })).toBeVisible();
|
||||
await expect(canvas.getByRole("region", { name: "Browser takeover cancelled" })).toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
export const PromptQuestionsInChat: Story = {
|
||||
@@ -1668,79 +1430,6 @@ export const SevenQueuedMessages: Story = {
|
||||
},
|
||||
};
|
||||
|
||||
export const SevenQueuedMessagesInteractions: Story = {
|
||||
...SevenQueuedMessages,
|
||||
name: "Seven queued messages interactions",
|
||||
tags: ["!dev"],
|
||||
play: async ({ canvas, canvasElement, userEvent }) => {
|
||||
const messagesInQueue = () =>
|
||||
Array.from(canvasElement.querySelectorAll(".agent-queue-message"), (element) => element.textContent);
|
||||
const composer = canvasElement.querySelector<HTMLElement>(".composer");
|
||||
const editor = canvas.getByRole("textbox", { name: "Message Chief" });
|
||||
if (!composer) throw new Error("Composer is missing.");
|
||||
|
||||
const paddingPointerDown = new PointerEvent("pointerdown", { bubbles: true, cancelable: true });
|
||||
expect(composer.dispatchEvent(paddingPointerDown)).toBe(false);
|
||||
await waitFor(() => expect(editor).toHaveFocus());
|
||||
|
||||
// The panel mounts from an effect, so the first row arrives after the composer takes focus.
|
||||
const firstRow = await waitFor(() => {
|
||||
const row = canvasElement.querySelector<HTMLFieldSetElement>(".agent-queue-item");
|
||||
if (!row) throw new Error("Queue row is missing.");
|
||||
return row;
|
||||
});
|
||||
|
||||
fireEvent.keyDown(firstRow, { key: "ArrowDown", altKey: true });
|
||||
await waitFor(() =>
|
||||
expect(messagesInQueue().slice(0, 2)).toEqual([queueReferenceMessages[1], queueReferenceMessages[0]]),
|
||||
);
|
||||
|
||||
const movedRow = Array.from(canvasElement.querySelectorAll<HTMLFieldSetElement>(".agent-queue-item")).find((row) =>
|
||||
row.textContent?.includes(queueReferenceMessages[0]),
|
||||
);
|
||||
if (!movedRow) throw new Error("Moved queue row is missing.");
|
||||
fireEvent.keyDown(movedRow, { key: "ArrowUp", altKey: true });
|
||||
await waitFor(() =>
|
||||
expect(messagesInQueue().slice(0, 2)).toEqual([queueReferenceMessages[0], queueReferenceMessages[1]]),
|
||||
);
|
||||
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Edit queued message 1" }));
|
||||
await waitFor(() => expect(editor).toHaveFocus());
|
||||
await waitFor(() => expect(canvas.getByRole("button", { name: "Save queued message" })).toBeVisible());
|
||||
await waitFor(() => expect(messagesInQueue()).toHaveLength(queueReferenceMessages.length - 1));
|
||||
expect(messagesInQueue()).not.toContain(queueReferenceMessages[0]);
|
||||
editor.textContent = "Updated queue message from Storybook";
|
||||
await fireEvent.input(editor);
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Save queued message" }));
|
||||
await waitFor(() => expect(messagesInQueue()[0]).toBe("Updated queue message from Storybook"));
|
||||
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Edit queued message 1" }));
|
||||
await waitFor(() => expect(messagesInQueue()).toHaveLength(queueReferenceMessages.length - 1));
|
||||
editor.textContent = queueReferenceMessages[0];
|
||||
await fireEvent.input(editor);
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Save queued message" }));
|
||||
await waitFor(() => expect(messagesInQueue()[0]).toBe(queueReferenceMessages[0]));
|
||||
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Edit queued message 3" }));
|
||||
const attachmentCard = canvasElement.querySelector<HTMLElement>(".composer-attachment");
|
||||
const queuePanel = canvasElement.querySelector<HTMLElement>(".agent-queue-panel");
|
||||
if (!attachmentCard || !queuePanel) throw new Error("Queue attachment edit layout is missing.");
|
||||
await waitFor(() =>
|
||||
expect(queuePanel.getBoundingClientRect().bottom).toBeLessThanOrEqual(attachmentCard.getBoundingClientRect().top),
|
||||
);
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Save queued message" }));
|
||||
await waitFor(() => expect(messagesInQueue()).toHaveLength(queueReferenceMessages.length));
|
||||
|
||||
editor.textContent = "Queued from the Storybook composer";
|
||||
await fireEvent.input(editor);
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Send message" }));
|
||||
await waitFor(() => expect(messagesInQueue().at(-1)).toBe("Queued from the Storybook composer"));
|
||||
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Delete queued message 8" }));
|
||||
await waitFor(() => expect(messagesInQueue()).toHaveLength(queueReferenceMessages.length));
|
||||
},
|
||||
};
|
||||
|
||||
export const QueueWithItems: Story = {
|
||||
args: { queue: queueWithItems(3) },
|
||||
};
|
||||
@@ -1951,10 +1640,6 @@ export const ActionMarkerHistory: Story = {
|
||||
: message,
|
||||
),
|
||||
},
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Show history for Daily source check" }));
|
||||
await expect(canvas.getByRole("list", { name: "Earlier routine states" })).toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
export const NarrowActionMarkerSpacing: Story = {
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
import { ChoiceCard } from "@openbot/ui/features/conversation/ConversationPrompts";
|
||||
import { userEvent, within } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
|
||||
const choiceArgs: Parameters<typeof ChoiceCard>[0] = {
|
||||
@@ -55,17 +54,6 @@ export const LongContent: Story = {
|
||||
},
|
||||
};
|
||||
|
||||
export const Selected: Story = {
|
||||
play: async ({ canvasElement }) => {
|
||||
await userEvent.click(within(canvasElement).getByRole("radio", { name: "Research & writing" }));
|
||||
},
|
||||
};
|
||||
|
||||
export const CustomAnswer: Story = {
|
||||
args: { choices: [...choiceArgs.choices, "Something else"] },
|
||||
play: async ({ canvasElement }) => {
|
||||
const canvas = within(canvasElement);
|
||||
await userEvent.click(canvas.getByRole("radio", { name: "Something else" }));
|
||||
await userEvent.type(canvas.getByRole("textbox", { name: "Custom answer" }), "Prepare the release notes");
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { CustomProviderDialog } from "@openbot/ui/features/custom-providers/CustomProviderDialog";
|
||||
import type { CustomProviderDraft } from "@openbot/ui/features/custom-providers/custom-provider-form";
|
||||
import { expect, fn, within } from "storybook/test";
|
||||
import { fn } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
|
||||
const localEndpoint: CustomProviderDraft = {
|
||||
@@ -57,32 +57,6 @@ export const DialogErrors: Story = {
|
||||
|
||||
export const DialogSubmits: Story = {
|
||||
args: { draft: localEndpoint },
|
||||
play: async ({ args: storyArgs, userEvent }) => {
|
||||
const body = within(document.body);
|
||||
await userEvent.click(body.getByRole("button", { name: "Submit" }));
|
||||
await expect(storyArgs.onSubmit).toHaveBeenCalledWith(
|
||||
expect.objectContaining({ id: "studio-local", apiKey: "story-placeholder-not-a-key" }),
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
export const DialogRefusesAnEmptyForm: Story = {
|
||||
play: async ({ args: storyArgs, userEvent }) => {
|
||||
const body = within(document.body);
|
||||
await userEvent.click(body.getByRole("button", { name: "Submit" }));
|
||||
await expect(body.findByText("Enter a provider ID.")).resolves.toBeTruthy();
|
||||
await expect(storyArgs.onSubmit).not.toHaveBeenCalled();
|
||||
},
|
||||
};
|
||||
|
||||
export const DialogAddsRows: Story = {
|
||||
args: { draft: localEndpoint },
|
||||
play: async ({ userEvent }) => {
|
||||
const body = within(document.body);
|
||||
await userEvent.click(body.getByRole("button", { name: "Add model" }));
|
||||
await expect(body.findByRole("textbox", { name: "Model 3 ID" })).resolves.toBeTruthy();
|
||||
await userEvent.click(body.getByRole("button", { name: "Remove model 3" }));
|
||||
},
|
||||
};
|
||||
|
||||
export const DialogBusy: Story = {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import type { DirectMessage } from "@openbot/contracts/ipc";
|
||||
import { DirectConversation } from "@openbot/ui/features/conversation/DirectConversation";
|
||||
import { createEffect, createSignal } from "solid-js";
|
||||
import { expect, fireEvent, fn } from "storybook/test";
|
||||
import { fn } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
import { requireFixture, STORY_DIRECT_SNAPSHOTS, STORY_PRESENCE } from "./fixtures";
|
||||
|
||||
@@ -89,45 +89,6 @@ function StatefulDirectConversation(props: { args: Parameters<typeof DirectConve
|
||||
);
|
||||
}
|
||||
|
||||
/*
|
||||
* The pill that counts what arrived below the reader. The snapshot lives in a signal, because the
|
||||
* count is a function of arrival: the play function has to append to a thread the reader is
|
||||
* already scrolled away from.
|
||||
*/
|
||||
const directPillBaseSnapshot = {
|
||||
...memberSnapshot,
|
||||
revision: 2,
|
||||
messages: unreadDirectMessages,
|
||||
readState: { unreadCount: 0, firstUnreadMessageId: null, throughSequence: 24 },
|
||||
};
|
||||
|
||||
function directPillArrival(index: number, own: boolean): DirectMessage {
|
||||
return {
|
||||
id: `direct-pill-arrival-${index}`,
|
||||
threadId: "direct-alice",
|
||||
senderMemberId: own ? "member-self" : member.id,
|
||||
recipientMemberId: own ? member.id : "member-self",
|
||||
text: `Arrived while the reader was scrolled up (${index}).`,
|
||||
createdAt: `2026-08-19T10:${String(index).padStart(2, "0")}:00.000Z`,
|
||||
sequence: unreadDirectMessages.length + index,
|
||||
};
|
||||
}
|
||||
|
||||
const [directPillSnapshot, setDirectPillSnapshot] =
|
||||
createSignal<Parameters<typeof DirectConversation>[0]["snapshot"]>(directPillBaseSnapshot);
|
||||
|
||||
function appendDirectPillMessage(index: number, own: boolean): void {
|
||||
setDirectPillSnapshot((current) =>
|
||||
current
|
||||
? {
|
||||
...current,
|
||||
revision: (current.revision ?? 0) + 1,
|
||||
messages: [...current.messages, directPillArrival(index, own)],
|
||||
}
|
||||
: current,
|
||||
);
|
||||
}
|
||||
|
||||
const meta = {
|
||||
title: "Team/DirectConversation",
|
||||
component: DirectConversation,
|
||||
@@ -138,14 +99,7 @@ const meta = {
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof meta>;
|
||||
|
||||
export const Conversation: Story = {
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
const input = canvas.getByRole("textbox", { name: "Message Alice Chen" });
|
||||
await userEvent.type(input, "I’ll review it now.");
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Send direct message" }));
|
||||
await expect(input).toHaveValue("");
|
||||
},
|
||||
};
|
||||
export const Conversation: Story = {};
|
||||
|
||||
export const UnreadMessages: Story = {
|
||||
render: (storyArgs) => <StatefulDirectConversation args={storyArgs} />,
|
||||
@@ -177,62 +131,6 @@ export const ScrollToLatest: Story = {
|
||||
},
|
||||
},
|
||||
},
|
||||
play: async ({ canvas, canvasElement }) => {
|
||||
const scrollElement = canvasElement.querySelector<HTMLElement>(".direct-message-list");
|
||||
if (!scrollElement) throw new Error("Direct message scroll element is missing.");
|
||||
Object.defineProperties(scrollElement, {
|
||||
clientHeight: { configurable: true, value: 600 },
|
||||
scrollHeight: { configurable: true, value: 1_200 },
|
||||
});
|
||||
scrollElement.scrollTop = 0;
|
||||
scrollElement.dispatchEvent(new Event("scroll"));
|
||||
await expect(canvas.findByRole("button", { name: "Scroll to latest message" })).resolves.toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
export const NewMessagesPill: Story = {
|
||||
name: "New messages pill",
|
||||
render: (storyArgs) => (
|
||||
<StatefulDirectConversation
|
||||
args={{
|
||||
...storyArgs,
|
||||
get snapshot() {
|
||||
return directPillSnapshot();
|
||||
},
|
||||
}}
|
||||
/>
|
||||
),
|
||||
args: { snapshot: directPillBaseSnapshot },
|
||||
play: async ({ canvas, canvasElement }) => {
|
||||
setDirectPillSnapshot(directPillBaseSnapshot);
|
||||
const scrollElement = canvasElement.querySelector<HTMLElement>(".direct-message-list");
|
||||
if (!scrollElement) throw new Error("Direct message scroll element is missing.");
|
||||
Object.defineProperties(scrollElement, {
|
||||
clientHeight: { configurable: true, value: 600 },
|
||||
scrollHeight: { configurable: true, value: 1_200 },
|
||||
});
|
||||
scrollElement.scrollTop = 0;
|
||||
scrollElement.dispatchEvent(new Event("scroll"));
|
||||
await expect(canvas.findByRole("button", { name: "Scroll to latest message" })).resolves.toBeVisible();
|
||||
|
||||
appendDirectPillMessage(1, false);
|
||||
await expect(canvas.findByRole("button", { name: "Jump to 1 new message" })).resolves.toBeVisible();
|
||||
|
||||
// The reader's own message is not news to them.
|
||||
appendDirectPillMessage(2, true);
|
||||
await expect(canvas.findByRole("button", { name: "Jump to 1 new message" })).resolves.toBeVisible();
|
||||
|
||||
appendDirectPillMessage(3, false);
|
||||
await expect(canvas.findByRole("button", { name: "Jump to 2 new messages" })).resolves.toBeVisible();
|
||||
|
||||
fireEvent.click(await canvas.findByRole("button", { name: "Dismiss new message count" }));
|
||||
await expect(canvas.findByRole("button", { name: "Scroll to latest message" })).resolves.toBeVisible();
|
||||
expect(scrollElement.scrollTop).toBe(0);
|
||||
|
||||
// A dismissed count comes back with the next arrival, from zero.
|
||||
appendDirectPillMessage(4, false);
|
||||
await expect(canvas.findByRole("button", { name: "Jump to 1 new message" })).resolves.toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
export const Typing: Story = {
|
||||
|
||||
@@ -7,7 +7,7 @@ import { FileList } from "@openbot/ui/features/files/FileList";
|
||||
import { StorageOverview } from "@openbot/ui/features/files/StorageOverview";
|
||||
import { SettingsDialogShell } from "@openbot/ui/features/settings/SettingsDialogShell";
|
||||
import { createSignal, Show } from "solid-js";
|
||||
import { expect, fn, userEvent, waitFor, within } from "storybook/test";
|
||||
import { fn } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
import {
|
||||
FILES_AGENT_USAGE,
|
||||
@@ -71,43 +71,12 @@ function OverviewStage(props: { args: OverviewArgs; narrow?: boolean }) {
|
||||
export const StorageReady: Story = {
|
||||
name: "Storage: Ready",
|
||||
render: () => <OverviewStage args={overviewArgs()} />,
|
||||
play: async ({ canvas }) => {
|
||||
await expect(canvas.getByRole("img", { name: /^Storage by type: Agent workspaces 3\.6 GB/u })).toBeVisible();
|
||||
await expect(canvas.getByRole("list", { name: "Storage by type" })).toBeVisible();
|
||||
await userEvent.click(canvas.getByRole("button", { name: /^All files/u }));
|
||||
const all = await canvas.findByRole("region", { name: "All files on This Mac" });
|
||||
await expect(within(all).getByRole("heading", { name: "Today" })).toBeVisible();
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Back to storage" }));
|
||||
await expect(await canvas.findByRole("heading", { name: "Largest chats" })).toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
export const StorageClearConfirm: Story = {
|
||||
name: "Storage: Clear confirm",
|
||||
render: () => <OverviewStage args={overviewArgs()} />,
|
||||
play: async ({ canvas }) => {
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Clear Cached server files" }));
|
||||
const body = within(document.body);
|
||||
const dialog = await body.findByRole("alertdialog", { name: "Clear cached server files?" });
|
||||
// The dialog fades in; wait for the animation to end.
|
||||
await waitFor(() => expect(dialog).toBeVisible());
|
||||
},
|
||||
};
|
||||
|
||||
// A member of a remote server reads the same page, without Clean up and without Delete.
|
||||
export const StorageMember: Story = {
|
||||
name: "Storage: Member",
|
||||
render: () => <OverviewStage args={{ ...overviewArgs(), hostName: "Studio server", canManage: false }} />,
|
||||
play: async ({ canvas }) => {
|
||||
await expect(canvas.queryByRole("heading", { name: "Clean up" })).toBeNull();
|
||||
await userEvent.click(canvas.getByRole("button", { name: /^All files/u }));
|
||||
await userEvent.click(await canvas.findByRole("button", { name: "More actions for release-notes-v4.md" }));
|
||||
const body = within(document.body);
|
||||
await expect(await body.findByRole("menuitem", { name: "Open" })).toBeVisible();
|
||||
await expect(body.queryByRole("menuitem", { name: "Delete" })).toBeNull();
|
||||
await userEvent.keyboard("{Escape}");
|
||||
await waitFor(() => expect(body.queryByRole("menu")).toBeNull());
|
||||
},
|
||||
};
|
||||
|
||||
export const StorageScanning: Story = {
|
||||
@@ -125,10 +94,6 @@ export const StorageScanning: Story = {
|
||||
}}
|
||||
/>
|
||||
),
|
||||
play: async ({ canvas }) => {
|
||||
await expect(canvas.getByRole("progressbar", { name: "Measuring storage" })).toBeVisible();
|
||||
await expect(canvas.getByRole("button", { name: /Measuring/u })).toBeDisabled();
|
||||
},
|
||||
};
|
||||
|
||||
export const StorageEmpty: Story = {
|
||||
@@ -235,12 +200,6 @@ function ServerSettingsStage(props: { args: OverviewArgs }) {
|
||||
export const StorageInServerSettings: Story = {
|
||||
name: "Storage: Server settings, this Mac",
|
||||
render: () => <ServerSettingsStage args={overviewArgs()} />,
|
||||
play: async () => {
|
||||
const body = within(document.body);
|
||||
const dialog = await body.findByRole("dialog", { name: "Storage" });
|
||||
await expect(within(dialog).getByRole("tab", { name: "Storage" })).toHaveAttribute("aria-selected", "true");
|
||||
await expect(within(dialog).getByRole("img", { name: /^Storage by type/u })).toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
|
||||
export const StorageInRemoteServerSettings: Story = {
|
||||
@@ -321,22 +280,11 @@ function AgentFilesStory(props: { initiallyOpen: boolean; loading?: boolean; emp
|
||||
export const AgentFilesLink: Story = {
|
||||
name: "Agent files: Settings row",
|
||||
render: () => <AgentFilesStory initiallyOpen={false} />,
|
||||
play: async ({ canvas }) => {
|
||||
await userEvent.click(canvas.getByRole("button", { name: /^Files/u }));
|
||||
await expect(await canvas.findByRole("region", { name: "Files of Chief" })).toBeVisible();
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Back to settings" }));
|
||||
await expect(await canvas.findByRole("button", { name: /^Files/u })).toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
export const AgentFilesReady: Story = {
|
||||
name: "Agent files: Ready",
|
||||
render: () => <AgentFilesStory initiallyOpen />,
|
||||
play: async ({ canvas }) => {
|
||||
// The settings detail slides in; wait for the animation to end.
|
||||
await waitFor(() => expect(canvas.getByRole("button", { name: "Open workspace folder" })).toBeVisible());
|
||||
await expect(canvas.getByRole("heading", { name: "Chats by size" })).toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
export const AgentFilesEmpty: Story = {
|
||||
@@ -372,18 +320,7 @@ function ConversationStage(props: Partial<Parameters<typeof ConversationFilesPan
|
||||
|
||||
export const ConversationReady: Story = {
|
||||
name: "Chat files: Ready",
|
||||
render: () => {
|
||||
const onFileAction = fn(async () => undefined);
|
||||
return <ConversationStage onFileAction={onFileAction} />;
|
||||
},
|
||||
play: async ({ canvas }) => {
|
||||
const panel = canvas.getByRole("complementary", { name: "Files in Launch plan and release notes" });
|
||||
await expect(within(panel).getByRole("heading", { name: "Today" })).toBeVisible();
|
||||
await userEvent.click(within(panel).getByRole("button", { name: "More actions for release-notes-v4.md" }));
|
||||
await expect(await within(document.body).findByRole("menuitem", { name: "Show in chat" })).toBeVisible();
|
||||
await userEvent.keyboard("{Escape}");
|
||||
await waitFor(() => expect(within(document.body).queryByRole("menu")).toBeNull());
|
||||
},
|
||||
render: () => <ConversationStage />,
|
||||
};
|
||||
|
||||
export const ConversationEmpty: Story = {
|
||||
@@ -432,13 +369,6 @@ function ListStage(props: Partial<Parameters<typeof FileList>[0]>) {
|
||||
export const ListFilters: Story = {
|
||||
name: "File list: Search and filters",
|
||||
render: () => <ListStage />,
|
||||
play: async ({ canvas }) => {
|
||||
const images = canvas.getByRole("button", { name: /^Images/u });
|
||||
await userEvent.click(images);
|
||||
await expect(images).toHaveAttribute("aria-pressed", "true");
|
||||
await userEvent.type(canvas.getByRole("searchbox", { name: "Search files" }), "moodboard");
|
||||
await expect(canvas.getAllByRole("button", { name: /^Preview moodboard/u })).toHaveLength(3);
|
||||
},
|
||||
};
|
||||
|
||||
export const ListLargestFirst: Story = {
|
||||
@@ -449,24 +379,6 @@ export const ListLargestFirst: Story = {
|
||||
export const ListNoMatch: Story = {
|
||||
name: "File list: No match",
|
||||
render: () => <ListStage initialQuery={{ search: "invoice-2019" }} />,
|
||||
play: async ({ canvas }) => {
|
||||
await expect(canvas.getByText("No matching files")).toBeVisible();
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Clear filters" }));
|
||||
await expect(canvas.getByRole("searchbox", { name: "Search files" })).toHaveValue("");
|
||||
},
|
||||
};
|
||||
|
||||
export const ListDeleteConfirm: Story = {
|
||||
name: "File list: Delete confirm",
|
||||
render: () => <ListStage />,
|
||||
play: async ({ canvas }) => {
|
||||
await userEvent.click(canvas.getByRole("button", { name: "More actions for release-notes-v4.md" }));
|
||||
const body = within(document.body);
|
||||
await userEvent.click(await body.findByRole("menuitem", { name: "Delete" }));
|
||||
const dialog = await body.findByRole("alertdialog", { name: "Delete this file?" });
|
||||
// The dialog fades in; wait for the animation to end.
|
||||
await waitFor(() => expect(dialog).toBeVisible());
|
||||
},
|
||||
};
|
||||
|
||||
export const ListLoading: Story = {
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
type FirstAgentSuggestion,
|
||||
} from "@openbot/ui/features/agents/FirstAgentSetup";
|
||||
import { createEffect, createSignal } from "solid-js";
|
||||
import { expect, fireEvent, fn } from "storybook/test";
|
||||
import { fn } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
|
||||
function draftFromSuggestion(suggestion: FirstAgentSuggestion): FirstAgentDraft {
|
||||
@@ -73,85 +73,7 @@ const meta = {
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof meta>;
|
||||
|
||||
export const Default: Story = {
|
||||
play: async ({ canvas, canvasElement }) => {
|
||||
const createButton = canvas.getByRole("button", { name: "Create agent" });
|
||||
await expect(canvas.getAllByRole("listitem")).toHaveLength(6);
|
||||
await expect(createButton).toBeEnabled();
|
||||
await expect(canvas.getByRole("textbox", { name: "Name" })).toHaveValue("New agent");
|
||||
await expect(canvas.getByRole("textbox", { name: "What should this agent help with?" })).toHaveValue("");
|
||||
await expect(canvas.getAllByRole("button", { name: /agent color$/ })).toHaveLength(9);
|
||||
await expect(canvas.queryByRole("button", { name: "Lime agent color" })).not.toBeInTheDocument();
|
||||
await expect(canvas.queryByRole("button", { name: "Violet agent color" })).not.toBeInTheDocument();
|
||||
|
||||
const suggestionViewport = canvasElement.querySelector<HTMLElement>(".first-agent-suggestion-viewport");
|
||||
const suggestionList = canvasElement.querySelector<HTMLElement>(".first-agent-suggestion-list");
|
||||
if (!suggestionViewport || !suggestionList) throw new Error("The agent suggestion scroller is missing.");
|
||||
await expect(getComputedStyle(suggestionList).scrollSnapType).toBe("none");
|
||||
await expect(suggestionViewport).toHaveClass("can-scroll-forward");
|
||||
await expect(suggestionViewport).not.toHaveClass("can-scroll-back");
|
||||
const suggestionAvatars = Array.from(
|
||||
canvasElement.querySelectorAll<HTMLElement>(".first-agent-suggestion-card .agent-avatar-motion-always"),
|
||||
);
|
||||
await expect(suggestionAvatars).toHaveLength(6);
|
||||
const suggestionCards = Array.from(canvasElement.querySelectorAll<HTMLElement>(".first-agent-suggestion-card"));
|
||||
await expect(new Set(suggestionCards.map((card) => card.dataset.animationCycleOffset)).size).toBe(6);
|
||||
await expect(new Set(suggestionCards.map((card) => card.dataset.animationOffset)).size).toBe(6);
|
||||
await expect(canvasElement.querySelector(".first-agent-live-avatar .agent-avatar-motion-idle")).toBeInTheDocument();
|
||||
await expect(canvasElement.querySelector(".first-agent-live-avatar")).toHaveAttribute(
|
||||
"data-avatar-seed",
|
||||
DEFAULT_FIRST_AGENT_DRAFT.avatarSeed,
|
||||
);
|
||||
|
||||
suggestionList.scrollLeft = suggestionList.scrollWidth;
|
||||
await fireEvent.scroll(suggestionList);
|
||||
await expect(suggestionViewport).toHaveClass("can-scroll-back");
|
||||
await expect(suggestionViewport).not.toHaveClass("can-scroll-forward");
|
||||
suggestionList.scrollLeft = 0;
|
||||
await fireEvent.scroll(suggestionList);
|
||||
},
|
||||
};
|
||||
|
||||
export const Interactions: Story = {
|
||||
play: async ({ args: storyArgs, canvas, canvasElement, userEvent }) => {
|
||||
const createButton = canvas.getByRole("button", { name: "Create agent" });
|
||||
|
||||
const tripPlanner = canvas.getByRole("button", {
|
||||
name: "Trip Planner. Compares options and builds practical itineraries.",
|
||||
});
|
||||
await userEvent.click(tripPlanner);
|
||||
|
||||
const suggestion = FIRST_AGENT_SUGGESTIONS[1];
|
||||
if (!suggestion) throw new Error("The Trip Planner suggestion is missing.");
|
||||
await expect(canvas.getByRole("textbox", { name: "Name" })).toHaveValue(suggestion.name);
|
||||
await expect(canvas.getByRole("textbox", { name: "What should this agent help with?" })).toHaveValue(
|
||||
suggestion.purpose,
|
||||
);
|
||||
await expect(tripPlanner).toHaveAttribute("aria-pressed", "true");
|
||||
await expect(createButton).toBeEnabled();
|
||||
|
||||
const liveAvatar = canvasElement.querySelector<HTMLElement>(".first-agent-live-avatar");
|
||||
const headerAvatar = canvasElement.querySelector<HTMLElement>(".first-agent-header-identity");
|
||||
await expect(liveAvatar).toHaveAttribute("data-avatar-seed", suggestion.avatarSeed);
|
||||
await expect(headerAvatar).toHaveAttribute("data-avatar-seed", suggestion.avatarSeed);
|
||||
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Create agent" }));
|
||||
await expect(storyArgs.onSubmit).toHaveBeenCalledWith(draftFromSuggestion(suggestion));
|
||||
|
||||
const nameInput = canvas.getByRole("textbox", { name: "Name" });
|
||||
await userEvent.clear(nameInput);
|
||||
await userEvent.type(nameInput, "Weekend Planner");
|
||||
await expect(tripPlanner).toHaveAttribute("aria-pressed", "false");
|
||||
await expect(storyArgs.onChange).toHaveBeenLastCalledWith(
|
||||
expect.objectContaining({ name: "Weekend Planner", suggestionId: null }),
|
||||
);
|
||||
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Blue agent color" }));
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Agent face 2" }));
|
||||
await expect(canvas.getByRole("button", { name: "Blue agent color" })).toHaveAttribute("aria-pressed", "true");
|
||||
await expect(canvas.getByRole("button", { name: "Agent face 2" })).toHaveAttribute("aria-pressed", "true");
|
||||
},
|
||||
};
|
||||
export const Default: Story = {};
|
||||
|
||||
const selectedSuggestion = FIRST_AGENT_SUGGESTIONS[1];
|
||||
|
||||
@@ -168,32 +90,8 @@ export const Submitting: Story = {
|
||||
submitting: true,
|
||||
onCancel: fn(),
|
||||
},
|
||||
play: async ({ canvas }) => {
|
||||
await expect(canvas.getByRole("button", { name: "Creating agent…" })).toBeDisabled();
|
||||
await expect(canvas.getByRole("button", { name: "Cancel" })).toBeDisabled();
|
||||
await expect(canvas.getByRole("textbox", { name: "Name" })).toBeDisabled();
|
||||
await expect(canvas.getByRole("textbox", { name: "What should this agent help with?" })).toBeDisabled();
|
||||
await expect(canvas.getByRole("button", { name: /^Inbox Helper\./ })).toBeDisabled();
|
||||
},
|
||||
};
|
||||
|
||||
export const SmallWindow: Story = {
|
||||
parameters: { viewport: { defaultViewport: "firstAgentSmall" } },
|
||||
play: async ({ canvas, canvasElement }) => {
|
||||
const suggestionList = canvasElement.querySelector<HTMLElement>(".first-agent-suggestion-list");
|
||||
if (!suggestionList) throw new Error("The agent suggestion list is missing.");
|
||||
await expect(suggestionList.scrollWidth).toBeGreaterThan(suggestionList.clientWidth);
|
||||
|
||||
const selectedFace = canvas.getByRole("button", { name: "Agent face 1" });
|
||||
const faceBody = selectedFace.querySelector<SVGRectElement>("svg rect");
|
||||
if (!faceBody) throw new Error("The selected agent face body is missing.");
|
||||
const buttonBounds = selectedFace.getBoundingClientRect();
|
||||
const bodyBounds = faceBody.getBoundingClientRect();
|
||||
await expect(
|
||||
Math.abs(buttonBounds.left + buttonBounds.width / 2 - (bodyBounds.left + bodyBounds.width / 2)),
|
||||
).toBeLessThan(1);
|
||||
await expect(
|
||||
Math.abs(buttonBounds.top + buttonBounds.height / 2 - (bodyBounds.top + bodyBounds.height / 2)),
|
||||
).toBeLessThan(1);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Button, Field, Heading, Input, NativeSelect, Textarea } from "@openbot/ui";
|
||||
import { createSignal } from "solid-js";
|
||||
import { expect } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
|
||||
const meta = {
|
||||
@@ -63,12 +62,4 @@ export const ControlledTyping: Story = {
|
||||
</main>
|
||||
);
|
||||
},
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
const name = canvas.getByRole("textbox", { name: "Agent name" });
|
||||
const description = canvas.getByRole("textbox", { name: "Description" });
|
||||
await userEvent.type(name, "Fast typing stays intact");
|
||||
await userEvent.type(description, "Every character remains editable.");
|
||||
await expect(name).toHaveValue("Fast typing stays intact");
|
||||
await expect(description).toHaveValue("Every character remains editable.");
|
||||
},
|
||||
};
|
||||
|
||||
@@ -21,7 +21,7 @@ import {
|
||||
Trash2,
|
||||
} from "@openbot/ui";
|
||||
import { createSignal } from "solid-js";
|
||||
import { expect, fn, within } from "storybook/test";
|
||||
import { fn } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
|
||||
const meta = {
|
||||
@@ -59,21 +59,6 @@ export const DialogFocus: Story = {
|
||||
</Dialog.Root>
|
||||
</main>
|
||||
),
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
const trigger = canvas.getByRole("button", { name: "Open dialog" });
|
||||
await userEvent.click(trigger);
|
||||
const body = within(document.body);
|
||||
const dialog = await body.findByRole("dialog");
|
||||
await expect(dialog).toBeVisible();
|
||||
await userEvent.keyboard("{Tab}");
|
||||
const activeElement = document.activeElement;
|
||||
await expect(activeElement).toBeInstanceOf(HTMLElement);
|
||||
if (activeElement instanceof HTMLElement) await expect(dialog).toContainElement(activeElement);
|
||||
await userEvent.keyboard("{Escape}");
|
||||
await expect(body.queryByRole("dialog")).not.toBeInTheDocument();
|
||||
await new Promise<void>((resolve) => requestAnimationFrame(() => requestAnimationFrame(() => resolve())));
|
||||
await expect(trigger).toHaveFocus();
|
||||
},
|
||||
};
|
||||
|
||||
export const AlertDialogConfirmation: Story = {
|
||||
@@ -108,16 +93,6 @@ export const AlertDialogConfirmation: Story = {
|
||||
</AlertDialog.Root>
|
||||
</main>
|
||||
),
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
const trigger = canvas.getByRole("button", { name: "Delete agent" });
|
||||
await userEvent.click(trigger);
|
||||
const body = within(document.body);
|
||||
await expect(await body.findByRole("alertdialog")).toBeVisible();
|
||||
await userEvent.click(body.getByRole("button", { name: "Cancel" }));
|
||||
await new Promise<void>((resolve) => requestAnimationFrame(() => requestAnimationFrame(() => resolve())));
|
||||
await expect(body.queryByRole("alertdialog")).not.toBeInTheDocument();
|
||||
await expect(trigger).toHaveFocus();
|
||||
},
|
||||
};
|
||||
|
||||
export const MenuPopoverTooltip: Story = {
|
||||
@@ -185,66 +160,6 @@ export const MenuPopoverTooltip: Story = {
|
||||
</div>
|
||||
</main>
|
||||
),
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
const body = within(document.body);
|
||||
const menuTrigger = canvas.getByRole("button", { name: "Agent actions" });
|
||||
await userEvent.click(menuTrigger);
|
||||
const menu = await body.findByRole("menu");
|
||||
const [firstItem] = within(menu).getAllByRole("menuitem");
|
||||
if (!firstItem) throw new Error("Agent actions menu has no items.");
|
||||
const menuStyle = getComputedStyle(menu);
|
||||
const firstItemStyle = getComputedStyle(firstItem);
|
||||
await expect(menu).toBeVisible();
|
||||
await expect(menu).toHaveClass("ui-action-menu");
|
||||
await expect(menu.getBoundingClientRect().width).toBe(160);
|
||||
await expect(menuStyle.padding).toBe("4px");
|
||||
await expect(menuStyle.borderRadius).toBe("8px");
|
||||
await expect(firstItem.getBoundingClientRect().height).toBe(32);
|
||||
await expect(firstItemStyle.padding).toBe("6px 8px");
|
||||
await expect(firstItemStyle.gap).toBe("8px");
|
||||
await expect(firstItemStyle.borderRadius).toBe("6px");
|
||||
await expect(firstItemStyle.fontSize).toBe("14px");
|
||||
await expect(firstItemStyle.lineHeight).toBe("20px");
|
||||
await expect(firstItemStyle.backgroundColor).not.toBe("rgba(0, 0, 0, 0)");
|
||||
await expect(firstItem.querySelector("svg")?.getBoundingClientRect().width).toBe(16);
|
||||
await expect(body.getByRole("menuitem", { name: "Duplicate" })).toHaveAttribute("data-disabled");
|
||||
const deleteItem = body.getByRole("menuitem", { name: "Delete" });
|
||||
const deleteIcon = deleteItem.querySelector("svg");
|
||||
const menuSeparator = within(menu).getByRole("separator");
|
||||
const subtleDividerColor = getComputedStyle(document.documentElement)
|
||||
.getPropertyValue("--openbot-shadow-ring")
|
||||
.trim();
|
||||
await expect(deleteItem).toHaveClass("ui-action-menu-danger");
|
||||
await expect(getComputedStyle(deleteItem).color).not.toBe(firstItemStyle.color);
|
||||
await expect(getComputedStyle(menuSeparator).backgroundColor).toBe(subtleDividerColor);
|
||||
await expect(getComputedStyle(menuSeparator).margin).toBe("4px 0px");
|
||||
if (!(deleteIcon instanceof SVGElement)) throw new Error("Delete icon was not found.");
|
||||
await expect(getComputedStyle(deleteIcon).color).toBe(getComputedStyle(deleteItem).color);
|
||||
await userEvent.keyboard("{ArrowDown}{End}");
|
||||
await expect(body.getByRole("menuitem", { name: "Delete" })).toHaveAttribute("data-highlighted");
|
||||
await userEvent.keyboard("{Escape}");
|
||||
await new Promise<void>((resolve) => requestAnimationFrame(() => requestAnimationFrame(() => resolve())));
|
||||
await expect(menuTrigger).toHaveFocus();
|
||||
|
||||
const tooltipTrigger = canvas.getByRole("button", { name: "Hover or focus" });
|
||||
tooltipTrigger.focus();
|
||||
await expect(await body.findByRole("tooltip")).toBeVisible();
|
||||
await userEvent.keyboard("{Escape}");
|
||||
await expect(body.queryByRole("tooltip")).not.toBeInTheDocument();
|
||||
|
||||
const popoverTrigger = canvas.getByRole("button", { name: "Show details" });
|
||||
await userEvent.click(popoverTrigger);
|
||||
await expect(await body.findByRole("dialog", { name: "Agent details" })).toBeVisible();
|
||||
await userEvent.click(body.getByRole("button", { name: "Close" }));
|
||||
await expect(body.queryByRole("dialog", { name: "Agent details" })).not.toBeInTheDocument();
|
||||
|
||||
const contextTrigger = canvas.getByText("Right-click for actions");
|
||||
await userEvent.pointer({ keys: "[MouseRight]", target: contextTrigger });
|
||||
await expect(await body.findByRole("menu")).toHaveClass("ui-action-menu");
|
||||
await userEvent.keyboard("{Home}");
|
||||
await expect(body.getByRole("menuitem", { name: "Open" })).toHaveAttribute("data-highlighted");
|
||||
await userEvent.keyboard("{Escape}");
|
||||
},
|
||||
};
|
||||
|
||||
export const TabsAndRadioGroup: Story = {
|
||||
@@ -300,18 +215,6 @@ export const TabsAndRadioGroup: Story = {
|
||||
</main>
|
||||
);
|
||||
},
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
const models = canvas.getByRole("tab", { name: "Models" });
|
||||
models.focus();
|
||||
await userEvent.keyboard("{End}");
|
||||
await expect(canvas.getByRole("tab", { name: "Permissions" })).toHaveFocus();
|
||||
await expect(canvas.getByRole("tabpanel")).toHaveTextContent("Permission settings");
|
||||
|
||||
const general = canvas.getByRole("radio", { name: "General" });
|
||||
general.focus();
|
||||
await userEvent.keyboard("{ArrowDown}");
|
||||
await expect(canvas.getByRole("radio", { name: "Research" })).toBeChecked();
|
||||
},
|
||||
};
|
||||
|
||||
export const SlidingSelectionTabs: Story = {
|
||||
@@ -334,17 +237,6 @@ export const SlidingSelectionTabs: Story = {
|
||||
</SlidingTabs.Root>
|
||||
</main>
|
||||
),
|
||||
play: async ({ canvasElement, userEvent }) => {
|
||||
const canvas = within(canvasElement);
|
||||
const plan = canvas.getByRole("tab", { name: "Plan" });
|
||||
const debug = canvas.getByRole("tab", { name: "Debug" });
|
||||
await expect(plan).toHaveAttribute("aria-selected", "true");
|
||||
await userEvent.click(debug);
|
||||
await expect(debug).toHaveAttribute("aria-selected", "true");
|
||||
debug.focus();
|
||||
await userEvent.keyboard("{ArrowRight}");
|
||||
await expect(canvas.getByRole("tab", { name: "Ask" })).toHaveAttribute("aria-selected", "true");
|
||||
},
|
||||
};
|
||||
|
||||
const pickerOptions = ["GPT-5", "Claude Sonnet", "Gemini Pro"];
|
||||
@@ -409,18 +301,4 @@ export const Pickers: Story = {
|
||||
</div>
|
||||
</main>
|
||||
),
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
const select = canvas.getByRole("button", { name: /Model/ });
|
||||
select.focus();
|
||||
await userEvent.keyboard("{ArrowDown}");
|
||||
const body = within(document.body);
|
||||
await expect((await body.findAllByRole("listbox")).at(-1)).toBeVisible();
|
||||
await userEvent.keyboard("{End}{Enter}");
|
||||
await expect(select).toHaveTextContent("Gemini Pro");
|
||||
|
||||
const combobox = canvas.getByRole("combobox", { name: "Search model" });
|
||||
await userEvent.click(combobox);
|
||||
await userEvent.type(combobox, "Claude");
|
||||
await expect(combobox).toHaveValue("Claude");
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { JoinServerDialog } from "@openbot/ui/features/servers/JoinServerDialog";
|
||||
import { expect, fn, within } from "storybook/test";
|
||||
import { fn } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
|
||||
const preview = {
|
||||
@@ -50,15 +50,6 @@ export const EmailBoundInvite: Story = {
|
||||
},
|
||||
};
|
||||
|
||||
export const InviteReady: Story = {
|
||||
play: async ({ args: storyArgs, userEvent }) => {
|
||||
const body = within(document.body);
|
||||
await expect(body.findByText("Studio host")).resolves.toBeTruthy();
|
||||
await userEvent.click(body.getByRole("button", { name: "Connect" }));
|
||||
await expect(storyArgs.onJoin).toHaveBeenCalledWith({ inviteUrl: args.inviteUrl });
|
||||
},
|
||||
};
|
||||
|
||||
export const EmptyInvite: Story = {
|
||||
args: { inviteUrl: "" },
|
||||
};
|
||||
@@ -70,24 +61,12 @@ export const ErrorState: Story = {
|
||||
throw new Error("The OpenBot invitation link is invalid.");
|
||||
},
|
||||
},
|
||||
play: async ({ userEvent }) => {
|
||||
const body = within(document.body);
|
||||
await userEvent.type(body.getByRole("textbox", { name: "Invite link" }), "https://openbot.run/join?bad");
|
||||
await userEvent.click(body.getByRole("button", { name: "Review invite" }));
|
||||
await expect(body.getByRole("alert")).toHaveTextContent("The OpenBot invitation link is invalid.");
|
||||
},
|
||||
};
|
||||
|
||||
export const Joining: Story = {
|
||||
args: {
|
||||
onJoin: () => new Promise<void>(() => undefined),
|
||||
},
|
||||
play: async ({ userEvent }) => {
|
||||
const body = within(document.body);
|
||||
await expect(body.findByText("Studio host")).resolves.toBeTruthy();
|
||||
await userEvent.click(body.getByRole("button", { name: "Connect" }));
|
||||
await expect(body.getByRole("button", { name: "Connecting…" })).toBeDisabled();
|
||||
},
|
||||
};
|
||||
|
||||
export const JoinError: Story = {
|
||||
@@ -96,12 +75,6 @@ export const JoinError: Story = {
|
||||
throw new Error("OpenBot could not connect to this host.");
|
||||
},
|
||||
},
|
||||
play: async ({ userEvent }) => {
|
||||
const body = within(document.body);
|
||||
await expect(body.findByText("Studio host")).resolves.toBeTruthy();
|
||||
await userEvent.click(body.getByRole("button", { name: "Connect" }));
|
||||
await expect(body.getByRole("alert")).toHaveTextContent("OpenBot could not connect to this host.");
|
||||
},
|
||||
};
|
||||
|
||||
export const LongIdentity: Story = {
|
||||
|
||||
@@ -9,7 +9,6 @@ import {
|
||||
SettingsSection,
|
||||
} from "@openbot/ui";
|
||||
import { createSignal } from "solid-js";
|
||||
import { expect, within } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
import type { AppLanguage } from "../src/features/settings/app-languages";
|
||||
import { LanguageSelect } from "../src/features/settings/LanguageSelect";
|
||||
@@ -55,18 +54,9 @@ export const Gallery: Story = {
|
||||
</div>
|
||||
</main>
|
||||
),
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
// The trigger reads its label and its value, so match the start of the name.
|
||||
const [trigger] = canvas.getAllByRole("button", { name: /^Language/ });
|
||||
if (!trigger) throw new Error("Language trigger is missing.");
|
||||
await userEvent.click(trigger);
|
||||
const body = within(document.body);
|
||||
await userEvent.click(await body.findByRole("option", { name: "日本語" }));
|
||||
await expect(trigger).toHaveTextContent("日本語");
|
||||
},
|
||||
};
|
||||
|
||||
/** The list left open, so the native names and the checked row can be reviewed as a set. */
|
||||
/** A selected language. Open the list to review the native names and the checked row as a set. */
|
||||
export const Expanded: Story = {
|
||||
render: () => (
|
||||
<main class="foundation-story">
|
||||
@@ -77,10 +67,4 @@ export const Expanded: Story = {
|
||||
</div>
|
||||
</main>
|
||||
),
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
const trigger = canvas.getByRole("button", { name: /^Language/ });
|
||||
await userEvent.click(trigger);
|
||||
const body = within(document.body);
|
||||
await expect(await body.findByRole("option", { name: "日本語" })).toHaveAttribute("aria-selected", "true");
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { MarketplacePluginDetail } from "@openbot/ui/features/settings/MarketplacePluginDetail";
|
||||
import type { MarketplacePluginDetail as PluginDetail } from "@openbot/ui/features/settings/marketplace-plugins";
|
||||
import { createSignal } from "solid-js";
|
||||
import { expect, fn, within } from "storybook/test";
|
||||
import { fn } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
import { STORY_MARKETPLACE_PLUGIN_AAVE as aave, STORY_AGENT_SUMMARIES } from "../src/preview/fixtures";
|
||||
|
||||
@@ -68,35 +68,8 @@ const meta = {
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof meta>;
|
||||
|
||||
/** The spies the interaction story asserts on. Held here so `play` and `render` see the same ones. */
|
||||
const defaultSpies = { install: fn(), copyLink: fn(), runPrompt: fn(), uninstall: fn() };
|
||||
|
||||
export const Default: Story = {
|
||||
render: () => (
|
||||
<PluginDetailStory
|
||||
onInstall={defaultSpies.install}
|
||||
onCopyLink={defaultSpies.copyLink}
|
||||
onRunPrompt={defaultSpies.runPrompt}
|
||||
/>
|
||||
),
|
||||
play: async ({ userEvent }) => {
|
||||
defaultSpies.install.mockClear();
|
||||
defaultSpies.copyLink.mockClear();
|
||||
defaultSpies.runPrompt.mockClear();
|
||||
const body = within(document.body);
|
||||
await expect(await body.findByRole("region", { name: "Aave details" })).toBeVisible();
|
||||
|
||||
await userEvent.click(await body.findByRole("button", { name: "Copy link" }));
|
||||
await expect(defaultSpies.copyLink).toHaveBeenCalled();
|
||||
|
||||
await userEvent.click(await body.findByRole("button", { name: "Install plugin" }));
|
||||
await expect(defaultSpies.install).toHaveBeenCalled();
|
||||
|
||||
const [first] = aave.prompts;
|
||||
if (!first) throw new Error("The Aave fixture must carry at least one example prompt.");
|
||||
await userEvent.click(await body.findByRole("button", { name: `Ask Aave: ${first.text}` }));
|
||||
await expect(defaultSpies.runPrompt).toHaveBeenCalledWith(first);
|
||||
},
|
||||
render: () => <PluginDetailStory />,
|
||||
};
|
||||
|
||||
/** No agent on this computer yet: the target reads "No local agents" and the install waits. */
|
||||
@@ -106,13 +79,7 @@ export const NoAgents: Story = {
|
||||
|
||||
/** Already on this computer: the one control offers the way back out instead of the install. */
|
||||
export const Installed: Story = {
|
||||
render: () => <PluginDetailStory installed onUninstall={defaultSpies.uninstall} />,
|
||||
play: async ({ userEvent }) => {
|
||||
defaultSpies.uninstall.mockClear();
|
||||
const body = within(document.body);
|
||||
await userEvent.click(await body.findByRole("button", { name: "Uninstall plugin" }));
|
||||
await expect(defaultSpies.uninstall).toHaveBeenCalled();
|
||||
},
|
||||
render: () => <PluginDetailStory installed />,
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -121,11 +88,6 @@ export const Installed: Story = {
|
||||
*/
|
||||
export const PartlyInstalled: Story = {
|
||||
render: () => <PluginDetailStory removable />,
|
||||
play: async () => {
|
||||
const body = within(document.body);
|
||||
await expect(await body.findByRole("button", { name: "Install plugin" })).toBeVisible();
|
||||
await expect(await body.findByRole("button", { name: "Uninstall plugin" })).toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
export const Installing: Story = {
|
||||
@@ -175,6 +137,5 @@ export const LongContent: Story = {
|
||||
|
||||
export const Narrow: Story = {
|
||||
...Default,
|
||||
play: undefined,
|
||||
globals: { viewport: { value: "marketplaceNarrow", isRotated: false } },
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { AgentMessage } from "@openbot/ui/data";
|
||||
import { MessageActions } from "@openbot/ui/features/conversation/MessageRendering";
|
||||
import { expect, fn, waitFor, within } from "storybook/test";
|
||||
import { fn } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
|
||||
const message: AgentMessage = {
|
||||
@@ -38,31 +38,10 @@ export const Default: Story = {};
|
||||
|
||||
export const ReactionPicker: Story = {
|
||||
args: { pickerOpen: true },
|
||||
play: async ({ canvasElement }) => {
|
||||
const menu = await waitFor(() => {
|
||||
const element = canvasElement.ownerDocument.querySelector<HTMLElement>(".reaction-picker");
|
||||
if (!element) throw new Error("Reaction picker was not mounted.");
|
||||
return element;
|
||||
});
|
||||
await expect(menu).toHaveClass("ui-action-menu");
|
||||
await expect(menu).toHaveAttribute("role", "menu");
|
||||
await expect(menu).toHaveAttribute("aria-label", "Choose a reaction");
|
||||
await expect(menu).toHaveAttribute("data-menu-layout", "grid");
|
||||
await expect(getComputedStyle(menu).padding).toBe("4px");
|
||||
await expect(getComputedStyle(menu).borderRadius).toBe("8px");
|
||||
},
|
||||
};
|
||||
|
||||
export const MoreMenu: Story = {
|
||||
args: { moreOpen: true },
|
||||
play: async ({ canvasElement }) => {
|
||||
const menu = await within(canvasElement.ownerDocument.body).findByRole("menu");
|
||||
const item = within(menu).getByRole("menuitem", { name: "Copy" });
|
||||
await expect(menu).toHaveClass("ui-action-menu");
|
||||
await expect(menu.getBoundingClientRect().width).toBe(160);
|
||||
await expect(item.getBoundingClientRect().height).toBe(32);
|
||||
await expect(item.querySelector("svg")?.getBoundingClientRect().width).toBe(16);
|
||||
},
|
||||
};
|
||||
|
||||
export const PreviewOnly: Story = {
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
import { Bubble, BubbleContent, type BubbleVariant } from "@openbot/ui";
|
||||
import type { AgentMessage } from "@openbot/ui/data";
|
||||
import { MessageBody } from "@openbot/ui/features/conversation/MessageRendering";
|
||||
import { expect, fn } from "storybook/test";
|
||||
import { fn } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
import { STORY_AGENTS, STORY_ATTACHMENTS } from "./fixtures";
|
||||
|
||||
@@ -74,10 +74,6 @@ export const AuthError: Story = {
|
||||
},
|
||||
},
|
||||
render: (storyArgs) => <MessageBodySurface args={storyArgs} width="420px" />,
|
||||
play: async ({ canvas }) => {
|
||||
await expect(canvas.getByText("Sign in required")).toBeInTheDocument();
|
||||
await expect(canvas.queryByText(/AppServerError|chatgpt\.com/u)).not.toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
|
||||
export const WithReplyContext: Story = {
|
||||
@@ -139,11 +135,6 @@ export const Markdown: Story = {
|
||||
},
|
||||
},
|
||||
render: (storyArgs) => <MessageBodySurface args={storyArgs} width="460px" />,
|
||||
play: async ({ canvas }) => {
|
||||
await expect(canvas.getByRole("heading", { level: 2, name: "Recommendation" })).toBeInTheDocument();
|
||||
await expect(canvas.getByText("Kobalte").tagName).toBe("STRONG");
|
||||
await expect(canvas.getByRole("checkbox", { name: "Tested" })).toBeChecked();
|
||||
},
|
||||
};
|
||||
|
||||
export const WorkspaceFileLinks: Story = {
|
||||
@@ -165,23 +156,6 @@ export const WorkspaceFileLinks: Story = {
|
||||
onOpenWorkspaceFile: fn(),
|
||||
},
|
||||
render: (storyArgs) => <MessageBodySurface args={storyArgs} width="620px" />,
|
||||
play: async ({ args: storyArgs, canvas }) => {
|
||||
const pageLink = canvas.getByRole("button", { name: "Open workspace file page.tsx" });
|
||||
const cssLink = canvas.getByRole("button", { name: "Open workspace file globals.css" });
|
||||
const htmlLink = canvas.getByRole("button", { name: "Open workspace file lutra-brand-board.html" });
|
||||
await expect(pageLink).toHaveTextContent("page.tsx");
|
||||
await expect(cssLink).toHaveTextContent("globals.css");
|
||||
await expect(htmlLink).toHaveTextContent("otwórz tablicę Lutra w HTML");
|
||||
await expect(canvas.queryByText(/\/Users\/test\/OpenBot/u)).not.toBeInTheDocument();
|
||||
await expect(canvas.queryByText(/\(<|>\)/u)).not.toBeInTheDocument();
|
||||
pageLink.click();
|
||||
htmlLink.click();
|
||||
await expect(storyArgs.onOpenWorkspaceFile).toHaveBeenNthCalledWith(
|
||||
1,
|
||||
"/Users/test/OpenBot/Agents/builder/app/page.tsx",
|
||||
);
|
||||
await expect(storyArgs.onOpenWorkspaceFile).toHaveBeenNthCalledWith(2, "lutra-brand-board.html");
|
||||
},
|
||||
};
|
||||
|
||||
export const CodeBlock: Story = {
|
||||
@@ -206,15 +180,6 @@ export const CodeBlock: Story = {
|
||||
},
|
||||
},
|
||||
render: (storyArgs) => <MessageBodySurface args={storyArgs} variant="ghost" width="460px" />,
|
||||
play: async ({ canvas }) => {
|
||||
await expect(canvas.getByText("The helper is ready:")).toBeInTheDocument();
|
||||
await expect(canvas.getByRole("region", { name: "TypeScript code block" })).toBeInTheDocument();
|
||||
await expect(canvas.getByText("churn.ts")).toBeInTheDocument();
|
||||
const copyButton = canvas.getByRole("button", { name: "Copy code" });
|
||||
await expect(copyButton.querySelectorAll("svg")).toHaveLength(2);
|
||||
await expect(copyButton.querySelector('.message-code-copy-icons > span[data-visible="true"]')).toBeInTheDocument();
|
||||
await expect(canvas.queryByText("```ts churn.ts")).not.toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
|
||||
export const StreamingCodeBlock: Story = {
|
||||
@@ -233,12 +198,6 @@ export const StreamingCodeBlock: Story = {
|
||||
},
|
||||
},
|
||||
render: (storyArgs) => <MessageBodySurface args={storyArgs} variant="ghost" width="460px" />,
|
||||
play: async ({ canvas }) => {
|
||||
await expect(canvas.getByRole("region", { name: "TypeScript code block" })).toBeInTheDocument();
|
||||
await expect(canvas.getByText("AgentCard.tsx")).toBeInTheDocument();
|
||||
const region = canvas.getByRole("region", { name: "TypeScript code block" });
|
||||
await expect(region.querySelector(".message-code-caret")).toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
|
||||
export const DataTable: Story = {
|
||||
@@ -258,11 +217,6 @@ export const DataTable: Story = {
|
||||
},
|
||||
},
|
||||
render: (storyArgs) => <MessageBodySurface args={storyArgs} variant="ghost" width="460px" />,
|
||||
play: async ({ canvas }) => {
|
||||
await expect(canvas.getByRole("table")).toBeInTheDocument();
|
||||
await expect(canvas.getAllByRole("columnheader")).toHaveLength(3);
|
||||
await expect(canvas.queryByText("| --- | --- | ---: |")).not.toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
|
||||
export const DataTableNarrow: Story = {
|
||||
@@ -281,12 +235,6 @@ export const DataTableNarrow: Story = {
|
||||
},
|
||||
},
|
||||
render: (storyArgs) => <MessageBodySurface args={storyArgs} variant="ghost" width="320px" />,
|
||||
play: async ({ canvas }) => {
|
||||
const region = canvas.getByRole("region", { name: "Data table" });
|
||||
await expect(region.scrollWidth).toBeGreaterThan(region.clientWidth);
|
||||
const longFixture = canvas.getByText("Newcastle–Bournemouth");
|
||||
await expect(getComputedStyle(longFixture).textOverflow).toBe("clip");
|
||||
},
|
||||
};
|
||||
|
||||
export const ComparisonTable: Story = {
|
||||
@@ -307,12 +255,6 @@ export const ComparisonTable: Story = {
|
||||
},
|
||||
},
|
||||
render: (storyArgs) => <MessageBodySurface args={storyArgs} variant="ghost" width="460px" />,
|
||||
play: async ({ canvas }) => {
|
||||
await expect(canvas.getByRole("region", { name: "Comparison table" })).toBeInTheDocument();
|
||||
await expect(canvas.getAllByRole("columnheader")).toHaveLength(3);
|
||||
await expect(canvas.getAllByText("✓")).toHaveLength(6);
|
||||
await expect(canvas.getAllByText("—")).toHaveLength(2);
|
||||
},
|
||||
};
|
||||
|
||||
export const ComparisonTableNarrow: Story = {
|
||||
@@ -332,10 +274,6 @@ export const ComparisonTableNarrow: Story = {
|
||||
},
|
||||
},
|
||||
render: (storyArgs) => <MessageBodySurface args={storyArgs} variant="ghost" width="320px" />,
|
||||
play: async ({ canvas }) => {
|
||||
const region = canvas.getByRole("region", { name: "Comparison table" });
|
||||
await expect(region.scrollWidth).toBeGreaterThan(region.clientWidth);
|
||||
},
|
||||
};
|
||||
|
||||
export const CompletedAnswerReveal: Story = {
|
||||
|
||||
@@ -2,7 +2,7 @@ import { isManagedRuntimeProvider, type ManagedProviderId } from "@openbot/contr
|
||||
import type { AgentProviderId, AgentStatus, AppSetupState, ProviderRuntimeStatus } from "@openbot/contracts/ipc";
|
||||
import { Toaster, toast } from "@openbot/ui";
|
||||
import { createSignal, onCleanup } from "solid-js";
|
||||
import { expect, fn, waitFor, within } from "storybook/test";
|
||||
import { fn } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
import { OnboardingFlow } from "../src/features/onboarding/OnboardingFlow";
|
||||
import { providerKeyApi } from "../src/features/settings/provider-key-api";
|
||||
@@ -345,11 +345,6 @@ export const Initial: Story = {};
|
||||
/** The row that adds a self-described endpoint. OpenCode is installed, so the row offers Add. */
|
||||
export const AddCustomProvider: Story = {
|
||||
args: { agentStatus: openCodeInstalledAgentStatus },
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(await canvas.findByRole("button", { name: "Add custom provider" }));
|
||||
const body = within(document.body);
|
||||
await expect(body.findByRole("heading", { name: "Custom provider" })).resolves.toBeTruthy();
|
||||
},
|
||||
};
|
||||
|
||||
/** The endpoint is refused, so the form stays with the values, including the key the user typed. */
|
||||
@@ -360,20 +355,6 @@ export const CustomProviderSaveFails: Story = {
|
||||
throw new Error("House Router refused the API key.");
|
||||
}),
|
||||
},
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(await canvas.findByRole("button", { name: "Add custom provider" }));
|
||||
const body = within(document.body);
|
||||
// A required field appends an aria-hidden asterisk to its label, so its name is not an exact match.
|
||||
await userEvent.type(await body.findByLabelText(/^Provider ID/), "house-router");
|
||||
await userEvent.type(body.getByLabelText(/^Display name/), "House Router");
|
||||
await userEvent.type(body.getByLabelText(/^Base URL/), "https://models.example.com/v1");
|
||||
await userEvent.type(body.getByLabelText("Model 1 ID"), "glm-5-air");
|
||||
await userEvent.type(body.getByLabelText("Model 1 display name"), "GLM 5 Air");
|
||||
await userEvent.click(body.getByRole("button", { name: "Submit" }));
|
||||
|
||||
await expect(body.findByText("House Router refused the API key.")).resolves.toBeTruthy();
|
||||
await expect(body.getByLabelText(/^Provider ID/)).toHaveValue("house-router");
|
||||
},
|
||||
};
|
||||
|
||||
export const NarrowProviderVersions: Story = {
|
||||
@@ -397,23 +378,6 @@ export const NoProvidersConnected: Story = {
|
||||
onConnectProvider: fn(),
|
||||
onRefreshProviders: fn(),
|
||||
},
|
||||
play: async ({ args: storyArgs, canvas, userEvent }) => {
|
||||
const providers = canvas.getByRole("radiogroup", { name: "Default provider" });
|
||||
await expect(within(providers).getByRole("radio", { name: /ChatGPT/ })).not.toBeChecked();
|
||||
await expect(within(providers).getByRole("radio", { name: /Claude/ })).toBeEnabled();
|
||||
await expect(within(providers).getByRole("radio", { name: /Grok/ })).toBeEnabled();
|
||||
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Connect ChatGPT" }));
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Connect Claude" }));
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Connect Grok" }));
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Refresh providers" }));
|
||||
|
||||
await expect(storyArgs.onConnectProvider).toHaveBeenCalledWith("codex");
|
||||
await expect(storyArgs.onConnectProvider).toHaveBeenCalledWith("claude");
|
||||
await expect(storyArgs.onConnectProvider).toHaveBeenCalledWith("grok");
|
||||
await expect(storyArgs.onRefreshProviders).toHaveBeenCalledOnce();
|
||||
await expect(canvas.queryByRole("button", { name: "Next" })).not.toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -428,12 +392,6 @@ export const SignInWithCode: Story = {
|
||||
onRefreshProviders: fn(),
|
||||
codeLogin: createFakeCodeLogin({ finishAfterMs: 0 }),
|
||||
},
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(canvas.getByRole("button", { name: "More actions for ChatGPT" }));
|
||||
const body = within(document.body);
|
||||
await userEvent.click(await body.findByRole("menuitem", { name: "Log in with code" }));
|
||||
await expect(await body.findByLabelText("Login code K T Q 4 - B 6 2 M X")).toHaveTextContent("KTQ4-B62MX");
|
||||
},
|
||||
};
|
||||
|
||||
export const RefreshingProviders: Story = {
|
||||
@@ -443,17 +401,6 @@ export const RefreshingProviders: Story = {
|
||||
onConnectProvider: fn(),
|
||||
onRefreshProviders: fn(),
|
||||
},
|
||||
play: async ({ canvas }) => {
|
||||
const providers = canvas.getByRole("radiogroup", { name: "Default provider" });
|
||||
await expect(canvas.getByRole("button", { name: "Checking providers" })).toBeDisabled();
|
||||
await expect(canvas.queryByRole("button", { name: /^Install / })).not.toBeInTheDocument();
|
||||
await expect(canvas.getByRole("button", { name: "Connect ChatGPT" })).toBeDisabled();
|
||||
await expect(canvas.getByRole("button", { name: "Connect Claude" })).toBeDisabled();
|
||||
await expect(canvas.getByRole("button", { name: "Connect Grok" })).toBeDisabled();
|
||||
await expect(within(providers).getByRole("radio", { name: /ChatGPT/ })).toBeEnabled();
|
||||
await expect(within(providers).getByRole("radio", { name: /Claude/ })).toBeEnabled();
|
||||
await expect(canvas.getByRole("button", { name: "Connect" })).toBeEnabled();
|
||||
},
|
||||
};
|
||||
|
||||
export const ConnectedWithRefreshWarning: Story = {
|
||||
@@ -485,12 +432,6 @@ export const ConnectingChatGPT: Story = {
|
||||
onConnectProvider: fn(),
|
||||
onRefreshProviders: fn(),
|
||||
},
|
||||
play: async ({ canvas }) => {
|
||||
await expect(canvas.getByRole("button", { name: "Restart ChatGPT" })).toBeEnabled();
|
||||
await expect(canvas.getByRole("button", { name: "Connect Claude" })).toBeEnabled();
|
||||
await expect(canvas.getByRole("button", { name: "Refresh providers" })).toBeEnabled();
|
||||
await expect(canvas.getByRole("button", { name: "Connect" })).toBeEnabled();
|
||||
},
|
||||
};
|
||||
|
||||
export const ConnectingClaude: Story = {
|
||||
@@ -504,12 +445,6 @@ export const ConnectingClaude: Story = {
|
||||
onConnectProvider: fn(),
|
||||
onRefreshProviders: fn(),
|
||||
},
|
||||
play: async ({ canvas }) => {
|
||||
await expect(canvas.getByRole("button", { name: "Restart Claude" })).toBeEnabled();
|
||||
await expect(canvas.getByRole("button", { name: "Connect ChatGPT" })).toBeEnabled();
|
||||
await expect(canvas.getByRole("button", { name: "Refresh providers" })).toBeEnabled();
|
||||
await expect(canvas.getByRole("button", { name: "Connect" })).toBeEnabled();
|
||||
},
|
||||
};
|
||||
|
||||
export const ConnectingBoth: Story = {
|
||||
@@ -518,11 +453,6 @@ export const ConnectingBoth: Story = {
|
||||
onConnectProvider: fn(),
|
||||
onRefreshProviders: fn(),
|
||||
},
|
||||
play: async ({ canvas }) => {
|
||||
await expect(canvas.getByRole("button", { name: "Restart ChatGPT" })).toBeEnabled();
|
||||
await expect(canvas.getByRole("button", { name: "Restart Claude" })).toBeEnabled();
|
||||
await expect(canvas.getByRole("button", { name: "Refresh providers" })).toBeEnabled();
|
||||
},
|
||||
};
|
||||
|
||||
export const RefreshResettingConnections: Story = {
|
||||
@@ -532,15 +462,6 @@ export const RefreshResettingConnections: Story = {
|
||||
onRefreshProviders: fn(),
|
||||
},
|
||||
render: (storyArgs) => <RefreshResettingFlow args={storyArgs} />,
|
||||
play: async ({ args: storyArgs, canvas, userEvent }) => {
|
||||
await expect(canvas.getByRole("button", { name: "Restart ChatGPT" })).toBeEnabled();
|
||||
await expect(canvas.getByRole("button", { name: "Restart Claude" })).toBeEnabled();
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Refresh providers" }));
|
||||
await waitFor(() => expect(canvas.getByRole("button", { name: "Connect ChatGPT" })).toBeEnabled());
|
||||
await expect(canvas.getByRole("button", { name: "Connect Claude" })).toBeEnabled();
|
||||
await expect(storyArgs.onRefreshProviders).toHaveBeenCalledOnce();
|
||||
await expect(canvas.queryByRole("alert")).not.toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
|
||||
export const ConnectedWithReconnect: Story = {
|
||||
@@ -549,13 +470,6 @@ export const ConnectedWithReconnect: Story = {
|
||||
onConnectProvider: fn(),
|
||||
onRefreshProviders: fn(),
|
||||
},
|
||||
play: async ({ canvas }) => {
|
||||
const providers = canvas.getByRole("radiogroup", { name: "Default provider" });
|
||||
await expect(within(providers).getByRole("radio", { name: /ChatGPT/ })).toBeChecked();
|
||||
await expect(canvas.getByRole("button", { name: "Reconnect ChatGPT" })).toBeEnabled();
|
||||
await expect(canvas.getByRole("button", { name: "Reconnect Claude" })).toBeEnabled();
|
||||
await expect(canvas.getByRole("button", { name: "Next" })).toBeEnabled();
|
||||
},
|
||||
};
|
||||
|
||||
export const LazyProviderDownloads: Story = {
|
||||
|
||||
@@ -12,7 +12,7 @@
|
||||
import { Toaster, toast } from "@openbot/ui";
|
||||
import { ProviderCodeLoginDialog, type ProviderCodeLoginState } from "@openbot/ui/components/ProviderCodeLoginDialog";
|
||||
import { createSignal, onCleanup } from "solid-js";
|
||||
import { expect, fn, within } from "storybook/test";
|
||||
import { fn } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
|
||||
const USER_CODE = "KTQ4-B62MX";
|
||||
@@ -51,16 +51,7 @@ export default meta;
|
||||
type Story = StoryObj<typeof meta>;
|
||||
|
||||
/** The code is on screen and the provider has not answered. The whole reason the flow exists. */
|
||||
export const Waiting: Story = {
|
||||
// The dialog is a portal, so every query starts at the body rather than the story root.
|
||||
play: async ({ userEvent, args }) => {
|
||||
const body = within(document.body);
|
||||
// The code is reachable as characters, not as the word a screen reader would make of it.
|
||||
await expect(await body.findByLabelText("Login code K T Q 4 - B 6 2 M X")).toHaveTextContent(USER_CODE);
|
||||
await userEvent.click(body.getByRole("button", { name: VERIFICATION_URL }));
|
||||
await expect(args.onOpenVerificationUrl).toHaveBeenCalledWith(VERIFICATION_URL);
|
||||
},
|
||||
};
|
||||
export const Waiting: Story = {};
|
||||
|
||||
/**
|
||||
* A provider that puts the code in the link itself. Scanning this QR opens a page that needs no
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import { ProviderModelPicker } from "@openbot/ui/components/ProviderModelPicker";
|
||||
import { expect, fn, within } from "storybook/test";
|
||||
import { fn } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
import { STORY_AGENT_STATUS, STORY_MODELS } from "./fixtures";
|
||||
|
||||
@@ -33,14 +33,6 @@ export const Disabled: Story = {
|
||||
args: { disabled: true, disabledReason: "Choose a provider first." },
|
||||
};
|
||||
|
||||
export const Opens: Story = {
|
||||
args: { reasoningEffort: "medium", onReasoningEffortChange: fn() },
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(canvas.getByRole("button", { name: /Agent model: GPT-5.6 Luna/ }));
|
||||
await canvas.findByRole("dialog", { name: "Choose agent model" });
|
||||
},
|
||||
};
|
||||
|
||||
export const UnavailableProvidersOpen: Story = {
|
||||
args: {
|
||||
modelOptions: STORY_MODELS.filter((model) => model.provider === "codex"),
|
||||
@@ -61,7 +53,6 @@ export const UnavailableProvidersOpen: Story = {
|
||||
),
|
||||
},
|
||||
},
|
||||
play: Opens.play,
|
||||
};
|
||||
|
||||
export const ProviderDownloadsOpen: Story = {
|
||||
@@ -86,7 +77,6 @@ export const ProviderDownloadsOpen: Story = {
|
||||
onCancelProviderDownload: fn(),
|
||||
onConnectProvider: fn(),
|
||||
},
|
||||
play: Opens.play,
|
||||
};
|
||||
|
||||
export const DiscoveredModels: Story = {
|
||||
@@ -103,7 +93,6 @@ export const DiscoveredModels: Story = {
|
||||
},
|
||||
],
|
||||
},
|
||||
play: Opens.play,
|
||||
};
|
||||
|
||||
export const OpenCodeCatalog: Story = {
|
||||
@@ -132,10 +121,6 @@ export const OpenCodeCatalog: Story = {
|
||||
})),
|
||||
),
|
||||
},
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(canvas.getByRole("button", { name: /Agent model:/ }));
|
||||
await canvas.findByRole("textbox", { name: "Search models" });
|
||||
},
|
||||
};
|
||||
|
||||
const openCodeCatalog = (entries: [string, string][]) =>
|
||||
@@ -166,7 +151,6 @@ export const OpenCodeLocalModels: Story = {
|
||||
["openai/gpt", "OpenAI/GPT"],
|
||||
]),
|
||||
},
|
||||
play: OpenCodeCatalog.play,
|
||||
};
|
||||
|
||||
const openCodeStatus = {
|
||||
@@ -200,12 +184,6 @@ export const CustomTabEmpty: Story = {
|
||||
modelOptions: openCodeCatalog([["opencode/example", "OpenCode Zen/Example"]]),
|
||||
onAddCustomProvider: fn(),
|
||||
},
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(canvas.getByRole("button", { name: /Agent model:/ }));
|
||||
const dialog = within(await canvas.findByRole("dialog", { name: "Choose agent model" }));
|
||||
await userEvent.click(dialog.getByRole("tab", { name: /^Custom:/ }));
|
||||
await expect(dialog.findByRole("button", { name: "Add provider" })).resolves.toBeTruthy();
|
||||
},
|
||||
};
|
||||
|
||||
export const CustomTabWithModels: Story = {
|
||||
@@ -223,11 +201,6 @@ export const CustomTabWithModels: Story = {
|
||||
["openai/gpt", "OpenAI/GPT"],
|
||||
]),
|
||||
},
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(canvas.getByRole("button", { name: /Agent model:/ }));
|
||||
const dialog = within(await canvas.findByRole("dialog", { name: "Choose agent model" }));
|
||||
await expect(dialog.findByRole("option", { name: "Qwen3 Coder 30B" })).resolves.toBeTruthy();
|
||||
},
|
||||
};
|
||||
|
||||
/** The same catalog on the OpenCode tab, which must not list the two custom endpoints again. */
|
||||
@@ -236,10 +209,4 @@ export const OpenCodeTabExcludesCustom: Story = {
|
||||
...CustomTabWithModels.args,
|
||||
value: "opencode/example-free",
|
||||
},
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(canvas.getByRole("button", { name: /Agent model:/ }));
|
||||
const dialog = within(await canvas.findByRole("dialog", { name: "Choose agent model" }));
|
||||
await expect(dialog.findByRole("option", { name: "Example Free" })).resolves.toBeTruthy();
|
||||
await expect(dialog.queryByRole("option", { name: "Qwen3 Coder 30B" })).toBeNull();
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
import type { ProviderPickerOption } from "@openbot/ui/components/ProviderPicker";
|
||||
import { expect, fn, within } from "storybook/test";
|
||||
import { fn } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
import { ProviderPicker } from "../src/components/ProviderPicker";
|
||||
|
||||
@@ -144,11 +144,6 @@ function withOpenCode(state: ProviderPickerOption["state"]): ProviderPickerOptio
|
||||
|
||||
export const CustomProviderNotInstalled: Story = {
|
||||
args: { options: withOpenCode("not-installed"), onAddCustomProvider: fn(), onInstallProvider: fn() },
|
||||
play: async ({ args, canvas, userEvent }) => {
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Install custom provider" }));
|
||||
await expect(args.onInstallProvider).toHaveBeenCalledWith("opencode");
|
||||
await expect(canvas.queryByRole("button", { name: "Add custom provider" })).toBeNull();
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -182,20 +177,6 @@ export const CustomProviderEndpoints: Story = {
|
||||
onSelectCustomProvider: fn(),
|
||||
onManageCustomProviders: fn(),
|
||||
},
|
||||
play: async ({ args, canvas, userEvent }) => {
|
||||
const providers = within(canvas.getByRole("radiogroup", { name: "Default provider" }));
|
||||
const custom = providers.getByRole("radio", { name: /Custom provider/ });
|
||||
await userEvent.click(custom);
|
||||
await expect(args.onSelectCustomProvider).toHaveBeenCalledTimes(1);
|
||||
// The count counts, and opens the list. The radio keeps its own name.
|
||||
await expect(custom).not.toHaveAccessibleName(/endpoints/);
|
||||
const manage = canvas.getByRole("button", { name: "Manage 2 endpoints" });
|
||||
await expect(manage).toHaveTextContent("2 endpoints");
|
||||
await userEvent.click(manage);
|
||||
await expect(args.onManageCustomProviders).toHaveBeenCalledTimes(1);
|
||||
// Add keeps its own place on the row, so choosing the row never opens the form.
|
||||
await expect(canvas.getByRole("button", { name: "Add custom provider" })).toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -219,24 +200,8 @@ export const CustomProviderSelected: Story = {
|
||||
onAddCustomProvider: fn(),
|
||||
onSelectCustomProvider: fn(),
|
||||
},
|
||||
play: async ({ canvas }) => {
|
||||
const providers = within(canvas.getByRole("radiogroup", { name: "Default provider" }));
|
||||
const custom = providers.getByRole("radio", { name: /Custom provider/ });
|
||||
await expect(custom).toBeChecked();
|
||||
await expect(custom).toHaveAccessibleName(/1 endpoint/);
|
||||
await expect(providers.getByRole("radio", { name: /OpenCode/ })).not.toBeChecked();
|
||||
},
|
||||
};
|
||||
|
||||
export const CustomProviderReady: Story = {
|
||||
args: { options: withOpenCode("sign-in-required"), onAddCustomProvider: fn() },
|
||||
play: async ({ args, canvas, userEvent }) => {
|
||||
// Anywhere on the row answers, as it does on the rows above, not only the button at its edge.
|
||||
await userEvent.click(canvas.getByText("Custom provider"));
|
||||
await expect(args.onAddCustomProvider).toHaveBeenCalledTimes(1);
|
||||
// It adds, it does not select, so it stays outside the group of choices.
|
||||
await expect(canvas.getByRole("radiogroup", { name: "Default provider" })).not.toContainElement(
|
||||
canvas.getByRole("button", { name: "Add custom provider" }),
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
@@ -4,7 +4,6 @@ import { Button, Checkbox, Heading, Text, Toaster } from "@openbot/ui";
|
||||
import type { ProviderPickerOption } from "@openbot/ui/components/ProviderPicker";
|
||||
import { type ProviderUpdate, providerUpdatesToAnnounce } from "@openbot/ui/features/provider-updates/provider-update";
|
||||
import { createEffect, createSignal, createUniqueId, onCleanup, Show } from "solid-js";
|
||||
import { expect, waitFor, within } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
import { ProviderPicker } from "../src/components/ProviderPicker";
|
||||
import {
|
||||
@@ -35,7 +34,7 @@ const AVAILABLE: Record<ManagedProviderId, string | null> = {
|
||||
opencode: null,
|
||||
};
|
||||
|
||||
/** Fast enough that a play function settles in a couple of seconds, slow enough to read. */
|
||||
/** Fast enough to finish in a couple of seconds, slow enough to read. */
|
||||
const PROGRESS_STEP = 8;
|
||||
const PROGRESS_INTERVAL = 120;
|
||||
const FINISHING_DELAY = 500;
|
||||
@@ -55,12 +54,12 @@ function readyRuntimes(): Record<ManagedProviderId, ProviderRuntimeStatus> {
|
||||
* cleanup. `mock-openbot.ts` still stubs `providerRuntimes` inert, and no contract carries
|
||||
* `availableVersion` yet, so props are the only honest source for these states today.
|
||||
*/
|
||||
function ProviderUpdateFlow(props: { failOnce?: boolean; controls?: boolean }) {
|
||||
function ProviderUpdateFlow(props: { controls?: boolean }) {
|
||||
const [runtimes, setRuntimes] = createSignal(readyRuntimes());
|
||||
const [provider, setProvider] = createSignal<AgentProviderId>("claude");
|
||||
// One update fails, and the flag is spent when it does, so the Retry after it succeeds. The
|
||||
// `UpdateFails` story starts it armed; the playground puts the same switch under the reader.
|
||||
const [failNext, setFailNext] = createSignal(Boolean(props.failOnce));
|
||||
// playground puts the switch under the reader.
|
||||
const [failNext, setFailNext] = createSignal(false);
|
||||
const failToggleId = createUniqueId();
|
||||
const timers = new Set<number>();
|
||||
const running = new Set<AgentProviderId>();
|
||||
@@ -227,39 +226,4 @@ export const Playground: Story = {
|
||||
};
|
||||
|
||||
/** The offer, on both surfaces at once. */
|
||||
export const UpdateAvailable: Story = {
|
||||
play: async ({ canvasElement, userEvent }) => {
|
||||
const body = within(canvasElement.ownerDocument.body);
|
||||
await expect(body.findByRole("button", { name: "Update" })).resolves.toBeEnabled();
|
||||
await userEvent.click(await body.findByRole("button", { name: "More actions for Claude" }));
|
||||
await expect(body.findByRole("menuitem", { name: "Update to 2.1.250" })).resolves.toBeEnabled();
|
||||
},
|
||||
};
|
||||
|
||||
/** The toast is the whole point: one click starts the update, and the same toast reports it. */
|
||||
export const UpdateFromToast: Story = {
|
||||
play: async ({ canvasElement, userEvent }) => {
|
||||
const body = within(canvasElement.ownerDocument.body);
|
||||
await userEvent.click(await body.findByRole("button", { name: "Update" }));
|
||||
|
||||
await waitFor(() => expect(body.getByRole("button", { name: "Cancel Claude" })).toBeEnabled());
|
||||
await expect(body.findByText("Claude is up to date", undefined, { timeout: 8_000 })).resolves.toBeInTheDocument();
|
||||
// The notification no longer offers an update the user already took. Sonner merges by toast id,
|
||||
// so the settled notification keeps the offer's Update button unless the action is cleared by name.
|
||||
await expect(body.queryByRole("button", { name: "Update" })).toBeNull();
|
||||
},
|
||||
};
|
||||
|
||||
/** A failed update is not a dead end either: Retry is on the notification that reported the failure. */
|
||||
export const UpdateFails: Story = {
|
||||
render: () => <ProviderUpdateFlow failOnce />,
|
||||
play: async ({ canvasElement, userEvent }) => {
|
||||
const body = within(canvasElement.ownerDocument.body);
|
||||
await userEvent.click(await body.findByRole("button", { name: "More actions for Claude" }));
|
||||
await userEvent.click(await body.findByRole("menuitem", { name: "Update to 2.1.250" }));
|
||||
|
||||
await expect(body.findByText("Claude update failed", undefined, { timeout: 8_000 })).resolves.toBeInTheDocument();
|
||||
await userEvent.click(await body.findByRole("button", { name: "Retry" }));
|
||||
await expect(body.findByText("Claude is up to date", undefined, { timeout: 8_000 })).resolves.toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
export const UpdateAvailable: Story = {};
|
||||
|
||||
@@ -13,7 +13,7 @@ import {
|
||||
} from "@openbot/ui";
|
||||
import { QuestionPromptBubble, type QuestionPromptBubbleProps } from "@openbot/ui/components/QuestionPromptBubble";
|
||||
import { AgentAvatar } from "@openbot/ui/features/agents/AgentAvatar";
|
||||
import { expect, fn, waitFor } from "storybook/test";
|
||||
import { fn } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
|
||||
const singleQuestion: AgentPromptQuestion[] = [
|
||||
@@ -220,15 +220,6 @@ export const SingleQuestion: Story = {
|
||||
render: renderInChat,
|
||||
};
|
||||
|
||||
export const SelectedAnswer: Story = {
|
||||
render: renderInChat,
|
||||
play: async ({ args, canvas, userEvent }) => {
|
||||
await userEvent.click(canvas.getByRole("radio", { name: /Send that reply/ }));
|
||||
await expect(canvas.getByRole("radio", { name: /Send that reply/ })).toBeChecked();
|
||||
await waitFor(() => expect(args.onSubmit).toHaveBeenCalledWith({ reply: ["Send that reply"] }));
|
||||
},
|
||||
};
|
||||
|
||||
export const MultipleQuestions: Story = {
|
||||
args: { questions: multipleQuestions },
|
||||
render: renderInChat,
|
||||
@@ -237,32 +228,16 @@ export const MultipleQuestions: Story = {
|
||||
export const CustomAnswer: Story = {
|
||||
args: { questions: customQuestion },
|
||||
render: renderInChat,
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
const input = canvas.getByRole("textbox", { name: /Custom answer/ });
|
||||
await userEvent.type(input, "A short technical brief with risks and owners.");
|
||||
await expect(input).toHaveFocus();
|
||||
},
|
||||
};
|
||||
|
||||
export const SecretAnswer: Story = {
|
||||
args: { questions: secretQuestion },
|
||||
render: renderInChat,
|
||||
play: async ({ canvas }) => {
|
||||
const input = canvas.getByLabelText(/Custom answer/);
|
||||
await expect(input).toHaveAttribute("type", "password");
|
||||
await expect(input).toHaveFocus();
|
||||
},
|
||||
};
|
||||
|
||||
export const Sending: Story = {
|
||||
args: { pending: true },
|
||||
render: renderInChat,
|
||||
play: async ({ canvas }) => {
|
||||
await expect(canvas.getByRole("status")).toHaveTextContent("Sending");
|
||||
await expect(canvas.getByRole("button", { name: "Skip" })).toBeDisabled();
|
||||
await expect(canvas.getByRole("button", { name: "Cancel questions" })).toBeDisabled();
|
||||
for (const option of canvas.getAllByRole("radio")) await expect(option).toBeDisabled();
|
||||
},
|
||||
};
|
||||
|
||||
export const Empty: Story = {
|
||||
@@ -282,40 +257,6 @@ export const Narrow: Story = {
|
||||
],
|
||||
};
|
||||
|
||||
export const AutoAdvanceAndPreserveAnswers: Story = {
|
||||
args: { questions: multipleQuestions },
|
||||
render: renderInChat,
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
const firstDraft = canvas.getByRole("textbox", { name: /Custom answer for: Which auth/ });
|
||||
await userEvent.type(firstDraft, "Keep the existing session format.");
|
||||
await userEvent.click(canvas.getByRole("radio", { name: /Session cookies/ }));
|
||||
await waitFor(() => expect(canvas.getByRole("radio", { name: /Environment file/ })).toBeEnabled());
|
||||
await userEvent.click(canvas.getByRole("radio", { name: /Environment file/ }));
|
||||
await waitFor(() => expect(canvas.getByRole("radio", { name: /Gradual rollout/ })).toBeEnabled());
|
||||
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Previous question" }));
|
||||
await waitFor(() => expect(canvas.getByRole("radio", { name: /Environment file/ })).toBeEnabled());
|
||||
await expect(canvas.getByRole("radio", { name: /Environment file/ })).toBeChecked();
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Previous question" }));
|
||||
await waitFor(() => expect(canvas.getByRole("radio", { name: /Session cookies/ })).toBeEnabled());
|
||||
await expect(canvas.getByRole("radio", { name: /Session cookies/ })).toBeChecked();
|
||||
await expect(canvas.getByRole("textbox", { name: /Custom answer for: Which auth/ })).toHaveValue(
|
||||
"Keep the existing session format.",
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
export const SkipAndCancel: Story = {
|
||||
args: { questions: multipleQuestions },
|
||||
render: renderInChat,
|
||||
play: async ({ args, canvas, userEvent }) => {
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Skip" }));
|
||||
await waitFor(() => expect(canvas.getByRole("button", { name: "Cancel questions" })).toBeEnabled());
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Cancel questions" }));
|
||||
await waitFor(() => expect(args.onSubmit).toHaveBeenCalledWith({}));
|
||||
},
|
||||
};
|
||||
|
||||
export const PersistedAnswered: Story = {
|
||||
args: {
|
||||
questions: multipleQuestions,
|
||||
|
||||
@@ -3,7 +3,7 @@ import { serializeChatTagReference } from "@openbot/contracts/chat-tag-reference
|
||||
import type { AttachmentSummary } from "@openbot/contracts/ipc";
|
||||
import type { MessageCitation } from "@openbot/ui/data";
|
||||
import { RichMessageText } from "@openbot/ui/features/conversation/RichMessageText";
|
||||
import { expect, fn, waitFor, within } from "storybook/test";
|
||||
import { fn } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
import { requireFixture, STORY_AGENTS, STORY_ATTACHMENTS, STORY_INSTALLED_SKILLS } from "./fixtures";
|
||||
|
||||
@@ -109,18 +109,6 @@ export const InlineCitations: Story = {
|
||||
body: "Transformers scale well with data and compute [1], though attention is quadratic in sequence length [2].",
|
||||
citations,
|
||||
},
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
const marker = canvas.getByRole("link", {
|
||||
name: "Open citation 1: Attention Is All You Need",
|
||||
});
|
||||
await expect(marker.getBoundingClientRect().width).toBe(16);
|
||||
await expect(marker.getBoundingClientRect().height).toBe(16);
|
||||
await expect(getComputedStyle(marker).color).toBe("rgba(255, 255, 255, 0.72)");
|
||||
await userEvent.hover(marker);
|
||||
await expect(within(document.body).findByRole("tooltip")).resolves.toBeInTheDocument();
|
||||
await userEvent.click(marker);
|
||||
await expect(canvas.getByRole("link", { name: "Open source 1: Attention Is All You Need" })).toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
|
||||
export const CitationEdges: Story = {
|
||||
@@ -145,29 +133,6 @@ export const CitationEdges: Story = {
|
||||
</p>
|
||||
</div>
|
||||
),
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
const first = canvas.getByRole("link", {
|
||||
name: "Open citation 1: Attention Is All You Need",
|
||||
});
|
||||
await userEvent.hover(first);
|
||||
const firstTooltip = await within(document.body).findByRole("tooltip");
|
||||
await waitFor(() => expect(firstTooltip).toHaveAttribute("data-ready", "true"));
|
||||
const firstBounds = firstTooltip.getBoundingClientRect();
|
||||
await expect(firstTooltip).toHaveAttribute("data-placement", "bottom");
|
||||
await expect(firstBounds.left).toBeGreaterThanOrEqual(8);
|
||||
await expect(firstBounds.right).toBeLessThanOrEqual(window.innerWidth - 8);
|
||||
await userEvent.unhover(first);
|
||||
|
||||
const second = canvas.getByRole("link", {
|
||||
name: "Open citation 2: Efficient Transformers: A Survey",
|
||||
});
|
||||
await userEvent.hover(second);
|
||||
const secondTooltip = await within(document.body).findByRole("tooltip");
|
||||
await waitFor(() => expect(secondTooltip).toHaveAttribute("data-ready", "true"));
|
||||
const secondBounds = secondTooltip.getBoundingClientRect();
|
||||
await expect(secondBounds.left).toBeGreaterThanOrEqual(8);
|
||||
await expect(secondBounds.right).toBeLessThanOrEqual(window.innerWidth - 8);
|
||||
},
|
||||
};
|
||||
|
||||
export const PlainText: Story = {
|
||||
@@ -180,13 +145,6 @@ export const InlineFileReferences: Story = {
|
||||
attachments: STORY_ATTACHMENTS,
|
||||
onOpenAttachment: fn(),
|
||||
},
|
||||
play: async ({ args: storyArgs, canvas, userEvent }) => {
|
||||
const reference = canvas.getByRole("button", {
|
||||
name: `Open attached file ${firstStoryAttachment.name}`,
|
||||
});
|
||||
await userEvent.click(reference);
|
||||
await expect(storyArgs.onOpenAttachment).toHaveBeenCalledWith(firstStoryAttachment);
|
||||
},
|
||||
};
|
||||
|
||||
export const PlainFileReferences: Story = {
|
||||
@@ -196,16 +154,6 @@ export const PlainFileReferences: Story = {
|
||||
onOpenAttachment: fn(),
|
||||
onOpenSharedFile: fn(),
|
||||
},
|
||||
play: async ({ args: storyArgs, canvas, userEvent }) => {
|
||||
const attached = canvas.getByRole("button", {
|
||||
name: `Open attached file ${firstStoryAttachment.name}`,
|
||||
});
|
||||
const shared = canvas.getByRole("button", { name: "Open shared file brief.pdf" });
|
||||
await expect(attached).toBeInTheDocument();
|
||||
await expect(shared).toBeInTheDocument();
|
||||
await userEvent.click(shared);
|
||||
await expect(storyArgs.onOpenSharedFile).toHaveBeenCalledWith("~/OpenBot/Shared/brief.pdf");
|
||||
},
|
||||
};
|
||||
|
||||
export const LongFileReference: Story = {
|
||||
@@ -219,26 +167,6 @@ export const LongFileReference: Story = {
|
||||
<RichMessageText {...storyArgs} />
|
||||
</section>
|
||||
),
|
||||
play: async ({ args: storyArgs, canvas, userEvent }) => {
|
||||
const reference = canvas.getByRole("button", {
|
||||
name: `Open attached file ${longAttachment.name}`,
|
||||
});
|
||||
const label = reference.querySelector<HTMLElement>(".inline-file-reference-name");
|
||||
if (!label) throw new Error("The file reference label is missing");
|
||||
await expect(label.scrollWidth).toBeGreaterThan(label.clientWidth);
|
||||
const sampleBounds = canvas.getByLabelText("Long file reference sample").getBoundingClientRect();
|
||||
await expect(reference.getBoundingClientRect().right).toBeLessThanOrEqual(sampleBounds.right);
|
||||
|
||||
await userEvent.hover(reference);
|
||||
await expect(within(document.body).findByRole("tooltip")).resolves.toHaveTextContent(longAttachment.name);
|
||||
await userEvent.unhover(reference);
|
||||
reference.focus();
|
||||
await expect(within(document.body).findByRole("tooltip")).resolves.toHaveTextContent(longAttachment.name);
|
||||
await userEvent.keyboard("{Escape}");
|
||||
await expect(within(document.body).queryByRole("tooltip")).not.toBeInTheDocument();
|
||||
await userEvent.click(reference);
|
||||
await expect(storyArgs.onOpenAttachment).toHaveBeenCalledWith(longAttachment);
|
||||
},
|
||||
};
|
||||
|
||||
export const FileReferenceTypes: Story = {
|
||||
@@ -253,58 +181,6 @@ export const FileReferenceTypes: Story = {
|
||||
<RichMessageText {...storyArgs} />
|
||||
</p>
|
||||
),
|
||||
play: async ({ canvas }) => {
|
||||
await expect(canvas.getByText("TS")).toBeInTheDocument();
|
||||
await expect(canvas.getByText("JS")).toBeInTheDocument();
|
||||
await expect(canvas.getByText("HTML")).toBeInTheDocument();
|
||||
await expect(canvas.getByText("CSS")).toBeInTheDocument();
|
||||
await expect(canvas.getByText("XLSX")).toBeInTheDocument();
|
||||
await expect(canvas.getByText("PDF")).toBeInTheDocument();
|
||||
await expect(canvas.getByText("PNG")).toBeInTheDocument();
|
||||
await expect(canvas.getByText("CS")).toBeInTheDocument();
|
||||
const references = canvas.getAllByRole("button", { name: /Open attached file/u });
|
||||
await expect(references).toHaveLength(9);
|
||||
await expect(references.map((reference) => reference.dataset.fileTone)).toEqual([
|
||||
"source",
|
||||
"script",
|
||||
"markup",
|
||||
"style",
|
||||
"data",
|
||||
"document",
|
||||
"media",
|
||||
"default",
|
||||
"default",
|
||||
]);
|
||||
const root = references[0]?.parentElement;
|
||||
if (!root) throw new Error("The file reference story root is missing");
|
||||
await expect(root.querySelectorAll(".attachment-reference-visual > svg")).toHaveLength(1);
|
||||
|
||||
const typeScriptReference = references[0];
|
||||
if (!typeScriptReference) throw new Error("The TypeScript file reference is missing");
|
||||
const typeScriptBadge = typeScriptReference.querySelector<HTMLElement>(".attachment-reference-visual");
|
||||
if (!typeScriptBadge) throw new Error("The TypeScript badge is missing");
|
||||
const htmlBadge = references[2]?.querySelector<HTMLElement>(".attachment-reference-visual");
|
||||
const cssBadge = references[3]?.querySelector<HTMLElement>(".attachment-reference-visual");
|
||||
if (!htmlBadge || !cssBadge) throw new Error("The long file type badges are missing");
|
||||
await expect(typeScriptReference.getBoundingClientRect().height).toBe(22);
|
||||
await expect(typeScriptBadge.getBoundingClientRect().width).toBe(16);
|
||||
await expect(typeScriptBadge.getBoundingClientRect().height).toBe(16);
|
||||
await expect(cssBadge.getBoundingClientRect().width).toBe(20);
|
||||
await expect(htmlBadge.getBoundingClientRect().width).toBe(24);
|
||||
await expect(
|
||||
Array.from(root.querySelectorAll<HTMLElement>(".attachment-reference-visual[data-badge-length]")).every(
|
||||
(badge) => {
|
||||
const label = badge.querySelector<HTMLElement>("span");
|
||||
return label !== null && label.getBoundingClientRect().width <= badge.getBoundingClientRect().width;
|
||||
},
|
||||
),
|
||||
).toBe(true);
|
||||
await expect(getComputedStyle(typeScriptReference).gap).toBe("4px");
|
||||
await expect(getComputedStyle(typeScriptReference).padding).toBe("1px 6px 1px 3px");
|
||||
typeScriptReference.focus();
|
||||
await expect(getComputedStyle(typeScriptReference).outlineColor).toBe("rgb(116, 185, 255)");
|
||||
await expect(getComputedStyle(typeScriptReference).boxShadow).toBe("none");
|
||||
},
|
||||
};
|
||||
|
||||
export const MixedReferencesStress: Story = {
|
||||
@@ -320,13 +196,6 @@ export const MixedReferencesStress: Story = {
|
||||
<RichMessageText {...storyArgs} />
|
||||
</article>
|
||||
),
|
||||
play: async ({ canvas }) => {
|
||||
const sample = canvas.getByLabelText("Mixed references stress sample");
|
||||
await expect(sample.scrollWidth).toBeLessThanOrEqual(sample.clientWidth);
|
||||
await expect(canvas.getAllByRole("button", { name: /Open attached file/u })).toHaveLength(3);
|
||||
await expect(canvas.getByRole("button", { name: "Open agent Research" })).toBeInTheDocument();
|
||||
await expect(canvas.getAllByRole("link", { name: /Open citation/u })).toHaveLength(2);
|
||||
},
|
||||
};
|
||||
|
||||
export const InlineAlignment: Story = {
|
||||
|
||||
@@ -6,7 +6,7 @@ import {
|
||||
} from "@openbot/ui/features/conversation/RoutineScheduleCard";
|
||||
import { ROUTINE_WORKDAYS, type RoutineScheduleDraft } from "@openbot/ui/features/conversation/routine-schedule-draft";
|
||||
import { createSignal } from "solid-js";
|
||||
import { expect, fn, waitFor, within } from "storybook/test";
|
||||
import { fn } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
import { requireFixture, STORY_AGENTS } from "./fixtures";
|
||||
|
||||
@@ -67,13 +67,7 @@ const meta = {
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof meta>;
|
||||
|
||||
export const Created: Story = {
|
||||
play: async ({ args, canvas, userEvent }) => {
|
||||
await expect(canvas.getByRole("article", { name: "Morning brief" })).toHaveTextContent("Created routine");
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Open routine Morning brief" }));
|
||||
await expect(args.onOpenRoutine).toHaveBeenCalled();
|
||||
},
|
||||
};
|
||||
export const Created: Story = {};
|
||||
|
||||
export const UpdatedEditing: Story = {
|
||||
args: {
|
||||
@@ -82,14 +76,6 @@ export const UpdatedEditing: Story = {
|
||||
schedule: { kind: "weekly", weekday: 5, time: "16:00" },
|
||||
nextRunLabel: "Fri, Sep 25 at 4:00 PM",
|
||||
},
|
||||
play: async ({ args, canvas, canvasElement, userEvent }) => {
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Days: Fri" }));
|
||||
const body = within(canvasElement.ownerDocument.body);
|
||||
await userEvent.click(await body.findByRole("radio", { name: "Thursday" }));
|
||||
await waitFor(() => expect(args.onChange).toHaveBeenCalled());
|
||||
await userEvent.keyboard("{Escape}");
|
||||
await waitFor(() => expect(canvas.getByRole("button", { name: "Days: Thu" })).toHaveFocus());
|
||||
},
|
||||
};
|
||||
|
||||
export const Saving: Story = { args: { state: "saving" } };
|
||||
@@ -99,11 +85,6 @@ export const Saved: Story = { args: { action: "updated", state: "saved" } };
|
||||
/** A later card changed this routine. This one keeps the old schedule as a record only. */
|
||||
export const Superseded: Story = {
|
||||
args: { state: "superseded", nextRunLabel: undefined, onShowLatest: fn() },
|
||||
play: async ({ args, canvas, userEvent }) => {
|
||||
await expect(canvas.getByRole("button", { name: /^Frequency/ })).toBeDisabled();
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Show latest" }));
|
||||
await expect(args.onShowLatest).toHaveBeenCalledOnce();
|
||||
},
|
||||
};
|
||||
|
||||
/** The routine runs in a zone that is not the viewer's, for example a teammate's computer. */
|
||||
@@ -111,17 +92,10 @@ export const OtherTimeZone: Story = { args: { timeZoneLabel: "Warsaw time" } };
|
||||
|
||||
export const SaveError: Story = {
|
||||
args: { action: "updated", state: "error", errorText: "Could not save the schedule. Try again." },
|
||||
play: async ({ canvas }) => {
|
||||
await expect(canvas.getByRole("alert")).toHaveTextContent("Could not save the schedule. Try again.");
|
||||
},
|
||||
};
|
||||
|
||||
export const Deleted: Story = {
|
||||
args: { state: "deleted", nextRunLabel: undefined },
|
||||
play: async ({ canvas }) => {
|
||||
await expect(canvas.getByRole("button", { name: /^Frequency/ })).toBeDisabled();
|
||||
await expect(canvas.queryByRole("button", { name: /Open routine/ })).not.toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
|
||||
export const ReadOnly: Story = {
|
||||
|
||||
@@ -7,7 +7,7 @@ import {
|
||||
routineDraftSummary,
|
||||
} from "@openbot/ui/features/conversation/routine-schedule-draft";
|
||||
import { createSignal } from "solid-js";
|
||||
import { expect, fn, waitFor, within } from "storybook/test";
|
||||
import { fn } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
|
||||
/*
|
||||
@@ -91,9 +91,6 @@ export const Monthly: Story = { args: { schedule: { kind: "monthly", day: 24, ti
|
||||
|
||||
export const MonthlyLateDay: Story = {
|
||||
args: { schedule: { kind: "monthly", day: 31, time: "18:00" } },
|
||||
play: async ({ canvas }) => {
|
||||
await expect(canvas.getByText("Skipped in months without day 31.")).toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
export const Yearly: Story = { args: { schedule: { kind: "yearly", month: 9, day: 24, time: "08:20" } } };
|
||||
@@ -116,94 +113,3 @@ export const Wide: Story = {
|
||||
};
|
||||
|
||||
export const Disabled: Story = { args: { disabled: true, schedule: { kind: "weekly", weekday: 4, time: "08:20" } } };
|
||||
|
||||
export const FrequencyMenuOpen: Story = {
|
||||
play: async ({ canvas, canvasElement, userEvent }) => {
|
||||
await userEvent.click(canvas.getByRole("button", { name: /^Frequency/ }));
|
||||
const body = within(canvasElement.ownerDocument.body);
|
||||
await userEvent.click(await body.findByRole("option", { name: "Weekly" }));
|
||||
// A change of frequency keeps the time already set.
|
||||
await expect(canvas.getByRole("button", { name: "Time: 7:30 AM" })).toBeVisible();
|
||||
await expect(canvas.getByRole("button", { name: "Days: Sun" })).toBeVisible();
|
||||
await userEvent.click(canvas.getByRole("button", { name: /^Frequency/ }));
|
||||
await waitFor(async () => expect(await body.findByRole("option", { name: "Custom" })).toBeVisible());
|
||||
},
|
||||
};
|
||||
|
||||
export const WeekdaysOpen: Story = {
|
||||
args: { schedule: { kind: "daily", days: ROUTINE_EVERY_DAY, time: "07:30" } },
|
||||
play: async ({ canvas, canvasElement, userEvent }) => {
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Days: Every day" }));
|
||||
const body = within(canvasElement.ownerDocument.body);
|
||||
await userEvent.click(await body.findByRole("button", { name: "Sunday" }));
|
||||
await userEvent.click(body.getByRole("button", { name: "Saturday" }));
|
||||
await expect(body.getByRole("button", { name: "Monday" })).toHaveAttribute("aria-pressed", "true");
|
||||
await expect(body.getByRole("button", { name: "Sunday" })).toHaveAttribute("aria-pressed", "false");
|
||||
// The open popover is modal and hides the row, so the chip is read after it closes.
|
||||
await userEvent.keyboard("{Escape}");
|
||||
await waitFor(() => expect(canvas.getByRole("button", { name: "Days: Weekdays" })).toHaveFocus());
|
||||
},
|
||||
};
|
||||
|
||||
export const WeeklyDayOpen: Story = {
|
||||
args: { schedule: { kind: "weekly", weekday: 4, time: "08:20" } },
|
||||
play: async ({ canvas, canvasElement, userEvent }) => {
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Days: Thu" }));
|
||||
const body = within(canvasElement.ownerDocument.body);
|
||||
await expect(await body.findByRole("radio", { name: "Thursday" })).toBeChecked();
|
||||
},
|
||||
};
|
||||
|
||||
export const TimeFieldOpen: Story = {
|
||||
args: { schedule: { kind: "weekly", weekday: 4, time: "08:20" } },
|
||||
play: async ({ canvas, canvasElement, userEvent }) => {
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Time: 8:20 AM" }));
|
||||
const body = within(canvasElement.ownerDocument.body);
|
||||
const hour = await body.findByRole("textbox", { name: "Time hour" });
|
||||
await expect(hour).toHaveValue("8");
|
||||
await expect(body.getByRole("textbox", { name: "Time minute" })).toHaveValue("20");
|
||||
await userEvent.click(body.getByRole("radio", { name: "PM" }));
|
||||
await userEvent.keyboard("{Escape}");
|
||||
await waitFor(() => expect(canvas.getByRole("button", { name: "Time: 8:20 PM" })).toHaveFocus());
|
||||
},
|
||||
};
|
||||
|
||||
export const HoursWindowOpen: Story = {
|
||||
args: {
|
||||
schedule: { kind: "hourly", everyHours: 1, days: ROUTINE_EVERY_DAY, window: { start: "09:00", end: "18:00" } },
|
||||
},
|
||||
play: async ({ canvas, canvasElement, userEvent }) => {
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Hours: 9 AM–6 PM" }));
|
||||
const body = within(canvasElement.ownerDocument.body);
|
||||
await expect(await body.findByRole("radio", { name: /Between hours/ })).toBeChecked();
|
||||
await waitFor(() => expect(body.getByText("10 times a day")).toBeVisible());
|
||||
await userEvent.click(body.getByRole("button", { name: /^Repeat/ }));
|
||||
await userEvent.click(await body.findByRole("option", { name: "every 2 hours" }));
|
||||
await waitFor(() => expect(body.getByText("5 times a day")).toBeVisible());
|
||||
await userEvent.keyboard("{Escape}");
|
||||
// The step moves to the frequency chip, so the row does not say "hourly" twice.
|
||||
await expect(canvas.getByRole("button", { name: /^Frequency/ })).toHaveTextContent("Every 2h");
|
||||
await expect(canvas.getByRole("button", { name: "Hours: 9 AM–6 PM" })).toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
export const MonthlyDayOpen: Story = {
|
||||
args: { schedule: { kind: "monthly", day: 24, time: "08:20" } },
|
||||
play: async ({ canvas, canvasElement, userEvent }) => {
|
||||
await userEvent.click(canvas.getByRole("button", { name: /^Day of month/ }));
|
||||
const body = within(canvasElement.ownerDocument.body);
|
||||
await expect(await body.findByRole("option", { name: "Day 24" })).toHaveAttribute("aria-selected", "true");
|
||||
},
|
||||
};
|
||||
|
||||
export const OnceDateOpen: Story = {
|
||||
args: { schedule: { kind: "once", date: "2026-09-24", time: "08:20" } },
|
||||
play: async ({ canvas, canvasElement, userEvent }) => {
|
||||
await userEvent.click(canvas.getByRole("button", { name: "Date: Thu, Sep 24" }));
|
||||
const body = within(canvasElement.ownerDocument.body);
|
||||
await expect(await body.findByRole("button", { name: "Wednesday, September 23, 2026" })).toBeDisabled();
|
||||
await expect(body.getByRole("button", { name: "Previous month" })).toBeDisabled();
|
||||
await userEvent.click(body.getByRole("button", { name: "Tuesday, September 29, 2026" }));
|
||||
await expect(await canvas.findByRole("button", { name: "Date: Tue, Sep 29" })).toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
import { Heading, Select, SelectContent, SelectItem, SelectTrigger, SelectValue } from "@openbot/ui";
|
||||
import { createSignal } from "solid-js";
|
||||
import { expect, within } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
|
||||
const options = ["Low", "Medium", "High", "Extra high"];
|
||||
@@ -43,12 +42,4 @@ export const Gallery: Story = {
|
||||
</div>
|
||||
</main>
|
||||
),
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
const [trigger] = canvas.getAllByRole("button", { name: /Reasoning level/ });
|
||||
if (!trigger) throw new Error("Reasoning level trigger is missing.");
|
||||
await userEvent.click(trigger);
|
||||
const body = within(document.body);
|
||||
await userEvent.click(await body.findByRole("option", { name: "High" }));
|
||||
await expect(trigger).toHaveTextContent("High");
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { type MessageTextSelection, SelectionActionsBar } from "@openbot/ui/features/conversation/SelectionActions";
|
||||
import { createSignal, onSettled, Show } from "solid-js";
|
||||
import { expect, fn, userEvent, waitFor, within } from "storybook/test";
|
||||
import { fn } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
|
||||
function SelectionActionsDemo(props: {
|
||||
@@ -60,64 +60,9 @@ type Story = StoryObj<typeof meta>;
|
||||
|
||||
export const Default: Story = {};
|
||||
|
||||
export const CustomInstruction: Story = {
|
||||
play: async ({ canvasElement }) => {
|
||||
const page = within(canvasElement.ownerDocument.body);
|
||||
await selectionActionsReady(page);
|
||||
const toolbar = page.getByRole("toolbar", { name: "Actions for selected text" });
|
||||
const input = await page.findByRole("textbox", { name: "Describe edits" });
|
||||
const initialWidth = toolbar.getBoundingClientRect().width;
|
||||
await userEvent.type(input, "M");
|
||||
await new Promise((resolve) => setTimeout(resolve, 450));
|
||||
expect(Math.abs(toolbar.getBoundingClientRect().width - initialWidth)).toBeLessThan(1);
|
||||
await userEvent.type(input, "ake this friendlier");
|
||||
await expect(page.getByRole("button", { name: "Send edit instruction" })).toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
export const Expanded: Story = {
|
||||
play: async ({ canvasElement }) => {
|
||||
const page = within(canvasElement.ownerDocument.body);
|
||||
await selectionActionsReady(page);
|
||||
await userEvent.click(await page.findByRole("button", { name: "Show more actions" }));
|
||||
await waitFor(() => expect(page.getByRole("button", { name: "Grammar" })).toBeVisible());
|
||||
},
|
||||
};
|
||||
|
||||
export const Sending: Story = {
|
||||
args: {
|
||||
onSend: () => new Promise<boolean>(() => undefined),
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
const page = within(canvasElement.ownerDocument.body);
|
||||
await selectionActionsReady(page);
|
||||
await userEvent.click(await page.findByRole("button", { name: "Improve" }));
|
||||
await expect(page.getByRole("status")).toHaveTextContent("Sending…");
|
||||
},
|
||||
};
|
||||
|
||||
export const SendError: Story = {
|
||||
args: {
|
||||
onSend: fn().mockResolvedValue(false),
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
const page = within(canvasElement.ownerDocument.body);
|
||||
await selectionActionsReady(page);
|
||||
await userEvent.click(await page.findByRole("button", { name: "Improve" }));
|
||||
await expect(page.findByRole("alert")).resolves.toHaveTextContent("Couldn’t send");
|
||||
},
|
||||
};
|
||||
|
||||
export const Narrow: Story = {
|
||||
args: { width: "280px" },
|
||||
parameters: {
|
||||
viewport: { defaultViewport: "mobile2" },
|
||||
},
|
||||
};
|
||||
|
||||
async function selectionActionsReady(page: ReturnType<typeof within>): Promise<void> {
|
||||
const toolbar = await page.findByRole("toolbar", { name: "Actions for selected text" });
|
||||
const layer = toolbar.closest(".selection-actions-layer");
|
||||
if (!layer) throw new Error("Selection actions layer is missing");
|
||||
await waitFor(() => expect(layer).toHaveAttribute("data-ready", "true"));
|
||||
}
|
||||
|
||||
@@ -1,344 +0,0 @@
|
||||
import { createSignal } from "solid-js";
|
||||
import { expect, fireEvent, fn, waitFor, within } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
import type { McpServerConfig } from "../src/features/servers/mcp-servers";
|
||||
import { ServerSettingsModal, type ServerSettingsModalProps } from "../src/features/servers/ServerSettingsModal";
|
||||
import {
|
||||
STORY_HOST_STATUS,
|
||||
STORY_INVITES,
|
||||
STORY_MCP_SERVERS,
|
||||
STORY_PRESENCE,
|
||||
STORY_SERVERS,
|
||||
} from "../src/preview/fixtures";
|
||||
|
||||
/**
|
||||
* Story args never change, so the panel would answer a switch with the same row. This owner keeps
|
||||
* the list in a signal and still calls the spy args, which is what the play functions assert on.
|
||||
*/
|
||||
function McpSettingsHost(props: ServerSettingsModalProps) {
|
||||
const [servers, setServers] = createSignal<McpServerConfig[]>(props.mcpServers ?? []);
|
||||
|
||||
return (
|
||||
<ServerSettingsModal
|
||||
{...props}
|
||||
mcpServers={servers()}
|
||||
onSaveMcpServer={async (config) => {
|
||||
await props.onSaveMcpServer?.(config);
|
||||
setServers((current) =>
|
||||
current.some((server) => server.id === config.id)
|
||||
? current.map((server) => (server.id === config.id ? config : server))
|
||||
: [...current, config],
|
||||
);
|
||||
}}
|
||||
onRemoveMcpServer={async (id) => {
|
||||
await props.onRemoveMcpServer?.(id);
|
||||
setServers((current) => current.filter((server) => server.id !== id));
|
||||
}}
|
||||
onSetMcpServerEnabled={async (id, enabled) => {
|
||||
await props.onSetMcpServerEnabled?.(id, enabled);
|
||||
setServers((current) => current.map((server) => (server.id === id ? { ...server, enabled } : server)));
|
||||
}}
|
||||
/>
|
||||
);
|
||||
}
|
||||
|
||||
const localServer = STORY_SERVERS.find((server) => server.kind === "local") ?? STORY_SERVERS[0];
|
||||
|
||||
const meta = {
|
||||
title: "Settings/ServerMcp",
|
||||
component: ServerSettingsModal,
|
||||
render: (args) => <McpSettingsHost {...args} />,
|
||||
args: {
|
||||
open: true,
|
||||
onOpenChange: fn(),
|
||||
platform: "darwin",
|
||||
server: localServer,
|
||||
hostStatus: STORY_HOST_STATUS,
|
||||
members: STORY_PRESENCE.members,
|
||||
invites: STORY_INVITES,
|
||||
loading: false,
|
||||
loadError: null,
|
||||
onRetry: fn(async () => undefined),
|
||||
onSaveIdentity: fn(async () => undefined),
|
||||
onSetPublished: fn(async () => undefined),
|
||||
onSetMuted: fn(async () => undefined),
|
||||
onCreateInvite: fn(async (input) => ({
|
||||
id: "invite-story",
|
||||
inviteUrl: "https://team.example.com/invite/story",
|
||||
expiresAt: "2026-08-29T10:00:00.000Z",
|
||||
role: input.role,
|
||||
usedAt: null,
|
||||
email: input.email ?? null,
|
||||
permanent: input.permanent ?? false,
|
||||
useCount: 0,
|
||||
})),
|
||||
onUpdateMember: fn(async () => undefined),
|
||||
onRemoveMember: fn(async () => undefined),
|
||||
onRevokeInvite: fn(async () => undefined),
|
||||
mcpServers: STORY_MCP_SERVERS,
|
||||
onSaveMcpServer: fn(async () => undefined),
|
||||
onRemoveMcpServer: fn(async () => undefined),
|
||||
onSetMcpServerEnabled: fn(async () => undefined),
|
||||
// A test answers for the configuration given, so the one whose command is not on this machine
|
||||
// fails even though every other field is filled in.
|
||||
onTestMcpServer: fn(async (config: McpServerConfig) =>
|
||||
config.command.startsWith("bunx")
|
||||
? { toolCount: 0, error: "Command not found: bunx" }
|
||||
: { toolCount: 12, error: null },
|
||||
),
|
||||
},
|
||||
parameters: {
|
||||
layout: "fullscreen",
|
||||
a11y: { test: "error" },
|
||||
viewport: {
|
||||
options: {
|
||||
serverDesktop: { name: "Server settings — 1200 × 820", styles: { width: "1200px", height: "820px" } },
|
||||
serverMinimum: { name: "Server settings — 960 × 640", styles: { width: "960px", height: "640px" } },
|
||||
serverMobile: { name: "Server settings — 640 × 720", styles: { width: "640px", height: "720px" } },
|
||||
serverNarrow: { name: "Server settings — 480 × 720", styles: { width: "480px", height: "720px" } },
|
||||
},
|
||||
},
|
||||
},
|
||||
} satisfies Meta<typeof ServerSettingsModal>;
|
||||
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof meta>;
|
||||
|
||||
/** Every story starts on General, so each one opens the MCP section the way a user would. */
|
||||
async function openMcp(userEvent: { click: (element: Element) => Promise<void> }) {
|
||||
const body = within(document.body);
|
||||
await body.findByRole("dialog", { name: "General" });
|
||||
await userEvent.click(body.getByRole("tab", { name: "MCP" }));
|
||||
return body;
|
||||
}
|
||||
|
||||
async function openForm(userEvent: { click: (element: Element) => Promise<void> }) {
|
||||
const body = await openMcp(userEvent);
|
||||
await userEvent.click(body.getByRole("button", { name: "Connect a custom MCP" }));
|
||||
return body;
|
||||
}
|
||||
|
||||
/**
|
||||
* Text entry goes through `fireEvent.input`, the way the other server settings stories do:
|
||||
* `userEvent.type` drops characters on these controlled inputs.
|
||||
*/
|
||||
async function enter(field: Element, value: string) {
|
||||
await fireEvent.input(field, { target: { value } });
|
||||
}
|
||||
|
||||
/** The modal fades in, so an element can be in the document before it is visible. */
|
||||
async function expectVisible(element: Element) {
|
||||
await waitFor(() => expect(element).toBeVisible());
|
||||
}
|
||||
|
||||
/**
|
||||
* The rows report what the user set, not a connection: OpenBot connects only when the user asks for
|
||||
* a test, so a row that was never tested says only whether its tools are offered to the agents.
|
||||
*/
|
||||
export const McpList: Story = {
|
||||
play: async ({ userEvent }) => {
|
||||
const body = await openMcp(userEvent);
|
||||
await expectVisible(await body.findByText("Disabled"));
|
||||
await expect(body.getAllByText("Enabled")).toHaveLength(3);
|
||||
await expect(body.getByRole("switch", { name: "Enable Figma" })).not.toBeChecked();
|
||||
|
||||
// Local SQLite is the only fixture that names a working directory, and only Claude can carry
|
||||
// one. The row says so without a test having been run, because it reads the stored
|
||||
// configuration rather than a connection.
|
||||
await expectVisible(await body.findByText(/Claude only/u));
|
||||
await expect(body.getAllByText(/Claude only/u)).toHaveLength(1);
|
||||
},
|
||||
};
|
||||
|
||||
export const TestFromRowMenu: Story = {
|
||||
play: async ({ args, userEvent }) => {
|
||||
const body = await openMcp(userEvent);
|
||||
await userEvent.click(body.getByRole("button", { name: "Actions for Local SQLite" }));
|
||||
await userEvent.click(await body.findByRole("menuitem", { name: "Test connection" }));
|
||||
await expectVisible(await body.findByText("Connected · 12 tools"));
|
||||
await expect(args.onTestMcpServer).toHaveBeenCalledWith(expect.objectContaining({ id: "mcp-sqlite" }));
|
||||
},
|
||||
};
|
||||
|
||||
/** A failed test says why on the row, and the server stays exactly as it was. */
|
||||
export const TestFails: Story = {
|
||||
play: async ({ args, userEvent }) => {
|
||||
const body = await openMcp(userEvent);
|
||||
await userEvent.click(body.getByRole("button", { name: "Actions for Playwright" }));
|
||||
await userEvent.click(await body.findByRole("menuitem", { name: "Test connection" }));
|
||||
await expectVisible(await body.findByText("Command not found: bunx"));
|
||||
await expect(body.getByRole("switch", { name: "Enable Playwright" })).toBeChecked();
|
||||
await expect(args.onSetMcpServerEnabled).not.toHaveBeenCalled();
|
||||
},
|
||||
};
|
||||
|
||||
/** The form tests the draft on screen, which is the answer a user wants before they save it. */
|
||||
export const TestDraftBeforeSaving: Story = {
|
||||
play: async ({ args, userEvent }) => {
|
||||
const body = await openForm(userEvent);
|
||||
await enter(body.getByRole("textbox", { name: "Name" }), "Local SQLite");
|
||||
await enter(body.getByRole("textbox", { name: "Command to launch" }), "openai-dev-mcp");
|
||||
await userEvent.click(body.getByRole("button", { name: "Test connection" }));
|
||||
await expectVisible(await body.findByText("Connected · 12 tools"));
|
||||
await expect(args.onTestMcpServer).toHaveBeenCalledWith(expect.objectContaining({ id: "", name: "Local SQLite" }));
|
||||
await expect(args.onSaveMcpServer).not.toHaveBeenCalled();
|
||||
},
|
||||
};
|
||||
|
||||
export const McpEmpty: Story = {
|
||||
args: { mcpServers: [] },
|
||||
play: async ({ userEvent }) => {
|
||||
const body = await openMcp(userEvent);
|
||||
await expectVisible(await body.findByText("No MCP servers yet."));
|
||||
await expectVisible(body.getByRole("button", { name: "Connect a custom MCP" }));
|
||||
},
|
||||
};
|
||||
|
||||
/** A read that failed, which is not the same statement as a server that holds no MCP servers. */
|
||||
export const McpLoadFailed: Story = {
|
||||
args: {
|
||||
mcpServers: [],
|
||||
mcpLoadError: "The MCP servers could not load.",
|
||||
onRetryMcpServers: fn(),
|
||||
},
|
||||
play: async ({ args, userEvent }) => {
|
||||
const body = await openMcp(userEvent);
|
||||
await expectVisible(await body.findByText("The MCP servers could not load."));
|
||||
await expect(body.queryByText("No MCP servers yet.")).toBeNull();
|
||||
await userEvent.click(body.getByRole("button", { name: "Retry" }));
|
||||
await expect(args.onRetryMcpServers).toHaveBeenCalled();
|
||||
},
|
||||
};
|
||||
|
||||
export const ToggleServer: Story = {
|
||||
play: async ({ args, userEvent }) => {
|
||||
const body = await openMcp(userEvent);
|
||||
await userEvent.click(body.getByRole("switch", { name: "Enable Linear" }));
|
||||
await expect(args.onSetMcpServerEnabled).toHaveBeenCalledWith("mcp-linear", false);
|
||||
},
|
||||
};
|
||||
|
||||
export const AddCustomStdio: Story = {
|
||||
play: async ({ args, userEvent }) => {
|
||||
const body = await openForm(userEvent);
|
||||
await enter(body.getByRole("textbox", { name: "Name" }), "Local SQLite");
|
||||
await enter(body.getByRole("textbox", { name: "Command to launch" }), "openai-dev-mcp");
|
||||
// The command names the program alone. Each word after it is an argument of its own, which is
|
||||
// what the launch makes of this configuration.
|
||||
await enter(body.getByRole("textbox", { name: "Argument 1" }), "serve-sqlite");
|
||||
await userEvent.click(body.getByRole("button", { name: "Add argument" }));
|
||||
await enter(await body.findByRole("textbox", { name: "Argument 2" }), "--database");
|
||||
await userEvent.click(body.getByRole("button", { name: "Add argument" }));
|
||||
await enter(await body.findByRole("textbox", { name: "Argument 3" }), "./openbot.db");
|
||||
await enter(body.getByRole("textbox", { name: "Environment variable 1 key" }), "SQLITE_READONLY");
|
||||
await enter(body.getByRole("textbox", { name: "Environment variable 1 value" }), "1");
|
||||
await enter(body.getByRole("textbox", { name: "Working directory" }), "~/code");
|
||||
|
||||
const save = await body.findByRole("button", { name: "Save" });
|
||||
await expect(save).toBeEnabled();
|
||||
await userEvent.click(save);
|
||||
await expect(args.onSaveMcpServer).toHaveBeenCalledWith(
|
||||
expect.objectContaining({
|
||||
// A new server is saved with no id: the store mints it. A client-minted id reads to the
|
||||
// store as an edit of a row that is not there, and every add fails.
|
||||
id: "",
|
||||
name: "Local SQLite",
|
||||
transport: "stdio",
|
||||
command: "openai-dev-mcp",
|
||||
args: ["serve-sqlite", "--database", "./openbot.db"],
|
||||
env: [{ key: "SQLITE_READONLY", value: "1" }],
|
||||
workingDirectory: "~/code",
|
||||
url: "",
|
||||
}),
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
export const AddCustomHttp: Story = {
|
||||
play: async ({ userEvent }) => {
|
||||
const body = await openForm(userEvent);
|
||||
await userEvent.click(body.getByRole("tab", { name: "Streamable HTTP" }));
|
||||
const url = await body.findByRole("textbox", { name: "Server URL" });
|
||||
await expectVisible(url);
|
||||
await enter(url, "https://mcp.linear.app/mcp");
|
||||
await enter(body.getByRole("textbox", { name: "Header 1 key" }), "Authorization");
|
||||
|
||||
// The name is still empty, so the first save attempt reports it and blocks the button.
|
||||
await userEvent.click(await body.findByRole("button", { name: "Save" }));
|
||||
await expectVisible(await body.findByText("Enter a name for this MCP server."));
|
||||
await expect(body.getByRole("button", { name: "Save" })).toBeDisabled();
|
||||
|
||||
await enter(body.getByRole("textbox", { name: "Name" }), "Linear");
|
||||
await waitFor(() => expect(body.getByRole("button", { name: "Save" })).toBeEnabled());
|
||||
},
|
||||
};
|
||||
|
||||
export const EditExisting: Story = {
|
||||
play: async ({ userEvent }) => {
|
||||
const body = await openMcp(userEvent);
|
||||
await userEvent.click(body.getByRole("button", { name: "Actions for Local SQLite" }));
|
||||
await userEvent.click(await body.findByRole("menuitem", { name: "Edit" }));
|
||||
await expect(await body.findByRole("textbox", { name: "Name" })).toHaveValue("Local SQLite");
|
||||
await expect(body.getByRole("textbox", { name: "Command to launch" })).toHaveValue("openai-dev-mcp");
|
||||
await expect(body.getByRole("textbox", { name: "Argument 1" })).toHaveValue("serve-sqlite");
|
||||
await expect(body.getByRole("textbox", { name: "Argument 3" })).toHaveValue("./openbot.db");
|
||||
await expect(body.getByRole("textbox", { name: "Environment variable 1 key" })).toHaveValue("SQLITE_READONLY");
|
||||
},
|
||||
};
|
||||
|
||||
/** The save bar only appears once the form holds a change, so this one types the command first. */
|
||||
export const ValidationErrors: Story = {
|
||||
play: async ({ userEvent }) => {
|
||||
const body = await openForm(userEvent);
|
||||
await expect(body.queryByRole("button", { name: "Save" })).toBeNull();
|
||||
await enter(body.getByRole("textbox", { name: "Command to launch" }), "openai-dev-mcp");
|
||||
await userEvent.click(await body.findByRole("button", { name: "Save" }));
|
||||
await expectVisible(await body.findByText("Enter a name for this MCP server."));
|
||||
await expect(body.getByRole("button", { name: "Save" })).toBeDisabled();
|
||||
},
|
||||
};
|
||||
|
||||
/** Reset puts the form back to the stored configuration and takes the save bar away with it. */
|
||||
export const ResetForm: Story = {
|
||||
play: async ({ userEvent }) => {
|
||||
const body = await openMcp(userEvent);
|
||||
await userEvent.click(body.getByRole("button", { name: "Actions for Local SQLite" }));
|
||||
await userEvent.click(await body.findByRole("menuitem", { name: "Edit" }));
|
||||
const name = await body.findByRole("textbox", { name: "Name" });
|
||||
await enter(name, "Local SQLite copy");
|
||||
await expectVisible(await body.findByText("Changes not saved"));
|
||||
await userEvent.click(body.getByRole("button", { name: "Reset" }));
|
||||
await waitFor(() => expect(name).toHaveValue("Local SQLite"));
|
||||
await waitFor(() => expect(body.queryByRole("button", { name: "Reset" })).toBeNull());
|
||||
},
|
||||
};
|
||||
|
||||
export const RemoveConfirmation: Story = {
|
||||
play: async ({ args, userEvent }) => {
|
||||
const body = await openMcp(userEvent);
|
||||
await userEvent.click(body.getByRole("button", { name: "Actions for Playwright" }));
|
||||
await userEvent.click(await body.findByRole("menuitem", { name: "Remove" }));
|
||||
await expectVisible(await body.findByRole("alertdialog", { name: "Remove Playwright?" }));
|
||||
await userEvent.click(body.getByRole("button", { name: "Remove MCP server" }));
|
||||
await expect(args.onRemoveMcpServer).toHaveBeenCalledWith("mcp-playwright");
|
||||
},
|
||||
};
|
||||
|
||||
export const McpNarrowViewport: Story = {
|
||||
parameters: { viewport: { defaultViewport: "serverNarrow" } },
|
||||
play: McpList.play,
|
||||
};
|
||||
|
||||
/** The repeatable rows are the risk at this width, so this one stops in the form instead of saving. */
|
||||
export const McpFormNarrowViewport: Story = {
|
||||
parameters: { viewport: { defaultViewport: "serverMobile" } },
|
||||
play: async ({ userEvent }) => {
|
||||
const body = await openForm(userEvent);
|
||||
await enter(body.getByRole("textbox", { name: "Name" }), "Local SQLite");
|
||||
await enter(body.getByRole("textbox", { name: "Command to launch" }), "openai-dev-mcp");
|
||||
await enter(body.getByRole("textbox", { name: "Argument 1" }), "--database");
|
||||
await enter(body.getByRole("textbox", { name: "Environment variable 1 key" }), "SQLITE_READONLY");
|
||||
await enter(body.getByRole("textbox", { name: "Environment variable 1 value" }), "1");
|
||||
await expectVisible(body.getByRole("button", { name: "MCP" }));
|
||||
},
|
||||
};
|
||||
@@ -1,6 +1,6 @@
|
||||
import { ServerRail } from "@openbot/ui/features/servers/ServerRail";
|
||||
import { createMemo, createSignal } from "solid-js";
|
||||
import { expect, fireEvent, fn, userEvent, waitFor, within } from "storybook/test";
|
||||
import { fn } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
import { STORY_SERVERS } from "./fixtures";
|
||||
|
||||
@@ -80,103 +80,7 @@ const meta = {
|
||||
export default meta;
|
||||
type Story = StoryObj<typeof meta>;
|
||||
|
||||
export const Populated: Story = {
|
||||
play: async ({ canvas }) => {
|
||||
const rail = canvas.getByRole("complementary", { name: "Servers" });
|
||||
const local = canvas.getByRole("button", { name: "Local server" });
|
||||
const remote = canvas.getByRole("button", { name: "OpenBot team server" });
|
||||
const localMarker = local.querySelector<HTMLElement>(".server-rail-mark");
|
||||
const remoteMarker = remote.querySelector<HTMLElement>(".server-rail-mark");
|
||||
const list = rail.querySelector<HTMLElement>(".server-rail-list");
|
||||
const localTile = local.querySelector<HTMLElement>(".ui-server-gradient-logo");
|
||||
const dividerStyle = getComputedStyle(rail, "::after");
|
||||
|
||||
await expect(getComputedStyle(rail).borderRightWidth).toBe("0px");
|
||||
await expect(dividerStyle.top).toBe("38px");
|
||||
await expect(dividerStyle.bottom).toBe("0px");
|
||||
if (!localMarker || !remoteMarker || !list) throw new Error("A server rail element is missing");
|
||||
await expect(getComputedStyle(localMarker).height).toBe("26px");
|
||||
await expect(getComputedStyle(localMarker).opacity).toBe("1");
|
||||
await expect(getComputedStyle(remoteMarker).height).toBe("0px");
|
||||
await expect(getComputedStyle(remoteMarker).opacity).toBe("0");
|
||||
await expect(getComputedStyle(remoteMarker).transitionDuration).toContain("0.16s");
|
||||
await expect(localMarker.getBoundingClientRect().left).toBeGreaterThanOrEqual(list.getBoundingClientRect().left);
|
||||
await expect(rail.querySelector(".server-rail-state")).not.toBeInTheDocument();
|
||||
await expect(local).not.toHaveAttribute("title");
|
||||
await expect(remote).not.toHaveAttribute("title");
|
||||
|
||||
const addServer = canvas.getByRole("button", { name: "Add remote server" });
|
||||
await expect(addServer).not.toHaveAttribute("title");
|
||||
await userEvent.hover(addServer);
|
||||
await expect(await within(document.body).findByRole("tooltip")).toHaveTextContent("Add remote server");
|
||||
await userEvent.unhover(addServer);
|
||||
await waitFor(() => expect(within(document.body).queryByRole("tooltip")).not.toBeInTheDocument());
|
||||
|
||||
if (!localTile) throw new Error("The local server tile is missing");
|
||||
const idleButtonStyle = {
|
||||
background: getComputedStyle(local).background,
|
||||
color: getComputedStyle(local).color,
|
||||
};
|
||||
const idleStyle = {
|
||||
background: getComputedStyle(localTile).background,
|
||||
borderRadius: getComputedStyle(localTile).borderRadius,
|
||||
color: getComputedStyle(localTile).color,
|
||||
transform: getComputedStyle(localTile).transform,
|
||||
};
|
||||
|
||||
await userEvent.hover(local);
|
||||
const serverTooltip = await within(document.body).findByRole("tooltip");
|
||||
await expect(serverTooltip).toHaveTextContent("Local");
|
||||
await waitFor(() =>
|
||||
expect(serverTooltip.getBoundingClientRect().left).toBeGreaterThan(local.getBoundingClientRect().right),
|
||||
);
|
||||
await expect(getComputedStyle(local).background).toBe(idleButtonStyle.background);
|
||||
await expect(getComputedStyle(local).color).toBe(idleButtonStyle.color);
|
||||
await expect(getComputedStyle(localTile).background).toBe(idleStyle.background);
|
||||
await expect(getComputedStyle(localTile).borderRadius).toBe(idleStyle.borderRadius);
|
||||
await expect(getComputedStyle(localTile).color).toBe(idleStyle.color);
|
||||
await expect(getComputedStyle(localTile).transform).toBe(idleStyle.transform);
|
||||
|
||||
await userEvent.unhover(local);
|
||||
await waitFor(() => expect(within(document.body).queryByRole("tooltip")).not.toBeInTheDocument());
|
||||
|
||||
local.focus();
|
||||
await expect(await within(document.body).findByRole("tooltip")).toHaveTextContent("Local");
|
||||
local.blur();
|
||||
await waitFor(() => expect(within(document.body).queryByRole("tooltip")).not.toBeInTheDocument());
|
||||
|
||||
await userEvent.hover(remote);
|
||||
await waitFor(async () =>
|
||||
expect(await within(document.body).findByRole("tooltip")).toHaveTextContent("OpenBot team"),
|
||||
);
|
||||
await expect(getComputedStyle(localMarker).height).toBe("26px");
|
||||
|
||||
await userEvent.click(remote);
|
||||
const selectedRemote = canvas.getByRole("button", { name: "OpenBot team server" });
|
||||
const inactiveLocal = canvas.getByRole("button", { name: "Local server" });
|
||||
const selectedRemoteMarker = selectedRemote.querySelector<HTMLElement>(".server-rail-mark");
|
||||
const inactiveLocalMarker = inactiveLocal.querySelector<HTMLElement>(".server-rail-mark");
|
||||
if (!selectedRemoteMarker || !inactiveLocalMarker) throw new Error("A server marker is missing after selection");
|
||||
await expect(selectedRemote).toBe(remote);
|
||||
await expect(inactiveLocal).toBe(local);
|
||||
await expect(selectedRemote).toHaveAttribute("aria-pressed", "true");
|
||||
await expect(inactiveLocal).toHaveAttribute("aria-pressed", "false");
|
||||
await waitFor(() => expect(getComputedStyle(selectedRemoteMarker).height).toBe("26px"));
|
||||
await waitFor(() => expect(getComputedStyle(inactiveLocalMarker).height).toBe("0px"));
|
||||
await userEvent.unhover(selectedRemote);
|
||||
await waitFor(() => expect(within(document.body).queryByRole("tooltip")).not.toBeInTheDocument());
|
||||
|
||||
await userEvent.click(inactiveLocal);
|
||||
const restoredLocal = canvas.getByRole("button", { name: "Local server" });
|
||||
const restoredRemote = canvas.getByRole("button", { name: "OpenBot team server" });
|
||||
const restoredLocalMarker = restoredLocal.querySelector<HTMLElement>(".server-rail-mark");
|
||||
const restoredRemoteMarker = restoredRemote.querySelector<HTMLElement>(".server-rail-mark");
|
||||
if (!restoredLocalMarker || !restoredRemoteMarker) throw new Error("A restored server marker is missing");
|
||||
await waitFor(() => expect(getComputedStyle(restoredLocalMarker).height).toBe("26px"));
|
||||
await waitFor(() => expect(getComputedStyle(restoredRemoteMarker).height).toBe("0px"));
|
||||
await userEvent.unhover(restoredLocal);
|
||||
},
|
||||
};
|
||||
export const Populated: Story = {};
|
||||
|
||||
export const OfflineRemote: Story = {
|
||||
args: {
|
||||
@@ -184,119 +88,27 @@ export const OfflineRemote: Story = {
|
||||
server.kind === "remote" ? { ...server, state: "offline" as const } : server,
|
||||
),
|
||||
},
|
||||
play: async ({ canvas }) => {
|
||||
const rail = canvas.getByRole("complementary", { name: "Servers" });
|
||||
await expect(rail.querySelector(".server-rail-state")).not.toBeInTheDocument();
|
||||
await expect(canvas.getByRole("button", { name: "OpenBot team server, offline" })).toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
|
||||
export const ManyServers: Story = {
|
||||
args: { servers: MANY_SERVERS },
|
||||
play: async ({ canvas }) => {
|
||||
const rail = canvas.getByRole("complementary", { name: "Servers" });
|
||||
const list = rail.querySelector<HTMLElement>(".server-rail-list");
|
||||
if (!list) throw new Error("The server list is missing");
|
||||
|
||||
await expect(getComputedStyle(list).overflowY).toBe("auto");
|
||||
await waitFor(() => expect(list.scrollHeight).toBeGreaterThan(list.clientHeight));
|
||||
list.scrollTop = list.scrollHeight;
|
||||
await waitFor(() => expect(list.scrollTop).toBeGreaterThan(0));
|
||||
await expect(canvas.getByRole("button", { name: "Add remote server" })).toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
|
||||
export const SortableServers: Story = {
|
||||
args: { servers: MANY_SERVERS.slice(0, 4) },
|
||||
play: async ({ args: storyArgs, canvas }) => {
|
||||
const local = canvas.getByRole("button", { name: "Local server" });
|
||||
const first = canvas.getByRole("button", { name: "Remote server 1 server" });
|
||||
const remoteList = first.closest<HTMLElement>(".server-rail-remote-list");
|
||||
if (!remoteList) throw new Error("The remote server list is missing");
|
||||
|
||||
await expect(local.closest(".server-rail-server-item")).toBeNull();
|
||||
await expect(first.closest(".server-rail-server-item")).toHaveAttribute("draggable", "true");
|
||||
await expect(first).toHaveAttribute("aria-keyshortcuts", "Alt+ArrowUp Alt+ArrowDown");
|
||||
first.focus();
|
||||
await userEvent.keyboard("{Alt>}{ArrowDown}{/Alt}");
|
||||
|
||||
await waitFor(() => {
|
||||
const order = Array.from(remoteList.querySelectorAll<HTMLElement>(".server-rail-server-item")).map(
|
||||
(item) => item.dataset.serverId,
|
||||
);
|
||||
expect(order).toEqual(["remote-2", "remote-1", "remote-3"]);
|
||||
});
|
||||
await expect(storyArgs.onReorder).toHaveBeenLastCalledWith(["remote-2", "remote-1", "remote-3"]);
|
||||
await expect(canvas.getByText("Moved server to position 2 of 3.")).toBeInTheDocument();
|
||||
|
||||
const third = canvas.getByRole("button", { name: "Remote server 3 server" });
|
||||
const sourceItem = first.closest<HTMLElement>(".server-rail-server-item");
|
||||
const targetItem = third.closest<HTMLElement>(".server-rail-server-item");
|
||||
if (!sourceItem || !targetItem) throw new Error("A sortable server item is missing");
|
||||
const dataTransfer = new DataTransfer();
|
||||
fireEvent.dragStart(sourceItem, { dataTransfer });
|
||||
await waitFor(() => expect(sourceItem).toHaveClass("server-rail-server-item-dragging"));
|
||||
const targetBounds = targetItem.getBoundingClientRect();
|
||||
const targetY = targetBounds.top + targetBounds.height / 2;
|
||||
const dragAccepted = fireEvent.dragOver(remoteList, { dataTransfer, clientY: targetY });
|
||||
await expect(dragAccepted).toBe(false);
|
||||
fireEvent.drop(remoteList, { dataTransfer, clientY: targetY });
|
||||
|
||||
await expect(storyArgs.onReorder).toHaveBeenLastCalledWith(["remote-2", "remote-3", "remote-1"]);
|
||||
await expect(getComputedStyle(sourceItem).transitionProperty).toContain("transform");
|
||||
},
|
||||
};
|
||||
|
||||
export const AutoScrollServers: Story = {
|
||||
args: { servers: MANY_SERVERS },
|
||||
play: async ({ canvas }) => {
|
||||
const rail = canvas.getByRole("complementary", { name: "Servers" });
|
||||
const list = rail.querySelector<HTMLElement>(".server-rail-list");
|
||||
const remoteList = rail.querySelector<HTMLElement>(".server-rail-remote-list");
|
||||
const first = canvas.getByRole("button", { name: "Remote server 1 server" });
|
||||
const sourceItem = first.closest<HTMLElement>(".server-rail-server-item");
|
||||
if (!list || !remoteList || !sourceItem) throw new Error("An auto-scroll server rail element is missing");
|
||||
|
||||
list.scrollTop = 0;
|
||||
await waitFor(() => expect(list).toHaveClass("scroll-fade-bottom"));
|
||||
await expect(list).not.toHaveClass("scroll-fade-top");
|
||||
const dataTransfer = new DataTransfer();
|
||||
fireEvent.dragStart(sourceItem, { dataTransfer });
|
||||
await waitFor(() => expect(sourceItem).toHaveClass("server-rail-server-item-dragging"));
|
||||
const listBounds = list.getBoundingClientRect();
|
||||
fireEvent.dragOver(remoteList, { dataTransfer, clientY: listBounds.bottom - 1 });
|
||||
|
||||
await waitFor(() => expect(list.scrollTop).toBeGreaterThan(0));
|
||||
await expect(list).toHaveClass("scroll-fade-top", "scroll-fade-bottom");
|
||||
fireEvent.dragEnd(sourceItem, { dataTransfer });
|
||||
const stoppedScrollTop = list.scrollTop;
|
||||
await new Promise((resolve) => window.setTimeout(resolve, 50));
|
||||
await expect(list.scrollTop).toBe(stoppedScrollTop);
|
||||
},
|
||||
};
|
||||
|
||||
export const RemoteSelected: Story = {
|
||||
args: {
|
||||
servers: STORY_SERVERS.map((server) => ({ ...server, active: server.kind === "remote" })),
|
||||
},
|
||||
play: async ({ canvas }) => {
|
||||
const local = canvas.getByRole("button", { name: "Local server" });
|
||||
const remote = canvas.getByRole("button", { name: "OpenBot team server" });
|
||||
const localMarker = local.querySelector<HTMLElement>(".server-rail-mark");
|
||||
const remoteMarker = remote.querySelector<HTMLElement>(".server-rail-mark");
|
||||
if (!localMarker || !remoteMarker) throw new Error("A server marker is missing");
|
||||
|
||||
await expect(getComputedStyle(localMarker).height).toBe("0px");
|
||||
await expect(getComputedStyle(remoteMarker).height).toBe("26px");
|
||||
await expect(canvas.queryByRole("button", { name: /Remote Mac|Show screen/i })).not.toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
|
||||
export const Muted: Story = {
|
||||
args: { servers: STORY_SERVERS.map((server) => ({ ...server, notificationsMuted: server.kind === "remote" })) },
|
||||
};
|
||||
|
||||
/** A remote server muted for one hour, with its menu open on the unmute item and the level choice. */
|
||||
/** A remote server muted for one hour, with notifications set to only when it needs me. */
|
||||
export const MutedUntil: Story = {
|
||||
args: {
|
||||
servers: STORY_SERVERS.map((server) =>
|
||||
@@ -310,11 +122,4 @@ export const MutedUntil: Story = {
|
||||
: server,
|
||||
),
|
||||
},
|
||||
play: async ({ canvasElement }) => {
|
||||
const canvas = within(canvasElement);
|
||||
await fireEvent.contextMenu(canvas.getByRole("button", { name: /notifications muted/ }));
|
||||
const page = within(canvasElement.ownerDocument.body);
|
||||
await expect(await page.findByRole("menuitem", { name: /Unmute server.*Muted until/ })).toBeVisible();
|
||||
await expect(page.getByRole("menuitem", { name: /Notification settings.*Only when it needs me/ })).toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { HostStatus } from "@openbot/contracts/ipc";
|
||||
import { createSignal, onSettled } from "solid-js";
|
||||
import { expect, fireEvent, fn, waitFor, within } from "storybook/test";
|
||||
import { fn } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
import { ServerSettingsModal, type ServerSettingsModalProps } from "../src/features/servers/ServerSettingsModal";
|
||||
import { STORY_HOST_STATUS, STORY_INVITES, STORY_PRESENCE, STORY_SERVERS } from "../src/preview/fixtures";
|
||||
@@ -9,17 +9,6 @@ import { createMockOpenBot } from "./mock-openbot";
|
||||
const localServer = STORY_SERVERS.find((server) => server.kind === "local") ?? STORY_SERVERS[0];
|
||||
const remoteServer = STORY_SERVERS.find((server) => server.kind === "remote") ?? STORY_SERVERS[1];
|
||||
if (!remoteServer) throw new Error("Story server fixtures need a remote server.");
|
||||
const denseMembers = Array.from({ length: 4 }, (_, group) =>
|
||||
STORY_PRESENCE.members.map((member, index) => ({
|
||||
...member,
|
||||
id: `${member.id}-${group}`,
|
||||
name: group === 0 ? member.name : `${member.name} ${group + 1}`,
|
||||
username: `${member.username}-${group}`,
|
||||
email: `member-${group}-${index}@example.com`,
|
||||
role: group === 0 ? member.role : "member",
|
||||
online: (group + index) % 3 === 0,
|
||||
})),
|
||||
).flat();
|
||||
|
||||
const meta = {
|
||||
title: "Settings/ServerSettingsModal",
|
||||
@@ -106,34 +95,6 @@ export const LocalFirstSetup: Story = {
|
||||
members: [],
|
||||
invites: [],
|
||||
},
|
||||
play: async () => {
|
||||
const dialog = await within(document.body).findByRole("dialog", { name: "General" });
|
||||
const name = within(dialog).getByRole("textbox", { name: "Server name" });
|
||||
await expect(name).toHaveValue("");
|
||||
await expect(name).toHaveAttribute("placeholder", "e.g. Design studio");
|
||||
},
|
||||
};
|
||||
|
||||
export const FirstSetupInvalidName: Story = {
|
||||
args: LocalFirstSetup.args,
|
||||
play: async () => {
|
||||
const dialog = await within(document.body).findByRole("dialog", { name: "General" });
|
||||
const name = within(dialog).getByRole("textbox", { name: "Server name" });
|
||||
await fireEvent.input(name, { target: { value: "Tiny" } });
|
||||
await fireEvent.blur(name);
|
||||
await expect(within(dialog).getByText("Enter at least 6 characters.")).toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
export const FirstSetupValidFooter: Story = {
|
||||
args: LocalFirstSetup.args,
|
||||
play: async () => {
|
||||
const dialog = await within(document.body).findByRole("dialog", { name: "General" });
|
||||
await fireEvent.input(within(dialog).getByRole("textbox", { name: "Server name" }), {
|
||||
target: { value: "First server" },
|
||||
});
|
||||
await expect(within(dialog).getByRole("button", { name: "Set up server" })).toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
export const FirstSetupInvalidNameSmallViewport: Story = {
|
||||
@@ -141,16 +102,10 @@ export const FirstSetupInvalidNameSmallViewport: Story = {
|
||||
parameters: {
|
||||
viewport: { defaultViewport: "serverMobile" },
|
||||
},
|
||||
play: FirstSetupInvalidName.play,
|
||||
};
|
||||
|
||||
export const RemoteDesktopAfterPublication: Story = {
|
||||
render: (args) => <PublicationSetupStory settings={args} />,
|
||||
play: async () => {
|
||||
const body = within(document.body);
|
||||
await fireEvent.click(await body.findByRole("switch", { name: "Publish this server" }));
|
||||
await expect(await body.findByRole("button", { name: "Set up" })).toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
function PublicationSetupStory(props: { settings: ServerSettingsModalProps }) {
|
||||
@@ -177,34 +132,6 @@ export const LocalOnline: Story = {
|
||||
apiUrl: "https://eu-west-1.gateway.example.com/openbot/servers/team_7f3c19a2",
|
||||
},
|
||||
},
|
||||
play: async ({ userEvent }) => {
|
||||
const dialog = await within(document.body).findByRole("dialog", { name: "General" });
|
||||
const name = within(dialog).getByRole("textbox", { name: "Server name" });
|
||||
await expect(name).toHaveValue("Local");
|
||||
await fireEvent.input(name, { target: { value: "Local studio" } });
|
||||
await expect(name).toHaveValue("Local studio");
|
||||
await userEvent.click(within(dialog).getByRole("button", { name: "Reset" }));
|
||||
await expect(name).toHaveValue("Local");
|
||||
await expect(within(dialog).getByRole("switch", { name: "Publish this server" })).toBeChecked();
|
||||
},
|
||||
};
|
||||
|
||||
export const FocusedInput: Story = {
|
||||
play: async ({ userEvent }) => {
|
||||
const dialog = await within(document.body).findByRole("dialog", { name: "General" });
|
||||
const name = within(dialog).getByRole("textbox", { name: "Server name" });
|
||||
await userEvent.click(name);
|
||||
await expect(name).toHaveFocus();
|
||||
},
|
||||
};
|
||||
|
||||
export const DirtyFooter: Story = {
|
||||
play: async () => {
|
||||
const dialog = await within(document.body).findByRole("dialog", { name: "General" });
|
||||
const name = within(dialog).getByRole("textbox", { name: "Server name" });
|
||||
await fireEvent.input(name, { target: { value: "OpenBot production" } });
|
||||
await waitFor(() => expect(within(dialog).getByRole("region", { name: "Unsaved changes" })).toBeVisible());
|
||||
},
|
||||
};
|
||||
|
||||
export const ActionError: Story = {
|
||||
@@ -220,163 +147,17 @@ export const RemoteAdministrator: Story = {
|
||||
},
|
||||
};
|
||||
|
||||
export const Members: Story = {
|
||||
play: async ({ userEvent }) => {
|
||||
const body = within(document.body);
|
||||
await body.findByRole("dialog", { name: "General" });
|
||||
await userEvent.click(body.getByRole("tab", { name: "Members" }));
|
||||
await expect(body.getByTestId("server-members-list")).toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
export const InviteLinkReady: Story = {
|
||||
play: async ({ userEvent }) => {
|
||||
const body = within(document.body);
|
||||
await body.findByRole("dialog", { name: "General" });
|
||||
await userEvent.click(body.getByRole("tab", { name: "Members" }));
|
||||
await userEvent.click(body.getByRole("tab", { name: "Invite link" }));
|
||||
await userEvent.click(body.getByRole("button", { name: "Create link" }));
|
||||
await expect(await body.findByRole("textbox", { name: "Invitation link" })).toHaveValue(
|
||||
"https://team.example.com/invite/story",
|
||||
);
|
||||
},
|
||||
};
|
||||
|
||||
export const MembersEmptyResults: Story = {
|
||||
play: async ({ userEvent }) => {
|
||||
const body = within(document.body);
|
||||
await body.findByRole("dialog", { name: "General" });
|
||||
await userEvent.click(body.getByRole("tab", { name: "Members" }));
|
||||
await userEvent.type(body.getByRole("searchbox", { name: "Search members" }), "nobody");
|
||||
await expect(body.getByText("No members match this search.")).toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
export const MembersUnpublished: Story = {
|
||||
args: {
|
||||
server: { ...remoteServer, state: "offline", role: "admin" },
|
||||
hostStatus: null,
|
||||
},
|
||||
play: async ({ userEvent }) => {
|
||||
const body = within(document.body);
|
||||
await body.findByRole("dialog", { name: "General" });
|
||||
await userEvent.click(body.getByRole("tab", { name: "Members" }));
|
||||
await expect(body.getByRole("status")).toBeVisible();
|
||||
await expect(body.getByRole("button", { name: "Send invite" })).toBeDisabled();
|
||||
},
|
||||
};
|
||||
|
||||
export const MembersSmallViewport: Story = {
|
||||
parameters: {
|
||||
viewport: { defaultViewport: "serverNarrow" },
|
||||
},
|
||||
play: Members.play,
|
||||
};
|
||||
|
||||
export const DenseMemberList: Story = {
|
||||
args: {
|
||||
server: { ...remoteServer, role: "admin" },
|
||||
hostStatus: null,
|
||||
members: denseMembers,
|
||||
},
|
||||
play: async ({ userEvent }) => {
|
||||
const body = within(document.body);
|
||||
await body.findByRole("dialog", { name: "General" });
|
||||
await userEvent.click(body.getByRole("tab", { name: "Members" }));
|
||||
await expect(body.getByTestId("server-members-list")).toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
export const RemoveMemberConfirmation: Story = {
|
||||
args: {
|
||||
server: { ...remoteServer, role: "admin" },
|
||||
hostStatus: null,
|
||||
},
|
||||
play: async ({ userEvent }) => {
|
||||
const body = within(document.body);
|
||||
await body.findByRole("dialog", { name: "General" });
|
||||
await userEvent.click(body.getByRole("tab", { name: "Members" }));
|
||||
await userEvent.click(body.getByRole("button", { name: "Actions for Jon Bell" }));
|
||||
await userEvent.click(await body.findByRole("menuitem", { name: "Remove member" }));
|
||||
const confirmation = await body.findByRole("alertdialog", { name: "Remove Jon Bell?" });
|
||||
await waitFor(() => expect(confirmation).toBeVisible());
|
||||
},
|
||||
};
|
||||
|
||||
export const RemoteMember: Story = {
|
||||
args: {
|
||||
server: { ...remoteServer, role: "member" },
|
||||
hostStatus: null,
|
||||
invites: [],
|
||||
},
|
||||
play: async () => {
|
||||
const body = within(document.body);
|
||||
await body.findByRole("dialog", { name: "General" });
|
||||
await expect(body.queryByRole("textbox", { name: "Server name" })).not.toBeInTheDocument();
|
||||
await waitFor(() =>
|
||||
expect(body.getByText(remoteServer.name, { selector: ".server-settings-readonly-value" })).toBeVisible(),
|
||||
);
|
||||
body.getByRole("tab", { name: "Members" }).click();
|
||||
await expect(body.queryByRole("button", { name: "Send invite" })).not.toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
|
||||
export const RemoteDesktop: Story = {
|
||||
args: {
|
||||
server: { ...remoteServer, role: "admin" },
|
||||
hostStatus: null,
|
||||
},
|
||||
play: async () => {
|
||||
const body = within(document.body);
|
||||
await body.findByRole("dialog", { name: "General" });
|
||||
body.getByRole("tab", { name: "Remote desktop" }).click();
|
||||
await expect(body.getByText("Service available")).toBeVisible();
|
||||
await expect(body.queryByRole("button", { name: "Connect" })).not.toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
|
||||
export const HostScreenRecordingBlocked: Story = {
|
||||
args: { hostStatus: { ...STORY_HOST_STATUS, remoteDesktopScreenRecordingDenied: true } },
|
||||
play: async () => {
|
||||
const body = within(document.body);
|
||||
await body.findByRole("dialog", { name: "General" });
|
||||
await fireEvent.click(body.getByRole("tab", { name: "Remote desktop" }));
|
||||
await fireEvent.click(body.getByRole("button", { name: "Check again" }));
|
||||
await waitFor(() => expect(body.getAllByText("Blocked")).toHaveLength(2));
|
||||
await expect(body.getByRole("button", { name: "Grant Accessibility access" })).toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
export const HostPermissionsReady: Story = {
|
||||
render: (args) => <RemoteSetupStory settings={args} permission="allowed" />,
|
||||
play: async () => {
|
||||
const body = within(document.body);
|
||||
await body.findByRole("dialog", { name: "General" });
|
||||
await fireEvent.click(body.getByRole("tab", { name: "Remote desktop" }));
|
||||
await fireEvent.click(body.getByRole("button", { name: "Check again" }));
|
||||
await waitFor(() => expect(body.getAllByText("Allowed")).toHaveLength(2));
|
||||
},
|
||||
};
|
||||
|
||||
export const HostPermissionCheckFailed: Story = {
|
||||
render: (args) => <RemoteSetupStory settings={args} permission="failed" />,
|
||||
play: async () => {
|
||||
const body = within(document.body);
|
||||
await body.findByRole("dialog", { name: "General" });
|
||||
await fireEvent.click(body.getByRole("tab", { name: "Remote desktop" }));
|
||||
await fireEvent.click(body.getByRole("button", { name: "Check again" }));
|
||||
await waitFor(() => expect(body.getAllByText("Check failed")).toHaveLength(2));
|
||||
},
|
||||
};
|
||||
|
||||
function RemoteSetupStory(props: { settings: ServerSettingsModalProps; permission?: "allowed" | "failed" }) {
|
||||
function RemoteSetupStory(props: { settings: ServerSettingsModalProps }) {
|
||||
const previous = window.openbot;
|
||||
const mock = createMockOpenBot({ hostStatus: props.settings.hostStatus ?? undefined });
|
||||
const check = mock.api.remoteDesktop.checkSetup;
|
||||
mock.api.remoteDesktop.checkSetup = async (serverId) => ({
|
||||
...(await check(serverId)),
|
||||
...(props.permission ? { screenRecording: props.permission, accessibility: props.permission } : {}),
|
||||
});
|
||||
window.openbot = mock.api;
|
||||
onSettled(() => () => {
|
||||
mock.dispose();
|
||||
|
||||
@@ -11,7 +11,7 @@ import type {
|
||||
import { Button, Heading, Text, Toaster, toast } from "@openbot/ui";
|
||||
import { DEFAULT_GENERAL_SETTINGS } from "@openbot/ui/features/settings/app-settings";
|
||||
import { createSignal, onCleanup } from "solid-js";
|
||||
import { expect, fn, waitFor, within } from "storybook/test";
|
||||
import { fn } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
import { createProviderRuntimeStore } from "../src/features/provider-updates/provider-runtime-store";
|
||||
import { SettingsModal } from "../src/features/settings/SettingsModal";
|
||||
@@ -34,28 +34,6 @@ const storyUpdateStatus: UpdateStatus = {
|
||||
message: null,
|
||||
errorCode: null,
|
||||
};
|
||||
const availableUpdateStatus: UpdateStatus = {
|
||||
...storyUpdateStatus,
|
||||
phase: "available",
|
||||
availableVersion: "0.3.0",
|
||||
};
|
||||
const readyUpdateStatus: UpdateStatus = {
|
||||
...availableUpdateStatus,
|
||||
phase: "ready",
|
||||
progress: 100,
|
||||
};
|
||||
/** A managed Mac: Host Manager owns the shared application, so the tenant only watches. */
|
||||
const hostManagedUpdateStatus: UpdateStatus = {
|
||||
...storyUpdateStatus,
|
||||
phase: "up-to-date",
|
||||
managedByHost: true,
|
||||
};
|
||||
const hostManagedDownloadStatus: UpdateStatus = {
|
||||
...hostManagedUpdateStatus,
|
||||
phase: "downloading",
|
||||
availableVersion: "0.3.0",
|
||||
progress: 42,
|
||||
};
|
||||
const providerAgentStatus: AgentStatus = {
|
||||
phase: "blocked",
|
||||
cliVersion: null,
|
||||
@@ -131,15 +109,11 @@ const providerUpdateRuntimeStatuses: ProviderRuntimeSnapshot["providers"] = {
|
||||
|
||||
function SettingsModalStory(props: {
|
||||
initialOpen: boolean;
|
||||
initialUpdateStatus?: UpdateStatus;
|
||||
mockDownloadUpdate?: boolean;
|
||||
providerDownloads?: boolean;
|
||||
providerUpdate?: boolean;
|
||||
providerUpdateFailure?: boolean;
|
||||
simulateMobileConnection?: boolean;
|
||||
openCodeInstalled?: boolean;
|
||||
customProviderList?: boolean;
|
||||
customProviderSaveFails?: boolean;
|
||||
codeSignIn?: boolean;
|
||||
}) {
|
||||
const previousApi = window.openbot;
|
||||
@@ -162,7 +136,7 @@ function SettingsModalStory(props: {
|
||||
});
|
||||
const [open, setOpen] = createSignal(props.initialOpen);
|
||||
const [value, setValue] = createSignal({ ...DEFAULT_GENERAL_SETTINGS });
|
||||
const [updateStatus, setUpdateStatus] = createSignal<UpdateStatus>(props.initialUpdateStatus ?? storyUpdateStatus);
|
||||
const [updateStatus, setUpdateStatus] = createSignal<UpdateStatus>(storyUpdateStatus);
|
||||
const [account, setAccount] = createSignal<CentralAuthUser>({ ...storyAccount });
|
||||
const [mobileDevices, setMobileDevices] = createSignal<MobileConnectedDevice[]>([
|
||||
{
|
||||
@@ -173,19 +147,12 @@ function SettingsModalStory(props: {
|
||||
lastActiveAt: Date.now() - 45_000,
|
||||
},
|
||||
]);
|
||||
let mobileConnectionTimer: number | undefined;
|
||||
|
||||
onCleanup(() => {
|
||||
if (mobileConnectionTimer !== undefined) window.clearTimeout(mobileConnectionTimer);
|
||||
});
|
||||
|
||||
const codeLogin = createFakeCodeLogin({ finishAfterMs: 0 });
|
||||
const [customProviders, setCustomProviders] = createSignal<CustomProviderSummary[]>(
|
||||
props.customProviderList ? [...STORY_CUSTOM_PROVIDERS] : [],
|
||||
);
|
||||
|
||||
async function addCustomProvider(): Promise<CustomProviderRestart> {
|
||||
if (props.customProviderSaveFails) throw new Error("House Router refused the API key.");
|
||||
return "restarted";
|
||||
}
|
||||
|
||||
@@ -206,34 +173,10 @@ function SettingsModalStory(props: {
|
||||
}
|
||||
|
||||
async function runUpdateAction(): Promise<void> {
|
||||
if (!props.mockDownloadUpdate || updateStatus().phase !== "available") {
|
||||
setUpdateStatus({ ...storyUpdateStatus, phase: "up-to-date", checkedAt: new Date().toISOString() });
|
||||
return;
|
||||
}
|
||||
|
||||
const downloadingStatus = { ...updateStatus(), phase: "downloading", progress: 0 } as const;
|
||||
setUpdateStatus(downloadingStatus);
|
||||
await new Promise((resolve) => setTimeout(resolve, 400));
|
||||
setUpdateStatus({ ...downloadingStatus, progress: 48 });
|
||||
await new Promise((resolve) => setTimeout(resolve, 400));
|
||||
setUpdateStatus({ ...downloadingStatus, phase: "ready", progress: 100 });
|
||||
setUpdateStatus({ ...storyUpdateStatus, phase: "up-to-date", checkedAt: new Date().toISOString() });
|
||||
}
|
||||
|
||||
async function createMobileConnect(): Promise<{ qrData: string; expiresAt: number }> {
|
||||
if (props.simulateMobileConnection) {
|
||||
mobileConnectionTimer = window.setTimeout(() => {
|
||||
setMobileDevices((current) => [
|
||||
...current,
|
||||
{
|
||||
sessionId: "22222222-2222-4222-8222-222222222222",
|
||||
name: "OpenBot iPhone",
|
||||
platform: "ios",
|
||||
connectedAt: Date.now(),
|
||||
lastActiveAt: Date.now(),
|
||||
},
|
||||
]);
|
||||
}, 500);
|
||||
}
|
||||
return {
|
||||
qrData:
|
||||
"openbot://mobile-connect?api=https%3A%2F%2Fapi.openbot.run&ticket=storybook-mobile-ticket_1234567890abcdef",
|
||||
@@ -359,68 +302,22 @@ export const Open: Story = {
|
||||
/** The row that adds a self-described endpoint. OpenCode is installed, so the row offers Add. */
|
||||
export const AddCustomProvider: Story = {
|
||||
render: () => <SettingsModalStory initialOpen openCodeInstalled />,
|
||||
play: async ({ userEvent }) => {
|
||||
const body = within(document.body);
|
||||
await userEvent.click(await body.findByRole("button", { name: "Add custom provider" }));
|
||||
await expect(body.findByRole("heading", { name: "Custom provider" })).resolves.toBeTruthy();
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* The saved endpoints, and the removal that discards a key. They are listed in a dialog the count on
|
||||
* the Custom provider row opens, so the AI providers section keeps its rows of fixed height.
|
||||
* Two saved endpoints. The count on the Custom provider row opens the dialog that lists them, so the
|
||||
* AI providers section keeps its rows of fixed height.
|
||||
*/
|
||||
export const CustomProviderList: Story = {
|
||||
render: () => <SettingsModalStory initialOpen openCodeInstalled customProviderList />,
|
||||
play: async ({ userEvent }) => {
|
||||
const body = within(document.body);
|
||||
await userEvent.click(await body.findByRole("button", { name: "Manage 2 endpoints" }));
|
||||
await expect(body.findByRole("button", { name: "Delete Studio Local" })).resolves.toBeTruthy();
|
||||
// The removal asks first, in a confirmation dialog above the list.
|
||||
await userEvent.click(body.getByRole("button", { name: "Delete House Router" }));
|
||||
const first = await body.findByRole("alertdialog", { name: "Remove House Router?" });
|
||||
await userEvent.click(within(first).getByRole("button", { name: "Remove" }));
|
||||
await waitFor(() => expect(body.queryByRole("button", { name: "Delete House Router" })).toBeNull());
|
||||
await expect(body.getByRole("button", { name: "Delete Studio Local" })).toBeVisible();
|
||||
// The last endpoint leaves the dialog on its empty state rather than closing under the hand.
|
||||
await userEvent.click(body.getByRole("button", { name: "Delete Studio Local" }));
|
||||
const last = await body.findByRole("alertdialog", { name: "Remove Studio Local?" });
|
||||
await userEvent.click(within(last).getByRole("button", { name: "Remove" }));
|
||||
await expect(body.findByText("No custom endpoints yet.")).resolves.toBeTruthy();
|
||||
},
|
||||
};
|
||||
|
||||
/** The endpoint is refused, so the form stays with the values, including the key the user typed. */
|
||||
export const CustomProviderSaveFails: Story = {
|
||||
render: () => <SettingsModalStory initialOpen openCodeInstalled customProviderSaveFails />,
|
||||
play: async ({ userEvent }) => {
|
||||
const body = within(document.body);
|
||||
await userEvent.click(await body.findByRole("button", { name: "Add custom provider" }));
|
||||
// A required field appends an aria-hidden asterisk to its label, so its name is not an exact match.
|
||||
await userEvent.type(await body.findByLabelText(/^Provider ID/), "house-router");
|
||||
await userEvent.type(body.getByLabelText(/^Display name/), "House Router");
|
||||
await userEvent.type(body.getByLabelText(/^Base URL/), "https://models.example.com/v1");
|
||||
await userEvent.type(body.getByLabelText("Model 1 ID"), "glm-5-air");
|
||||
await userEvent.type(body.getByLabelText("Model 1 display name"), "GLM 5 Air");
|
||||
await userEvent.click(body.getByRole("button", { name: "Submit" }));
|
||||
|
||||
await expect(body.findByText("House Router refused the API key.")).resolves.toBeTruthy();
|
||||
await expect(body.getByLabelText(/^Provider ID/)).toHaveValue("house-router");
|
||||
},
|
||||
};
|
||||
|
||||
/**
|
||||
* The ChatGPT row signed out. The sign-in finished on another device sits in the row's actions
|
||||
* menu, so the row still leads with one button; choosing it opens the code over the modal.
|
||||
* menu, so the row still leads with one button.
|
||||
*/
|
||||
export const CodeSignIn: Story = {
|
||||
render: () => <SettingsModalStory initialOpen codeSignIn />,
|
||||
play: async ({ userEvent }) => {
|
||||
const body = within(document.body);
|
||||
await userEvent.click(await body.findByRole("button", { name: "More actions for ChatGPT" }));
|
||||
await userEvent.click(await body.findByRole("menuitem", { name: "Log in with code" }));
|
||||
await expect(await body.findByLabelText("Login code K T Q 4 - B 6 2 M X")).toHaveTextContent("KTQ4-B62MX");
|
||||
},
|
||||
};
|
||||
|
||||
export const Narrow: Story = {
|
||||
@@ -436,207 +333,12 @@ export const ProviderDownloads: Story = {
|
||||
/** The durable surface: the update the toast offers is still here after the toast is gone. */
|
||||
export const ProviderUpdateAvailable: Story = {
|
||||
render: () => <SettingsModalStory initialOpen providerUpdate />,
|
||||
play: async ({ userEvent }) => {
|
||||
const body = within(document.body);
|
||||
await userEvent.click(await body.findByRole("button", { name: "More actions for Claude" }));
|
||||
await expect(body.findByRole("menuitem", { name: "Update to 2.1.250" })).resolves.toBeEnabled();
|
||||
},
|
||||
};
|
||||
|
||||
export const ProviderUpdateFromSettings: Story = {
|
||||
render: () => <SettingsModalStory initialOpen providerUpdate />,
|
||||
play: async ({ userEvent }) => {
|
||||
const body = within(document.body);
|
||||
await userEvent.click(await body.findByRole("button", { name: "More actions for Claude" }));
|
||||
await userEvent.click(await body.findByRole("menuitem", { name: "Update to 2.1.250" }));
|
||||
await expect(body.findByText("Updating Claude")).resolves.toBeInTheDocument();
|
||||
await expect(body.findByText("Claude is up to date", undefined, { timeout: 8_000 })).resolves.toBeInTheDocument();
|
||||
},
|
||||
};
|
||||
|
||||
export const ProviderUpdateRetry: Story = {
|
||||
render: () => <SettingsModalStory initialOpen providerUpdate providerUpdateFailure />,
|
||||
};
|
||||
|
||||
export const Profile: Story = {
|
||||
render: () => <SettingsModalStory initialOpen />,
|
||||
play: async ({ userEvent }) => {
|
||||
const body = within(document.body);
|
||||
await userEvent.click(await body.findByRole("tab", { name: "Profile" }));
|
||||
},
|
||||
};
|
||||
|
||||
export const DynamicIsland: Story = {
|
||||
render: () => <SettingsModalStory initialOpen />,
|
||||
play: async ({ userEvent }) => {
|
||||
const body = within(document.body);
|
||||
await userEvent.click(await body.findByRole("tab", { name: "Dynamic Island" }));
|
||||
await expect(body.findByRole("slider", { name: "Width" })).resolves.toBeEnabled();
|
||||
},
|
||||
};
|
||||
|
||||
export const ComputerUse: Story = {
|
||||
render: () => <SettingsModalStory initialOpen />,
|
||||
play: async ({ userEvent }) => {
|
||||
const body = within(document.body);
|
||||
await userEvent.click(await body.findByRole("tab", { name: "Computer Use" }));
|
||||
},
|
||||
};
|
||||
|
||||
export const Updates: Story = {
|
||||
render: () => <SettingsModalStory initialOpen />,
|
||||
play: async ({ userEvent }) => {
|
||||
const body = within(document.body);
|
||||
await userEvent.click(await body.findByRole("tab", { name: "Updates" }));
|
||||
},
|
||||
};
|
||||
|
||||
export const MobileConnect: Story = {
|
||||
render: () => <SettingsModalStory initialOpen />,
|
||||
play: async ({ userEvent }) => {
|
||||
const body = within(document.body);
|
||||
await userEvent.click(await body.findByRole("tab", { name: "Mobile Connect" }));
|
||||
await userEvent.click(await body.findByRole("button", { name: "Generate QR code" }));
|
||||
await expect(await body.findByRole("img", { name: "Mobile Connect sign-in QR code" })).toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
export const MobileConnectSuccess: Story = {
|
||||
render: () => <SettingsModalStory initialOpen simulateMobileConnection />,
|
||||
play: async ({ userEvent }) => {
|
||||
const body = within(document.body);
|
||||
await userEvent.click(await body.findByRole("tab", { name: "Mobile Connect" }));
|
||||
await userEvent.click(await body.findByRole("button", { name: "Generate QR code" }));
|
||||
await expect(await body.findByText("Phone connected", undefined, { timeout: 3_000 })).toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
export const UpdateAvailable: Story = {
|
||||
render: () => <SettingsModalStory initialOpen initialUpdateStatus={availableUpdateStatus} />,
|
||||
play: async ({ userEvent }) => {
|
||||
const body = within(document.body);
|
||||
await userEvent.click(await body.findByRole("tab", { name: "Updates" }));
|
||||
},
|
||||
};
|
||||
|
||||
export const DownloadUpdateFlow: Story = {
|
||||
render: () => <SettingsModalStory initialOpen initialUpdateStatus={availableUpdateStatus} mockDownloadUpdate />,
|
||||
play: async ({ step, userEvent }) => {
|
||||
const body = within(document.body);
|
||||
|
||||
await step("Open the available OpenBot update", async () => {
|
||||
await userEvent.click(await body.findByRole("tab", { name: "Updates" }));
|
||||
await expect(body.getByText("OpenBot v0.3.0 is available to download.")).toBeVisible();
|
||||
});
|
||||
|
||||
await step("Start the mocked download", async () => {
|
||||
const downloadButton = body.getByRole("button", { name: "Download update" });
|
||||
await expect(downloadButton).toBeEnabled();
|
||||
await userEvent.click(downloadButton);
|
||||
await expect(await body.findByText("Downloading OpenBot v0.3.0 · 0%")).toBeVisible();
|
||||
await expect(body.getByRole("button", { name: "Downloading update…" })).toBeDisabled();
|
||||
});
|
||||
|
||||
await step("Finish the mocked download", async () => {
|
||||
await waitFor(() => expect(body.getByText("Downloading OpenBot v0.3.0 · 48%")).toBeVisible());
|
||||
await waitFor(() => expect(body.getByText("OpenBot v0.3.0 is ready. Restart to apply.")).toBeVisible());
|
||||
await expect(body.getByRole("button", { name: "Restart to update" })).toBeEnabled();
|
||||
});
|
||||
},
|
||||
};
|
||||
|
||||
export const ReadyToInstall: Story = {
|
||||
render: () => <SettingsModalStory initialOpen initialUpdateStatus={readyUpdateStatus} />,
|
||||
play: async ({ userEvent }) => {
|
||||
const body = within(document.body);
|
||||
await userEvent.click(await body.findByRole("tab", { name: "Updates" }));
|
||||
},
|
||||
};
|
||||
|
||||
export const HostManagedUpdates: Story = {
|
||||
render: () => <SettingsModalStory initialOpen initialUpdateStatus={hostManagedUpdateStatus} />,
|
||||
play: async ({ userEvent }) => {
|
||||
const body = within(document.body);
|
||||
await userEvent.click(await body.findByRole("tab", { name: "Updates" }));
|
||||
await expect(await body.findByText("Managed by Host")).toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
export const HostManagedUpdateInProgress: Story = {
|
||||
render: () => <SettingsModalStory initialOpen initialUpdateStatus={hostManagedDownloadStatus} />,
|
||||
play: async ({ userEvent }) => {
|
||||
const body = within(document.body);
|
||||
await userEvent.click(await body.findByRole("tab", { name: "Updates" }));
|
||||
await expect(await body.findByText("Downloading OpenBot v0.3.0 · 42%")).toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
export const Interactive: Story = {
|
||||
render: () => <SettingsModalStory initialOpen={false} />,
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
const body = within(document.body);
|
||||
const trigger = canvas.getByRole("button", { name: "Open settings" });
|
||||
|
||||
await userEvent.click(trigger);
|
||||
let dialog = await body.findByRole("dialog", { name: "General" });
|
||||
await waitFor(() => expect(dialog).toBeVisible());
|
||||
await expect(body.getByTestId("settings-modal-scroll-frame")).toHaveAttribute("data-scroll-down");
|
||||
|
||||
const generalTab = body.getByRole("tab", { name: "General" });
|
||||
generalTab.focus();
|
||||
await userEvent.keyboard("{ArrowDown}");
|
||||
const computerUseTab = body.getByRole("tab", { name: "Computer Use" });
|
||||
await expect(computerUseTab).toHaveAttribute("aria-selected", "true");
|
||||
await expect(body.getByRole("heading", { name: "Computer Use", level: 2 })).toBeVisible();
|
||||
|
||||
await userEvent.keyboard("{ArrowDown}");
|
||||
const profileTab = body.getByRole("tab", { name: "Profile" });
|
||||
await expect(profileTab).toHaveAttribute("aria-selected", "true");
|
||||
await expect(body.getByRole("heading", { name: "Profile", level: 2 })).toBeVisible();
|
||||
await expect(body.getByRole("textbox", { name: "Display name" })).toHaveValue("Norbert");
|
||||
|
||||
await userEvent.keyboard("{ArrowDown}");
|
||||
const updatesTab = body.getByRole("tab", { name: "Updates" });
|
||||
await expect(updatesTab).toHaveAttribute("aria-selected", "true");
|
||||
await expect(body.getByRole("heading", { name: "Updates", level: 2 })).toBeVisible();
|
||||
|
||||
await userEvent.click(generalTab);
|
||||
await expect(generalTab).toHaveAttribute("aria-selected", "true");
|
||||
|
||||
const linkTarget = body.getByRole("button", { name: /^Open external links in/ });
|
||||
await userEvent.click(linkTarget);
|
||||
await waitFor(() => expect(body.getByRole("listbox")).toBeVisible());
|
||||
await userEvent.click(body.getByRole("option", { name: "OpenBot" }));
|
||||
await expect(linkTarget).toHaveTextContent("OpenBot");
|
||||
|
||||
const launchSwitch = body.getByRole("switch", { name: "Launch OpenBot at login" });
|
||||
await expect(launchSwitch).toBeChecked();
|
||||
await userEvent.click(launchSwitch);
|
||||
await expect(launchSwitch).not.toBeChecked();
|
||||
|
||||
await userEvent.click(updatesTab);
|
||||
await userEvent.click(body.getByRole("button", { name: "Check for updates" }));
|
||||
await expect(body.getByText("OpenBot is up to date on the Stable track.")).toBeVisible();
|
||||
|
||||
await userEvent.click(generalTab);
|
||||
|
||||
await userEvent.click(body.getByRole("button", { name: "Close settings" }));
|
||||
await expect(dialog).toHaveAttribute("data-motion", "closing");
|
||||
await waitFor(() => expect(body.queryByRole("dialog", { name: "General" })).not.toBeInTheDocument());
|
||||
await waitFor(() => expect(trigger).toHaveFocus());
|
||||
|
||||
await userEvent.click(trigger);
|
||||
dialog = await body.findByRole("dialog", { name: "General" });
|
||||
await expect(body.getByRole("switch", { name: "Launch OpenBot at login" })).not.toBeChecked();
|
||||
await userEvent.keyboard("{Escape}");
|
||||
await expect(dialog).toHaveAttribute("data-motion", "closing");
|
||||
await waitFor(() => expect(body.queryByRole("dialog", { name: "General" })).not.toBeInTheDocument());
|
||||
await waitFor(() => expect(trigger).toHaveFocus());
|
||||
|
||||
await userEvent.click(trigger);
|
||||
await body.findByRole("dialog", { name: "General" });
|
||||
await userEvent.click(body.getByTestId("settings-modal-backdrop"));
|
||||
await waitFor(() => expect(body.queryByRole("dialog", { name: "General" })).not.toBeInTheDocument());
|
||||
await waitFor(() => expect(trigger).toHaveFocus());
|
||||
},
|
||||
};
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import type { SharedTable } from "@openbot/contracts/ipc";
|
||||
import { onCleanup } from "solid-js";
|
||||
import { expect, fn, waitFor, within } from "storybook/test";
|
||||
import { fn } from "storybook/test";
|
||||
import type { Meta, StoryObj } from "storybook-solidjs-vite";
|
||||
import AgentSettingsPanel from "../src/features/conversation/AgentSettingsPanel";
|
||||
import { STORY_AGENT, STORY_AGENT_STATUS, STORY_AGENTS, STORY_MODELS, STORY_SHARED_TABLES } from "./fixtures";
|
||||
@@ -75,38 +75,8 @@ type Story = StoryObj<typeof meta>;
|
||||
|
||||
export const SettingsRow: Story = {
|
||||
render: () => <SharedTablesStory tables={STORY_SHARED_TABLES} />,
|
||||
play: async ({ canvas }) => {
|
||||
await waitFor(() => expect(canvas.getByRole("button", { name: /Tables/ })).toHaveTextContent("6 tables"));
|
||||
},
|
||||
};
|
||||
|
||||
export const OpenModal: Story = {
|
||||
render: () => <SharedTablesStory tables={STORY_SHARED_TABLES} />,
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(await canvas.findByRole("button", { name: /Tables/ }));
|
||||
const body = within(document.body);
|
||||
await expect(await body.findByRole("dialog", { name: "Tables" })).toBeVisible();
|
||||
await expect(body.getByText("people")).toBeVisible();
|
||||
await expect(body.getByText(`214 records · Kept by ${storyAgent.name}`)).toBeVisible();
|
||||
await expect(body.getByText(/not counted · Made outside OpenBot/)).toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
export const DeleteConfirmation: Story = {
|
||||
render: () => <SharedTablesStory tables={STORY_SHARED_TABLES} />,
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(await canvas.findByRole("button", { name: /Tables/ }));
|
||||
const body = within(document.body);
|
||||
await userEvent.click(await body.findByRole("button", { name: "Delete people" }));
|
||||
await expect(await body.findByText("Delete this for every agent?", { exact: false })).toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
export const EmptyState: Story = {
|
||||
render: () => <SharedTablesStory tables={[]} />,
|
||||
play: async ({ canvas, userEvent }) => {
|
||||
await userEvent.click(await canvas.findByRole("button", { name: /Tables/ }));
|
||||
const body = within(document.body);
|
||||
await expect(await body.findByText("No tables yet", { exact: false })).toBeVisible();
|
||||
},
|
||||
};
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user