Skip to content

test: cleanup common issues #938

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

Open
wants to merge 5 commits into
base: main
Choose a base branch
from

Conversation

Udit-takkar
Copy link
Contributor

@Udit-takkar Udit-takkar commented Aug 16, 2025

Part of #584 point 3 (Reset database back to seed data between tests)

Screenshots of all test passing locally

Screenshot 2025-08-16 at 8 53 51 PM

Summary by CodeRabbit

  • Tests
    • Improved end-to-end reliability by cleaning up test data after create, edit, and search scenarios in common issues tests.
    • Added a shared cleanup utility to remove test artifacts from the database, ensuring better test isolation and preventing data leakage across runs.
    • Integrated cleanup calls into multiple common-issues tests to ensure created artifacts are removed after assertions.

Copy link

vercel bot commented Aug 16, 2025

@Udit-takkar is attempting to deploy a commit to the Antiwork Team on Vercel.

A member of the Team first needs to authorize it.

Copy link
Contributor

coderabbitai bot commented Aug 16, 2025

Walkthrough

Adds a new E2E test utility to delete common issue records by title and updates the common issues E2E spec to call this cleanup after specific tests.

Changes

Cohort / File(s) Summary
E2E Tests — Common Issues Spec
tests/e2e/common-issues/commonIssues.spec.ts
Imported deleteCommonIssuesFromDb and added calls to it at the end of three tests to remove created issue records by title (create, edit, search scenarios).
E2E Utils — Cleanup Helper
tests/e2e/utils/commonIssueCleanup.ts
New helper exporting async function deleteCommonIssuesFromDb(titles: string[]). Uses drizzle-orm (eq, inArray) with db.delete(issueGroups).where(inArray(issueGroups.title, titles)); no-op for empty input; wrapped in try/catch that swallows errors.

Sequence Diagram(s)

sequenceDiagram
    participant Test
    participant CleanupHelper
    participant DB

    Test->>CleanupHelper: deleteCommonIssuesFromDb([titles])
    CleanupHelper->>DB: DELETE FROM issueGroups WHERE title IN (titles)
    DB-->>CleanupHelper: result / error
    CleanupHelper-->>Test: void
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Possibly related PRs

Suggested reviewers

  • binary-koan

Poem

I nibble through specs with tidy delight,
Sweeping stray issues from database night—
hop, hop, delete, with a whisker’s grace,
Leaving our tests in a pristine place.
Carrots for green checks! 🥕✅

Tip

🔌 Remote MCP (Model Context Protocol) integration is now available!

Pro plan users can now connect to remote MCP servers from the Integrations page. Connect with popular remote MCPs such as Notion and Linear to add more context to your reviews and chats.

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment

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
🪧 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.
    • 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.
  • 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 the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

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

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • 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.

@Udit-takkar
Copy link
Contributor Author

@binary-koan can I get a review on this PR? and others related to cleaning up data

Copy link
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: 3

♻️ Duplicate comments (1)
tests/e2e/common-issues/commonIssues.spec.ts (1)

2-2: Resolved: missing import added

Import for the cleanup helper is correctly added. This addresses the earlier review feedback.

📜 Review details

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

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 5274587 and 94c5929.

📒 Files selected for processing (2)
  • tests/e2e/common-issues/commonIssues.spec.ts (4 hunks)
  • tests/e2e/utils/commonIssueCleanup.ts (1 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (2)
tests/e2e/utils/commonIssueCleanup.ts (1)
db/schema/issueGroups.ts (1)
  • issueGroups (6-19)
tests/e2e/common-issues/commonIssues.spec.ts (1)
tests/e2e/utils/commonIssueCleanup.ts (1)
  • deleteCommonIssuesFromDb (5-11)
🔇 Additional comments (2)
tests/e2e/common-issues/commonIssues.spec.ts (2)

78-78: No-op whitespace change

Nothing to do here.


116-116: LGTM: thorough cleanup after search test

All created issues are cleaned up; this should keep the DB deterministic for downstream tests.

Copy link
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: 0

♻️ Duplicate comments (1)
tests/e2e/common-issues/commonIssues.spec.ts (1)

82-82: Also include originalTitle in cleanup to cover mid-test failures

If the test fails before the rename completes, the record with originalTitle can be left behind. Deleting both titles makes the cleanup resilient.

Apply this diff:

-    await deleteCommonIssuesFromDb([newTitle]);
+    await deleteCommonIssuesFromDb([originalTitle, newTitle]);
🧹 Nitpick comments (1)
tests/e2e/common-issues/commonIssues.spec.ts (1)

59-59: Guarantee cleanup with try/finally (or afterEach) to avoid residue on assertion failures

Right now, cleanup runs only if the test reaches the end. Wrap test bodies in try/finally (or use test.afterEach for this suite) so DB cleanup always executes even when assertions throw.

Example pattern:

test("should create new common issues with form validation", async ({ page }) => {
  const createdTitles: string[] = [];
  try {
    const titleOnlyIssue = `Test Issue ${generateRandomString(8)}`;
    const titleDescriptionIssue = `Test Issue with Description ${generateRandomString(8)}`;
    // ... create issues
    createdTitles.push(titleOnlyIssue, titleDescriptionIssue);
    // ... assertions
  } finally {
    await deleteCommonIssuesFromDb(createdTitles);
  }
});

Optional: ensure the helper logs (at least debug) on failure so silent cleanup errors don’t mask data bleed in CI.

Also applies to: 82-82, 116-116

📜 Review details

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

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 94c5929 and ac3ddda.

📒 Files selected for processing (1)
  • tests/e2e/common-issues/commonIssues.spec.ts (4 hunks)
🧰 Additional context used
🧬 Code Graph Analysis (1)
tests/e2e/common-issues/commonIssues.spec.ts (1)
tests/e2e/utils/commonIssueCleanup.ts (1)
  • deleteCommonIssuesFromDb (5-11)
🔇 Additional comments (4)
tests/e2e/common-issues/commonIssues.spec.ts (4)

2-2: Import added for cleanup helper — good fix

This unblocks the new DB-cleanup flow in tests and resolves the earlier missing import note.


59-59: Cleanup both created issues — prevents DB bleed

Good call deleting both artifacts created in this test. This addresses the data bleed risk between tests.


116-116: Thorough teardown for search test — looks good

All created records are removed, aligning with the PR goal to reset to seed between tests.


78-78: No-op whitespace change

Nothing to do here.

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