Open
Conversation
|
|
Contributor
There was a problem hiding this comment.
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.tssuite 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.createdAtis typed asDate | string, butfindManualAffiliationsBulkselectsNULL::timestamptz AS "createdAt", so runtime rows can havecreatedAt = null. Now that this interface is exported, it should accurately reflect the DB shape (e.g., allownulland ensure callers handle it, or return a non-nullcreatedAtfrom 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
buildTimelineis now exported, which makes it part of the public@crowd/data-access-layerAPI 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.
services/libs/data-access-layer/src/affiliations/__tests__/affiliations.test.ts
Show resolved
Hide resolved
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
Signed-off-by: Umberto Sgueglia <usgueglia@contractor.linuxfoundation.org>
a1ae269 to
4441da0
Compare
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
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(newvitest.config.ts, newtestscripts, andvitestdevDependency), with lockfile updates for Vitest/Vite tooling.Introduces a comprehensive unit test suite for
affiliationsresolution (selectPrimaryWorkExperience,buildTimeline, andresolveAffiliationsByMemberIds) using mocked DB/logging dependencies, and exposesIWorkExperienceResolution,selectPrimaryWorkExperience, andbuildTimelinefromsrc/affiliations/index.tsto enable direct testing.Written by Cursor Bugbot for commit 4441da0. This will update automatically on new commits. Configure here.