-
Notifications
You must be signed in to change notification settings - Fork 753
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'main' into crowd-linux
- Loading branch information
Showing
33 changed files
with
408 additions
and
441 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -691,7 +691,7 @@ describe('MemberService tests', () => { | |
}) | ||
}) | ||
|
||
it('Should create non existent member - organization as id, no enrichment', async () => { | ||
it('Should create non existent member - organization as id', async () => { | ||
const mockIServiceOptions = await SequelizeTestUtils.getTestIServiceOptions(db) | ||
|
||
const oCreated = await new OrganizationService(mockIServiceOptions).createOrUpdate({ | ||
|
@@ -793,119 +793,6 @@ describe('MemberService tests', () => { | |
}) | ||
}) | ||
|
||
it('Should create non existent member - organization with enrichment', async () => { | ||
const mockIServiceOptions = await SequelizeTestUtils.getTestIServiceOptions( | ||
db, | ||
Plans.values.growth, | ||
) | ||
|
||
const member1 = { | ||
username: 'anil', | ||
platform: PlatformType.GITHUB, | ||
emails: ['[email protected]'], | ||
score: 10, | ||
attributes: {}, | ||
reach: 10, | ||
bio: 'Computer Science', | ||
organizations: [{ name: 'crowd.dev', url: 'https://crowd.dev', description: 'Here' }], | ||
joinedAt: '2020-05-28T15:13:30Z', | ||
location: 'Istanbul', | ||
} | ||
|
||
const memberCreated = await new MemberService(mockIServiceOptions).upsert(member1) | ||
|
||
memberCreated.createdAt = memberCreated.createdAt.toISOString().split('T')[0] | ||
memberCreated.updatedAt = memberCreated.updatedAt.toISOString().split('T')[0] | ||
|
||
const organization = (await OrganizationRepository.findAndCountAll({}, mockIServiceOptions)) | ||
.rows[0] | ||
|
||
const foundMember = await MemberRepository.findById(memberCreated.id, mockIServiceOptions) | ||
|
||
const o1 = foundMember.organizations[0].get({ plain: true }) | ||
delete o1.createdAt | ||
delete o1.updatedAt | ||
|
||
expect(o1).toStrictEqual({ | ||
id: organization.id, | ||
displayName: 'crowd.dev', | ||
github: null, | ||
location: null, | ||
website: null, | ||
description: | ||
'Understand, grow, and engage your developer community with zero hassle. With crowd.dev, you can build developer communities that drive your business forward.', | ||
emails: ['[email protected]', '[email protected]', '[email protected]'], | ||
phoneNumbers: ['+42 424242'], | ||
logo: 'https://logo.clearbit.com/crowd.dev', | ||
memberOrganizations: { | ||
dateEnd: null, | ||
dateStart: null, | ||
title: null, | ||
source: null, | ||
}, | ||
tags: [], | ||
twitter: { | ||
id: '1362101830923259908', | ||
bio: 'Community-led Growth for Developer-first Companies.\nJoin our private beta. 👇', | ||
site: 'https://t.co/GRLDhqFWk4', | ||
avatar: 'https://pbs.twimg.com/profile_images/1419741008716251141/6exZe94-_normal.jpg', | ||
handle: 'CrowdDotDev', | ||
location: '🌍 remote', | ||
followers: 107, | ||
following: 0, | ||
}, | ||
linkedin: { | ||
handle: 'company/crowddevhq', | ||
}, | ||
crunchbase: { | ||
handle: null, | ||
}, | ||
employees: 5, | ||
revenueRange: { | ||
max: 1, | ||
min: 0, | ||
}, | ||
importHash: null, | ||
deletedAt: null, | ||
tenantId: mockIServiceOptions.currentTenant.id, | ||
createdById: mockIServiceOptions.currentUser.id, | ||
updatedById: mockIServiceOptions.currentUser.id, | ||
isTeamOrganization: false, | ||
type: null, | ||
ticker: null, | ||
size: null, | ||
naics: null, | ||
lastEnrichedAt: null, | ||
industry: null, | ||
headline: null, | ||
geoLocation: null, | ||
founded: null, | ||
employeeCountByCountry: null, | ||
address: null, | ||
profiles: null, | ||
attributes: {}, | ||
manuallyCreated: false, | ||
affiliatedProfiles: null, | ||
allSubsidiaries: null, | ||
alternativeDomains: null, | ||
alternativeNames: null, | ||
averageEmployeeTenure: null, | ||
averageTenureByLevel: null, | ||
averageTenureByRole: null, | ||
directSubsidiaries: null, | ||
employeeChurnRate: null, | ||
employeeCountByMonth: null, | ||
employeeGrowthRate: null, | ||
employeeCountByMonthByLevel: null, | ||
employeeCountByMonthByRole: null, | ||
gicsSector: null, | ||
grossAdditionsByMonth: null, | ||
grossDeparturesByMonth: null, | ||
ultimateParent: null, | ||
immediateParent: null, | ||
}) | ||
}) | ||
|
||
it('Should update existent member succesfully - simple', async () => { | ||
const mockIServiceOptions = await SequelizeTestUtils.getTestIServiceOptions(db) | ||
|
||
|
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -5,42 +5,6 @@ import OrganizationService from '../organizationService' | |
|
||
const db = null | ||
|
||
const expectedEnriched = { | ||
identities: [ | ||
{ | ||
name: 'crowd.dev', | ||
platform: 'crowd', | ||
}, | ||
], | ||
description: | ||
'Understand, grow, and engage your developer community with zero hassle. With crowd.dev, you can build developer communities that drive your business forward.', | ||
emails: ['[email protected]', '[email protected]', '[email protected]'], | ||
phoneNumbers: ['+42 424242'], | ||
logo: 'https://logo.clearbit.com/crowd.dev', | ||
tags: [], | ||
twitter: { | ||
handle: 'CrowdDotDev', | ||
id: '1362101830923259908', | ||
bio: 'Community-led Growth for Developer-first Companies.\nJoin our private beta. 👇', | ||
followers: 107, | ||
following: 0, | ||
location: '🌍 remote', | ||
site: 'https://t.co/GRLDhqFWk4', | ||
avatar: 'https://pbs.twimg.com/profile_images/1419741008716251141/6exZe94-_normal.jpg', | ||
}, | ||
linkedin: { | ||
handle: 'company/crowddevhq', | ||
}, | ||
crunchbase: { | ||
handle: null, | ||
}, | ||
employees: 5, | ||
revenueRange: { | ||
min: 0, | ||
max: 1, | ||
}, | ||
} | ||
|
||
describe('OrganizationService tests', () => { | ||
beforeEach(async () => { | ||
await SequelizeTestUtils.wipeDatabase(db) | ||
|
@@ -52,44 +16,7 @@ describe('OrganizationService tests', () => { | |
}) | ||
|
||
describe('Create method', () => { | ||
it('Should add without enriching when enrichP is false', async () => { | ||
const mockIServiceOptions = await SequelizeTestUtils.getTestIServiceOptions( | ||
db, | ||
Plans.values.growth, | ||
) | ||
const service = new OrganizationService(mockIServiceOptions) | ||
|
||
const toAdd = { | ||
identities: [ | ||
{ | ||
name: 'crowd.dev', | ||
platform: 'crowd', | ||
}, | ||
], | ||
} | ||
|
||
const added = await service.createOrUpdate(toAdd, false) | ||
expect(added.identities[0].url).toEqual(null) | ||
}) | ||
|
||
it('Should add without enriching when tenant is not growth', async () => { | ||
const mockIServiceOptions = await SequelizeTestUtils.getTestIServiceOptions(db) | ||
const service = new OrganizationService(mockIServiceOptions) | ||
|
||
const toAdd = { | ||
identities: [ | ||
{ | ||
name: 'crowd.dev', | ||
platform: 'crowd', | ||
}, | ||
], | ||
} | ||
|
||
const added = await service.createOrUpdate(toAdd, true) | ||
expect(added.identities[0].url).toEqual(null) | ||
}) | ||
|
||
it('Should enrich and add an organization by identity name', async () => { | ||
it('Should create organization', async () => { | ||
const mockIServiceOptions = await SequelizeTestUtils.getTestIServiceOptions( | ||
db, | ||
Plans.values.growth, | ||
|
@@ -101,120 +28,12 @@ describe('OrganizationService tests', () => { | |
{ | ||
name: 'crowd.dev', | ||
platform: 'crowd', | ||
url: 'https://crowd.dev', | ||
}, | ||
], | ||
} | ||
|
||
const added = await service.createOrUpdate(toAdd) | ||
expect(added.identities[0].url).toEqual(toAdd.identities[0].url) | ||
expect(added.identities[0].name).toEqual(toAdd.identities[0].name) | ||
expect(added.description).toEqual(expectedEnriched.description) | ||
expect(added.emails).toEqual(expectedEnriched.emails) | ||
expect(added.phoneNumbers).toEqual(expectedEnriched.phoneNumbers) | ||
expect(added.logo).toEqual(expectedEnriched.logo) | ||
expect(added.tags).toStrictEqual(expectedEnriched.tags) | ||
expect(added.twitter).toStrictEqual(expectedEnriched.twitter) | ||
expect(added.linkedin).toStrictEqual(expectedEnriched.linkedin) | ||
expect(added.crunchbase).toStrictEqual(expectedEnriched.crunchbase) | ||
expect(added.employees).toEqual(expectedEnriched.employees) | ||
expect(added.revenueRange).toStrictEqual(expectedEnriched.revenueRange) | ||
|
||
// Check cache table was created | ||
const foundCache = await organizationCacheRepository.findByName( | ||
'crowd.dev', | ||
mockIServiceOptions, | ||
) | ||
|
||
expect(foundCache.url).toEqual('crowd.dev') | ||
expect(foundCache.name).toEqual(toAdd.identities[0].name) | ||
expect(foundCache.description).toEqual(expectedEnriched.description) | ||
expect(foundCache.emails).toEqual(expectedEnriched.emails) | ||
expect(foundCache.phoneNumbers).toEqual(expectedEnriched.phoneNumbers) | ||
expect(foundCache.logo).toEqual(expectedEnriched.logo) | ||
expect(foundCache.tags).toStrictEqual(expectedEnriched.tags) | ||
expect(foundCache.twitter).toStrictEqual(expectedEnriched.twitter) | ||
expect(foundCache.linkedin).toStrictEqual(expectedEnriched.linkedin) | ||
expect(foundCache.crunchbase).toStrictEqual(expectedEnriched.crunchbase) | ||
expect(foundCache.employees).toEqual(expectedEnriched.employees) | ||
expect(foundCache.revenueRange).toStrictEqual(expectedEnriched.revenueRange) | ||
}) | ||
|
||
it('Should not re-enrich when the record is already in the cache table. By Name', async () => { | ||
const mockIServiceOptions = await SequelizeTestUtils.getTestIServiceOptions( | ||
db, | ||
Plans.values.growth, | ||
) | ||
const mockIServiceOptions2 = await SequelizeTestUtils.getTestIServiceOptions( | ||
db, | ||
Plans.values.growth, | ||
) | ||
|
||
const service = new OrganizationService(mockIServiceOptions) | ||
const service2 = new OrganizationService(mockIServiceOptions2) | ||
|
||
const toAdd = { | ||
identities: [ | ||
{ | ||
name: 'crowd.dev', | ||
platform: 'crowd', | ||
url: 'https://crowd.dev', | ||
}, | ||
], | ||
} | ||
|
||
const added = await service.createOrUpdate(toAdd) | ||
expect(added.identities[0].url).toEqual(toAdd.identities[0].url) | ||
expect(added.identities[0].name).toEqual(toAdd.identities[0].name) | ||
expect(added.description).toEqual(expectedEnriched.description) | ||
expect(added.emails).toEqual(expectedEnriched.emails) | ||
expect(added.phoneNumbers).toEqual(expectedEnriched.phoneNumbers) | ||
expect(added.logo).toEqual(expectedEnriched.logo) | ||
expect(added.tags).toStrictEqual(expectedEnriched.tags) | ||
expect(added.twitter).toStrictEqual(expectedEnriched.twitter) | ||
expect(added.linkedin).toStrictEqual(expectedEnriched.linkedin) | ||
expect(added.crunchbase).toStrictEqual(expectedEnriched.crunchbase) | ||
expect(added.employees).toEqual(expectedEnriched.employees) | ||
expect(added.revenueRange).toStrictEqual(expectedEnriched.revenueRange) | ||
|
||
// Check cache table was created | ||
const foundCache = await organizationCacheRepository.findByName( | ||
'crowd.dev', | ||
mockIServiceOptions, | ||
) | ||
|
||
expect(foundCache.name).toEqual('crowd.dev') | ||
expect(foundCache.description).toEqual(expectedEnriched.description) | ||
expect(foundCache.emails).toEqual(expectedEnriched.emails) | ||
expect(foundCache.phoneNumbers).toEqual(expectedEnriched.phoneNumbers) | ||
expect(foundCache.logo).toEqual(expectedEnriched.logo) | ||
expect(foundCache.tags).toStrictEqual(expectedEnriched.tags) | ||
expect(foundCache.twitter).toStrictEqual(expectedEnriched.twitter) | ||
expect(foundCache.linkedin).toStrictEqual(expectedEnriched.linkedin) | ||
expect(foundCache.crunchbase).toStrictEqual(expectedEnriched.crunchbase) | ||
expect(foundCache.employees).toEqual(expectedEnriched.employees) | ||
expect(foundCache.revenueRange).toStrictEqual(expectedEnriched.revenueRange) | ||
|
||
const added2 = await service2.createOrUpdate(toAdd) | ||
expect(added2.identities[0].url).toEqual(toAdd.identities[0].url) | ||
expect(added2.description).toEqual(expectedEnriched.description) | ||
expect(added2.emails).toEqual(expectedEnriched.emails) | ||
expect(added2.phoneNumbers).toEqual(expectedEnriched.phoneNumbers) | ||
expect(added2.logo).toEqual(expectedEnriched.logo) | ||
expect(added2.tags).toStrictEqual(expectedEnriched.tags) | ||
expect(added2.twitter).toStrictEqual(expectedEnriched.twitter) | ||
expect(added2.linkedin).toStrictEqual(expectedEnriched.linkedin) | ||
expect(added2.crunchbase).toStrictEqual(expectedEnriched.crunchbase) | ||
expect(added2.employees).toEqual(expectedEnriched.employees) | ||
expect(added2.revenueRange).toStrictEqual(expectedEnriched.revenueRange) | ||
// Check they are indeed in different tenants | ||
expect(added2.tenantId).not.toBe(added.tenantId) | ||
|
||
const foundCache2 = await organizationCacheRepository.findByName( | ||
'crowd.dev', | ||
mockIServiceOptions, | ||
) | ||
expect(foundCache2.id).toEqual(foundCache.id) | ||
expect(added.identities[0].url).toEqual(null) | ||
}) | ||
|
||
it('Should throw an error when name is not sent', async () => { | ||
|
This file contains 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
Oops, something went wrong.