diff --git a/scripts/lib/portable-package.mjs b/scripts/lib/portable-package.mjs index 7f7afb6..20e8aaa 100644 --- a/scripts/lib/portable-package.mjs +++ b/scripts/lib/portable-package.mjs @@ -208,7 +208,7 @@ async function waitForHealth(child) { 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-")); try { const escapedZip = zipPath.replaceAll("'", "''"); @@ -235,22 +235,36 @@ async function verifyExtractedPackage(zipPath, packageName, expectedSupport) { }); try { 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`, { body: JSON.stringify({ - brands: [{ brand: expectedSupport.brand, version: String(expectedSupport.major) }], - full_version_list: [{ brand: expectedSupport.brand, version: expectedSupport.fullVersion }], + brands, + full_version_list: fullVersionList, platform: "Windows", }), headers: { "content-type": "application/json", - "sec-ch-ua": `"${expectedSupport.brand}";v="${expectedSupport.major}"`, - "sec-ch-ua-full-version-list": `"${expectedSupport.brand}";v="${expectedSupport.fullVersion}"`, + host: `127.0.0.1:${fixedPort}`, + 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"', }, method: "POST", }); 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 { api: { executable: "runtime/node.exe", health, pid: api.pid, release_gate: { status_code: releaseGate.status }, status: "passed" },