Skip to content

test(editor): reduce flaky in turbo renderer test#11973

Merged
graphite-app[bot] merged 1 commit into
canaryfrom
0424/flaky_2
Apr 25, 2025
Merged

test(editor): reduce flaky in turbo renderer test#11973
graphite-app[bot] merged 1 commit into
canaryfrom
0424/flaky_2

Conversation

@doodlewind
Copy link
Copy Markdown
Collaborator

@doodlewind doodlewind commented Apr 24, 2025

Summary by CodeRabbit

  • Tests
    • Improved test resource cleanup for the viewport turbo renderer, ensuring proper teardown after each test for more reliable and isolated test execution.
    • Enhanced stability by preventing errors during cleanup when certain elements or editors are absent.

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Apr 24, 2025

Walkthrough

The test suite for the viewport turbo renderer was updated to improve resource cleanup management by declaring the cleanup function at the describe block scope and assigning it within the beforeEach hook. An afterEach hook was added to explicitly invoke the cleanup function after each test, ensuring proper teardown. Additionally, optional chaining was added to safely call remove() on appElement and window.editor in the setup and cleanup functions to prevent runtime errors if these objects are absent.

Changes

File(s) Change Summary
blocksuite/integration-test/src/tests/edgeless/turbo-renderer.spec.ts Refactored test setup and teardown: moved cleanup variable to describe scope, assigned in beforeEach, and invoked in new afterEach hook.
blocksuite/integration-test/src/tests/utils/setup.ts Added optional chaining (?.) to safely call remove() on appElement and window.editor in setupEditor and cleanup functions.

Suggested reviewers

  • akumatus

Poem

In the warren of tests, neat and clean,
A rabbit ensures no mess can be seen.
With cleanup in paw, afterEach in tow,
The tests hop along, as tidy as snow.
No dangling resources, no cluttered night—
Just code that’s as crisp as a carrot bite! 🥕


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 1113cd7 and a46f1a3.

📒 Files selected for processing (2)
  • blocksuite/integration-test/src/__tests__/edgeless/turbo-renderer.spec.ts (3 hunks)
  • blocksuite/integration-test/src/__tests__/utils/setup.ts (1 hunks)
🚧 Files skipped from review as they are similar to previous changes (2)
  • blocksuite/integration-test/src/tests/utils/setup.ts
  • blocksuite/integration-test/src/tests/edgeless/turbo-renderer.spec.ts
✨ Finishing Touches
  • 📝 Generate Docstrings

🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Generate unit testing code for this file.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query. Examples:
    • @coderabbitai generate unit testing code for this file.
    • @coderabbitai modularize this function.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read src/utils.ts and generate unit testing code.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR comments)

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai resolve resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Documentation and Community

  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link
Copy Markdown
Collaborator Author


How to use the Graphite Merge Queue

Add either label to this PR to merge it via the merge queue:

  • merge - adds this PR to the back of the merge queue
  • hotfix - for urgent hot fixes, skip the queue and merge this PR next

You must have a Graphite account in order to use the merge queue. Sign up using this link.

An organization admin has enabled the Graphite Merge Queue in this repository.

Please do not merge from GitHub as this will restart CI on PRs being processed by the merge queue.

This stack of pull requests is managed by Graphite. Learn more about stacking.

@github-actions github-actions Bot added the test Related to test cases label Apr 24, 2025
@doodlewind doodlewind marked this pull request as ready for review April 24, 2025 10:35
@doodlewind doodlewind requested a review from a team as a code owner April 24, 2025 10:35
@graphite-app graphite-app Bot requested review from a team April 24, 2025 10:35
Copy link
Copy Markdown
Contributor

@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

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between eaa1bc6 and e8933f7.

📒 Files selected for processing (1)
  • blocksuite/integration-test/src/__tests__/edgeless/turbo-renderer.spec.ts (3 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
blocksuite/integration-test/src/__tests__/edgeless/turbo-renderer.spec.ts (1)
blocksuite/integration-test/src/__tests__/utils/setup.ts (1)
  • setupEditor (118-135)
🔇 Additional comments (4)
blocksuite/integration-test/src/__tests__/edgeless/turbo-renderer.spec.ts (4)

10-10: Import of afterEach for explicit cleanup.

Added the afterEach import to support the new cleanup approach.


21-22: Improved test cleanup reliability by declaring cleanup at describe scope.

Moving the cleanup function declaration to the describe block scope ensures it's accessible to all test lifecycle hooks, which helps address potential flakiness issues.


24-24: Using outer cleanup variable to ensure resource management.

Now storing the cleanup function in the outer scope variable rather than a local one, ensuring it's properly persisted between hooks.


34-35: Added explicit afterEach hook to ensure consistent cleanup.

This is a good practice that ensures resources are properly released after each test, which helps prevent test flakiness caused by resource leaks or interference between tests.

@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 24, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 55.87%. Comparing base (aae65d2) to head (a46f1a3).
Report is 1 commits behind head on canary.

Additional details and impacted files
@@           Coverage Diff           @@
##           canary   #11973   +/-   ##
=======================================
  Coverage   55.87%   55.87%           
=======================================
  Files        2599     2599           
  Lines      115345   115345           
  Branches    18552    18552           
=======================================
+ Hits        64449    64450    +1     
  Misses      48907    48907           
+ Partials     1989     1988    -1     
Flag Coverage Δ
server-test 78.88% <ø> (ø)
unittest 31.56% <ø> (+<0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

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

@graphite-app
Copy link
Copy Markdown
Contributor

graphite-app Bot commented Apr 24, 2025

Merge activity

<!-- This is an auto-generated comment: release notes by coderabbit.ai -->
## Summary by CodeRabbit

- **Tests**
  - Improved test resource cleanup for the viewport turbo renderer, ensuring proper teardown after each test for more reliable and isolated test execution.
  - Enhanced stability by preventing errors during cleanup when certain elements or editors are absent.
<!-- end of auto-generated comment: release notes by coderabbit.ai -->
@graphite-app graphite-app Bot merged commit a46f1a3 into canary Apr 25, 2025
111 checks passed
@graphite-app graphite-app Bot deleted the 0424/flaky_2 branch April 25, 2025 00:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

test Related to test cases

Projects

Status: No status

Development

Successfully merging this pull request may close these issues.

2 participants