Skip to content

Commit 6371239

Browse files
committed
Add plugin drawer lifecycle coverage
1 parent 1dba1cd commit 6371239

3 files changed

Lines changed: 45 additions & 0 deletions

File tree

‎apps/web/test/plugins-page.test.tsx‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -654,6 +654,7 @@ describe("PluginsRoute", () => {
654654

655655
// The delete resolved and `onChanged` fired `reloadPlugins`; its fetch
656656
// is now the deferred one above, still pending.
657+
expect(document.body.querySelector('[role="dialog"]')).toBeNull();
657658
expect(el.textContent).not.toContain("Loading plugins…");
658659
expect(el.textContent).toContain("GitHub");
659660

‎packages/plugins-ui/test/plugin-connect-panel.test.tsx‎

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,10 @@ describe("PluginConnectPanel", () => {
337337
const field = container.querySelector(
338338
"#mcp-preset-token-github-mcp",
339339
) as HTMLInputElement;
340+
expect(
341+
container.querySelector(`label[for="${field.id}"]`)?.textContent,
342+
).toContain("Personal access token");
343+
expect(field.autocomplete).toBe("new-password");
340344
const setter = Object.getOwnPropertyDescriptor(
341345
HTMLInputElement.prototype,
342346
"value",

‎packages/plugins-ui/test/plugins-gallery.test.tsx‎

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -329,6 +329,46 @@ describe("PluginsGallery", () => {
329329
).not.toBeNull();
330330
});
331331

332+
test("dismissing a token drawer discards its pasted token before reopening", async () => {
333+
const { container } = await renderGallery();
334+
const connect = container.querySelector(
335+
'[data-plugin-slug="github-mcp"] [aria-label="Connect GitHub MCP"]',
336+
) as HTMLButtonElement;
337+
338+
connect.focus();
339+
act(() => connect.click());
340+
const field = document.body.querySelector(
341+
"#mcp-preset-token-github-mcp",
342+
) as HTMLInputElement;
343+
const setter = Object.getOwnPropertyDescriptor(
344+
HTMLInputElement.prototype,
345+
"value",
346+
)?.set;
347+
await act(async () => {
348+
setter?.call(field, "ghp_unsubmitted");
349+
field.dispatchEvent(new Event("input", { bubbles: true }));
350+
});
351+
expect(field.value).toBe("ghp_unsubmitted");
352+
353+
const close = document.body.querySelector(
354+
'[role="dialog"] [aria-label="Close"]',
355+
) as HTMLButtonElement;
356+
await act(async () => {
357+
close.click();
358+
});
359+
expect(document.body.querySelector('[role="dialog"]')).toBeNull();
360+
expect(document.activeElement).toBe(connect);
361+
362+
act(() => connect.click());
363+
expect(
364+
(
365+
document.body.querySelector(
366+
"#mcp-preset-token-github-mcp",
367+
) as HTMLInputElement
368+
).value,
369+
).toBe("");
370+
});
371+
332372
test("status remains visible as a core field", async () => {
333373
const { container } = await renderGallery();
334374
const caption = [...container.querySelectorAll("span")].find(

0 commit comments

Comments
 (0)