flows, listing translate, scan 2.2 + --originality, prices export with subscriptions, site sections
- storebound flow list|validate|run: repo-local workflows (store/workflows/*.yml, storebound.workflows.*), writes dry unless --apply, owner steps never run, --from / --resume; init templates for app and game; MCP flow_list + dry flow_run; release-flows skill - storebound listing translate|check|reviewed: per-language listing drafts with store limits and keyword rules, agent or --translate hook, marked until reviewed; MCP listing_translate / listing_check; listing-localization skill - scan: Apple 2.2 beta/demo/test wording rule; scan --originality [--against] - prices export includes subscriptions; prices import skips their rows - site: rejection scan section, Desktop app section with fixture-mode screenshots, Everything else grid, FAQ 4.3 answer - README, CHANGELOG, adapters, API tables
This commit is contained in:
parent
e44897ca4e
commit
526dfd3b09
45 changed files with 2176 additions and 53 deletions
205
tests/flow.test.ts
Normal file
205
tests/flow.test.ts
Normal file
|
|
@ -0,0 +1,205 @@
|
|||
// storebound flow: the YAML subset, step classification (owner steps never run, writes dry unless --apply), checks,
|
||||
// the plan, and real runs in a temp project (progress, capture, failure and --resume, the init templates).
|
||||
import { afterAll, describe, expect, test } from 'bun:test';
|
||||
import { existsSync, mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
import { classify, evalIf, expand, type Flow, flowsOfFile, parseParams, planStep, resumePoint, splitArgs, startIndex, substitute, toFlow, validateFlows } from '../cli/lib/flow';
|
||||
import { parseYaml } from '../cli/lib/yaml';
|
||||
import { FORBIDDEN_ARGS, TOOLS, toArgv, validateInput } from '../cli/mcp-tools';
|
||||
|
||||
const ROOT = join(import.meta.dir, '..');
|
||||
const CLI = join(ROOT, 'cli', 'index.ts');
|
||||
const tmp = mkdtempSync(join(tmpdir(), 'storebound-flow-'));
|
||||
afterAll(() => rmSync(tmp, { recursive: true, force: true }));
|
||||
const sb = (cwd: string, ...args: string[]) => Bun.spawnSync([process.execPath, CLI, ...args], { cwd, stdout: 'pipe', stderr: 'pipe', stdin: 'ignore' });
|
||||
const C = { apple: true, play: false, exists: (p: string) => p === 'store/whats-new' };
|
||||
const flow = (name: string, steps: unknown[], extra: Record<string, unknown> = {}): Flow => toFlow(name, 'test.yml', { steps, ...extra }).flow!;
|
||||
|
||||
describe('yaml subset', () => {
|
||||
test('maps, lists of maps, lists at the key indentation, scalars, quotes, comments, inline lists, block scalars', () => {
|
||||
const v = parseYaml(`# a flow
|
||||
description: Ship it # trailing comment
|
||||
params:
|
||||
VERSION: "1.0.0"
|
||||
N: 3
|
||||
ON: true
|
||||
steps:
|
||||
- id: a
|
||||
run: apple next-build
|
||||
capture: BUILD
|
||||
- id: b
|
||||
run: 'say "hi" # not a comment'
|
||||
continueOnError: false
|
||||
tags: [one, "two", 3]
|
||||
note: |
|
||||
line one
|
||||
line two
|
||||
fold: >
|
||||
a
|
||||
b
|
||||
`);
|
||||
expect(v).toEqual({ description: 'Ship it', params: { VERSION: '1.0.0', N: 3, ON: true },
|
||||
steps: [{ id: 'a', run: 'apple next-build', capture: 'BUILD' }, { id: 'b', run: 'say "hi" # not a comment', continueOnError: false }],
|
||||
tags: ['one', 'two', 3], note: 'line one\nline two\n', fold: 'a b\n' });
|
||||
expect(parseYaml('steps:\n - id: x\n run: check\n - plain\n')).toEqual({ steps: [{ id: 'x', run: 'check' }, 'plain'] });
|
||||
});
|
||||
test('errors name the line', () => {
|
||||
expect(() => parseYaml('a: 1\na: 2')).toThrow('line 2: "a" twice');
|
||||
expect(() => parseYaml('a:\n\tb: 1')).toThrow('tabs');
|
||||
expect(() => parseYaml('a: {b: 1}')).toThrow('inline maps');
|
||||
expect(() => parseYaml('a: &x 1')).toThrow('anchors');
|
||||
expect(() => parseYaml('a: "open')).toThrow('line 1');
|
||||
});
|
||||
});
|
||||
|
||||
describe('steps', () => {
|
||||
test('classification: reads, writes, waits, owner steps', () => {
|
||||
expect(classify(['validate'])).toBe('read');
|
||||
expect(classify(['release', 'plan', '1.2.0'])).toBe('read');
|
||||
expect(classify(['apple', 'next-build'])).toBe('read');
|
||||
expect(classify(['apple', 'upload', '--no-wait'])).toBe('write');
|
||||
expect(classify(['whats-new', 'apply'])).toBe('write');
|
||||
expect(classify(['apple', 'testflight', 'wait', '--build', '7'])).toBe('wait');
|
||||
for (const owner of [['apple', 'release', '--phased', 'on'], ['play', 'rollout', '--complete'], ['reviews', 'send'], ['prices', 'import'],
|
||||
['apple', 'testflight', 'distribute', '--build', '7', '--group', 'x', '--submit-review'], ['apple', 'iap-submit'], ['apple', 'ppo', 'start'], ['play', 'release', '--production', 'completed']])
|
||||
expect(classify(owner)).toBe('owner');
|
||||
expect(classify(['prices', 'import', '--dry'])).toBe('read');
|
||||
expect(splitArgs(`apple testflight what-to-test --text "New levels, fewer bugs" --build 7`)).toEqual(['apple', 'testflight', 'what-to-test', '--text', 'New levels, fewer bugs', '--build', '7']);
|
||||
});
|
||||
test('plan per mode: writes get --dry unless --apply, owner steps never run, shell only with --apply, if conditions', () => {
|
||||
const vars = { VERSION: '1.2.0', BUILD: '42' };
|
||||
const up = { id: 'upload', run: 'apple upload --no-wait' };
|
||||
expect(planStep(up, 'steps', 'dry', vars, C)).toMatchObject({ kind: 'write', argv: ['apple', 'upload', '--no-wait', '--dry'], dryAdded: true });
|
||||
expect(planStep(up, 'steps', 'apply', vars, C)).toMatchObject({ argv: ['apple', 'upload', '--no-wait'], dryAdded: false });
|
||||
expect(planStep(up, 'steps', 'plan', vars, C).skip).toContain('plan only');
|
||||
expect(planStep({ id: 'w', run: 'apple testflight wait --build ${BUILD}' }, 'steps', 'dry', vars, C).argv).toEqual(['apple', 'testflight', 'wait', '--build', '42', '--dry']);
|
||||
expect(planStep({ id: 'v', run: 'validate' }, 'steps', 'dry', vars, C)).toMatchObject({ argv: ['validate'], dryAdded: false });
|
||||
for (const mode of ['plan', 'dry', 'apply'] as const) {
|
||||
expect(planStep({ id: 'r', run: 'apple release --phased on' }, 'steps', mode, vars, C)).toMatchObject({ kind: 'owner', skip: expect.stringContaining('your click') });
|
||||
expect(planStep({ id: 's', owner: 'Submit ${VERSION}' }, 'steps', mode, vars, C)).toMatchObject({ kind: 'owner', owner: 'Submit 1.2.0' });
|
||||
}
|
||||
expect(planStep({ id: 'sh', sh: 'npm run build' }, 'steps', 'dry', vars, C).skip).toContain('--apply');
|
||||
expect(planStep({ id: 'sh', sh: 'npm run build' }, 'steps', 'apply', vars, C).skip).toBeUndefined();
|
||||
expect(planStep({ id: 'p', run: 'play build', if: 'play' }, 'steps', 'apply', vars, C).skip).toBe('if play: false');
|
||||
expect(planStep({ id: 'n', run: 'whats-new apply', if: 'exists store/whats-new' }, 'steps', 'apply', vars, C).skip).toBeUndefined();
|
||||
});
|
||||
test('conditions, variables, params', () => {
|
||||
expect(evalIf('apple && !play', C)).toBe(true);
|
||||
expect(evalIf('1.2 == 1.2', C)).toBe(true);
|
||||
expect(evalIf('a != a', C)).toBe(false);
|
||||
expect(evalIf('${UNSET}', C)).toBe(false);
|
||||
expect(evalIf('false', C)).toBe(false);
|
||||
expect(substitute('v${VERSION} ${env.HOME_X} ${NOPE}', { VERSION: '2' }, { HOME_X: 'h' })).toBe('v2 h ${NOPE}');
|
||||
expect(parseParams(['VERSION=1.2.0', 'GROUP=a=b'])).toEqual({ VERSION: '1.2.0', GROUP: 'a=b' });
|
||||
expect(() => parseParams(['version=1'])).toThrow('NAME=value');
|
||||
});
|
||||
test('validation: --yes refused, unknown variables, duplicate ids, cycles, unknown commands, storebound prefix', () => {
|
||||
const f = flow('bad', [{ id: 'a', run: 'apple upload --yes' }, { id: 'a', run: 'check ${NOPE}' }, { id: 'c', run: 'storebound check' }, { id: 'd', run: 'frobnicate now' }, { id: 'e', flow: 'loop' }]);
|
||||
const loop = flow('loop', [{ id: 'x', flow: 'bad' }]);
|
||||
const e = validateFlows([f, loop], { commands: new Set(['check', 'apple upload']) }).join('\n');
|
||||
expect(e).toContain('--yes is not allowed');
|
||||
expect(e).toContain('${NOPE} is not a param');
|
||||
expect(e).toContain('id used twice');
|
||||
expect(e).toContain('without "storebound"');
|
||||
expect(e).toContain('"frobnicate now" is not a storebound command');
|
||||
expect(e).toContain('cycle');
|
||||
expect(toFlow('x', 'f.yml', { steps: [{ id: 'a', run: 'check', sh: 'ls' }], extra: 1 }).errors.join()).toContain('exactly one of run, sh, owner, flow');
|
||||
expect(flowsOfFile('w.yml', { flows: { a: { steps: [{ id: 's', run: 'check' }] } } }, null).flows.map(x => x.name)).toEqual(['a']);
|
||||
});
|
||||
test('sub-flows expand with prefixed ids; --from and --resume points', () => {
|
||||
const beta = flow('beta', [{ id: 'build', run: 'apple build' }, { id: 'upload', run: 'apple upload' }], { private: true, params: { GROUP: 'qa' } });
|
||||
const rel = flow('release', [{ id: 'check', run: 'check' }, { id: 'beta', flow: 'beta', if: 'apple' }, { id: 'plan', run: 'release plan 1.0' }]);
|
||||
const all = new Map([['beta', beta], ['release', rel]]);
|
||||
const x = expand(rel, all);
|
||||
expect(x.steps.map(s => s.id)).toEqual(['check', 'beta.build', 'beta.upload', 'plan']);
|
||||
expect(x.steps[1]!.if).toBe('apple');
|
||||
expect(x.params).toEqual({ GROUP: 'qa' });
|
||||
expect(startIndex(x.steps, 'beta')).toBe(1);
|
||||
expect(() => startIndex(x.steps, 'nope')).toThrow('no such step');
|
||||
expect(resumePoint(x.steps, { flow: 'release', mode: 'dry', startedAt: '', vars: {}, ok: false,
|
||||
results: [{ id: 'check', part: 'steps', kind: 'read', status: 'ok' }, { id: 'beta.build', part: 'steps', kind: 'write', status: 'failed' }] })).toBe('beta.build');
|
||||
});
|
||||
});
|
||||
|
||||
describe('flow command', () => {
|
||||
const app = join(tmp, 'app');
|
||||
mkdirSync(join(app, 'store', 'workflows'), { recursive: true });
|
||||
test('init writes release and beta flows per profile; they validate and plan', () => {
|
||||
for (const profile of ['app', 'game']) {
|
||||
const dir = join(tmp, `init-${profile}`);
|
||||
mkdirSync(dir);
|
||||
expect(sb(dir, 'init', '--profile', profile).exitCode).toBe(0);
|
||||
expect(existsSync(join(dir, 'store/workflows/release.yml'))).toBe(true);
|
||||
expect(existsSync(join(dir, 'store/workflows/beta.yml'))).toBe(true);
|
||||
const v = sb(dir, 'flow', 'validate');
|
||||
expect(v.stderr.toString() + v.stdout.toString()).toContain('2 flow(s) in 2 file(s): ok');
|
||||
const l = JSON.parse(sb(dir, 'flow', 'list', '--json').stdout.toString());
|
||||
const steps = l.flows.find((f: { name: string }) => f.name === 'release').steps.map((s: { id: string }) => s.id);
|
||||
expect(steps.slice(0, 4)).toEqual(profile === 'app' ? ['next-build', 'build', 'upload', 'wait'] : ['shots', 'next-build', 'build', 'upload']);
|
||||
expect(steps.slice(-4)).toEqual(['validate', 'scan', 'plan', 'submit']);
|
||||
const p = sb(dir, 'flow', 'run', 'release', 'VERSION=2.0.0', '--dry', '--json');
|
||||
expect(p.exitCode).toBe(0);
|
||||
const r = JSON.parse(p.stdout.toString());
|
||||
expect(r.mode).toBe('plan');
|
||||
expect(r.results.find((x: { id: string }) => x.id === 'submit').status).toBe('owner');
|
||||
expect(r.results.find((x: { id: string }) => x.id === 'upload').command).toBe('storebound apple upload --no-wait --dry');
|
||||
expect(r.results.find((x: { id: string }) => x.id === 'build').command).toContain('--version 2.0.0');
|
||||
}
|
||||
});
|
||||
|
||||
test('a real run: progress, capture, dry writes, owner click, failure, --resume', () => {
|
||||
writeFileSync(join(app, 'store', 'workflows', 'ship.yml'), `description: test flow
|
||||
params:
|
||||
NAME: demo
|
||||
steps:
|
||||
- id: version
|
||||
run: version
|
||||
capture: V
|
||||
- id: marker
|
||||
sh: test -f ok.txt
|
||||
- id: after
|
||||
sh: echo "got \${V} \${NAME}" > out.txt
|
||||
- id: submit
|
||||
owner: "Submit \${NAME} \${V}"
|
||||
`);
|
||||
const dry = sb(app, 'flow', 'run', 'ship');
|
||||
const out = dry.stdout.toString();
|
||||
expect(dry.exitCode).toBe(0);
|
||||
expect(out).toContain('1/4 version: storebound version --dry (dry run)');
|
||||
expect(out).toContain('V=');
|
||||
expect(out).toContain('shell step: runs with --apply');
|
||||
expect(out).toContain('YOUR CLICK Submit demo');
|
||||
expect(out).toContain('dry run: nothing changed');
|
||||
expect(existsSync(join(app, 'out.txt'))).toBe(false);
|
||||
|
||||
const fail = sb(app, 'flow', 'run', 'ship', '--apply', 'NAME=x');
|
||||
expect(fail.exitCode).toBe(1);
|
||||
expect(fail.stdout.toString()).toContain('stopped at marker');
|
||||
const state = JSON.parse(readFileSync(join(app, '.storebound/flows/ship.json'), 'utf8'));
|
||||
expect(state.results.map((r: { id: string; status: string }) => `${r.id}:${r.status}`)).toEqual(['version:ok', 'marker:failed']);
|
||||
|
||||
writeFileSync(join(app, 'ok.txt'), '');
|
||||
const res = sb(app, 'flow', 'run', 'ship', '--resume', '--apply', 'NAME=x');
|
||||
expect(res.exitCode).toBe(0);
|
||||
expect(res.stdout.toString()).toContain('starting at marker (--resume)');
|
||||
expect(res.stdout.toString()).not.toContain('version: storebound version');
|
||||
const pkg = JSON.parse(readFileSync(join(ROOT, 'package.json'), 'utf8')).version;
|
||||
expect(readFileSync(join(app, 'out.txt'), 'utf8').trim()).toBe(`got ${pkg} x`);
|
||||
expect(sb(app, 'flow', 'run', 'ship', '--resume').stderr.toString()).toContain('nothing to resume');
|
||||
expect(sb(app, 'flow', 'run', 'ship', '--from', 'after', '--apply').exitCode).toBe(0);
|
||||
expect(sb(app, 'flow', 'run', 'nope').stderr.toString()).toContain('no flow "nope"');
|
||||
});
|
||||
|
||||
test('MCP: flow_list and a dry flow_run that never applies', () => {
|
||||
const list = TOOLS.find(t => t.name === 'flow_list')!;
|
||||
const run = TOOLS.find(t => t.name === 'flow_run')!;
|
||||
expect(list.write).toBe(false);
|
||||
expect(run.write).toBe(false);
|
||||
expect(validateInput(run, { name: 'release', params: { VERSION: '1.2.0' }, from: 'build' })).toEqual([]);
|
||||
expect(validateInput(run, { name: '--apply' }).join()).toContain('name');
|
||||
const argv = toArgv(run, { name: 'release', params: { VERSION: '1.2.0', bad: 'x' }, plan_only: true }).argv;
|
||||
expect(argv).toEqual(['flow', 'run', 'release', 'VERSION=1.2.0', '--dry', '--json']);
|
||||
expect(argv.some(a => FORBIDDEN_ARGS.includes(a) || a === '--apply')).toBe(false);
|
||||
});
|
||||
});
|
||||
99
tests/listing-translate.test.ts
Normal file
99
tests/listing-translate.test.ts
Normal file
|
|
@ -0,0 +1,99 @@
|
|||
// storebound listing translate / check / reviewed: per-language listing drafts in both listing files, store limits,
|
||||
// keyword rules, the --translate hook and the review marker.
|
||||
import { afterAll, describe, expect, test } from 'bun:test';
|
||||
import { mkdirSync, mkdtempSync, readFileSync, rmSync, writeFileSync } from 'node:fs';
|
||||
import { tmpdir } from 'node:os';
|
||||
import { join } from 'node:path';
|
||||
import { parseAppStoreListing, parsePlayListing } from '../cli/lib/copy';
|
||||
import { appleFields, checkFields, findAppleSection, findPlaySection, markerOf, normalizeKeywords, playFields, putSection, unmark } from '../cli/lib/listing-translate';
|
||||
|
||||
const ROOT = join(import.meta.dir, '..');
|
||||
const CLI = join(ROOT, 'cli', 'index.ts');
|
||||
const tmp = mkdtempSync(join(tmpdir(), 'storebound-listing-'));
|
||||
afterAll(() => rmSync(tmp, { recursive: true, force: true }));
|
||||
const sb = (cwd: string, ...args: string[]) => Bun.spawnSync([process.execPath, CLI, ...args], { cwd, stdout: 'pipe', stderr: 'pipe', stdin: 'ignore' });
|
||||
|
||||
describe('rules', () => {
|
||||
test('keywords: commas, duplicates, name / subtitle words, whole keywords cut at 100', () => {
|
||||
const r = normalizeKeywords('Liste , notizen,liste、 planer,Aufgaben,,familie', { name: 'Listen App', subtitle: 'Notizen und mehr' });
|
||||
expect(r.text).toBe('Liste,planer,Aufgaben,familie');
|
||||
expect(r.dropped).toEqual([{ kw: 'notizen', why: 'already in the name or subtitle' }, { kw: 'liste', why: 'duplicate' }]);
|
||||
const long = normalizeKeywords(Array.from({ length: 30 }, (_, i) => `keyword${i}`).join(','));
|
||||
expect(long.text.length).toBeLessThanOrEqual(100);
|
||||
expect(long.text.endsWith(',')).toBe(false);
|
||||
expect(long.dropped.at(-1)!.why).toBe('over 100');
|
||||
// multi-byte: 100 bytes, not characters
|
||||
expect(Buffer.byteLength(normalizeKeywords(Array.from({ length: 20 }, (_, i) => `日本語${i}`).join(',')).text)).toBeLessThanOrEqual(100);
|
||||
});
|
||||
test('limits per store field, keyword rules, untranslated and identical text', () => {
|
||||
const c = checkFields('apple', { subtitle: 'x'.repeat(31), keywords: 'a, b,a', description: 'Same long description text' }, { description: 'Same long description text' }, 'draft');
|
||||
expect(c.find(x => x.field === 'subtitle')!.problems).toEqual(['31 > 30 characters']);
|
||||
expect(c.find(x => x.field === 'keywords')!.problems.join()).toContain('spaces around commas');
|
||||
expect(c.find(x => x.field === 'keywords')!.problems.join()).toContain('duplicates: a');
|
||||
expect(c.find(x => x.field === 'description')!.problems).toEqual(['identical to the source language']);
|
||||
expect(checkFields('play', { short: 's'.repeat(81), full: 'ok' }).map(x => x.problems)).toEqual([['81 > 80 characters'], []]);
|
||||
expect(checkFields('play', { short: 'short' }, {}, 'translate')[0]!.problems).toEqual(['not translated yet (status=translate)']);
|
||||
});
|
||||
test('sections: replace in place keeps the rest, markers come off after review', () => {
|
||||
const md = '# X\n\n## en-US · English\n\n### subtitle\n```\nA\n```\n\n---\n\n## tr · Türkçe\n\n### subtitle\n```\nB\n```\n';
|
||||
const out = putSection(md, findAppleSection(md, 'en-US'), '## en-US · English\n<!-- storebound-translation from=tr status=draft -->\n\n### subtitle\n```\nC\n```\n');
|
||||
expect(out).toContain('```\nC\n```\n\n---\n\n## tr');
|
||||
expect(markerOf(findAppleSection(out, 'en-US')!)).toEqual({ from: 'tr', status: 'draft' });
|
||||
expect(unmark(findAppleSection(out, 'en-US')!)).toBe('## en-US · English\n\n### subtitle\n```\nC\n```\n\n---\n\n');
|
||||
});
|
||||
});
|
||||
|
||||
describe('listing commands', () => {
|
||||
const dir = join(tmp, 'app');
|
||||
mkdirSync(dir);
|
||||
sb(dir, 'init', '--profile', 'app');
|
||||
const cfg = join(dir, 'storebound.config.ts');
|
||||
writeFileSync(cfg, readFileSync(cfg, 'utf8').replace("{ id: 'tr', play: 'tr-TR', apple: 'tr' },", "{ id: 'tr', play: 'tr-TR', apple: 'tr' },\n { id: 'de', play: 'de-DE', apple: 'de-DE' },\n { id: 'ja', play: 'ja-JP', apple: 'ja' },"));
|
||||
const apple = join(dir, 'store/appstore.md'), play = join(dir, 'store/listing.md');
|
||||
|
||||
test('without a hook: source text copied in as status=translate, check fails until translated', () => {
|
||||
const r = sb(dir, 'listing', 'translate', '--to', 'de-DE,ja', '--json');
|
||||
expect(r.exitCode).toBe(0);
|
||||
const j = JSON.parse(r.stdout.toString());
|
||||
expect(j.source).toBe('en');
|
||||
expect(j.results.map((x: { lang: string; store: string; action: string }) => `${x.lang}/${x.store}/${x.action}`)).toEqual(
|
||||
['de/apple/added (status=translate)', 'de/play/added (status=translate)', 'ja/apple/added (status=translate)', 'ja/play/added (status=translate)']);
|
||||
const md = readFileSync(apple, 'utf8');
|
||||
expect(markerOf(findAppleSection(md, 'ja')!)).toEqual({ from: 'en-US', status: 'translate' });
|
||||
expect(appleFields(findAppleSection(md, 'ja')!).keywords).toBe(appleFields(findAppleSection(md, 'en-US')!).keywords);
|
||||
expect(Object.keys(parseAppStoreListing(md))).toEqual(['en-US', 'tr', 'de-DE', 'ja']);
|
||||
expect(parsePlayListing(readFileSync(play, 'utf8'), 'Example App').map(c => c.lang)).toEqual(['en-US', 'tr-TR', 'de-DE', 'ja-JP']);
|
||||
const c = sb(dir, 'listing', 'check');
|
||||
expect(c.exitCode).toBe(1);
|
||||
expect(c.stdout.toString()).toContain('TO TRANSLATE');
|
||||
expect(sb(dir, 'listing', 'reviewed', '--lang', 'ja').stderr.toString()).toContain('still status=translate');
|
||||
const check = sb(dir, 'check');
|
||||
expect(check.stderr.toString()).toContain('not translated yet (status=translate): de-DE, ja');
|
||||
});
|
||||
|
||||
test('with --translate: one call per field with the env, keywords cleaned up, drafts until reviewed; reviewed sections kept', () => {
|
||||
const hook = join(tmp, 'hook.sh');
|
||||
writeFileSync(hook, '#!/bin/sh\nif [ "$STOREBOUND_FIELD" = keywords ]; then echo "Liste, liste,notizen,$STOREBOUND_TARGET_LANG"; else printf "[%s %s %s %s] " "$STOREBOUND_STORE" "$STOREBOUND_FIELD" "$STOREBOUND_TARGET_LANG" "$STOREBOUND_LIMIT"; tr a-z A-Z; fi\n');
|
||||
const r = sb(dir, 'listing', 'translate', '--to', 'de', '--translate', `sh ${hook}`);
|
||||
expect(r.exitCode).toBe(0);
|
||||
const sec = findAppleSection(readFileSync(apple, 'utf8'), 'de-DE')!;
|
||||
expect(markerOf(sec)!.status).toBe('draft');
|
||||
const f = appleFields(sec);
|
||||
expect(f.subtitle).toBe('[apple subtitle de-DE 30] LISTS AND NOTES, IN SYNC');
|
||||
expect(f.keywords).toBe('Liste,notizen,de-DE');
|
||||
expect(r.stdout.toString()).toContain('dropped "liste" (duplicate)');
|
||||
const p = playFields(findPlaySection(readFileSync(play, 'utf8'), ['de-DE'])!);
|
||||
expect(p.short).toStartWith('[play short de-DE 80] ');
|
||||
expect(p.whatsNew).toBeUndefined();
|
||||
const c = sb(dir, 'listing', 'check', '--json');
|
||||
const j = JSON.parse(c.stdout.toString());
|
||||
expect(j.drafts).toEqual(['apple:de-DE', 'play:de-DE']);
|
||||
expect(sb(dir, 'listing', 'reviewed', '--lang', 'de').stdout.toString()).toContain('2 section(s) marked reviewed');
|
||||
expect(markerOf(findAppleSection(readFileSync(apple, 'utf8'), 'de-DE')!)).toBeNull();
|
||||
// a reviewed section is kept unless --force
|
||||
const again = JSON.parse(sb(dir, 'listing', 'translate', '--to', 'de', '--translate', `sh ${hook}`, '--json').stdout.toString());
|
||||
expect(again.results.map((x: { action: string }) => x.action)).toEqual(['kept (reviewed; --force replaces it)', 'kept (reviewed; --force replaces it)']);
|
||||
expect(sb(dir, 'listing', 'translate', '--to', 'en').stderr.toString()).toContain('source language');
|
||||
expect(sb(dir, 'listing', 'translate', '--to', 'xx').stderr.toString()).toContain('not a language of the config');
|
||||
});
|
||||
});
|
||||
|
|
@ -142,4 +142,21 @@ describe('originality report', () => {
|
|||
expect(none.exitCode).toBe(1);
|
||||
expect(none.stderr.toString()).toContain('nothing to compare with');
|
||||
});
|
||||
|
||||
test('scan --originality adds the 4.3 / repetitive content findings to the scan report', () => {
|
||||
const scan = (args: string[]) => Bun.spawnSync([process.execPath, join(ROOT, 'cli/index.ts'), 'scan', ...args], { cwd: me, stdout: 'pipe', stderr: 'pipe' });
|
||||
const j = JSON.parse(scan(['--originality', '--against', '..', '--json']).stdout.toString());
|
||||
const f = j.findings.filter((x: { rule: string }) => x.rule === 'originality');
|
||||
expect(f.length).toBeGreaterThan(0);
|
||||
expect(f[0].guideline).toBe('4.3');
|
||||
expect(f[0].title).toContain('Candy Merge Garden');
|
||||
expect(f[0].skill).toBe('portfolio-originality');
|
||||
expect(j.originality.flagged).toBe(1);
|
||||
expect(j.originality.pairs.map((p: { app: string }) => p.app)).toEqual(['Candy Merge Garden', 'Pace Runner']);
|
||||
const txt = scan(['--originality', '--against', '../pace']).stdout.toString();
|
||||
expect(txt).toContain('Originality (4.3 / Play repetitive content): 1 app(s) compared, 0 near-duplicate(s)');
|
||||
const plain = JSON.parse(scan(['--json']).stdout.toString());
|
||||
expect(plain.originality).toBeUndefined();
|
||||
expect(plain.findings.some((x: { rule: string }) => x.rule === 'originality')).toBe(false);
|
||||
});
|
||||
});
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@ import {
|
|||
type PriceRow, pricesCsv, sameSchedule,
|
||||
} from '../cli/lib/prices';
|
||||
import { TOOLS, toArgv } from '../cli/mcp-tools';
|
||||
import { appleSubPriceRows, playSubPriceRows } from '../cli/lib/subscriptions';
|
||||
|
||||
const P = 'com.example.game.remove_ads';
|
||||
const csv = `product,store,region,currency,price,start_date
|
||||
|
|
@ -65,6 +66,34 @@ describe('store state -> rows', () => {
|
|||
});
|
||||
});
|
||||
|
||||
describe('subscription rows (prices export)', () => {
|
||||
test('apple: price in effect today plus scheduled ones; play: base plan regional prices', () => {
|
||||
const resp = {
|
||||
data: [
|
||||
{ id: 'p1', type: 'subscriptionPrices', attributes: { startDate: null }, relationships: { subscriptionPricePoint: { data: { id: 'pp1' } }, territory: { data: { id: 'USA' } } } },
|
||||
{ id: 'p2', type: 'subscriptionPrices', attributes: { startDate: '2030-01-01' }, relationships: { subscriptionPricePoint: { data: { id: 'pp2' } }, territory: { data: { id: 'USA' } } } },
|
||||
{ id: 'p3', type: 'subscriptionPrices', attributes: { startDate: '2024-01-01' }, relationships: { subscriptionPricePoint: { data: { id: 'pp3' } }, territory: { data: { id: 'DEU' } } } },
|
||||
],
|
||||
included: [
|
||||
{ type: 'subscriptionPricePoints', id: 'pp1', attributes: { customerPrice: '4.99' } }, { type: 'subscriptionPricePoints', id: 'pp2', attributes: { customerPrice: '5.99' } },
|
||||
{ type: 'subscriptionPricePoints', id: 'pp3', attributes: { customerPrice: '4.99' } },
|
||||
{ type: 'territories', id: 'USA', attributes: { currency: 'USD' } }, { type: 'territories', id: 'DEU', attributes: { currency: 'EUR' } },
|
||||
],
|
||||
};
|
||||
expect(appleSubPriceRows('pro.monthly', resp, '2026-10-12')).toEqual([
|
||||
{ product: 'pro.monthly', store: 'apple', region: 'US', territory: 'USA', currency: 'USD', price: 4.99 },
|
||||
{ product: 'pro.monthly', store: 'apple', region: 'DE', territory: 'DEU', currency: 'EUR', price: 4.99 },
|
||||
{ product: 'pro.monthly', store: 'apple', region: 'US', territory: 'USA', currency: 'USD', price: 5.99, startDate: '2030-01-01' },
|
||||
]);
|
||||
const play = { productId: 'pro.monthly', basePlans: [{ basePlanId: 'monthly', regionalConfigs: [{ regionCode: 'US', price: { currencyCode: 'USD', units: '4', nanos: 990000000 } }, { regionCode: 'TR', price: { currencyCode: 'TRY', units: '99' } }] }] };
|
||||
expect(playSubPriceRows(play, 'monthly')).toEqual([
|
||||
{ product: 'pro.monthly', store: 'play', region: 'US', currency: 'USD', price: 4.99 }, { product: 'pro.monthly', store: 'play', region: 'TR', currency: 'TRY', price: 99 }]);
|
||||
// the rows round-trip through the sheet that apple / play subscriptions --csv read
|
||||
const csv = pricesCsv([...appleSubPriceRows('pro.monthly', resp, '2026-10-12').filter(r => !r.startDate), ...playSubPriceRows(play, 'monthly')]);
|
||||
expect(parsePriceCsv(csv, { products: ['pro.monthly'] }).length).toBe(4);
|
||||
});
|
||||
});
|
||||
|
||||
describe('diff', () => {
|
||||
const current: PriceRow[] = [
|
||||
{ product: P, store: 'apple', region: 'US', territory: 'USA', currency: 'USD', price: 2.99 },
|
||||
|
|
|
|||
|
|
@ -332,6 +332,25 @@ describe('config writing', () => {
|
|||
});
|
||||
|
||||
describe('integration', () => {
|
||||
test('2.2: beta / demo / test wording in the app name or the App Store text (not "demo account")', async () => {
|
||||
const dir = mkdtempSync(join(tmpdir(), 'storebound-scan-beta-'));
|
||||
try {
|
||||
cpSync(join(FX, 'clean'), dir, { recursive: true });
|
||||
const cfg = join(dir, 'storebound.config.ts');
|
||||
writeFileSync(cfg, readFileSync(cfg, 'utf8').replace("name: 'Clean Notes'", "name: 'Clean Notes Beta'"));
|
||||
const md = join(dir, 'store', 'appstore.md');
|
||||
const text = readFileSync(md, 'utf8');
|
||||
writeFileSync(md, text.replace(/(### description\n```\n)/, '$1This is a demo of the full app.\nReviewers use the demo account.\n'));
|
||||
const f = find((await runScan(dir)).report.findings, 'beta-wording', 'apple')!;
|
||||
expect(f.guideline).toBe('2.2');
|
||||
expect(f.severity).toBe('high');
|
||||
expect(f.evidence[0]!.text).toContain('Clean Notes Beta');
|
||||
expect(f.evidence.some(e => e.file === join('store', 'appstore.md') && /demo of the full app/.test(e.text))).toBe(true);
|
||||
writeFileSync(cfg, readFileSync(cfg, 'utf8').replace("'Clean Notes Beta'", "'Clean Notes'"));
|
||||
writeFileSync(md, text.replace(/(### description\n```\n)/, '$1Reviewers use the demo account. Start a free trial of Pro.\n'));
|
||||
expect(find((await runScan(dir)).report.findings, 'beta-wording')).toBeUndefined();
|
||||
} finally { rmSync(dir, { recursive: true, force: true }); }
|
||||
});
|
||||
test('JSON output, --store filter, exit code', () => {
|
||||
const r = Bun.spawnSync(['bun', CLI, 'scan', '--dir', join(FX, 'teaser'), '--json', '--store', 'apple'], { env: { ...process.env, REVIEW_DEMO_USER: '', REVIEW_DEMO_PASSWORD: '' } });
|
||||
expect(r.exitCode).toBe(1);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue