play-publish-changes: a release is ready only when the store page shows an older version; unknown reads are not determined, never a mismatch

This commit is contained in:
CRTkafa 2026-10-24 12:12:37 +08:00
parent 4e2ffd6b3d
commit 26f9559e1a
6 changed files with 40 additions and 15 deletions

View file

@ -7,7 +7,7 @@ import { consoleAnswers, PLAN_FORM_IDS, PLAN_ONLY_FORM_IDS } from '../cli/lib/co
import { declarationSaveAllowed, flowAllowed, forbiddenControl, formDef, forbiddenTick, publishingControl } from '../cli/lib/console-forms';
import { consolePlan, IN_PAGE_LOOP, playConsoleReminders, planText } from '../cli/lib/console-plan';
import { APP_CONTENT_CARDS, PLAY_MATERIAL_FACT, startLabel } from '../cli/lib/console-play-plans';
import { readyLines, readyToPublish } from '../cli/lib/play-publish';
import { readyLines, readyToPublish, readyUndetermined } from '../cli/lib/play-publish';
import { appPrivacyPublished, verifyPublishChangesApi, verifyAppContent, verifyPlayDeclaration, verifyText } from '../cli/lib/console-verify';
import { CONSOLE_PLAN_FORMS, TOOLS, validateInput } from '../cli/mcp-tools';
import { playRules, type PlaySnapshot } from '../cli/lib/validate-rules';
@ -343,11 +343,19 @@ describe('the first production release: countries, managed publishing, the owner
test('publish changes: ready = managed + completed production the store page does not show; verify by API and by page text', () => {
const tracks = [{ track: 'production', releases: [{ name: '2.0.0 (45)', versionCodes: ['45'], status: 'completed' }] }];
const ready = readyToPublish({ tracks, publicPage: { state: 'notPublic' }, managedPublishing: true });
expect(ready).toEqual([{ track: 'production', version: '2.0.0', build: '45', rollout: 'full rollout', liveVersion: null }]);
expect(readyToPublish({ tracks, publicPage: { state: 'notPublic' }, managedPublishing: false })).toEqual([]);
const ready = readyToPublish({ tracks, publicPage: { state: 'public', versionName: '1.9.0' }, managedPublishing: true });
expect(ready).toEqual([{ track: 'production', version: '2.0.0', build: '45', rollout: 'full rollout', liveVersion: '1.9.0' }]);
expect(readyToPublish({ tracks, publicPage: { state: 'public', versionName: '1.9.0' }, managedPublishing: false })).toEqual([]);
expect(readyToPublish({ tracks, publicPage: { state: 'public', versionName: '2.0.0' }, managedPublishing: true })).toEqual([]);
expect(readyToPublish({ tracks, publicPage: { state: 'public', versionName: '1.9.0' }, managedPublishing: true })[0]!.liveVersion).toBe('1.9.0');
// already published (real case: 2.0.0 / 2000001 full rollout, "Last published on ..."): never ready, whatever the page says
const live = [{ track: 'production', releases: [{ name: '2.0.0 (2000001)', versionCodes: ['2000001'], status: 'completed' }] }];
for (const publicPage of [{ state: 'public', versionName: '2.0.0' }, { state: 'public', versionName: '2.1.0' }, { state: 'public', versionName: null }, { state: 'public', varies: true }, { state: 'notPublic' }, { state: 'unknown' }, { state: 'public', versionName: '1.9.0', stale: true, checkedAt: '2026-10-24T00:00:00Z' }]) {
expect({ publicPage, ready: readyToPublish({ tracks: live, publicPage, managedPublishing: true }) }).toEqual({ publicPage, ready: [] });
}
const unk = Object.assign([], { undetermined: readyUndetermined({ tracks: live, publicPage: { state: 'notPublic' }, managedPublishing: true }) });
expect(unk.undetermined).toBe(true);
expect(verifyPublishChangesApi(unk).ok).toBe(true);
expect(verifyPublishChangesApi(unk).rows[0]!.seen).toContain('not determined');
expect(readyLines(ready).join('\n')).toContain('storebound console plan play-publish-changes');
expect(readyLines([])).toEqual([]);
expect(verifyPublishChangesApi(ready).ok).toBe(false);