Files
feuerwerk/tools/e2e/04-assets.mjs
T
rootandClaude Fable 5.1 1eb28314cf Refactoring: one file per node, consistent comments, shared helpers, split large modules
- Graph: nodes.ts split into nodes/<category>/<Type>.ts (62 files) with
  shared.ts factories and index.ts registry; NodeContext/values/NodeRegistry
  separated, writeTyped() replaces duplicated typed writes
- Comments: one style (JSDoc on non-obvious exports, // for decisions and
  traps), wrong/stale comments fixed or removed, ids.ts now real 10 base-36 chars
- Core: chainOf, shared worldPosition/editorPosition core, commands/require.ts,
  commands/naming.ts, util/list.ts, setBagValue/toPosition/propDef; dead code
  removed (isBehaviorAsset, SCENE_OBJECT_SCHEMA, CommandStack.subscribe,
  Input.axis, setMode, titleText, World.worldPosition, unused ctor params)
- Editor: Inspector split into inspector/ sections, App.ts into Editor.ts +
  debugHook.ts + shortcuts.ts, Viewport into items.ts + symbols.ts, shared
  "Add collider" action, unified type labels/swatches
- UI toolkit: Widget.trackHover/onPointerRelease, drawControlBox, math helpers,
  Popup.openBelow, Menu/Dialog/ColorPicker/ListRow in own files, named Theme sizes
- Tools: seed-demo/smoke-demo and demo-check project removed, tools/lib
  (harness, projects, builders), e2e.mjs as runner over tools/e2e/*.mjs sections
- Tests: tests/helpers.ts replaces copied fixtures and NodeContext doubles

Co-Authored-By: Claude Fable 5.1 <noreply@anthropic.com>
2026-09-08 08:37:22 +02:00

38 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('↺')`)));
}