дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-05 17:47:08 +02:00
* feat(github): align GitHub Issues tool window with Pull Requests * fix(github): deduplicate issue account reload, bind refresh keymap, and refine #number UX
195 рядки
8.1 KiB
TypeScript
195 рядки
8.1 KiB
TypeScript
import type { GhProjectAccountStatus } from "../src/bindings";
|
|
import { expect, stubDesktop, test } from "./fixtures";
|
|
|
|
test("GitHub Issues matches Pull Requests header, search chips, rows, and context menu", async ({
|
|
workbench: page,
|
|
}) => {
|
|
await page.setViewportSize({ width: 1280, height: 840 });
|
|
await stubDesktop(page);
|
|
await page.evaluate(() => {
|
|
const now = new Date().toISOString();
|
|
const yesterday = new Date(Date.now() - 86_400_000).toISOString();
|
|
const status: GhProjectAccountStatus = {
|
|
ghInstalled: true,
|
|
accounts: [
|
|
{ login: "l0ng-ai", active: true },
|
|
{ login: "l0ng-work", active: false },
|
|
],
|
|
configuredAccount: "",
|
|
effectiveAccount: "l0ng-ai",
|
|
suggestedAccount: null,
|
|
};
|
|
const issues = [
|
|
{
|
|
id: "I8139",
|
|
url: "https://github.com/l0ng-ai/openidea/issues/8139",
|
|
number: 8139,
|
|
title: "编辑器:跳到下一个匹配项后,Ctrl+V 无法覆盖当前匹配项",
|
|
state: "OPEN",
|
|
createdAt: yesterday,
|
|
updatedAt: now,
|
|
author: { __typename: "User", id: "U2", login: "alextrevisan", url: "", avatarUrl: "", name: null },
|
|
labels: { nodes: [{ id: "L1", url: "", name: "bug", color: "d73a4a" }] },
|
|
assignees: { nodes: [] },
|
|
comments: { totalCount: 2 },
|
|
},
|
|
{
|
|
id: "I8133",
|
|
url: "https://github.com/l0ng-ai/openidea/issues/8133",
|
|
number: 8133,
|
|
title: "Flatpak support",
|
|
state: "OPEN",
|
|
createdAt: yesterday,
|
|
updatedAt: yesterday,
|
|
author: { __typename: "User", id: "U3", login: "charli117", url: "", avatarUrl: "", name: null },
|
|
labels: { nodes: [{ id: "L2", url: "", name: "enhancement", color: "a2eeef" }] },
|
|
assignees: { nodes: [] },
|
|
comments: { totalCount: 0 },
|
|
},
|
|
{
|
|
id: "I8050",
|
|
url: "https://github.com/l0ng-ai/openidea/issues/8050",
|
|
number: 8050,
|
|
title: "Select Opened File in External Libraries",
|
|
state: "CLOSED",
|
|
createdAt: yesterday,
|
|
updatedAt: yesterday,
|
|
author: { __typename: "User", id: "U4", login: "wildcatDownstairs", url: "", avatarUrl: "", name: null },
|
|
labels: { nodes: [] },
|
|
assignees: { nodes: [] },
|
|
comments: { totalCount: 5 },
|
|
},
|
|
];
|
|
const prs = [
|
|
{
|
|
id: "PR7822",
|
|
url: "https://github.com/l0ng-ai/openidea/pull/7822",
|
|
number: 7822,
|
|
title: "feat(run): choose the run device from plugin device providers",
|
|
state: "OPEN",
|
|
isDraft: true,
|
|
createdAt: yesterday,
|
|
updatedAt: yesterday,
|
|
isReadByViewer: true,
|
|
author: { __typename: "User", id: "U2", login: "alextrevisan", url: "", avatarUrl: "", name: null },
|
|
assignees: { nodes: [] },
|
|
labels: { nodes: [{ id: "L2", url: "", name: "enhancement", color: "a2eeef" }] },
|
|
reviewRequests: { nodes: [] },
|
|
reviewThreads: { nodes: [] },
|
|
reviews: { nodes: [] },
|
|
reactions: { nodes: [], pageInfo: { hasNextPage: false, endCursor: null } },
|
|
mergeable: "MERGEABLE",
|
|
viewerCanUpdate: false,
|
|
viewerCanReact: false,
|
|
viewerDidAuthor: false,
|
|
},
|
|
];
|
|
Object.assign(window.__ipc.handlers, {
|
|
settings_get_global: () => ({}),
|
|
vcs_roots: () => [{ root: "/dev/openidea", name: "openidea", branch: "main" }],
|
|
vcs_remotes: () => [{ name: "origin", url: "https://github.com/l0ng-ai/openidea.git", resolvedUrl: null }],
|
|
gh_project_account_status: () => status,
|
|
gh_availability: () => ({
|
|
kind: "ready",
|
|
login: "l0ng-ai",
|
|
repo: { nameWithOwner: "l0ng-ai/openidea", url: "https://github.com/l0ng-ai/openidea" },
|
|
}),
|
|
gh_api: ({ request }: { request: { endpoint: string; body?: string | null } }) => {
|
|
if (request.endpoint === "user") return JSON.stringify({ login: "l0ng-ai", id: 1 });
|
|
const parsed = request.body
|
|
? (JSON.parse(request.body) as { query?: string; variables?: { query?: string } })
|
|
: {};
|
|
const q = parsed.variables?.query ?? "";
|
|
if (q.startsWith("type:issue")) {
|
|
const filtered = q.includes("is:closed")
|
|
? issues.filter((i) => i.state === "CLOSED")
|
|
: q.includes("is:open")
|
|
? issues.filter((i) => i.state === "OPEN")
|
|
: issues;
|
|
return JSON.stringify({
|
|
data: {
|
|
search: {
|
|
pageInfo: { startCursor: null, endCursor: null, hasNextPage: false, hasPreviousPage: false },
|
|
nodes: filtered,
|
|
},
|
|
},
|
|
});
|
|
}
|
|
if (q.startsWith("type:pr")) {
|
|
return JSON.stringify({
|
|
data: {
|
|
search: {
|
|
pageInfo: { startCursor: null, endCursor: null, hasNextPage: false, hasPreviousPage: false },
|
|
nodes: prs,
|
|
},
|
|
},
|
|
});
|
|
}
|
|
return JSON.stringify({
|
|
data: {
|
|
repository: {
|
|
id: "R1",
|
|
owner: { __typename: "User", id: "O1", login: "l0ng-ai" },
|
|
nameWithOwner: "l0ng-ai/openidea",
|
|
viewerPermission: "WRITE",
|
|
mergeCommitAllowed: true,
|
|
squashMergeAllowed: true,
|
|
rebaseMergeAllowed: true,
|
|
defaultBranchRef: { name: "main" },
|
|
isFork: false,
|
|
url: "https://github.com/l0ng-ai/openidea",
|
|
sshUrl: "[email protected]:l0ng-ai/openidea.git",
|
|
},
|
|
viewer: {
|
|
__typename: "User",
|
|
id: "U1",
|
|
login: "l0ng-ai",
|
|
url: "https://github.com/l0ng-ai",
|
|
avatarUrl: "",
|
|
name: null,
|
|
},
|
|
},
|
|
});
|
|
},
|
|
});
|
|
});
|
|
|
|
// Open Pull Requests first (baseline comparison)
|
|
await page.evaluate(async () => {
|
|
const contributions = "/src/workbench/contributions.ts";
|
|
const { toolWindowService } = await import(/* @vite-ignore */ contributions);
|
|
toolWindowService().show("pullRequests", true);
|
|
});
|
|
await expect(page.getByRole("textbox", { name: "Search pull requests" })).toBeVisible();
|
|
await expect(page.getByText("feat(run): choose the run device from plugin device providers")).toBeVisible();
|
|
|
|
// Switch to GitHub Issues
|
|
await page.evaluate(async () => {
|
|
const contributions = "/src/workbench/contributions.ts";
|
|
const { toolWindowService } = await import(/* @vite-ignore */ contributions);
|
|
toolWindowService().show("githubIssues", true);
|
|
});
|
|
await expect(page.getByRole("textbox", { name: "Search issues" })).toBeVisible();
|
|
await expect(page.getByRole("tab", { name: "openidea" })).toBeVisible();
|
|
await expect(page.getByRole("button", { name: "@l0ng-ai" })).toBeVisible();
|
|
await expect(page.getByRole("button", { name: "Author" })).toBeVisible();
|
|
await expect(page.getByRole("button", { name: "Label" })).toBeVisible();
|
|
await expect(page.getByRole("button", { name: "Assignee" })).toBeVisible();
|
|
await expect(page.getByRole("button", { name: "Sort" })).toBeVisible();
|
|
await expect(page.getByText("Flatpak support")).toBeVisible();
|
|
await expect(page.getByText(/^#8133 · created .+, by charli117$/)).toBeVisible();
|
|
|
|
// Clear State chip → closed issue appears with CLOSED pill
|
|
await page.getByRole("button", { name: "Reset State" }).click();
|
|
await expect(page.getByText("Select Opened File in External Libraries")).toBeVisible();
|
|
await expect(page.getByText("CLOSED", { exact: true })).toBeVisible();
|
|
|
|
// Right-click menu
|
|
await page.getByRole("option", { name: /Flatpak support/ }).click({ button: "right" });
|
|
await expect(page.getByRole("menuitem", { name: "View Issue", exact: true })).toBeVisible();
|
|
await expect(page.getByRole("menuitem", { name: "Create Branch from Issue…", exact: true })).toBeVisible();
|
|
await expect(page.getByRole("menuitem", { name: "View Issue in Browser", exact: true })).toBeVisible();
|
|
await expect(page.getByRole("menuitem", { name: "Copy Issue URL", exact: true })).toBeVisible();
|
|
await expect(page.getByRole("menuitem", { name: "Refresh List", exact: true })).toBeVisible();
|
|
});
|