## Summary - fall back to the existing scoped `RELEASE_MANAGER_GATE_TOKEN` when `SERVER_UPDATE_TOKEN` is absent - record the exact frontend SHA through the release-gate endpoint, then independently read it back - preserve the legacy dedicated-token path when it is configured - carry the scoped credential and exact run-attempt build ID through normal releases, rollback recovery, and restore-on-failure ## Dependency Depends on backend PR copenhagentruckwash/api#342 being merged and deployed before this PR is merged. ## Verification - focused release-gate updater test: 1 passed - direct exact-SHA update/readback execution passed - ESLint passed for changed JavaScript/tests - Prettier passed for both workflows and changed JavaScript/tests - Node syntax and `git diff --check` passed The existing broader cPanel release test is also updated; the local cached dependency set cannot collect that file because `jszip` is absent, so protected CI remains the full-suite authority.
41 lines
1.5 KiB
JavaScript
41 lines
1.5 KiB
JavaScript
import { describe, expect, it, vi } from "vitest";
|
|
|
|
import { updateServerVersion } from "../../scripts/release/update-server-version.mjs";
|
|
|
|
describe("release gate server version proof", () => {
|
|
it("uses the scoped release gate and independently reads back the exact full SHA", async () => {
|
|
const version = "b".repeat(40);
|
|
const calls = [];
|
|
const fetchImpl = vi.fn(async (url, options) => {
|
|
calls.push({ url: String(url), options });
|
|
return new Response(JSON.stringify({ data: { version } }));
|
|
});
|
|
|
|
const result = await updateServerVersion(
|
|
{
|
|
RELEASE_MANAGER_GATE_TOKEN: "release-gate-token",
|
|
RELEASE_VERSION_UPDATE_REQUIRED: "true",
|
|
RELEASE_VERSION: version,
|
|
RELEASE_BUILD_ID: "30818161014-2",
|
|
GITHUB_REPOSITORY: "copenhagentruckwash/pleno-vue",
|
|
SERVER_UPDATE_URL: "https://api.example.test/release/gate/frontend-version",
|
|
SERVER_VERSION_READ_URL: "https://api.example.test/release/gate/frontend-version",
|
|
},
|
|
fetchImpl
|
|
);
|
|
|
|
expect(result.observed).toBe(version);
|
|
expect(calls).toHaveLength(2);
|
|
expect(calls[0].options.method).toBe("POST");
|
|
expect(calls[0].options.headers.Authorization).toBe("Bearer release-gate-token");
|
|
expect(JSON.parse(calls[0].options.body)).toEqual({
|
|
version,
|
|
repository: "copenhagentruckwash/pleno-vue",
|
|
branch: "master",
|
|
build_id: "30818161014-2",
|
|
});
|
|
expect(calls[1].options.method).toBe("GET");
|
|
expect(calls[1].url).toContain("/release/gate/frontend-version?verify=");
|
|
});
|
|
});
|