Skip to content

test: [Stacked] migrate findTeamMembersMatchingAttributeLogic to integration tests#27697

Merged
joeauyeung merged 7 commits intomainfrom
use-integration-tests-for-findTeamMembersMatchibg
Feb 6, 2026
Merged

test: [Stacked] migrate findTeamMembersMatchingAttributeLogic to integration tests#27697
joeauyeung merged 7 commits intomainfrom
use-integration-tests-for-findTeamMembersMatchibg

Conversation

@hariombalhara
Copy link
Copy Markdown
Member

@hariombalhara hariombalhara commented Feb 6, 2026

What does this PR do?

Migrates findTeamMembersMatchingAttributeLogic tests from mock-based unit tests to integration tests that run against a real database via Prisma. This gives higher confidence that attribute matching logic works correctly end-to-end.

This PR only changes the test file — no production code is modified.

Changes

  • Renamed findTeamMembersMatchingAttributeLogic.test.ts.integration-test.ts
  • Removed all mocksvi.mock() for getAttributes and react-awesome-query-builder/widgets replaced with real Prisma fixture helpers (createTestOrganization, createTestTeam, createTestUser, createTestAttribute, createTestAttributeAssignment)
  • Proper lifecyclebeforeAll/afterAll for org+team setup/teardown, afterEach for per-test resource cleanup
  • Dynamic IDs — hardcoded userId: 1, teamId: 1 replaced with real DB-generated IDs via testFixtures and createdUsers
  • Enum usage"SINGLE_SELECT" as constAttributeType.SINGLE_SELECT
  • Performance test — scaled to 20 attributes × 400 users (down from 4000) with 60s timeout to account for real DB overhead
  • Error handling — unsupported attribute type test updated: expects null return instead of thrown error (aligns with actual runtime behavior for AttributeType.TEXT with select operators)
  • Negation operator tests — migrated from mock-based to integration-test style, including an additional test case ("should match users who have a different attribute but not the queried one")

Updates since last revision

  • Resolved merge conflict with main by keeping the integration-test version of the negation operator tests (discarding the duplicate mock-based version from main)
  • Reverted changes to apps/web/modules/event-types/components/AddMembersWithSwitch.tsx — this PR is now test-only

Mandatory Tasks (DO NOT REMOVE)

  • I have self-reviewed the code (A decent size PR without self-review might be rejected).
  • I have updated the developer docs in /docs if this PR makes changes that would require a documentation change. N/A — test-only change.
  • I confirm automated tests are in place that prove my fix is effective or that my feature works.

How should this be tested?

Run the integration tests (requires a running Postgres database):

VITEST_MODE=integration yarn test packages/features/routing-forms/lib/findTeamMembersMatchingAttributeLogic.integration-test.ts

Human Review Checklist

  • In createAttributesScenario, the if (member.userId) branch creates a new user and ignores the provided userId — this looks like dead code / a bug. Verify this is intentional or clean it up.
  • Performance test reduced from 4000 → 400 members — confirm this still provides meaningful coverage and isn't masking regressions.
  • Verify CI environment supports integration tests with real DB connections.
  • Confirm the error handling change (thrown error → null return for TEXT attributes) matches actual production behavior.

Link to Devin run: https://app.devin.ai/sessions/c58b5f1e6387461bae9e6b77a6a163a8
Requested by: @joeauyeung

@graphite-app graphite-app Bot added the core area: core, team members only label Feb 6, 2026
@graphite-app graphite-app Bot requested a review from a team February 6, 2026 10:29
@graphite-app graphite-app Bot added the enterprise area: enterprise, audit log, organisation, SAML, SSO label Feb 6, 2026
@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 6, 2026

Hey there and thank you for opening this pull request! 👋🏼

We require pull request titles to follow the Conventional Commits specification and it looks like your proposed title needs to be adjusted.

Details:

No release type found in pull request title "Fix exclusion filter - include all team members". Add a prefix to indicate what kind of release this pull request corresponds to. For reference, see https://www.conventionalcommits.org/

Available types:
 - feat: A new feature
 - fix: A bug fix
 - docs: Documentation only changes
 - style: Changes that do not affect the meaning of the code (white-space, formatting, missing semi-colons, etc)
 - refactor: A code change that neither fixes a bug nor adds a feature
 - perf: A code change that improves performance
 - test: Adding missing tests or correcting existing tests
 - build: Changes that affect the build system or external dependencies (example scopes: gulp, broccoli, npm)
 - ci: Changes to our CI configuration files and scripts (example scopes: Travis, Circle, BrowserStack, SauceLabs)
 - chore: Other changes that don't modify src or test files
 - revert: Reverts a previous commit

@paragon-review
Copy link
Copy Markdown

paragon-review Bot commented Feb 6, 2026

Paragon Review Skipped

Hi @hariombalhara! Your Polarity credit balance is insufficient to complete this review.

Please visit https://home.polarity.cc to add more credits and continue using Paragon reviews.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't mock getAttributes or DB queries here. So, we can better test the behavior e2e from the perspective of findTeamMembersMatchingAttributeLogic

@devin-ai-integration devin-ai-integration Bot changed the title Fix exclusion filter - include all team members fix: include all team members in exclusion attribute filter Feb 6, 2026
Copy link
Copy Markdown
Contributor

@devin-ai-integration devin-ai-integration Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Devin Review found 1 potential issue.

View 5 additional findings in Devin Review.

Open in Devin Review

@devin-ai-integration devin-ai-integration Bot changed the title fix: include all team members in exclusion attribute filter test: migrate findTeamMembersMatchingAttributeLogic to integration tests Feb 6, 2026
Copy link
Copy Markdown
Contributor

@cubic-dev-ai cubic-dev-ai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

1 issue found across 1 file

Prompt for AI agents (all issues)

Check if these issues are valid — if so, understand the root cause of each and fix them.


<file name="packages/features/routing-forms/lib/findTeamMembersMatchingAttributeLogic.integration-test.ts">

<violation number="1" location="packages/features/routing-forms/lib/findTeamMembersMatchingAttributeLogic.integration-test.ts:176">
P2: The `userId` parameter is accepted but never actually used. When `member.userId` is truthy, the code sets `userId = member.userId` but then immediately overwrites it by creating a new test user. Both branches of the if/else perform identical operations, making the `userId` parameter dead code. If a test passes a specific `userId` to reuse an existing user, a new user will be silently created instead.</violation>
</file>

Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Feb 6, 2026

Devin AI is addressing Cubic AI's review feedback

New feedback has been sent to the existing Devin session.

View Devin Session


✅ Pushed commit 9cda53c

@hariombalhara hariombalhara force-pushed the use-integration-tests-for-findTeamMembersMatchibg branch from 9cda53c to 029ea9b Compare February 6, 2026 11:25
@hariombalhara hariombalhara changed the title test: migrate findTeamMembersMatchingAttributeLogic to integration tests test: [Stacked] migrate findTeamMembersMatchingAttributeLogic to integration tests Feb 6, 2026
joeauyeung
joeauyeung previously approved these changes Feb 6, 2026
Base automatically changed from fix-exclusion-attribute-filter to main February 6, 2026 14:06
@joeauyeung joeauyeung dismissed their stale review February 6, 2026 14:06

The base branch was changed.

…ep integration test version of negation operators tests

Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com>
Co-Authored-By: joe@cal.com <j.auyeung419@gmail.com>
@joeauyeung joeauyeung merged commit 68022f3 into main Feb 6, 2026
55 checks passed
@joeauyeung joeauyeung deleted the use-integration-tests-for-findTeamMembersMatchibg branch February 6, 2026 17:48
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

core area: core, team members only enterprise area: enterprise, audit log, organisation, SAML, SSO ready-for-e2e size/XL

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants