This repository has been archived by the owner on Nov 21, 2020. It is now read-only.
-
-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
195 changed files
with
19,669 additions
and
740 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,15 @@ | ||
NODE_ENV=development | ||
PORT=3400 | ||
MONGO_URL=mongodb://localhost:3001/meteor | ||
TEST_MONGO_URL=mongodb://localhost/erxesApiTest | ||
NODE_ENV='development' | ||
PORT=3300 | ||
MONGO_URL=mongodb://localhost/erxes | ||
TEST_MONGO_URL=mongodb://localhost/test | ||
MAIN_APP_DOMAIN=http://localhost:3000 | ||
COMPANY_EMAIL_FROM='[email protected]' | ||
MAIL_SERVICE='sendgrid' | ||
MAIL_USER='apikey' | ||
MAIL_PASS='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' | ||
|
||
TWITTER_CONSUMER_KEY='xQlhyI9cAkRT5LOwGEpM1c2WU' | ||
TWITTER_CONSUMER_SECRET='zGn2j60tBAv0tsClKOSeS3j4HXywCH01DJxOQna32bdcrGMee0' | ||
TWITTER_REDIRECT_URL='http://5e574edb.ngrok.io/service/oauth/twitter_callback' | ||
|
||
FACEBOOK='[{"id":"","name":"","verifyToken":"","accessToken":""}]' |
This file was deleted.
Oops, something went wrong.
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 |
---|---|---|
@@ -0,0 +1,80 @@ | ||
/* eslint-env jest */ | ||
/* eslint-disable no-underscore-dangle */ | ||
|
||
import { connect, disconnect } from '../db/connection'; | ||
import cronJobs from '../cronJobs'; | ||
import { | ||
COC_CONTENT_TYPES, | ||
ACTIVITY_TYPES, | ||
ACTIVITY_ACTIONS, | ||
ACTIVITY_PERFORMER_TYPES, | ||
} from '../data/constants'; | ||
import { ActivityLogs } from '../db/models'; | ||
import { customerFactory, segmentFactory } from '../db/factories'; | ||
|
||
beforeAll(() => connect()); | ||
afterAll(() => disconnect()); | ||
|
||
describe('test activityLogsCronJob', () => { | ||
test('test if it is working as intended', async () => { | ||
// check if the activity log is being created ================== | ||
const nameEqualsConditions = [ | ||
{ | ||
type: 'string', | ||
dateUnit: 'days', | ||
value: 'John Smith', | ||
operator: 'e', | ||
field: 'name', | ||
}, | ||
]; | ||
|
||
const customer = await customerFactory({ name: 'john smith' }); | ||
const segment = await segmentFactory({ | ||
contentType: COC_CONTENT_TYPES.CUSTOMER, | ||
conditions: nameEqualsConditions, | ||
}); | ||
|
||
await cronJobs.createActivityLogsFromSegments(); | ||
|
||
expect(await ActivityLogs.find().count()).toBe(1); | ||
|
||
const aLog = await ActivityLogs.findOne(); | ||
|
||
expect(aLog.activity.toObject()).toEqual({ | ||
type: ACTIVITY_TYPES.SEGMENT, | ||
action: ACTIVITY_ACTIONS.CREATE, | ||
content: segment.name, | ||
id: segment._id, | ||
}); | ||
expect(aLog.coc.toObject()).toEqual({ | ||
type: COC_CONTENT_TYPES.CUSTOMER, | ||
id: customer._id, | ||
}); | ||
expect(aLog.performedBy.toObject()).toEqual({ | ||
type: ACTIVITY_PERFORMER_TYPES.SYSTEM, | ||
}); | ||
|
||
// check if the second activity log is being created | ||
// also check if the duplicate activity log is | ||
// not being created for the former customer ================ | ||
const nameEqualsConditions2 = [ | ||
{ | ||
type: 'string', | ||
dateUnit: 'days', | ||
value: 'jane smith', | ||
operator: 'e', | ||
field: 'name', | ||
}, | ||
]; | ||
|
||
await customerFactory({ name: 'jane smith' }); | ||
await segmentFactory({ | ||
contentType: COC_CONTENT_TYPES.CUSTOMER, | ||
conditions: nameEqualsConditions2, | ||
}); | ||
|
||
await cronJobs.createActivityLogsFromSegments(); | ||
|
||
expect(await ActivityLogs.find().count()).toBe(2); | ||
}); | ||
}); |
Oops, something went wrong.