Skip to content

test: Fix flaky tests#10320

Merged
mtrezza merged 6 commits intoparse-community:alphafrom
mtrezza:test/fix-flaky-tests
Mar 26, 2026
Merged

test: Fix flaky tests#10320
mtrezza merged 6 commits intoparse-community:alphafrom
mtrezza:test/fix-flaky-tests

Conversation

@mtrezza
Copy link
Member

@mtrezza mtrezza commented Mar 26, 2026

Pull Request

Issue

Fix flaky tests.

Tasks

  • Add tests
  • Add changes to documentation (guides, repository pages, code comments)
  • Add security check
  • Add new Parse Error codes to Parse JS SDK

Summary by CodeRabbit

  • Tests
    • Enhanced test isolation with improved cleanup procedures to prevent state leakage across test suites.
    • Refined session expiration assertions using numeric epoch comparisons with configurable tolerance windows.
    • Refactored asynchronous test handling with modern async/await patterns for better code clarity.

mtrezza added 5 commits March 26, 2026 01:03
…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')
@parse-github-assistant
Copy link

parse-github-assistant bot commented Mar 26, 2026

🚀 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

  • Keep pull requests small. Large PRs will be rejected. Break complex features into smaller, incremental PRs.
  • Use Test Driven Development. Write failing tests before implementing functionality. Ensure tests pass.
  • Group code into logical blocks. Add a short comment before each block to explain its purpose.
  • We offer conceptual guidance. Coding is up to you. PRs must be merge-ready for human review.
  • Our review focuses on concept, not quality. PRs with code issues will be rejected. Use an AI agent.
  • Human review time is precious. Avoid review ping-pong. Inspect and test your AI-generated code.

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.

@parseplatformorg
Copy link
Contributor

parseplatformorg commented Mar 26, 2026

Snyk checks have passed. No issues have been found so far.

Status Scan Engine Critical High Medium Low Total (0)
Open Source Security 0 0 0 0 0 issues

💻 Catch issues earlier using the plugins for VS Code, JetBrains IDEs, Visual Studio, and Eclipse.

@coderabbitai
Copy link

coderabbitai bot commented Mar 26, 2026

📝 Walkthrough

Walkthrough

These 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

Cohort / File(s) Summary
GraphQL Test Isolation
spec/ParseGraphQLController.spec.js, spec/ParseGraphQLServer.spec.js
Adds test setup/cleanup mechanisms: ParseGraphQLController now preserves and restores original databaseController method bindings via afterAll hook; ParseGraphQLServer clears parseGraphQLSchema.schemaCache before each test and after specific schema creation to prevent cache pollution between tests.
Session Test Improvements
spec/rest.spec.js
Updates session expiration assertions to compare numeric epoch milliseconds with tolerance windows instead of Date objects; refactors "can create a session with no expiration" test from callback style to async/await pattern and reconfigures server state within test rather than mutating config globally.

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Possibly related PRs

  • parse-community/parse-server#10303 — Addresses flaky tests through test setup/cleanup adjustments including database cleanup and schema cache handling to improve test isolation.
  • parse-community/parse-server#9947 — Modifies GraphQL test schema caching logic to ensure updated schemas are used in tests, directly related to parseGraphQLSchema.schemaCache management.
🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Title check ✅ Passed The title 'test: Fix flaky tests' accurately summarizes the primary objective of the changeset, which addresses test reliability issues across multiple test suites.
Description check ✅ Passed The description follows the template structure and includes the required Issue section; however, the Approach section is missing a detailed explanation of the changes made.
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

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.js

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.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@codecov
Copy link

codecov bot commented Mar 26, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 92.52%. Comparing base (92791c1) to head (2d616d8).
⚠️ Report is 2 commits behind head on alpha.

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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link

@coderabbitai coderabbitai bot left a 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

🧹 Nitpick comments (1)
spec/ParseGraphQLServer.spec.js (1)

10433-10433: Use the shared GraphQL cache reset helper for consistency.

Line 10433 clears only schemaCache. Prefer resetGraphQLCache() 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

📥 Commits

Reviewing files that changed from the base of the PR and between 7a1b11b and 2d616d8.

📒 Files selected for processing (3)
  • spec/ParseGraphQLController.spec.js
  • spec/ParseGraphQLServer.spec.js
  • spec/rest.spec.js

@mtrezza mtrezza merged commit f537e67 into parse-community:alpha Mar 26, 2026
24 checks passed
@mtrezza mtrezza deleted the test/fix-flaky-tests branch March 26, 2026 02:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants