Merge remote-tracking branch 'origin/main' into fix-scan-accounts

This commit is contained in:
CRTkafa 2026-10-11 18:03:08 +00:00
commit dc52eaa923
12 changed files with 1190 additions and 1380 deletions

View file

@ -0,0 +1,90 @@
// Store double for the teaser's CLI scenes (tests/teaser.test.ts): loaded with `preload` from a bunfig.toml in a temp
// project, so every `bun cli/index.ts …` started there (and the children `release plan` starts) answers from here and
// never reaches the network. It answers in the shapes App Store Connect and Google Play use (sanitized: placeholder
// ids only) for a brand-new app record of the placeholder project:
// TEASER_STORE=new the app record exists, nothing else: no version, no build, no listings, no products
// TEASER_STORE=catalog the two products of the teaser project exist on both stores, priced in every region
// Regions: the App Store's 175 storefronts (ALPHA3 in cli/lib/money.ts); Google Play the same list without mainland
// China (Play is not offered there), 174 regions, the count Play answered in a recorded read-only run
// (tests/play-post-reads.test.ts). Pages under https://example.com/ (the template's privacy policy and
// delete-account URLs) answer 200; any other request answers 599 with its URL.
import { ALPHA3, toMoney } from '../../cli/lib/money';
import { CURRENCY } from '../../cli/lib/ppp';
const STATE = process.env.TEASER_STORE ?? 'new';
const APP = '6400000101';
const ASC = 'https://api.appstoreconnect.apple.com';
const json = (o: unknown, status = 200): Response => new Response(JSON.stringify(o), { status, headers: { 'content-type': 'application/json' } });
const list = (data: unknown[], included: unknown[] = []): Response => json({ data, included, links: {}, meta: { paging: { total: data.length, limit: 200 } } });
/** The teaser project's products (the config in tests/teaser.test.ts): id, Apple type, US price. */
const PRODUCTS = [
{ id: 'com.example.app.no_ads', type: 'NON_CONSUMABLE', usd: 2.99 },
{ id: 'com.example.app.gems_100', type: 'CONSUMABLE', usd: 0.99 },
];
const APPLE_REGIONS = Object.keys(ALPHA3);
const PLAY_REGIONS = APPLE_REGIONS.filter(r => r !== 'CN');
/** One price per product everywhere (the values are not shown; the same price on both stores, so no parity gaps). */
const currency = (r: string): string => CURRENCY[r] ?? 'USD';
function apple(m: string, p: string): Response {
if (/^\/v1\/apps\?filter\[bundleId\]=/.test(p)) return list([{ type: 'apps', id: APP, attributes: { name: 'Example App', bundleId: decodeURIComponent(p.split('=')[1]!), primaryLocale: 'en-US', sku: 'EXAMPLE' } }]);
if (p.startsWith(`/v1/apps/${APP}/appInfos`)) return list([{ type: 'appInfos', id: 'info-1', attributes: { appStoreState: 'PREPARE_FOR_SUBMISSION', state: 'PREPARE_FOR_SUBMISSION' } }]);
if (STATE === 'catalog') {
if (p.startsWith(`/v1/apps/${APP}/inAppPurchasesV2`)) return list(PRODUCTS.map((x, i) => ({ type: 'inAppPurchases', id: `iap-${i}`, attributes: { productId: x.id, name: x.id.split('.').pop(), inAppPurchaseType: x.type, state: 'READY_TO_SUBMIT' } })));
const loc = p.match(/^\/v2\/inAppPurchases\/iap-\d\/inAppPurchaseLocalizations/);
if (loc) return list(['en-US', 'tr'].map((locale, i) => ({ type: 'inAppPurchaseLocalizations', id: `loc-${i}`, attributes: { locale, name: 'Example', description: 'Example.' } })));
const sched = p.match(/^\/v2\/inAppPurchases\/(iap-\d)\/iapPriceSchedule/);
if (sched) return json({ data: { type: 'inAppPurchasePriceSchedules', id: sched[1] } });
const prices = p.match(/^\/v1\/inAppPurchasePriceSchedules\/iap-(\d)\/(manualPrices|automaticPrices)/);
if (prices) {
const x = PRODUCTS[Number(prices[1])]!;
// US is the base territory (manual); every other storefront is equalized by Apple (automatic)
const regions = prices[2] === 'manualPrices' ? ['US'] : APPLE_REGIONS.filter(r => r !== 'US');
const data = regions.map(r => ({ type: 'inAppPurchasePrices', id: `price-${r}`, attributes: { startDate: null, endDate: null, manual: r === 'US' },
relationships: { inAppPurchasePricePoint: { data: { type: 'inAppPurchasePricePoints', id: `point-${r}` } }, territory: { data: { type: 'territories', id: ALPHA3[r] } } } }));
const included = regions.flatMap(r => [
{ type: 'inAppPurchasePricePoints', id: `point-${r}`, attributes: { customerPrice: String(x.usd), proceeds: String(x.usd * 0.85) } },
{ type: 'territories', id: ALPHA3[r], attributes: { currency: currency(r) } },
]);
return list(data, included);
}
if (/^\/v1\/inAppPurchasePriceSchedules\/iap-\d\/baseTerritory/.test(p)) return json({ data: { type: 'territories', id: 'USA', attributes: { currency: 'USD' } } });
}
if (m === 'GET') return list([]);
return json({ errors: [{ status: '599', detail: `teaser store double: no route for ${m} ${p}` }] }, 599);
}
function play(m: string, url: string): Response {
if (m === 'POST' && /\/edits$/.test(url)) return json({ id: 'edit-1', expiryTimeSeconds: '9999999999' });
if (m === 'DELETE') return new Response(null, { status: 204 });
if (/\/edits\/edit-1\/tracks$/.test(url)) return json({ kind: 'androidpublisher#tracksListResponse', tracks: [] });
if (/\/edits\/edit-1\/listings$/.test(url)) return json({ kind: 'androidpublisher#listingsListResponse' });
if (m === 'POST' && /\/pricing:convertRegionPrices$/.test(url)) return json({
convertedRegionPrices: Object.fromEntries(PLAY_REGIONS.map(r => [r, { regionCode: r, price: toMoney(currency(r), 1.99), taxAmount: toMoney(currency(r), 0) }])),
convertedOtherRegionsPrice: { usdPrice: toMoney('USD', 1.99), eurPrice: toMoney('EUR', 1.99) },
regionVersion: { version: '2022/02' },
});
const product = (x: (typeof PRODUCTS)[number]) => ({
packageName: 'com.example.app', productId: x.id,
listings: [{ languageCode: 'en-US', title: 'Example', description: 'Example.' }, { languageCode: 'tr-TR', title: 'Example', description: 'Example.' }],
purchaseOptions: [{ purchaseOptionId: 'buy', state: 'ACTIVE', buyOption: { legacyCompatible: true },
regionalPricingAndAvailabilityConfigs: PLAY_REGIONS.map(r => ({ regionCode: r, availability: 'AVAILABLE', price: toMoney(currency(r), x.usd) })) }],
});
if (/\/oneTimeProducts\?pageSize=/.test(url)) return json(STATE === 'catalog' ? { oneTimeProducts: PRODUCTS.map(product) } : {});
const one = url.match(/\/oneTimeProducts\/([^/?]+)$/);
if (one) { const x = PRODUCTS.find(p => p.id === decodeURIComponent(one[1]!)); return x && STATE === 'catalog' ? json(product(x)) : json({ error: { code: 404, message: 'not found', status: 'NOT_FOUND' } }, 404); }
if (/\/subscriptions\?pageSize=/.test(url)) return json({});
if (m === 'GET') return json({});
return json({ error: { code: 599, message: `teaser store double: no route for ${m} ${url}` } }, 599);
}
globalThis.fetch = (async (input: string | URL | Request, init?: RequestInit) => {
const url = String(input instanceof Request ? input.url : input);
const m = (init?.method ?? (input instanceof Request ? input.method : 'GET')).toUpperCase();
if (url.startsWith('https://oauth2.googleapis.com/token')) return json({ access_token: 'ya29.example', expires_in: 3600 });
if (url.startsWith(ASC)) return apple(m, url.slice(ASC.length));
if (url.startsWith('https://androidpublisher.googleapis.com/')) return play(m, url);
if (url.startsWith('https://example.com/')) return new Response('<!doctype html><title>Example</title><p>Example page.</p>', { status: 200, headers: { 'content-type': 'text/html' } });
return new Response(`teaser store double: no route for ${m} ${url}`, { status: 599 });
}) as typeof fetch;

View file

@ -1,140 +1,184 @@
// The teaser video (media/teaser): the scan text it shows is the real `storebound scan` output of the teaser fixtures,
// every cut sits on the beat grid, every caption is short and stays readable, every scene holds long enough.
import { beforeAll, describe, expect, test } from 'bun:test';
import { mkdirSync, mkdtempSync, rmSync, writeFileSync } from 'node:fs';
// The teaser video (media/teaser, v5): every CLI line it shows is real output of the command it names, each scene holds
// 4-5 s, each caption is fully on screen for at least 3 s, the whole cut is 38-46 s, and it is 16:9 only.
import { afterAll, beforeAll, describe, expect, test } from 'bun:test';
import { generateKeyPairSync } from 'node:crypto';
import { mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
import { tmpdir } from 'node:os';
import { join } from 'node:path';
import { ALPHA3 } from '../cli/lib/money';
import { SIZES } from '../cli/shots/lib';
const ROOT = join(import.meta.dir, '..');
const CLI = join(ROOT, 'cli', 'index.ts');
const FX = join(import.meta.dir, 'fixtures', 'scan');
const MOCK = join(import.meta.dir, 'helpers', 'teaser-store-mock.ts');
interface Scene { id: string; from: number; to: number; start: number; end: number; in: string | null }
interface Finding { sev: string; guideline: string; title: string; where: string; fix: string; skill: string }
interface Scene { id: string; start: number; end: number }
interface Teaser {
BEAT: number; DURATION: number; SCENES: Scene[];
FORMAT: { w: number; h: number }; DURATION: number; SCENES: Scene[]; DISSOLVE: number;
CAPTIONS: { id: string; lines: string[] }[];
captionTimes(): { id: string; words: string; count: number; at: number; from: number; to: number; hold: number }[];
SCAN_HEAD: { text: string }[]; SDKS: { name: string; what: string; dep: string; where: string }[];
RISKS_LINE: string; FINDINGS: Finding[]; RESCAN_LINE: string; RESCAN_NONE: string;
DECL_LINES: { what: string; value: string; where: string }[]; DECL_ASK: string; CMD: string;
MORE: { at: number; cmd: string; lines: string[]; stat: { text: string } }[]; MORE_CUTS: number[];
captionTimes(): { id: string; text: string; at: number; from: number; to: number; hold: number }[];
TODO: { text: string }[]; MAIL: { at: number; subject: string; guideline: string }; MAIL_IN: number;
INIT_CMD: string; INIT_LINES: string[];
PLAN_CMD: string; PLAN_LINES: string[]; PLAN_STEPS: number; PLAN_PILL: string;
COPY_FILE: string; COPY: { lang: string; title: string[] }[]; SHOT_SIZES: { id: string }[]; SHOT_LANGS: string[]; SHOTS_PILL: string;
PRODUCT_LINES: { text: string; cmd?: boolean }[]; PRODUCTS_PILL: { text: string };
DECL_LINES: { what: string; value: string; where: string }[]; DECL_ASK: string; DECL_TOTAL: number;
SCAN_CMD: string; RISKS_LINE: string; RESCAN_LINE: string;
FINDINGS: { sev: string; guideline: string; title: string; where: string; why: string }[];
}
const path: string = join(ROOT, 'media/teaser/script.js');
const T = (await import(path)) as Teaser;
const T = (await import(join(ROOT, 'media/teaser/script.js'))) as Teaser;
const scanText = (dir: string, demo: boolean): string => {
const env = { ...process.env, NO_COLOR: '1', REVIEW_DEMO_USER: demo ? 'demo@example.com' : '', REVIEW_DEMO_PASSWORD: demo ? 'example' : '' };
const r = Bun.spawnSync(['bun', CLI, 'scan', '--dir', join(FX, dir)], { env, stdout: 'pipe', stderr: 'pipe' });
// exit code 1 when blockers are found (the fixture before the fixes), 0 after
expect(r.exitCode).toBe(demo ? 0 : 1);
return r.stdout.toString() + r.stderr.toString();
/** Output lines without the clock prefix and the "(0s)" timer, as the video shows them. */
const lines = (out: string): string[] => out.split('\n').map(l => l.replace(/^\d\d:\d\d:\d\d /, '').replace(/ \(\d+s\)$/, '').trimEnd());
const run = (argv: string[], cwd: string, env: Record<string, string> = {}): { code: number; out: string } => {
const r = Bun.spawnSync(['bun', CLI, ...argv], { cwd, env: { ...process.env, NO_COLOR: '1', ASC_KEY_ID: '', ASC_ISSUER_ID: '', ASC_P8: '', PLAY_SERVICE_ACCOUNT: '', ...env }, stdout: 'pipe', stderr: 'pipe' });
return { code: r.exitCode, out: r.stdout.toString() + r.stderr.toString() };
};
let before = '', after = '';
beforeAll(() => { before = scanText('teaser', false); after = scanText('teaser-fixed', true); });
/** Runs a CLI command as the montage shows it (`storebound …` -> bun cli/index.ts …), offline, no store keys. */
const run = (cmd: string, cwd: string): string => {
const env = { ...process.env, NO_COLOR: '1', ASC_KEY_ID: '', ASC_ISSUER_ID: '', ASC_P8: '', PLAY_SERVICE_ACCOUNT: '' };
const r = Bun.spawnSync(['bun', CLI, ...cmd.replace(/^storebound /, '').split(' ')], { cwd, env, stdout: 'pipe', stderr: 'pipe' });
expect(r.exitCode, cmd).toBe(0);
return r.stdout.toString() + r.stderr.toString();
};
/** A throwaway Capacitor project with an example.com config (as in tests/build-sign.test.ts) for `play build --dry`. */
function buildProject(): string {
const d = mkdtempSync(join(tmpdir(), 'sb-teaser-'));
const put = (f: string, body = ''): void => { mkdirSync(join(d, f, '..'), { recursive: true }); writeFileSync(join(d, f), body); };
put('storebound.config.ts', `export default { app: { name: 'Example', privacyPolicyUrl: 'https://example.com/p', supportUrl: 'https://example.com', website: 'https://example.com', contactEmail: 'hi@example.com' },
languages: [{ id: 'en', apple: 'en-US', play: 'en-US' }], apple: { bundleId: 'com.example.game' }, play: { packageName: 'com.example.game' } };\n`);
put('capacitor.config.ts', 'export default {}');
put('android/settings.gradle'); put('android/gradlew', '#!/bin/sh'); put('android/app/build.gradle');
return d;
}
// One throwaway project for the init, plan and products scenes: `storebound init` in an empty folder, store answers
// from the teaser store double (tests/helpers/teaser-store-mock.ts, preloaded through bunfig.toml), placeholder keys.
let dir = '', initOut = '', keys: Record<string, string> = {};
beforeAll(() => {
dir = mkdtempSync(join(tmpdir(), 'sb-teaser-'));
initOut = run(['init'], dir).out;
writeFileSync(join(dir, 'bunfig.toml'), `preload = [${JSON.stringify(MOCK)}]\n`);
const ec = generateKeyPairSync('ec', { namedCurve: 'P-256' }).privateKey.export({ type: 'pkcs8', format: 'pem' }).toString();
const rsa = generateKeyPairSync('rsa', { modulusLength: 2048 }).privateKey.export({ type: 'pkcs8', format: 'pem' }).toString();
writeFileSync(join(dir, 'k.p8'), ec);
writeFileSync(join(dir, 'sa.json'), JSON.stringify({ client_email: 'sb@example.com', private_key: rsa, token_uri: 'https://oauth2.googleapis.com/token' }));
keys = { ASC_KEY_ID: 'ABCDE12345', ASC_ISSUER_ID: '00000000-0000-0000-0000-000000000000', ASC_P8: join(dir, 'k.p8'), PLAY_SERVICE_ACCOUNT: join(dir, 'sa.json') };
});
afterAll(() => rmSync(dir, { recursive: true, force: true }));
describe('teaser: the CLI montage is real output', () => {
test('three panels, two cuts on the beat', () => {
expect(T.MORE).toHaveLength(3);
expect(T.MORE_CUTS).toEqual([T.MORE[1]!.at, T.MORE[2]!.at]);
const s = T.SCENES.find(x => x.id === 'more')!;
expect(T.MORE[0]!.at).toBe(s.start);
for (const t of T.MORE_CUTS) { expect(t).toBeGreaterThan(s.start); expect(t).toBeLessThan(s.end); }
describe('teaser: every CLI line is real output', () => {
test('init: `storebound init` in an empty folder', () => {
expect(T.INIT_CMD).toBe('bunx storebound init');
const out = lines(initOut);
for (const l of T.INIT_LINES) expect(out, l).toContain(l);
});
test('`storebound api coverage`: the operation counts (revision dates left out)', () => {
const p = T.MORE[0]!;
expect(p.cmd).toBe('storebound api coverage');
const out = run(p.cmd, ROOT).replace(/ \(\d{8}\)/g, '');
for (const l of p.lines) expect(out).toContain(l);
const ops = (name: string): number => Number(out.match(new RegExp(`${name}[^:\n]*: (\\d+) operations`))![1]);
const apple = ops('App Store Connect API'), play = ops('Google Play Android Developer API') + ops('Google Play Developer Reporting API');
expect(p.stat.text).toBe(`*${apple}* App Store Connect + *${play}* Google Play endpoints`);
test('plan: `storebound release plan 1.0.0` against a brand-new app record on both stores', () => {
expect(T.PLAN_CMD).toBe('storebound release plan 1.0.0');
const r = run(T.PLAN_CMD.split(' ').slice(1), dir, { ...keys, TEASER_STORE: 'new' });
const out = lines(r.out);
for (const l of T.PLAN_LINES) expect(out, l).toContain(l);
// the lines keep the order of the real plan
const idx = T.PLAN_LINES.map(l => out.indexOf(l));
expect([...idx].sort((a, b) => a - b)).toEqual(idx);
const steps = out.filter(l => /^\s+\d+\. /.test(l)).length;
expect(steps).toBe(T.PLAN_STEPS);
expect(T.PLAN_PILL).toStartWith(`*${steps}* steps`);
expect(r.out).not.toContain('could not be read');
});
test('`storebound play build --dry`: the plan (clock and [build] prefix left out, the gradle flags trimmed)', () => {
const p = T.MORE[1]!;
expect(p.cmd).toStartWith('storebound play build --dry');
const d = buildProject();
test('products: `play products --dry` before, `catalog diff` after, with two products in the config', () => {
const cfg = join(dir, 'storebound.config.ts');
const src = readFileSync(cfg, 'utf8');
writeFileSync(cfg, src.replace(' dataSafety: {', ` products: [
{ id: 'com.example.app.no_ads', type: 'non_consumable', usd: 2.99, listings: { en: { title: 'No Ads', description: 'Removes every ad.' }, tr: { title: 'Reklamsız', description: 'Tüm reklamları kaldırır.' } } },
{ id: 'com.example.app.gems_100', type: 'consumable', usd: 0.99, listings: { en: { title: '100 Gems', description: 'A pouch of 100 gems.' }, tr: { title: '100 Mücevher', description: '100 mücevherlik bir kese.' } } },
],
dataSafety: {`));
try {
const out = run(p.cmd, d).split('\n').map(l => l.replace(/^\d\d:\d\d:\d\d \[build\] /, '').replace(/ \(\d+s\)$/, ''));
for (const l of p.lines) expect(out.some(o => o.startsWith(l)), l).toBe(true);
} finally { rmSync(d, { recursive: true, force: true }); }
const cmds = T.PRODUCT_LINES.filter(l => l.cmd).map(l => l.text.replace(/^\$ storebound /, ''));
expect(cmds).toEqual(['play products --dry', 'catalog diff']);
const before = run(cmds[0]!.split(' '), dir, { ...keys, TEASER_STORE: 'new' });
const after = run(cmds[1]!.split(' '), dir, { ...keys, TEASER_STORE: 'catalog' });
expect(before.code).toBe(0);
expect(after.code).toBe(0);
const out = [...lines(before.out), ...lines(after.out)];
for (const l of T.PRODUCT_LINES.filter(x => !x.cmd)) expect(out, l.text).toContain(l.text);
// the pill's numbers are the region counts above, and the App Store's 175 storefronts
expect(Object.keys(ALPHA3)).toHaveLength(175);
expect(T.PRODUCTS_PILL.text).toContain('*175* App Store regions');
expect(T.PRODUCTS_PILL.text).toContain('*174* Google Play regions');
expect(out.join('\n')).toContain('0 mismatch(es), 0 warning(s), 0 price difference(s)');
} finally { writeFileSync(cfg, src); }
});
test('`storebound console fill apple-app-privacy --dry` in examples/demo-app: answer lines (source column left out)', () => {
const p = T.MORE[2]!;
expect(p.cmd).toBe('storebound console fill apple-app-privacy --dry');
const out = run(p.cmd, join(ROOT, 'examples/demo-app')).split('\n').map(l => l.trim().replace(/\s+\([^()]*\)$/, ''));
for (const l of p.lines) expect(out).toContain(l);
expect(out.join('\n')).toContain('press Publish yourself');
test('forms: the Data safety answer count of `storebound check`', () => {
expect(run(['check'], dir).out).toContain(`data safety: ${T.DECL_TOTAL} CSV rows`);
});
});
describe('teaser: the scan text is real', () => {
test('command, header, SDKs and the risks line come from `storebound scan` of tests/fixtures/scan/teaser', () => {
expect(T.CMD).toBe('storebound scan');
for (const l of T.SCAN_HEAD) expect(before).toContain(l.text);
for (const s of T.SDKS) expect(before).toMatch(new RegExp(`${s.name}\\s+${s.what.replace(/[()]/g, '\\$&')} · ${s.dep} \\(${s.where}\\)`));
const scanText = (fixture: string, demo: boolean): string => {
const env = { REVIEW_DEMO_USER: demo ? 'demo@example.com' : '', REVIEW_DEMO_PASSWORD: demo ? 'example' : '' };
const r = run(['scan', '--dir', join(FX, fixture)], ROOT, env);
expect(r.code).toBe(demo ? 0 : 1); // exit 1 on blockers (before the fixes)
return r.out;
};
let before = '', after = '';
beforeAll(() => { before = scanText('teaser', false); after = scanText('teaser-fixed', true); });
test('rejections: the risks line and three findings (severity, guideline, title, file:line)', () => {
expect(T.SCAN_CMD).toBe('storebound scan');
expect(before).toContain(T.RISKS_LINE);
});
test('the five findings: severity, guideline, title, file:line, a verbatim piece of the fix, the skill', () => {
expect(T.FINDINGS).toHaveLength(5);
const blocks = before.split(/\n\s+\d\. /).slice(1);
T.FINDINGS.forEach((f, i) => {
const b = blocks[i]!;
expect(b.startsWith(`${f.sev.padEnd(7)} ${f.guideline} · App Store · ${f.title}`)).toBe(true);
expect(b).toContain(`at ${f.where}`);
expect(b).toContain(`skill: ${f.skill}`);
expect(b.match(/fix: (.*)/)![1]).toContain(f.fix);
});
for (const f of T.FINDINGS) {
const b = blocks.find(x => x.startsWith(`${f.sev.padEnd(7)} ${f.guideline} · App Store · ${f.title}`));
expect(b, f.title).toBeDefined();
expect(b!).toContain(`at ${f.where}`);
// the plain reason is an annotation, short enough to read
expect(f.why.split(' ').length, f.why).toBeLessThanOrEqual(10);
}
});
test('declarations proposal lines', () => {
test('rejections: the re-scan after the fixes (tests/fixtures/scan/teaser-fixed) is clean', () => {
expect(after).toContain(T.RESCAN_LINE);
});
test('forms: the declarations proposal lines and the ask-owner line', () => {
for (const d of T.DECL_LINES) expect(before).toContain(`detected ${d.what}: ${d.value}`);
for (const d of T.DECL_LINES) expect(before).toContain(`(${d.where})`);
expect(before).toContain(T.DECL_ASK);
});
test('the re-scan after the fixes (tests/fixtures/scan/teaser-fixed, demo account in the environment) is clean', () => {
expect(after).toContain(T.RESCAN_LINE);
expect(after).toContain(T.RESCAN_NONE);
});
describe('teaser: the store text and screenshots are the demo game\'s', () => {
test('copy: the hero title per language from examples/demo-game/store/shots/copy.json', () => {
const copy = JSON.parse(readFileSync(join(ROOT, 'examples/demo-game', T.COPY_FILE), 'utf8')) as Record<string, { hero: { title: string[] } }>;
for (const c of T.COPY) expect(c.title).toEqual(copy[c.lang]!.hero.title);
expect(T.SHOT_LANGS).toEqual(T.COPY.map(c => c.lang));
});
test('sizes: seven store sizes the demo game renders (iPhone, iPad, Play phone and tablets, feature graphic)', () => {
for (const s of T.SHOT_SIZES) expect(SIZES[s.id], s.id).toBeDefined();
expect(T.SHOT_SIZES).toHaveLength(7);
expect(T.SHOTS_PILL).toBe(`*7* sizes × *${T.COPY.length}* languages`);
expect(T.TODO.map(x => x.text)).toContain('7 screenshot sizes × 14 languages');
expect(T.TODO.map(x => x.text)).toContain('prices in 175 countries');
});
});
describe('teaser: timing', () => {
const near = (x: number): boolean => Math.abs(x / T.BEAT - Math.round(x / T.BEAT)) < 1e-9;
test('scenes are contiguous, cover the video and cut on the beat', () => {
describe('teaser: timing and format', () => {
test('16:9 only: the master is 1920x1080; the pipeline has no vertical output', () => {
expect(T.FORMAT).toEqual({ w: 1920, h: 1080 });
const render = readFileSync(join(ROOT, 'media/teaser/render.ts'), 'utf8');
expect(render).not.toMatch(/1080\s*x\s*1920|w: 1080, h: 1920|vertical/i);
expect(render).toContain('scale=1280:720');
});
test('scenes are contiguous, 4-5 s each, 38-46 s in total', () => {
expect(T.SCENES[0]!.start).toBe(0);
for (let i = 1; i < T.SCENES.length; i++) expect(T.SCENES[i]!.start).toBe(T.SCENES[i - 1]!.end);
expect(T.SCENES.at(-1)!.end).toBeCloseTo(T.DURATION, 9);
for (const s of T.SCENES) expect(near(s.start), s.id).toBe(true);
expect(T.DURATION).toBeGreaterThan(29);
expect(T.DURATION).toBeLessThan(38);
});
test('every scene holds at least 2.5 s', () => {
for (const s of T.SCENES) expect(s.end - s.start, s.id).toBeGreaterThanOrEqual(2.5);
});
test('captions: at most 7 words, fully on screen for at least 1.2 s, never overlapping', () => {
const c = T.captionTimes();
expect(c).toHaveLength(T.CAPTIONS.length);
for (const x of c) {
expect(x.count, x.words).toBeLessThanOrEqual(7);
expect(x.hold, x.words).toBeGreaterThanOrEqual(1.2);
for (const s of T.SCENES) {
expect(s.end - s.start, s.id).toBeGreaterThanOrEqual(4);
expect(s.end - s.start, s.id).toBeLessThanOrEqual(5);
}
for (let i = 1; i < c.length; i++) expect(c[i]!.at).toBeGreaterThanOrEqual(c[i - 1]!.to);
expect(T.DURATION).toBe(T.SCENES.at(-1)!.end);
expect(T.DURATION).toBeGreaterThanOrEqual(38);
expect(T.DURATION).toBeLessThanOrEqual(46);
});
test('one caption per scene, fully on screen for at least 3 s, inside its scene', () => {
const c = T.captionTimes();
expect(c.map(x => x.id)).toEqual(T.SCENES.map(s => s.id));
for (const x of c) {
const s = T.SCENES.find(y => y.id === x.id)!;
expect(x.hold, x.text).toBeGreaterThanOrEqual(3);
expect(x.at).toBeGreaterThanOrEqual(s.start);
expect(x.to).toBeLessThanOrEqual(s.end);
}
});
test('the rejection mail holds at least 2 s before the first cut', () => {
expect(T.SCENES[0]!.end - T.MAIL.at - T.MAIL_IN).toBeGreaterThanOrEqual(2);
expect(T.MAIL.guideline).toStartWith('Guideline 2.1');
});
});