дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-03 16:51:16 +02:00
A Package sources panel lists NuGet sources and adds, enables, disables or removes them through dotnet nuget, writing to a chosen NuGet.Config under the workspace or the user-wide file. Edits go only to the config file that defines a source, stale work is cancelled when the project or selection changes, and URL credentials are redacted from errors. CI installs SDK 10 and 11 for the real-CLI tests. Co-authored-by: wildcatDownstairs <[email protected]>
96 рядки
3.3 KiB
TypeScript
96 рядки
3.3 KiB
TypeScript
/**
|
|
* A stubbed `dotnet` process host for the NuGet window specs. No CLI runs: `window.__dotnetOut`
|
|
* (set by the spec) answers each argument list, and a thrown message becomes a non-zero exit.
|
|
* The real-CLI vitest tests (`src/features/dotnet/*.cli.test.ts`) are the evidence for what
|
|
* `dotnet` actually does; these specs check the UI and the exact commands it starts.
|
|
*/
|
|
import type { Locator, Page } from "@playwright/test";
|
|
import { stubDesktop } from "./fixtures";
|
|
|
|
declare global {
|
|
interface Window {
|
|
__runs: string[][];
|
|
__dotnetOut: (args: string[]) => string;
|
|
}
|
|
}
|
|
|
|
/** One project, `/dev/acme/src/App/App.csproj`, in the workspace rooted at `/dev/acme`. */
|
|
export const PROJECT = "/dev/acme/src/App/App.csproj";
|
|
|
|
export async function installDotnetHost(page: Page) {
|
|
await stubDesktop(page);
|
|
await page.evaluate(
|
|
async ({ project }) => {
|
|
window.__runs = [];
|
|
window.__dotnetOut = () => "";
|
|
let id = 100;
|
|
window.__ipc.handlers.run_start = (args) => {
|
|
const config = args.config as { args: string[] };
|
|
window.__runs.push(config.args);
|
|
const run = ++id;
|
|
setTimeout(() => {
|
|
let text: string;
|
|
let code = 0;
|
|
try {
|
|
text = window.__dotnetOut(config.args);
|
|
} catch (e) {
|
|
text = (e as Error).message;
|
|
code = 1;
|
|
}
|
|
window.__ipc.send(args.onOutput, { kind: "stdout", text });
|
|
window.__ipc.emit({ type: "runExited", run, code });
|
|
}, 20);
|
|
return { id: run, configId: "x", name: "dotnet", pid: 1, running: true, pty: false };
|
|
};
|
|
const dotnetStore = "/src/features/dotnet/store.ts";
|
|
const projectStore = "/src/platform/project.ts";
|
|
const { useDotnet } = await import(/* @vite-ignore */ dotnetStore);
|
|
const { useProject } = await import(/* @vite-ignore */ projectStore);
|
|
useProject.setState({ project: { ...useProject.getState().project, root: "/dev/acme" } });
|
|
useDotnet.setState({
|
|
model: {
|
|
projects: [
|
|
{
|
|
path: project,
|
|
name: "App",
|
|
frameworks: ["net9.0"],
|
|
configurations: ["Debug"],
|
|
references: [],
|
|
packages: [],
|
|
test: false,
|
|
runner: "vstest",
|
|
adapter: "mstest",
|
|
trx: false,
|
|
},
|
|
],
|
|
solutions: [],
|
|
},
|
|
selected: project,
|
|
framework: "net9.0",
|
|
});
|
|
},
|
|
{ project: PROJECT },
|
|
);
|
|
}
|
|
|
|
export const dotnetRuns = (page: Page) => page.evaluate(() => window.__runs);
|
|
|
|
/** Opens the NuGet Packages tool window through its action. */
|
|
export async function openNuget(page: Page) {
|
|
await page.evaluate(async () => {
|
|
const actions = "/src/platform/actions.ts";
|
|
const { executeAction } = await import(/* @vite-ignore */ actions);
|
|
await executeAction("dotnet.packages");
|
|
});
|
|
}
|
|
|
|
const SHOTS = process.env.E2E_SHOTS;
|
|
/** With `E2E_SHOTS` set: a screenshot of the NuGet Packages window scrolled to `focus` (fixture data only). */
|
|
export async function shot(page: Page, name: string, focus: Locator) {
|
|
if (!SHOTS) return;
|
|
await focus.scrollIntoViewIfNeeded();
|
|
await page
|
|
.locator('section[aria-label="NuGet Packages"]')
|
|
.screenshot({ path: `${SHOTS}/${name}.png`, animations: "disabled" });
|
|
}
|