test(coding-agent): fix git-update tests to use setPackages

Tests used setExtensionPaths but update() iterates packages, not
extensions. All 5 non-pinned tests were silently passing as no-ops.

Also add regression test for scope-aware update behavior.
This commit is contained in:
Aliou Diallo 2026-02-01 21:43:46 +01:00 committed by Mario Zechner
parent cafe12b79e
commit 7f78c383c9

View file

@ -98,8 +98,8 @@ describe("DefaultPackageManager git update", () => {
git(["config", "user.email", "test@test.com"], installedDir);
git(["config", "user.name", "Test"], installedDir);
// Add to settings so update() only processes this scope
settingsManager.setExtensionPaths([gitSource]);
// Add to global packages so update() processes this source
settingsManager.setPackages([gitSource]);
}
describe("normal updates (no force-push)", () => {
@ -207,7 +207,7 @@ describe("DefaultPackageManager git update", () => {
const initialCommit = getCurrentCommit(installedDir);
// Reconfigure with pinned ref
settingsManager.setExtensionPaths([`${gitSource}@${initialCommit}`]);
settingsManager.setPackages([`${gitSource}@${initialCommit}`]);
// Add new commit to remote
createCommit(remoteDir, "extension.ts", "// v2", "Second commit");
@ -220,4 +220,25 @@ describe("DefaultPackageManager git update", () => {
expect(getFileContent(installedDir, "extension.ts")).toBe("// v1");
});
});
describe("scope-aware update", () => {
it("should not install locally when source is only registered globally", async () => {
setupRemoteAndInstall();
// Add a new commit to remote
createCommit(remoteDir, "extension.ts", "// v2", "Second commit");
// The project-scope install path should not exist before or after update
const projectGitDir = join(tempDir, ".pi", "git", "github.com", "test", "extension");
expect(existsSync(projectGitDir)).toBe(false);
await packageManager.update(gitSource);
// Global install should be updated
expect(getFileContent(installedDir, "extension.ts")).toBe("// v2");
// Project-scope directory should NOT have been created
expect(existsSync(projectGitDir)).toBe(false);
});
});
});