Tooling: - Prettier as the single formatting authority (110 columns, single quotes, measured against the existing style); Markdown excluded because table-cell padding turns the README glossary into 1000-character lines. - Type-aware ESLint ending in eslint-config-prettier, so a rule always means "this is a bug", never "this looks different". - .editorconfig and an `npm run check` that runs typecheck, lint, format and tests in one go. Findings fixed on the first run: three more duplicate imports, four String(unknown) calls (parameter types narrowed instead of casts), two dead initialisers, two redundant casts, a console.log for a real error. Two warnings were false here and are disabled with a reason in place. Tests 132 -> 269: - node-catalog.test.ts covers every node with a run(), with a guard that fails when a new node has no row. - behavior-events.test.ts covers the ten event nodes through a running World, checking timing rather than existence. - Input's state machine (press/release/releaseAll) is reachable without DOM events now; the DOM handlers are thin adapters. Compare fell back to == without a configured operator although the schema default is <; aligned. Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
46 lines
2.0 KiB
JavaScript
46 lines
2.0 KiB
JavaScript
/** The asset panel: placing from the context menu, creating through "+", and resetting an asset value. */
|
|
export async function assets(t) {
|
|
const { check, sleep, evaluate, json, shot, click, clickText, undo, select, objects, asset } = t;
|
|
|
|
// 8. Context menu on the Crate asset → menu shows "Place in scene".
|
|
await clickText('Crate', 'right');
|
|
check('asset context menu opens', Boolean(await evaluate(`__gm.locate('Place in scene')`)));
|
|
await shot('11-context-menu');
|
|
await clickText('Place in scene');
|
|
await sleep(100);
|
|
const count = (await objects()).length;
|
|
check('placing from the menu adds an object', count === 8, `objects=${count}`);
|
|
|
|
// 9. Create a new asset through the + menu.
|
|
await clickText('+');
|
|
await clickText('Sprite');
|
|
await sleep(100);
|
|
const names = await json('__gm.state.project.assets.map(a => a.name)');
|
|
check('+ menu creates a sprite asset', names.includes('Sprite'), JSON.stringify(names));
|
|
await shot('12-new-asset');
|
|
|
|
// 12. Asset defaults: the Crate asset has height 60 (schema default 100), width and color at
|
|
// their defaults → exactly one reset button is visible. Clicking it puts height back to
|
|
// 100 and hides the button; undo brings 60 back.
|
|
await select({ kind: 'asset', assetId: 'crate' });
|
|
await sleep(200);
|
|
const resetButton = await evaluate(`__gm.locate('↺')`);
|
|
check('asset inspector shows a reset for the non-default height', Boolean(resetButton));
|
|
await click(resetButton.x, resetButton.y);
|
|
await sleep(100);
|
|
check(
|
|
'reset puts the asset property back to its default',
|
|
(await asset('crate')).props.height === 100,
|
|
`height=${(await asset('crate')).props.height}`,
|
|
);
|
|
check('reset button hidden once the value is at default', !(await evaluate(`__gm.locate('↺')`)));
|
|
await shot('15-asset-reset');
|
|
await undo();
|
|
check(
|
|
'undo restores the asset value',
|
|
(await asset('crate')).props.height === 60,
|
|
`height=${(await asset('crate')).props.height}`,
|
|
);
|
|
check('reset button visible again after undo', Boolean(await evaluate(`__gm.locate('↺')`)));
|
|
}
|