-
Notifications
You must be signed in to change notification settings - Fork 147
Refine the connect modal's API-key credential UX #1195
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
+193
−20
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,86 @@ | ||
| // Selfhost-only (browser): the connect modal's API-key credential UX. | ||
| // - the credential field MERGES the placement's lead + prefix as an affix, so | ||
| // it reads as the header value being built ("Authorization: Bearer ▏token"); | ||
| // - the "Add authentication method" editor offers placement presets; | ||
| // - a prefix with no trailing space (sent joined to the value) warns, and the | ||
| // warning clears once the space is restored. | ||
| // Video is the artifact. | ||
| import { randomBytes } from "node:crypto"; | ||
|
|
||
| import { Effect } from "effect"; | ||
| import { composePluginApi } from "@executor-js/api/server"; | ||
| import { openApiHttpPlugin } from "@executor-js/plugin-openapi/api"; | ||
| import { IntegrationSlug } from "@executor-js/sdk/shared"; | ||
|
|
||
| import { scenario } from "../src/scenario"; | ||
| import { Api, Browser, Target } from "../src/services"; | ||
|
|
||
| const api = composePluginApi([openApiHttpPlugin()] as const); | ||
|
|
||
| const bearerSpec = (): string => | ||
| JSON.stringify({ | ||
| openapi: "3.0.3", | ||
| info: { title: "Bearer Fixture", version: "1.0.0" }, | ||
| servers: [{ url: "https://api.bearerfix.test" }], | ||
| security: [{ bearerAuth: [] }], | ||
| components: { securitySchemes: { bearerAuth: { type: "http", scheme: "bearer" } } }, | ||
| paths: { | ||
| "/ping": { get: { operationId: "ping", responses: { "200": { description: "ok" } } } }, | ||
| }, | ||
| }); | ||
|
|
||
| scenario( | ||
| "Connect modal · API key credential UX: merged affix, add-method, prefix warning", | ||
| {}, | ||
| Effect.scoped( | ||
| Effect.gen(function* () { | ||
| const target = yield* Target; | ||
| const { client: makeApiClient } = yield* Api; | ||
| const browser = yield* Browser; | ||
| const identity = yield* target.newIdentity(); | ||
| const apiClient = yield* makeApiClient(api, identity); | ||
| const slug = `connect_ux_${randomBytes(4).toString("hex")}`; | ||
|
|
||
| yield* Effect.ensuring( | ||
| Effect.gen(function* () { | ||
| yield* apiClient.openapi.addSpec({ | ||
| payload: { spec: { kind: "blob", value: bearerSpec() }, slug }, | ||
| }); | ||
|
|
||
| yield* browser.session(identity, async ({ page, step }) => { | ||
| await step("Open the connect modal", async () => { | ||
| await page.goto(`/integrations/${slug}?addAccount=1`, { waitUntil: "networkidle" }); | ||
| await page.getByRole("heading", { name: /Add connection/ }).waitFor(); | ||
| }); | ||
|
|
||
| await step("The credential field merges the placement prefix", async () => { | ||
| // The placement's lead + prefix renders as a non-editable affix | ||
| // inside the field, so there is no separate preview line. | ||
| await page.getByText("Authorization: Bearer").first().waitFor(); | ||
| }); | ||
|
|
||
| await step("The add-method editor offers placement presets", async () => { | ||
| await page.getByRole("button", { name: "Add authentication method" }).click(); | ||
| await page.getByRole("heading", { name: "Add authentication method" }).waitFor(); | ||
| await page.getByRole("button", { name: "Bearer header" }).waitFor(); | ||
| await page.getByRole("button", { name: "API key query" }).waitFor(); | ||
| }); | ||
|
|
||
| await step("A prefix with no trailing space warns", async () => { | ||
| await page.getByPlaceholder("Bearer ").first().fill("Bearer"); | ||
| await page.getByText("Prefix has no trailing space").waitFor(); | ||
| }); | ||
|
|
||
| await step("Restoring the trailing space clears the warning", async () => { | ||
| await page.getByPlaceholder("Bearer ").first().fill("Bearer "); | ||
| await page.getByText("Prefix has no trailing space").waitFor({ state: "detached" }); | ||
| }); | ||
| }); | ||
| }), | ||
| apiClient.openapi | ||
| .removeSpec({ params: { slug: IntegrationSlug.make(slug) } }) | ||
| .pipe(Effect.ignore), | ||
| ); | ||
| }), | ||
| ), | ||
| ); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
<input>in the affix branch has no programmatic label. Whenaffixis truthy, no<Label>is rendered and there is noidto associate one with, so screen readers will announce this field with only its type ("password edit") and no description. Adding anaria-labeldirectly on the element covers the gap without altering the visual layout.Note: If this suggestion doesn't match your team's coding style, reply to this and let me know. I'll remember it for next time!