Skip to content

Commit 0e792da

Browse files
fix(scenarios): credit master-detail inline edit by the master's field groups, not inlineEdit: true (#37135)
repo:objectstack#4 · os-justin · session_01QSeKYo86w1wqy2z2fMrryr Fixes #37127 Clause-②: no Metadata-protocol: none ## 维护者速读 - 用户无感:只改场景卡评分器;主从子表「在主记录表单内联编辑」这一项,改为只看主对象的字段分组是否放置了子表。 - 为什么做:主从子表的内联由主对象字段分组决定(「一律只看分组」),评分器却仍按已退役的布尔开关给分,按正规方式内联的构建反被判不合格。 - 出错会怎样:只影响场景评测分数,不影响任何运行中的应用;可直接回退本次改动。 - 要你做什么:无。 ## What changes `records-forms.master-detail-inline-edit` (`packages/qa/scenarios/src/score/scenario-tags.ts`) credits a master-detail child as edited inline ONLY when a field group of its MASTER (the FK's `reference`) names it in `fieldGroups[].relatedList` (by child object name or `object.field`) and the FK is one a group may place. This is the runtime's own test, with the same two spec predicates: objectui `attachInlineSubforms` (`ui/packages/app-shell/src/providers/MetadataProvider.tsx`, lines 773-774) inlines a child only when `isGroupPlaceableRelationship(fk) && fieldGroupsPlaceRelationship(groupsOf(fk.reference), child, fk)` (`packages/spec/src/data/related-list-body-table.ts`, lines 80 and 110). `inlineEdit` takes no part. The `asserts` sentence and `packages/qa/scenarios/README.md` (the tag table) say the same. ## Deviation from the card The card asks to credit a child also "when `inlineEdit` is `'grid'` / `'form'`". This PR does not. It follows the maintainer's field-group ruling on #35889 (record 7046311205, 「一律只看分组」), which outranks the card's wording: the runtime inlines nothing without a placing field group (MetadataProvider.tsx L773-775; `inlineEdit` only feeds `resolveInlineMode`, the form factor). A scorer that credited it would pass a build that inlines nothing. Decided by the PM (zone a4-A). ## Tests `packages/qa/scenarios/test/score/scenario-tags.test.ts`: - The rich fixture inlines the tasks the supported way: a `project` field group naming `task`, no `inlineEdit` on the FK. - The degradation table pins two failing shapes: no placing group, and a lone retired `inlineEdit: true`. - A `describe` pins: field-group placement credits, by child name and by `object.field`; a group on the CHILD, or a group naming an FK with `relatedList: true`, does not credit; `inlineEdit: true` alone does not credit; `'grid'` and `'form'` with no placing group do not credit; a placed child credits under either form factor. ## Acceptance notes - **Serial: lands after #36802** (merged at 22:27Z; `main` merged into this branch since). Its `corpus.ts` places the golden corpus control cards' children (`invoice_with_line_items`, `project_with_tasks`) with field groups; before it, those two `scenario-cards.test.ts` pins read red under the corrected tag. Measured green with #36802's `corpus.ts` in place at head `2c1f1e68fa`: 137/137 across `scenario-cards.test.ts` and `scenario-tags.test.ts`. The CI run on the merged head is the verdict. ## Verification Two-minute check: `pnpm --filter @objectstack/scenarios exec vitest run --maxWorkers=2 test/score/` should pass, including the `master-detail inline edit` describe and both control cards. Files to read first: 1. `packages/qa/scenarios/src/score/scenario-tags.ts`, the tag's `run`. The risk is the master lookup: `rawObject(f, field.reference)` is matched by normalised name. 2. `packages/qa/scenarios/test/score/scenario-tags.test.ts`, the rich fixture edit in `richArtifact`. Every other tag scores this fixture. Readings: the dev reports on #37127 (round 1 and fix round 7146536492). --- 🤖 Generated with [Claude Code](https://claude.com/claude-code) https://claude.ai/code/session_01QSeKYo86w1wqy2z2fMrryr --------- Co-authored-by: Claude <noreply@anthropic.com> Co-authored-by: objectstack-fleet[bot] <332303061+objectstack-fleet[bot]@users.noreply.github.com>
1 parent 6ddb97b commit 0e792da

4 files changed

Lines changed: 76 additions & 7 deletions

File tree

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
---
2+
'@objectstack/scenarios': patch
3+
---
4+
5+
fix(scenarios): the `records-forms.master-detail-inline-edit` tag credits a child its master's field group places, and no longer credits `inlineEdit` alone
6+
7+
Clause-②: no
8+
Metadata-protocol: none
9+
10+
The tag now asks the same placement test the runtime's entry form uses: a master-detail child is edited inline on its master when a field group of the master names it (`fieldGroups[].relatedList`, the child object or `object.field`) and the FK is one a group may place. A build that inlines its lines that way, with no `inlineEdit` key, now passes the tag. `inlineEdit` alone credits nothing, whatever its value (`true`, `'grid'`, `'form'`): it does not place a child in the master's form, it only picks the form factor of a child a group places.

‎packages/qa/scenarios/README.md‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ discrimination test; ⛔ never match by area prefix.
196196
| Tag | Passes when the built artifact… |
197197
|:---|:---|
198198
| `records-forms.lookup` | carries a lookup field, and every lookup field resolves to an object the build or the platform serves |
199-
| `records-forms.master-detail-inline-edit` | has every master-detail field resolving, and one of them edited inline on its master (`inlineEdit`) |
199+
| `records-forms.master-detail-inline-edit` | has every master-detail field resolving, and one of them edited inline on its master: a field group of the master places the child (`fieldGroups[].relatedList`) |
200200
| `records-forms.roll-up-summary` | carries a roll-up summary, each reading a child object that relates back and, unless it counts, a child field that exists |
201201
| `records-forms.select-options` | carries a single-choice option field (`select`, `radio`), each offering at least two options |
202202
| `records-forms.formula-field` | carries a computed field (a `formula` field, or a stored field with an `expression`), each expression compiling at `record` scope against its object's columns |

‎packages/qa/scenarios/src/score/scenario-tags.ts‎

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,9 @@ import {
7070
import {
7171
SINGLE_OPTION_TYPES,
7272
controlledByParentMasterOf,
73+
fieldGroupsPlaceRelationship,
7374
injectedSystemColumnDefs,
75+
isGroupPlaceableRelationship,
7476
referenceTargetOf,
7577
summaryFunctionReadsField,
7678
} from '@objectstack/spec/data';
@@ -491,13 +493,19 @@ export const CAPABILITY_TAG_CHECKS: Readonly<Record<string, TagCheck>> = Object.
491493
},
492494

493495
'records-forms.master-detail-inline-edit': {
494-
asserts: 'every master-detail field resolves, and one of them is edited inline on its master (`inlineEdit`)',
496+
asserts: 'every master-detail field resolves, and one of them is edited inline on its master: a field group of the master places the child (`fieldGroups[].relatedList`)',
495497
run(f) {
496498
const rels = relationships(f.graph, 'master_detail');
497-
const inline = rels.filter(({ object, field }) => {
498-
const mode = rawField(f, object, field.name)?.inlineEdit;
499-
return mode === true || mode === 'grid' || mode === 'form';
500-
});
499+
// Placement is the runtime's own test (objectui `attachInlineSubforms`):
500+
// the master's form inlines the child only when a field group of the
501+
// MASTER names it (`relatedList`: the child object, or `object.field`)
502+
// and a group may place that FK. `inlineEdit` takes no part: since the
503+
// field-group ruling on #35889 it only picks the form factor of a child
504+
// a group places, so no value of it (`true`, `'grid'`, `'form'`) credits.
505+
const inline = rels.filter(({ object, field }) =>
506+
isGroupPlaceableRelationship(rawField(f, object, field.name))
507+
&& fieldGroupsPlaceRelationship(rawObject(f, field.reference!)?.fieldGroups, object, field.name),
508+
);
501509
return {
502510
checks: [
503511
check('master-detail-field-exists', rels.length > 0, `${rels.length} master-detail field(s)`),

‎packages/qa/scenarios/test/score/scenario-tags.test.ts‎

Lines changed: 52 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,10 @@ function richArtifact(edit?: (stack: Bag) => void): Bag {
4747
const fixture = DEFAULT_METADATA_EVAL_CORPUS.find((c) => c.id === 'project_with_tasks')!.fixture;
4848
const stack = structuredClone(fixture) as Bag;
4949
stack.objects[0].fields.sponsor = { type: 'user', label: 'Sponsor' };
50+
// The tasks are edited inline the supported way: a field group of the
51+
// project names them, and the FK declares no `inlineEdit` at all.
52+
stack.objects[0].fieldGroups = [{ key: 'tasks', label: 'Tasks', relatedList: 'task' }];
53+
delete stack.objects[1].fields.project.inlineEdit;
5054
stack.objects[1].fields.blocked_by = { type: 'lookup', label: 'Blocked By', reference: 'task' };
5155
stack.objects[1].fields.estimate_days = { type: 'formula', label: 'Estimate (days)', expression: 'record.estimate_hours / 8', returnType: 'number' };
5256
stack.objects[1].validations = [
@@ -151,7 +155,11 @@ const TAG_DEGRADATIONS: Record<string, Record<string, (a: Bag) => void>> = {
151155
'dangling lookup target': (a) => { field(a, 'task', 'blocked_by').reference = 'no_such_object'; },
152156
},
153157
'records-forms.master-detail-inline-edit': {
154-
'master-detail not edited inline': (a) => { delete field(a, 'task', 'project').inlineEdit; },
158+
'master-detail not edited inline': (a) => { delete (a.objects[0] as Bag).fieldGroups; },
159+
'master-detail carrying only the retired `inlineEdit: true`': (a) => {
160+
delete (a.objects[0] as Bag).fieldGroups;
161+
field(a, 'task', 'project').inlineEdit = true;
162+
},
155163
'dangling master-detail target': (a) => { field(a, 'task', 'project').reference = 'no_such_object'; },
156164
},
157165
'records-forms.roll-up-summary': {
@@ -417,6 +425,49 @@ const grade = (a: Bag, tag: string, card: ScenarioArtifactCard = CARD, namespace
417425
gradeCapabilityTags(readArtifactFacts(a), { ...card, capabilities: [tag] }, namespace === undefined ? {} : { namespace })[0]!;
418426
const pairs = (v: { checks: Array<{ check: string; pass: boolean }> }) => v.checks.map((c) => [c.check, c.pass]);
419427

428+
describe('master-detail inline edit — placed by a field group of the master, never by `inlineEdit` alone', () => {
429+
const inline = (a: Bag) => grade(a, 'records-forms.master-detail-inline-edit').checks.find((c) => c.check === 'master-detail-inline-edit');
430+
const noGroup = (a: Bag) => { delete (a.objects[0] as Bag).fieldGroups; return a; };
431+
432+
it('credits a child a field group of its master names, by child object or by `object.field`, with no `inlineEdit`', () => {
433+
expect(field(richArtifact(), 'task', 'project').inlineEdit).toBeUndefined();
434+
expect(inline(richArtifact())).toEqual({ check: 'master-detail-inline-edit', pass: true, detail: '1 edited inline' });
435+
const dotted = richArtifact((stack) => { stack.objects[0].fieldGroups[0].relatedList = 'task.project'; });
436+
expect(inline(dotted)?.pass).toBe(true);
437+
});
438+
439+
it('does not credit a group on the CHILD, or a group naming the child on an FK a group may not place', () => {
440+
const onChild = noGroup(richArtifact());
441+
(onChild.objects[1] as Bag).fieldGroups = [{ key: 'tasks', label: 'Tasks', relatedList: 'task' }];
442+
expect(inline(onChild)?.pass).toBe(false);
443+
const tab = richArtifact();
444+
field(tab, 'task', 'project').relatedList = true;
445+
expect(inline(tab)?.pass).toBe(false);
446+
});
447+
448+
it('does not credit the retired `inlineEdit: true` alone', () => {
449+
const a = noGroup(richArtifact());
450+
field(a, 'task', 'project').inlineEdit = true;
451+
expect(inline(a)).toEqual({ check: 'master-detail-inline-edit', pass: false, detail: '0 edited inline' });
452+
});
453+
454+
it("does not credit a form factor, `'grid'` or `'form'`, with no placing group (it inlines nothing at runtime)", () => {
455+
for (const mode of ['grid', 'form']) {
456+
const a = noGroup(richArtifact());
457+
field(a, 'task', 'project').inlineEdit = mode;
458+
expect(inline(a)?.pass).toBe(false);
459+
}
460+
});
461+
462+
it("credits a placed child whatever form factor it declares, `'grid'` or `'form'`", () => {
463+
for (const mode of ['grid', 'form']) {
464+
const a = richArtifact();
465+
field(a, 'task', 'project').inlineEdit = mode;
466+
expect(inline(a)?.pass).toBe(true);
467+
}
468+
});
469+
});
470+
420471
describe('formula field — a computed field whose expression compiles', () => {
421472
const formula = (a: Bag) => grade(a, 'records-forms.formula-field');
422473

0 commit comments

Comments
 (0)