fix(WP7-07): 修正最终包浏览器门禁探测
Dada P0-A isolated Windows CI / validate-and-package (push) Canceled after 0s

This commit is contained in:
suyx
2026-08-04 23:15:36 +08:00
parent 194b59d4a5
commit a22b1f19e9
+20 -6
View File
@@ -208,7 +208,7 @@ async function waitForHealth(child) {
throw new Error("Packaged API did not become healthy on fixed port 43121.", { cause: lastError }); throw new Error("Packaged API did not become healthy on fixed port 43121.", { cause: lastError });
} }
async function verifyExtractedPackage(zipPath, packageName, expectedSupport) { export async function verifyExtractedPackage(zipPath, packageName, expectedSupport) {
const extractRoot = mkdtempSync(join(tmpdir(), "dada-wp0-09-")); const extractRoot = mkdtempSync(join(tmpdir(), "dada-wp0-09-"));
try { try {
const escapedZip = zipPath.replaceAll("'", "''"); const escapedZip = zipPath.replaceAll("'", "''");
@@ -235,22 +235,36 @@ async function verifyExtractedPackage(zipPath, packageName, expectedSupport) {
}); });
try { try {
const health = await waitForHealth(api); const health = await waitForHealth(api);
const brands = [
{ brand: "Not_A Brand", version: "99" },
{ brand: "Chromium", version: String(expectedSupport.major) },
{ brand: expectedSupport.brand, version: String(expectedSupport.major) },
];
const fullVersionList = [
{ brand: "Not_A Brand", version: "99.0.0.0" },
{ brand: "Chromium", version: expectedSupport.fullVersion },
{ brand: expectedSupport.brand, version: expectedSupport.fullVersion },
];
const serializeBrands = (values) => values.map(({ brand, version }) => `"${brand}";v="${version}"`).join(", ");
const releaseGate = await fetch(`http://127.0.0.1:${fixedPort}/api/v1/support/check`, { const releaseGate = await fetch(`http://127.0.0.1:${fixedPort}/api/v1/support/check`, {
body: JSON.stringify({ body: JSON.stringify({
brands: [{ brand: expectedSupport.brand, version: String(expectedSupport.major) }], brands,
full_version_list: [{ brand: expectedSupport.brand, version: expectedSupport.fullVersion }], full_version_list: fullVersionList,
platform: "Windows", platform: "Windows",
}), }),
headers: { headers: {
"content-type": "application/json", "content-type": "application/json",
"sec-ch-ua": `"${expectedSupport.brand}";v="${expectedSupport.major}"`, host: `127.0.0.1:${fixedPort}`,
"sec-ch-ua-full-version-list": `"${expectedSupport.brand}";v="${expectedSupport.fullVersion}"`, origin: `http://127.0.0.1:${fixedPort}`,
"sec-ch-ua": serializeBrands(brands),
"sec-ch-ua-full-version-list": serializeBrands(fullVersionList),
"sec-ch-ua-platform": '"Windows"', "sec-ch-ua-platform": '"Windows"',
}, },
method: "POST", method: "POST",
}); });
if (releaseGate.status !== expectedSupport.statusCode) { if (releaseGate.status !== expectedSupport.statusCode) {
throw new Error(`Packaged RELEASE.json support gate returned ${releaseGate.status}; expected ${expectedSupport.statusCode}.`); const responseBody = await releaseGate.text();
throw new Error(`Packaged RELEASE.json support gate returned ${releaseGate.status}; expected ${expectedSupport.statusCode}: ${responseBody}`);
} }
return { return {
api: { executable: "runtime/node.exe", health, pid: api.pid, release_gate: { status_code: releaseGate.status }, status: "passed" }, api: { executable: "runtime/node.exe", health, pid: api.pid, release_gate: { status_code: releaseGate.status }, status: "passed" },