Open in Google Play Console deep-links the app: Play developer id per credential profile (accounts play-developer, desktop Accounts), shared playAppUrl builder for desktop, CLI and watch; developer chooser instead of the console root
This commit is contained in:
parent
7c769c18f4
commit
4a74989a95
33 changed files with 311 additions and 40 deletions
|
|
@ -33,7 +33,7 @@ describe('console-links', () => {
|
|||
|
||||
test('fallbacks: app list / developer chooser; reused verified shapes', () => {
|
||||
expect(consoleUrl('asc.age-rating', {})).toBe('https://appstoreconnect.apple.com/apps');
|
||||
expect(consoleUrl('play.data-safety', {})).toBe('https://play.google.com/console');
|
||||
expect(consoleUrl('play.data-safety', {})).toBe('https://play.google.com/console/u/0/developers');
|
||||
expect(consoleUrl('play.data-safety', { playDeveloperId: IDS.playDeveloperId })).toBe(`https://play.google.com/console/u/0/developers/${IDS.playDeveloperId}/app-list`);
|
||||
expect(consoleUrl('play.dashboard', IDS)).toBe(`https://play.google.com/console/u/0/developers/${IDS.playDeveloperId}/app/${IDS.playAppId}/app-dashboard`);
|
||||
expect(consoleUrl('play.content-rating', IDS)).toEndWith('/app-content/content-rating-overview');
|
||||
|
|
|
|||
55
tests/play-ids.test.ts
Normal file
55
tests/play-ids.test.ts
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
// Play Console deep links of one app: the link builder (playAppUrl) and where the ids come from (play-ids.ts).
|
||||
import { describe, expect, test } from 'bun:test';
|
||||
import { mkdtempSync, writeFileSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
import { PLAY_DEVELOPERS, pickConsoleId, playAppUrl } from '../cli/lib/console-links';
|
||||
import { rememberedPlay, resolvePlayIds } from '../cli/lib/play-ids';
|
||||
|
||||
const DEV = '5550000000000000001', APP = '4970000000000000002';
|
||||
|
||||
describe('playAppUrl', () => {
|
||||
test('both ids: the app dashboard', () => {
|
||||
expect(playAppUrl({ developerId: DEV, appId: APP })).toBe(`https://play.google.com/console/u/0/developers/${DEV}/app/${APP}/app-dashboard`);
|
||||
});
|
||||
test('developer id only: that developer\'s app list', () => {
|
||||
expect(playAppUrl({ developerId: DEV })).toBe(`https://play.google.com/console/u/0/developers/${DEV}/app-list`);
|
||||
});
|
||||
test('nothing known: the developer chooser, never the console root', () => {
|
||||
expect(playAppUrl({})).toBe(PLAY_DEVELOPERS);
|
||||
expect(playAppUrl({ appId: APP })).toBe(PLAY_DEVELOPERS);
|
||||
expect(playAppUrl({ developerId: 'abc' })).toBe(PLAY_DEVELOPERS);
|
||||
expect(playAppUrl({})).not.toBe('https://play.google.com/console');
|
||||
});
|
||||
});
|
||||
|
||||
describe('resolvePlayIds', () => {
|
||||
test('order: config > workspace > profile > remembered', () => {
|
||||
expect(resolvePlayIds({ config: { developerId: '1' }, workspace: '2', profile: '3', remembered: { developerId: '4' } }).developerId).toBe('1');
|
||||
expect(resolvePlayIds({ workspace: '2', profile: '3', remembered: { developerId: '4' } }).developerId).toBe('2');
|
||||
expect(resolvePlayIds({ profile: '3', remembered: { developerId: '4' } }).developerId).toBe('3');
|
||||
expect(resolvePlayIds({ remembered: { developerId: '4' } }).developerId).toBe('4');
|
||||
expect(resolvePlayIds({})).toEqual({ developerId: null, appId: null });
|
||||
});
|
||||
test('non-digit values are skipped, never guessed', () => {
|
||||
expect(resolvePlayIds({ config: { developerId: 'x1' }, profile: ` ${DEV} ` }).developerId).toBe(DEV);
|
||||
expect(pickConsoleId('', null, undefined, '12a')).toBeNull();
|
||||
});
|
||||
test('app id: config, then the remembered one', () => {
|
||||
expect(resolvePlayIds({ config: { appId: APP }, remembered: { appId: '9' } }).appId).toBe(APP);
|
||||
expect(resolvePlayIds({ remembered: { appId: '9' } }).appId).toBe('9');
|
||||
});
|
||||
});
|
||||
|
||||
describe('rememberedPlay', () => {
|
||||
test('reads console-accounts.json per package; missing / broken file = {}', () => {
|
||||
const dir = mkdtempSync(join(tmpdir(), 'sb-playids-'));
|
||||
const f = join(dir, 'console-accounts.json');
|
||||
expect(rememberedPlay('com.example.app', f)).toEqual({});
|
||||
writeFileSync(f, JSON.stringify({ version: 1, play: { 'com.example.app': { developerId: DEV, account: 'Example', at: '2026-10-01' } } }));
|
||||
expect(rememberedPlay('com.example.app', f)).toEqual({ developerId: DEV, appId: undefined });
|
||||
expect(rememberedPlay('com.example.other', f)).toEqual({});
|
||||
writeFileSync(f, '{nope');
|
||||
expect(rememberedPlay('com.example.app', f)).toEqual({});
|
||||
});
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue