




















1+// iOS Fastlane release gate tests keep TestFlight upload on one canonical path.
2+import { existsSync, readFileSync } from "node:fs";
3+import path from "node:path";
4+import { describe, expect, it } from "vitest";
5+6+const fastfilePath = path.join(process.cwd(), "apps", "ios", "fastlane", "Fastfile");
7+const packageJsonPath = path.join(process.cwd(), "package.json");
8+const legacyReleaseScriptPath = path.join(process.cwd(), "scripts", "ios-release.sh");
9+const uploadScriptPath = path.join(process.cwd(), "scripts", "ios-release-upload.sh");
10+11+function readFastfile(): string {
12+return readFileSync(fastfilePath, "utf8");
13+}
14+15+function laneBody(source: string, name: string): string {
16+const startMarker = `lane :${name} do`;
17+const start = source.indexOf(startMarker);
18+if (start < 0) {
19+throw new Error(`missing Fastlane lane ${name}`);
20+}
21+22+const rest = source.slice(start + startMarker.length);
23+const nextLane = rest.search(/\n\s+(?:desc|lane|private_lane) /);
24+return nextLane < 0 ? rest : rest.slice(0, nextLane);
25+}
26+27+describe("iOS Fastlane release upload gates", () => {
28+it("does not keep the old package release alias", () => {
29+const packageJson = JSON.parse(readFileSync(packageJsonPath, "utf8")) as {
30+scripts?: Record<string, string>;
31+};
32+33+expect(packageJson.scripts).toHaveProperty("ios:release:upload");
34+expect(packageJson.scripts).not.toHaveProperty("ios:release");
35+expect(existsSync(legacyReleaseScriptPath)).toBe(false);
36+});
37+38+it("routes the package upload wrapper through the guarded Fastlane lane", () => {
39+const script = readFileSync(uploadScriptPath, "utf8");
40+41+expect(script).toContain("OPENCLAW_IOS_RELEASE_WRAPPER=1");
42+expect(script).toContain("run_ios_fastlane ios release_upload");
43+});
44+45+it("keeps release_upload as the only Fastlane TestFlight upload implementation", () => {
46+const fastfile = readFastfile();
47+const uploadCalls = fastfile.match(/\bupload_to_testflight\s*\(/g) ?? [];
48+49+expect(uploadCalls).toHaveLength(1);
50+expect(laneBody(fastfile, "release_upload")).toContain("upload_to_testflight(");
51+expect(fastfile).not.toMatch(/\n\s+lane :app_store do\b/);
52+expect(fastfile).not.toContain("Deprecated. Use `pnpm ios:release:upload`.");
53+});
54+55+it("rejects direct Fastlane upload before release work", () => {
56+const fastfile = readFastfile();
57+const releaseUpload = laneBody(fastfile, "release_upload");
58+59+expect(releaseUpload).toContain('ENV["OPENCLAW_IOS_RELEASE_WRAPPER"] == "1"');
60+expect(releaseUpload).toContain("Use `pnpm ios:release:upload`");
61+expect(releaseUpload.indexOf("UI.user_error!")).toBeLessThan(
62+releaseUpload.indexOf("prepare_app_store_context"),
63+);
64+});
65+66+it("validates the exported IPA before the sole TestFlight upload call", () => {
67+const fastfile = readFastfile();
68+const validationCall = fastfile.indexOf("validate_app_store_ipa!(expected_ipa_path)");
69+const uploadCall = fastfile.indexOf("upload_to_testflight(");
70+71+expect(validationCall).toBeGreaterThanOrEqual(0);
72+expect(uploadCall).toBeGreaterThan(validationCall);
73+});
74+});
此内容由惯性聚合(RSS阅读器)自动聚合整理,仅供阅读参考。 原文来自 — 版权归原作者所有。