Skip to content

Commit 99097ff

Browse files
committed
feat: make source property optional in work experience interface
Signed-off-by: Yeganathan S <63534555+skwowet@users.noreply.github.com>
1 parent f29056f commit 99097ff

2 files changed

Lines changed: 85 additions & 1 deletion

File tree

services/libs/data-access-layer/src/affiliations/__tests__/affiliations.test.ts

Lines changed: 84 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -182,6 +182,90 @@ describe('selectPrimaryWorkExperience', () => {
182182
const result = selectPrimaryWorkExperience([shortRange, longRange])
183183
expect(result.organizationName).toBe('LongRange')
184184
})
185+
186+
it('email-domain beats enrichment when both are dated', () => {
187+
const enrichment = makeRow({
188+
organizationId: 'enrichment',
189+
organizationName: 'Enrichment Org',
190+
dateStart: '2020-01-01',
191+
source: 'enrichment-progai',
192+
})
193+
const emailDomain = makeRow({
194+
organizationId: 'email',
195+
organizationName: 'Email Org',
196+
dateStart: '2020-01-01',
197+
source: 'email-domain',
198+
})
199+
expect(selectPrimaryWorkExperience([enrichment, emailDomain]).organizationName).toBe('Email Org')
200+
})
201+
202+
it('ui beats email-domain when both are dated', () => {
203+
const emailDomain = makeRow({
204+
organizationId: 'email',
205+
organizationName: 'Email Org',
206+
dateStart: '2020-01-01',
207+
source: 'email-domain',
208+
})
209+
const ui = makeRow({
210+
organizationId: 'ui',
211+
organizationName: 'UI Org',
212+
dateStart: '2020-01-01',
213+
source: 'ui',
214+
})
215+
expect(selectPrimaryWorkExperience([emailDomain, ui]).organizationName).toBe('UI Org')
216+
})
217+
218+
it('ui beats enrichment when both are dated', () => {
219+
const enrichment = makeRow({
220+
organizationId: 'enrichment',
221+
organizationName: 'Enrichment Org',
222+
dateStart: '2020-01-01',
223+
source: 'enrichment-clearbit',
224+
})
225+
const ui = makeRow({
226+
organizationId: 'ui',
227+
organizationName: 'UI Org',
228+
dateStart: '2020-01-01',
229+
source: 'ui',
230+
})
231+
expect(selectPrimaryWorkExperience([enrichment, ui]).organizationName).toBe('UI Org')
232+
})
233+
234+
it('falls through to member count when source tiers are equal', () => {
235+
const small = makeRow({
236+
organizationId: 'small',
237+
organizationName: 'Small Enrichment',
238+
dateStart: '2020-01-01',
239+
memberCount: 10,
240+
source: 'enrichment-progai',
241+
})
242+
const large = makeRow({
243+
organizationId: 'large',
244+
organizationName: 'Large Enrichment',
245+
dateStart: '2020-01-01',
246+
memberCount: 100,
247+
source: 'enrichment-progai',
248+
})
249+
expect(selectPrimaryWorkExperience([small, large]).organizationName).toBe('Large Enrichment')
250+
})
251+
252+
it('undated rows are not affected by source priority — dated enrichment beats undated email-domain', () => {
253+
const undatedEmailDomain = makeRow({
254+
organizationId: 'email',
255+
organizationName: 'Email Org',
256+
dateStart: null,
257+
source: 'email-domain',
258+
})
259+
const datedEnrichment = makeRow({
260+
organizationId: 'enrichment',
261+
organizationName: 'Enrichment Org',
262+
dateStart: '2020-01-01',
263+
source: 'enrichment-progai',
264+
})
265+
expect(selectPrimaryWorkExperience([undatedEmailDomain, datedEnrichment]).organizationName).toBe(
266+
'Enrichment Org',
267+
)
268+
})
185269
})
186270

187271
// ---------------------------------------------------------------------------

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ export interface IWorkExperienceResolution {
2222
isPrimaryWorkExperience: boolean
2323
memberCount: number
2424
segmentId: string | null
25-
source: string | null
25+
source?: string | null
2626
}
2727

2828
/**

0 commit comments

Comments
 (0)