/**
 * Rule: create-reflects-in-list
 *
 * State-sync contract: after a mutation creates an entity, every
 * view reflecting that model must converge to show it within one
 * WebSocket round-trip. v1 seeds the entity via a direct backend
 * POST (through the vite dev proxy) rather than driving the UI
 * form flow — the form UI has known gaps in empty state (see
 * docs/plans/2026-04-14-RUNTIME-GAPS-FROM-CONTRACT-TESTS.md), so
 * this rule deliberately tests the state-sync path on its own.
 *
 * Skipped for models whose creation would require seeding parent
 * entities first (any required belongsTo relationship). For
 * poll-app this means: Poll gets a test; Option and Vote are
 * skipped until topological seed support lands.
 *
 * One TestCase per seedable model.
 */
import { pickDisplayAttribute, buildSeedData } from './_shared.js';
export const RULE_ID = 'create-reflects-in-list';
export const createReflectsInList = (spec) => {
    const cases = [];
    for (const model of spec.models) {
        const display = pickDisplayAttribute(model);
        if (!display)
            continue;
        const marker = `ct-create-${model.name}`;
        const seedData = buildSeedData(model, marker);
        if (!seedData)
            continue; // skip — requires parent entities
        const displayValue = seedData[display.name];
        if (typeof displayValue !== 'string')
            continue;
        cases.push({
            ruleId: RULE_ID,
            specElement: model.name,
            name: `[${RULE_ID}] creating a ${model.name} reflects in its list view`,
            steps: [
                { action: 'bootRuntime' },
                { action: 'navigateToModel', modelName: model.name },
                {
                    action: 'createEntity',
                    modelName: model.name,
                    data: seedData,
                    bindAs: '{ id: _createId, data: created }',
                    uniqueField: display.name,
                },
                {
                    action: 'expectEntityInList',
                    modelName: model.name,
                    displayExpr: `String(created[${JSON.stringify(display.name)}])`,
                },
            ],
        });
    }
    return cases;
};
//# sourceMappingURL=create-reflects-in-list.js.map