This repository was archived by the owner on Aug 18, 2026. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathios-version.test.ts
More file actions
138 lines (112 loc) · 4.36 KB
/
Copy pathios-version.test.ts
File metadata and controls
138 lines (112 loc) · 4.36 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
import fs from "node:fs";
import path from "node:path";
import { describe, expect, it } from "vitest";
import {
extractChangelogSection,
normalizeGatewayVersionToPinnedIosVersion,
renderIosReleaseNotes,
renderIosVersionXcconfig,
resolveGatewayVersionForIosRelease,
resolveIosVersion,
} from "../../scripts/lib/ios-version.ts";
import { installIosFixtureCleanup, writeIosFixture } from "./ios-version.test-support.ts";
installIosFixtureCleanup();
describe("resolveIosVersion", () => {
it("parses pinned CalVer versions and derives Apple marketing fields", () => {
const rootDir = writeIosFixture({
version: "2026.4.6",
changelog: "# OpenClaw iOS Changelog\n\n## 2026.4.6\n\nStable notes.\n",
});
expect(resolveIosVersion(rootDir)).toMatchObject({
canonicalVersion: "2026.4.6",
marketingVersion: "2026.4.6",
buildVersion: "1",
});
});
it("rejects semver-only versions", () => {
const rootDir = writeIosFixture({
version: "1.2.3",
changelog: "# OpenClaw iOS Changelog\n\n## Unreleased\n\nNotes.\n",
});
expect(() => resolveIosVersion(rootDir)).toThrow("Expected pinned CalVer like 2026.4.6");
});
it("rejects prerelease suffixes in the pinned iOS version file", () => {
const rootDir = writeIosFixture({
version: "2026.4.6-beta.1",
changelog: "# OpenClaw iOS Changelog\n\n## Unreleased\n\nNotes.\n",
});
expect(() => resolveIosVersion(rootDir)).toThrow("Expected pinned CalVer like 2026.4.6");
});
});
describe("gateway version normalization", () => {
it("keeps stable gateway CalVer values", () => {
expect(normalizeGatewayVersionToPinnedIosVersion("2026.4.6")).toBe("2026.4.6");
});
it("strips beta suffixes when pinning from gateway version", () => {
expect(normalizeGatewayVersionToPinnedIosVersion("2026.4.6-beta.2")).toBe("2026.4.6");
});
it("strips fallback correction suffixes when pinning from gateway version", () => {
expect(normalizeGatewayVersionToPinnedIosVersion("2026.4.6-3")).toBe("2026.4.6");
});
it("reads and normalizes the root package version for iOS releases", () => {
const rootDir = writeIosFixture({
version: "2026.4.6",
packageVersion: "2026.4.7-beta.5",
changelog: "# OpenClaw iOS Changelog\n\n## Unreleased\n\nNotes.\n",
});
expect(resolveGatewayVersionForIosRelease(rootDir)).toEqual({
packageVersion: "2026.4.7-beta.5",
pinnedIosVersion: "2026.4.7",
});
});
});
describe("renderIosVersionXcconfig", () => {
it("renders checked-in defaults from the pinned iOS version", () => {
const rootDir = writeIosFixture({
version: "2026.4.8",
changelog: "# OpenClaw iOS Changelog\n\n## 2026.4.8\n\nNotes.\n",
});
const version = resolveIosVersion(rootDir);
expect(renderIosVersionXcconfig(version)).toContain("OPENCLAW_IOS_VERSION = 2026.4.8");
expect(renderIosVersionXcconfig(version)).toContain("OPENCLAW_MARKETING_VERSION = 2026.4.8");
expect(renderIosVersionXcconfig(version)).toContain("OPENCLAW_BUILD_VERSION = 1");
});
});
describe("release note extraction", () => {
it("extracts exact pinned version sections first", () => {
const rootDir = writeIosFixture({
version: "2026.4.6",
changelog: `# OpenClaw iOS Changelog
## Unreleased
Draft notes.
## 2026.4.6
- Exact release notes.
`,
});
const version = resolveIosVersion(rootDir);
const changelog = fs.readFileSync(path.join(rootDir, "apps", "ios", "CHANGELOG.md"), "utf8");
expect(renderIosReleaseNotes(version, changelog)).toBe("- Exact release notes.\n");
});
it("falls back to Unreleased when the release section does not exist yet", () => {
const rootDir = writeIosFixture({
version: "2026.4.6",
changelog: `# OpenClaw iOS Changelog
## Unreleased
### Added
- New iOS feature.
`,
});
const version = resolveIosVersion(rootDir);
const changelog = fs.readFileSync(path.join(rootDir, "apps", "ios", "CHANGELOG.md"), "utf8");
expect(renderIosReleaseNotes(version, changelog)).toContain("### Added");
expect(renderIosReleaseNotes(version, changelog)).toContain("- New iOS feature.");
});
it("extracts markdown bodies without the version heading", () => {
expect(
extractChangelogSection(
`# OpenClaw iOS Changelog\n\n## 2026.4.6 - 2026-04-06\n\nLine one.\n\n## 2026.4.5\n`,
"2026.4.6",
),
).toBe("Line one.");
});
});