fix(language-server): allow group metadata key#2948
Conversation
🦋 Changeset detectedLatest commit: 18c6ac5 The changes in this PR will be included in the next version bump. This PR includes changesets to release 22 packages
Not sure what this means? Click here to learn what changesets are. Click here if you're a maintainer who wants to add another changeset to this PR |
|
@coderabbitai review |
✅ Actions performedReview triggered.
|
|
ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (3)
✅ Files skipped from review due to trivial changes (1)
🚧 Files skipped from review as they are similar to previous changes (2)
📝 WalkthroughWalkthroughThis PR fixes issue ChangesAllow Reserved Keywords as Metadata Keys
Sequence Diagram(s)sequenceDiagram
participant Parser
participant ModelBuilder
participant ViewFilter
Parser->>ModelBuilder: parse element with metadata keys (team, _group, group, other)
ModelBuilder->>ModelBuilder: build model preserving all metadata keys
ViewFilter->>ModelBuilder: query where metadata.group is 'group name'
ModelBuilder->>ViewFilter: return matching element(s)
Estimated code review effort🎯 2 (Simple) | ⏱️ ~12 minutes Possibly related PRs
Suggested reviewers
🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out. Comment |
There was a problem hiding this comment.
🧹 Nitpick comments (1)
packages/language-server/src/model/__tests__/model-builder.spec.ts (1)
246-266: ⚡ Quick winAssert the
where metadata.groupfilter outcome explicitly.Right now this test proves parse/build success, but it doesn’t verify that the view predicate actually filters as intended. Add a view assertion so the regression catches semantic breaks too.
Proposed test assertion
const model = await buildModel() expect(model).toBeDefined() expect(model.elements).toMatchObject({ test: { kind: 'system', metadata: { team: 'team name', _group: '_group name', group: 'group name', other: 'other name', }, }, }) + expect(model.views).toHaveProperty('index') + expect(model.views['index' as ViewId]!.nodes.map(n => n.id)).toContain('test')As per coding guidelines: “Aim to cover new features with relevant tests; keep test names descriptive”.
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the rest with a brief reason, keep changes minimal, and validate. In `@packages/language-server/src/model/__tests__/model-builder.spec.ts` around lines 246 - 266, The test currently builds the model with a view filter but doesn't assert the view's actual contents; add an assertion after buildModel() that checks the view named "index" (from the "views { view index { include * where metadata.group is 'group name' } }" snippet) yields only the expected element(s) — e.g. confirm model.views['index'] (or model.views.index) contains the "test" element and excludes others — so the predicate is validated; use buildModel(), model.elements and the view identifier "index" to locate where to insert the new expectation.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.
Nitpick comments:
In `@packages/language-server/src/model/__tests__/model-builder.spec.ts`:
- Around line 246-266: The test currently builds the model with a view filter
but doesn't assert the view's actual contents; add an assertion after
buildModel() that checks the view named "index" (from the "views { view index {
include * where metadata.group is 'group name' } }" snippet) yields only the
expected element(s) — e.g. confirm model.views['index'] (or model.views.index)
contains the "test" element and excludes others — so the predicate is validated;
use buildModel(), model.elements and the view identifier "index" to locate where
to insert the new expectation.
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 30ce3262-214e-415b-bdb7-c7ff6d31845a
📒 Files selected for processing (3)
.changeset/fix-metadata-group-key.mdpackages/language-server/src/like-c4.langiumpackages/language-server/src/model/__tests__/model-builder.spec.ts
2f60bfa to
18c6ac5
Compare
Fixes #2932
Summary:
Idrulemetadata.groupChecks:
pnpm generatevitest run --no-isolate packages/language-server/src/model/__tests__/model-builder.spec.ts -t "group metadata key"vitest run --no-isolate packages/language-server/srcpnpm --filter @likec4/language-server run typecheckpnpm --filter @likec4/language-server run lint