-
-
Notifications
You must be signed in to change notification settings - Fork 11
chore: reenable post-update test cases #277
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
WalkthroughRemoves a runtime assertion in ExpressionTransformer._member, activates previously skipped policy tests, updates test policies to replace future() with post-update rules, and introduces new allow/deny rules in sample schemas (Pet and Todo/List/Space). Adds a TODO item for custom functions. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
Pre-merge checks and finishing touches✅ Passed checks (3 passed)
✨ Finishing touches
🧪 Generate unit tests
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. 🧪 Early access (Sonnet 4.5): enabledWe are currently testing the Sonnet 4.5 model, which is expected to improve code review quality. However, this model may lead to increased noise levels in the review comments. Please disable the early access features if the noise level causes any inconvenience. Note:
Comment |
|
Claude finished @ymc9's task —— View job PR Review: chore: reenable post-update test casesSummaryThis PR re-enables post-update policy test cases that were previously disabled, following the implementation of post-update policies in PR #275. The changes are well-structured and consistent with the codebase patterns. Code Quality and Best Practices ✅Positive aspects:
Schema changes:
Test Coverage ✅Comprehensive test scenarios:
Test quality:
Potential Issues
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR re-enables post-update test cases by migrating from deprecated future() function to the post-update operation with before() function. The change allows testing of policy rules that validate data state transitions during updates.
- Replaces commented-out
future()policies with@@deny('post-update', before().ownerId != ownerId)rules - Updates test expectations from
toBeRejectedNotFound()totoBeRejectedByPolicy()for policy violations - Re-enables previously skipped test suites and individual test cases
Reviewed Changes
Copilot reviewed 12 out of 12 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| packages/runtime/test/schemas/todo/todo.zmodel | Adds post-update deny rules to prevent owner changes in List and Todo models |
| packages/runtime/test/schemas/todo/schema.ts | Updates compiled schema with new post-update deny attributes |
| packages/runtime/test/schemas/petstore/schema.zmodel | Adds update allow rule for authenticated users to Pet model |
| packages/runtime/test/schemas/petstore/schema.ts | Updates compiled schema with new update allow attribute |
| packages/runtime/test/policy/todo-sample.test.ts | Re-enables post-update test case |
| packages/runtime/test/policy/migrated/toplevel-operations.test.ts | Migrates from future() to post-update and updates test expectations |
| packages/runtime/test/policy/migrated/todo-sample.test.ts | Re-enables post-update test case |
| packages/runtime/test/policy/migrated/petstore-sample.test.ts | Re-enables entire test suite |
| packages/runtime/test/policy/migrated/nested-to-one.test.ts | Migrates nested update tests from future() to post-update |
| packages/runtime/test/policy/migrated/multi-id-fields.test.ts | Migrates multi-id field tests and fixes type inconsistencies |
| packages/runtime/src/plugins/policy/expression-transformer.ts | Removes invariant check for select query node |
| TODO.md | Adds custom functions task to todo list |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Actionable comments posted: 1
📜 Review details
Configuration used: Path: .coderabbit.yaml
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (12)
TODO.md(1 hunks)packages/runtime/src/plugins/policy/expression-transformer.ts(0 hunks)packages/runtime/test/policy/migrated/multi-id-fields.test.ts(6 hunks)packages/runtime/test/policy/migrated/nested-to-one.test.ts(2 hunks)packages/runtime/test/policy/migrated/petstore-sample.test.ts(1 hunks)packages/runtime/test/policy/migrated/todo-sample.test.ts(1 hunks)packages/runtime/test/policy/migrated/toplevel-operations.test.ts(3 hunks)packages/runtime/test/policy/todo-sample.test.ts(1 hunks)packages/runtime/test/schemas/petstore/schema.ts(1 hunks)packages/runtime/test/schemas/petstore/schema.zmodel(1 hunks)packages/runtime/test/schemas/todo/schema.ts(2 hunks)packages/runtime/test/schemas/todo/todo.zmodel(2 hunks)
💤 Files with no reviewable changes (1)
- packages/runtime/src/plugins/policy/expression-transformer.ts
🧰 Additional context used
📓 Path-based instructions (3)
{packages,samples,tests}/**
📄 CodeRabbit inference engine (CLAUDE.md)
Place packages only under
packages/,samples/, ortests/
Files:
packages/runtime/test/schemas/todo/todo.zmodelpackages/runtime/test/policy/todo-sample.test.tspackages/runtime/test/schemas/petstore/schema.zmodelpackages/runtime/test/schemas/petstore/schema.tspackages/runtime/test/policy/migrated/toplevel-operations.test.tspackages/runtime/test/policy/migrated/nested-to-one.test.tspackages/runtime/test/schemas/todo/schema.tspackages/runtime/test/policy/migrated/multi-id-fields.test.tspackages/runtime/test/policy/migrated/todo-sample.test.tspackages/runtime/test/policy/migrated/petstore-sample.test.ts
**/schema.zmodel
📄 CodeRabbit inference engine (CLAUDE.md)
Name ZModel schema files
schema.zmodel
Files:
packages/runtime/test/schemas/petstore/schema.zmodel
**/schema.ts
📄 CodeRabbit inference engine (CLAUDE.md)
The generated TypeScript schema should be named
schema.ts
Files:
packages/runtime/test/schemas/petstore/schema.tspackages/runtime/test/schemas/todo/schema.ts
🧬 Code graph analysis (2)
packages/runtime/test/schemas/petstore/schema.ts (1)
packages/runtime/src/schema/expression.ts (1)
ExpressionUtils(16-120)
packages/runtime/test/schemas/todo/schema.ts (1)
packages/runtime/src/schema/expression.ts (1)
ExpressionUtils(16-120)
🪛 markdownlint-cli2 (0.18.1)
TODO.md
104-104: Unordered list indentation
Expected: 2; Actual: 4
(MD007, ul-indent)
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (3)
- GitHub Check: claude-review
- GitHub Check: build-test (20.x, postgresql)
- GitHub Check: build-test (20.x, sqlite)
🔇 Additional comments (16)
packages/runtime/test/policy/todo-sample.test.ts (1)
386-444: LGTM! Post-update checks test successfully re-enabled.The test correctly verifies post-update policy enforcement by attempting to change ownership on both List and Todo entities (including nested updates), all of which should be rejected by policy.
TODO.md (1)
104-104: New TODO item added for custom functions.The addition tracks future work on custom functions in the access policy system, aligning with the PR's post-update policy improvements.
Note: The markdown linter flags the indentation (4 spaces vs. 2), but this matches the existing style in this file.
packages/runtime/test/policy/migrated/todo-sample.test.ts (1)
373-430: LGTM! Post-update checks test successfully re-enabled.This migrated test correctly verifies the same post-update policy enforcement scenarios as the non-migrated version, ensuring owner changes are properly rejected by policy.
packages/runtime/test/policy/migrated/petstore-sample.test.ts (1)
5-44: LGTM! Pet Store test suite successfully re-enabled.The test suite activation aligns with the PR objective and depends on the updated Pet schema with new authentication-based update permissions.
packages/runtime/test/schemas/petstore/schema.zmodel (1)
38-39: LGTM! Authentication-based update permission added.The new rule requires authentication for Pet updates, working in conjunction with the existing post-update rule to ensure:
- Only authenticated users can update pets
- Only the
orderIdfield can be changed (and only when previously null)This properly enforces the business logic for marking pets as sold.
packages/runtime/test/policy/migrated/nested-to-one.test.ts (2)
200-200: LGTM! Test successfully re-enabled.The test is now active and exercises the new post-update policy semantics.
218-219: Policy update aligns with post-update test semantics.The simplified update guard (
value > 1) and new post-update rule (value > 2) correctly enforce:
- Pre-update: current value must be > 1 to allow the update operation
- Post-update: final value must be > 2 to commit the change
Test expectations at lines 238 and 249 correctly validate denial and success scenarios.
packages/runtime/test/policy/migrated/toplevel-operations.test.ts (3)
136-136: LGTM! Test successfully re-enabled.The test now validates top-level update operations with the new post-update policy semantics.
145-146: Policy update correctly implements post-update validation.The simplified update rule (
value > 1) and new post-update constraint (value > 2) align with the test scenarios at lines 159-167 (rejection) and lines 170-178 (success).
167-167: Correct expectation: policy rejection rather than not-found.The change from
toBeRejectedNotFound()totoBeRejectedByPolicy()properly reflects that the update fails due to the post-update policy constraint (value > 2fails forvalue: 1), not because the record is missing.packages/runtime/test/schemas/todo/schema.ts (2)
314-314: Post-update ownership protection added for List.This generated rule correctly prevents ownership transfers by denying updates where
before().ownerId != ownerId. Ensure the source.zmodelfile contains the corresponding rule.
384-385: Post-update ownership protection added for Todo.The new denial rule at line 385 prevents ownership transfers, matching the pattern applied to the List model. The modification at line 384 appears to be part of the existing space membership access rule. Verify both align with the source
.zmodel.packages/runtime/test/schemas/todo/todo.zmodel (2)
120-122: Post-update denial correctly replaces future()-based ownership protection.The simplified update rule at line 120 combined with the new post-update denial at line 122 cleanly enforces the ownership immutability constraint. This approach is more explicit and aligns with the PR's migration away from
future().
149-150: Post-update denial added for Todo ownership protection.Mirrors the pattern applied to the List model, preventing ownership transfers via a post-update constraint. The comment at line 149 clearly documents the intent.
packages/runtime/test/policy/migrated/multi-id-fields.test.ts (2)
60-126: LGTM! Test re-enabled with correct policy logic.The test correctly validates the new policy structure where
@@allow('update', value > 0)checks the pre-update state and@@allow('post-update', value > 1)validates the post-update state. All test assertions align with these rules.
322-394: LGTM! Nested update test correctly implements new policy structure.The test validates nested updates with the same policy rules as the top-level update test. The data type correction on lines 372 and 387 (
y: 4as number) correctly matches theInttype in the schema.
Summary by CodeRabbit
New Features
Tests
Documentation