Skip to content

Commit b6cd3c6

Browse files
authored
test(tooling): use value fixtures for mobile release renderers (#134293)
1 parent ce097a1 commit b6cd3c6

2 files changed

Lines changed: 24 additions & 74 deletions

File tree

‎test/scripts/android-version.test.ts‎

Lines changed: 7 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -208,74 +208,39 @@ describe("gateway version normalization", () => {
208208

209209
describe("renderAndroidVersionProperties", () => {
210210
it("renders checked-in defaults from the pinned Android version", () => {
211-
const rootDir = writeAndroidFixture({
212-
version: "2026.6.2",
211+
const properties = renderAndroidVersionProperties({
212+
canonicalVersion: "2026.6.2",
213213
versionCode: 2026060201,
214214
});
215-
const version = resolveAndroidVersion(rootDir);
216215

217-
expect(renderAndroidVersionProperties(version)).toContain(
218-
"OPENCLAW_ANDROID_VERSION_NAME=2026.6.2",
219-
);
220-
expect(renderAndroidVersionProperties(version)).toContain(
221-
"OPENCLAW_ANDROID_VERSION_CODE=2026060201",
222-
);
216+
expect(properties).toContain("OPENCLAW_ANDROID_VERSION_NAME=2026.6.2");
217+
expect(properties).toContain("OPENCLAW_ANDROID_VERSION_CODE=2026060201");
223218
});
224219
});
225220

226221
describe("renderAndroidReleaseNotes", () => {
227222
it("extracts exact pinned-version notes before Unreleased notes", () => {
228-
const rootDir = writeAndroidFixture({
229-
version: "2026.6.2",
230-
versionCode: 2026060201,
231-
changelog: [
232-
"# OpenClaw Android Changelog",
233-
"",
234-
"## Unreleased",
235-
"",
236-
"Future Android changes.",
237-
"",
238-
"## 2026.6.2 - 2026-06-02",
239-
"",
240-
"Pinned Android release notes.",
241-
"",
242-
].join("\n"),
243-
});
244-
const version = resolveAndroidVersion(rootDir);
245-
246223
expect(
247224
renderAndroidReleaseNotes(
248-
version,
225+
{ canonicalVersion: "2026.6.2" },
249226
"# OpenClaw Android Changelog\n\n## Unreleased\n\nFuture Android changes.\n\n## 2026.6.2 - 2026-06-02\n\nPinned Android release notes.\n",
250227
),
251228
).toBe("Pinned Android release notes.\n");
252229
});
253230

254231
it("falls back to Unreleased notes while iterating on a release train", () => {
255-
const rootDir = writeAndroidFixture({
256-
version: "2026.6.2",
257-
versionCode: 2026060201,
258-
});
259-
const version = resolveAndroidVersion(rootDir);
260-
261232
expect(
262233
renderAndroidReleaseNotes(
263-
version,
234+
{ canonicalVersion: "2026.6.2" },
264235
"# OpenClaw Android Changelog\n\n## Unreleased\n\nPending Android notes.\n",
265236
),
266237
).toBe("Pending Android notes.\n");
267238
});
268239

269240
it("rejects changelogs without exact-version or Unreleased notes", () => {
270-
const rootDir = writeAndroidFixture({
271-
version: "2026.6.2",
272-
versionCode: 2026060201,
273-
});
274-
const version = resolveAndroidVersion(rootDir);
275-
276241
expect(() =>
277242
renderAndroidReleaseNotes(
278-
version,
243+
{ canonicalVersion: "2026.6.2" },
279244
"# OpenClaw Android Changelog\n\n## 2026.6.1\n\nOld notes.\n",
280245
),
281246
).toThrow("Unable to find Android changelog notes for 2026.6.2");

‎test/scripts/ios-version.test.ts‎

Lines changed: 17 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -298,9 +298,11 @@ describe("gateway version normalization", () => {
298298

299299
describe("release note extraction", () => {
300300
it("requires exact App Store version notes and adds the gateway association", () => {
301-
const rootDir = writeIosFixture({
302-
packageVersion: "2026.7.2",
303-
changelog: `# OpenClaw iOS Changelog
301+
const version = resolveIosVersion(".", {
302+
appStoreRevision: 1,
303+
releaseVersion: "2026.7.2",
304+
});
305+
const changelog = `# OpenClaw iOS Changelog
304306
305307
## Unreleased
306308
@@ -309,39 +311,28 @@ Draft notes.
309311
## 2026.7.21
310312
311313
- App Store revision notes.
312-
`,
313-
});
314-
const version = resolveIosVersion(rootDir, {
315-
appStoreRevision: 1,
316-
releaseVersion: "2026.7.2",
317-
});
318-
const changelog = fs.readFileSync(path.join(rootDir, "apps", "ios", "CHANGELOG.md"), "utf8");
314+
`;
319315

320316
expect(renderIosReleaseNotes(version, changelog)).toBe(
321317
"Gateway version: 2026.7.2\n\n- App Store revision notes.\n",
322318
);
323319
});
324320

325321
it("does not fall back to gateway or Unreleased notes for App Store revisions", () => {
326-
const rootDir = writeIosFixture({
327-
packageVersion: "2026.7.2",
328-
changelog: "# OpenClaw iOS Changelog\n\n## Unreleased\n\nDraft notes.\n",
329-
});
330-
const version = resolveIosVersion(rootDir, {
322+
const version = resolveIosVersion(".", {
331323
appStoreRevision: 1,
332324
releaseVersion: "2026.7.2",
333325
});
334-
const changelog = fs.readFileSync(path.join(rootDir, "apps", "ios", "CHANGELOG.md"), "utf8");
326+
const changelog = "# OpenClaw iOS Changelog\n\n## Unreleased\n\nDraft notes.\n";
335327

336328
expect(() => renderIosReleaseNotes(version, changelog)).toThrow(
337329
"Unable to find iOS changelog notes for 2026.7.21",
338330
);
339331
});
340332

341333
it("extracts exact pinned version sections first", () => {
342-
const rootDir = writeIosFixture({
343-
packageVersion: "2026.4.6",
344-
changelog: `# OpenClaw iOS Changelog
334+
const version = resolveIosVersion(".", { releaseVersion: "2026.4.6" });
335+
const changelog = `# OpenClaw iOS Changelog
345336
346337
## Unreleased
347338
@@ -350,31 +341,25 @@ Draft notes.
350341
## 2026.4.6
351342
352343
- Exact release notes.
353-
`,
354-
});
355-
const version = resolveIosVersion(rootDir);
356-
const changelog = fs.readFileSync(path.join(rootDir, "apps", "ios", "CHANGELOG.md"), "utf8");
344+
`;
357345

358346
expect(renderIosReleaseNotes(version, changelog)).toBe("- Exact release notes.\n");
359347
});
360348

361349
it("falls back to Unreleased when the release section does not exist yet", () => {
362-
const rootDir = writeIosFixture({
363-
packageVersion: "2026.4.6",
364-
changelog: `# OpenClaw iOS Changelog
350+
const version = resolveIosVersion(".", { releaseVersion: "2026.4.6" });
351+
const changelog = `# OpenClaw iOS Changelog
365352
366353
## Unreleased
367354
368355
### Added
369356
370357
- New iOS feature.
371-
`,
372-
});
373-
const version = resolveIosVersion(rootDir);
374-
const changelog = fs.readFileSync(path.join(rootDir, "apps", "ios", "CHANGELOG.md"), "utf8");
358+
`;
359+
const notes = renderIosReleaseNotes(version, changelog);
375360

376-
expect(renderIosReleaseNotes(version, changelog)).toContain("### Added");
377-
expect(renderIosReleaseNotes(version, changelog)).toContain("- New iOS feature.");
361+
expect(notes).toContain("### Added");
362+
expect(notes).toContain("- New iOS feature.");
378363
});
379364

380365
it("extracts markdown bodies without the version heading", () => {

0 commit comments

Comments
 (0)