test: Fix flaky tests#10320
Conversation
…y - Expected 0 to be greater than 0. - Error: Object not found.
…({ __type: 'Date', iso: '2027-03-26T00:12:38.015Z' }) to be undefined.
…oad for on fly creation through pointer and relation - TypeError: Cannot read properties of null (reading 'someClass')
…ailed: Class SomeClass already exists
|
🚀 Thanks for opening this pull request! We appreciate your effort in improving the project. Please let us know once your pull request is ready for review. Tip
Note Please respond to review comments from AI agents just like you would to comments from a human reviewer. Let the reviewer resolve their own comments, unless they have reviewed and accepted your commit, or agreed with your explanation for why the feedback was incorrect. Caution Pull requests must be written using an AI agent with human supervision. Pull requests written entirely by a human will likely be rejected, because of lower code quality, higher review effort and the higher risk of introducing bugs. Please note that AI review comments on this pull request alone do not satisfy this requirement. |
✅ Snyk checks have passed. No issues have been found so far.
💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse. |
📝 WalkthroughWalkthroughThese changes improve test isolation and assertion precision across three test files. They add cleanup hooks to restore original method bindings, clear schema caches between tests, and refactor session expiration assertions to use numeric timestamps instead of Date object comparisons. Changes
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~20 minutes Possibly related PRs
🚥 Pre-merge checks | ✅ 3✅ Passed checks (3 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches🧪 Generate unit tests (beta)
Warning There were issues while running some tools. Please review the errors and either fix the tool's configuration or disable the tool if it's a critical failure. 🔧 ast-grep (0.41.1)spec/ParseGraphQLServer.spec.jsThanks 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 |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## alpha #10320 +/- ##
=======================================
Coverage 92.52% 92.52%
=======================================
Files 192 192
Lines 16504 16504
Branches 227 227
=======================================
Hits 15270 15270
Misses 1214 1214
Partials 20 20 ☔ View full report in Codecov by Sentry. 🚀 New features to boost your workflow:
|
There was a problem hiding this comment.
Actionable comments posted: 1
🧹 Nitpick comments (1)
spec/ParseGraphQLServer.spec.js (1)
10433-10433: Use the shared GraphQL cache reset helper for consistency.Line 10433 clears only
schemaCache. PreferresetGraphQLCache()here (same scope) to keep invalidation behavior consistent with the rest of this suite.Suggested adjustment
- await parseGraphQLServer.parseGraphQLSchema.schemaCache.clear(); + await resetGraphQLCache();🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed. In `@spec/ParseGraphQLServer.spec.js` at line 10433, Replace the direct cache clear call parseGraphQLServer.parseGraphQLSchema.schemaCache.clear() with the shared helper resetGraphQLCache() so the test uses the same GraphQL cache invalidation behavior as the rest of the suite; locate the occurrence of parseGraphQLServer.parseGraphQLSchema.schemaCache.clear() and call resetGraphQLCache() in the same scope instead.
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.
Inline comments:
In `@spec/ParseGraphQLServer.spec.js`:
- Around line 8661-8666: The setup is swallowing all errors when calling
Parse.Schema('SomeClass').purge() and .delete() (and clearing the schema cache),
which hides real failures; update the beforeEach so each promise uses a catch
that only ignores the expected "class does not exist" error and rethrows any
other error. Concretely, replace the bare catch(() => {}) on schema.purge() and
schema.delete() with a handler that checks the Parse error (e.g., err.code ===
101 or message includes "class does not exist" / "does not exist") and returns
silently only for that case, otherwise rethrow the error; do the same defensive
handling around parseGraphQLServer.parseGraphQLSchema.schemaCache.clear() if it
can throw. Ensure you reference Parse.Schema, schema.purge, schema.delete, and
parseGraphQLServer.parseGraphQLSchema.schemaCache.clear when making the change.
---
Nitpick comments:
In `@spec/ParseGraphQLServer.spec.js`:
- Line 10433: Replace the direct cache clear call
parseGraphQLServer.parseGraphQLSchema.schemaCache.clear() with the shared helper
resetGraphQLCache() so the test uses the same GraphQL cache invalidation
behavior as the rest of the suite; locate the occurrence of
parseGraphQLServer.parseGraphQLSchema.schemaCache.clear() and call
resetGraphQLCache() in the same scope instead.
🪄 Autofix (Beta)
Fix all unresolved CodeRabbit comments on this PR:
- Push a commit to this branch (recommended)
- Create a new PR with the fixes
ℹ️ Review info
⚙️ Run configuration
Configuration used: Organization UI
Review profile: CHILL
Plan: Pro
Run ID: 11e9fb53-d6fa-4faa-aa00-50b108b832f8
📒 Files selected for processing (3)
spec/ParseGraphQLController.spec.jsspec/ParseGraphQLServer.spec.jsspec/rest.spec.js
Pull Request
Issue
Fix flaky tests.
Tasks
Summary by CodeRabbit