fix(e2e): escape Windows stale update import regex (#75315) thanks @steipete

Fix the Windows stale-import guard regex used by the Parallels npm update smoke path, with related maintainer-flow and regression-test cleanup preserved on a verified branch.
This commit is contained in:
clawsweeper[bot]
2026-05-02 19:10:44 -05:00
committed by GitHub
parent f30dc0aeb4
commit afe42fc977
11 changed files with 220 additions and 55 deletions

View File

@@ -28,10 +28,21 @@ describe("check-changelog-attributions", () => {
});
it("keeps PR changelog gates on the same attribution policy", () => {
const commonLib = readFileSync("scripts/pr-lib/common.sh", "utf8");
const changelogLib = readFileSync("scripts/pr-lib/changelog.sh", "utf8");
const gates = readFileSync("scripts/pr-lib/gates.sh", "utf8");
const mergeLib = readFileSync("scripts/pr-lib/merge.sh", "utf8");
const prepareCore = readFileSync("scripts/pr-lib/prepare-core.sh", "utf8");
expect(commonLib).toContain("pr_contributor_allows_human_trailers");
expect(commonLib).toContain("resolve_contributor_coauthor_email");
expect(changelogLib).toContain("node scripts/check-changelog-attributions.mjs CHANGELOG.md");
expect(changelogLib).toContain("changelog_thanks_required_for_contributor");
expect(changelogLib).toContain('"app/"*');
expect(changelogLib).toContain('"clawsweeper"');
expect(gates).toContain("validate_changelog_attribution_policy");
expect(prepareCore).toContain("resolve_contributor_coauthor_email");
expect(mergeLib).toContain("pr_contributor_allows_human_trailers");
expect(mergeLib).toContain("Skipping PR author co-author trailer check for bot/app author");
});
});

View File

@@ -1,8 +1,16 @@
import { readFileSync } from "node:fs";
import { describe, expect, it } from "vitest";
import { windowsUpdateScript } from "../../scripts/e2e/parallels/npm-update-scripts.ts";
const SCRIPT_PATH = "scripts/e2e/parallels/npm-update-smoke.ts";
const UPDATE_SCRIPTS_PATH = "scripts/e2e/parallels/npm-update-scripts.ts";
const TEST_AUTH = {
authChoice: "openai",
authKeyFlag: "--openai-api-key",
apiKeyEnv: "OPENAI_API_KEY",
apiKeyValue: "test-key",
modelId: "gpt-5.4",
};
describe("parallels npm update smoke", () => {
it("does not leave guard/server children attached to the wrapper", () => {
@@ -49,4 +57,33 @@ describe("parallels npm update smoke", () => {
);
expect(script).toContain("OPENCLAW_DISABLE_BUNDLED_PLUGINS=1 openclaw gateway stop");
});
it("generates a .NET-safe Windows stale import regex in the update-failure guard", () => {
const script = windowsUpdateScript({
auth: TEST_AUTH,
expectedNeedle: "2026.4.30",
updateTarget: "latest",
});
const staleImportLine = script.match(/\$stalePostSwapImport = [^\n]+/)?.[0];
const staleImportMatch = script.match(/\$updateText -match '(node_modules[^']+)'/);
const staleImportPattern = staleImportMatch?.[1];
if (!staleImportLine) {
throw new Error("missing generated Windows stale import guard");
}
if (!staleImportPattern) {
throw new Error("missing generated Windows stale import regex");
}
expect(staleImportLine).toContain("$updateText -match 'ERR_MODULE_NOT_FOUND'");
expect(staleImportLine).toContain(`$updateText -match '${staleImportPattern}'`);
expect(staleImportPattern).toBe(
String.raw`node_modules\\openclaw\\dist\\[^\\]+-[A-Za-z0-9_-]+\.js`,
);
expect(staleImportPattern).not.toContain("node_modules\\openclaw\\dist\\");
expect(staleImportPattern.match(/\\\\/g)).toHaveLength(4);
const representativeUpdateFailure = String.raw`Error [ERR_MODULE_NOT_FOUND]: Cannot find module 'C:\Users\runner\AppData\Roaming\npm\node_modules\openclaw\dist\main-a1_B2.js' imported from C:\Users\runner\AppData\Roaming\npm\node_modules\openclaw\dist\cli.js`;
const generatedRegex = new RegExp(staleImportPattern);
expect(generatedRegex.test(representativeUpdateFailure)).toBe(true);
expect(generatedRegex.test(String.raw`node_modules\openclaw\dist\main.js`)).toBe(false);
});
});