Skip to content

feat: add tests (CM-1063)#3976

Open
ulemons wants to merge 3 commits intomainfrom
feat/affiliations-logic-tests
Open

feat: add tests (CM-1063)#3976
ulemons wants to merge 3 commits intomainfrom
feat/affiliations-logic-tests

Conversation

@ulemons
Copy link
Copy Markdown
Contributor

@ulemons ulemons commented Mar 30, 2026

Note

Low Risk
Low risk: changes are test-only plus making a few previously-internal affiliations helpers/types exported; main risk is unintended reliance on these exports as part of the library API surface.

Overview
Adds a Vitest test setup to @crowd/data-access-layer (new vitest.config.ts, new test scripts, and vitest devDependency), with lockfile updates for Vitest/Vite tooling.

Introduces a comprehensive unit test suite for affiliations resolution (selectPrimaryWorkExperience, buildTimeline, and resolveAffiliationsByMemberIds) using mocked DB/logging dependencies, and exposes IWorkExperienceResolution, selectPrimaryWorkExperience, and buildTimeline from src/affiliations/index.ts to enable direct testing.

Written by Cursor Bugbot for commit 4441da0. This will update automatically on new commits. Configure here.

Copilot AI review requested due to automatic review settings March 30, 2026 12:14
@ulemons ulemons self-assigned this Mar 30, 2026
@CLAassistant
Copy link
Copy Markdown

CLA assistant check
Thank you for your submission! We really appreciate it. Like many open source projects, we ask that you sign our Contributor License Agreement before we can accept your contribution.
You have signed the CLA already but the status is still pending? Let us recheck it.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Adds Vitest-based unit tests for the data-access-layer affiliations resolution logic.

Changes:

  • Added Vitest configuration and test scripts for @crowd/data-access-layer.
  • Added a comprehensive affiliations.test.ts suite covering affiliation selection, timeline building, and bulk resolution behavior.
  • Exported previously-internal affiliations helpers/types to enable direct unit testing.

Reviewed changes

Copilot reviewed 4 out of 5 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
services/libs/data-access-layer/vitest.config.ts Introduces Vitest configuration for this workspace package.
services/libs/data-access-layer/src/affiliations/index.ts Exposes internal types/helpers used by the new tests.
services/libs/data-access-layer/src/affiliations/tests/affiliations.test.ts Adds new unit tests for affiliations resolution and timeline logic.
services/libs/data-access-layer/package.json Adds test scripts and Vitest devDependency.
pnpm-lock.yaml Locks new Vitest/Vite dependency graph changes.
Files not reviewed (1)
  • pnpm-lock.yaml: Language not supported
Comments suppressed due to low confidence (2)

services/libs/data-access-layer/src/affiliations/index.ts:24

  • IWorkExperienceResolution.createdAt is typed as Date | string, but findManualAffiliationsBulk selects NULL::timestamptz AS "createdAt", so runtime rows can have createdAt = null. Now that this interface is exported, it should accurately reflect the DB shape (e.g., allow null and ensure callers handle it, or return a non-null createdAt from the query).
export interface IWorkExperienceResolution {
  id: string
  memberId: string
  organizationId: string
  organizationName: string
  title: string | null
  dateStart: string | null
  dateEnd: string | null
  createdAt: Date | string
  isPrimaryWorkExperience: boolean
  memberCount: number
  segmentId: string | null

services/libs/data-access-layer/src/affiliations/index.ts:206

  • buildTimeline is now exported, which makes it part of the public @crowd/data-access-layer API because the package entrypoint re-exports ./affiliations. If this is intended as an internal implementation detail, consider keeping it non-exported to avoid locking in its signature/behavior for downstream consumers.
export function buildTimeline(
  allRows: IWorkExperienceResolution[],
  fallbackOrg: IWorkExperienceResolution | null,
  boundaries: Date[],
): IAffiliationPeriod[] {

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

ulemons added 3 commits March 30, 2026 16:01
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
@ulemons ulemons force-pushed the feat/affiliations-logic-tests branch from a1ae269 to 4441da0 Compare March 30, 2026 14:01
@ulemons ulemons requested a review from skwowet March 31, 2026 08:16
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.

3 participants