Skip to content

Commit

Permalink
feat(automations): added feature automations
Browse files Browse the repository at this point in the history
  • Loading branch information
Enkhtuvshin0513 committed Oct 5, 2021
1 parent 34ff9e5 commit 984a418
Show file tree
Hide file tree
Showing 242 changed files with 23,334 additions and 1,936 deletions.
12 changes: 12 additions & 0 deletions .github/workflows/api.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,18 @@ jobs:
ports:
- 27017:27017

elasticsearch:
image: docker.elastic.co/elasticsearch/elasticsearch:7.9.2
env:
discovery.type: single-node
options: >-
--health-cmd "curl http://localhost:9200/_cluster/health"
--health-interval 10s
--health-timeout 5s
--health-retries 10
ports:
- 9200:9200

steps:
- uses: actions/checkout@v2

Expand Down
87 changes: 87 additions & 0 deletions .github/workflows/automations.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
name: Automations CI

on:
push:
branches:
- "**"
paths:
- "automations/**"
- "!automations/**.md"
- "!.github/**"
- ".github/workflows/automations.yaml"
pull_request:
branches:
- master
- develop
paths:
- "automations/**"
- "!automations/**.md"
- "!.github/**"
- ".github/workflows/automations.yaml"

jobs:
automations:
runs-on: ubuntu-18.04

services:
mongodb:
image: mongo:4.0
ports:
- 27017:27017

steps:
- uses: actions/checkout@v2

- name: Use Node.js 12.19.x
uses: actions/setup-node@v1
with:
node-version: 12.19.x

# https://github.com/actions/cache/blob/master/examples.md#node---yarn
- name: Get yarn cache directory path
id: yarn-cache-dir-path
run: echo "::set-output name=dir::$(yarn cache dir)"

- uses: actions/cache@v2
id: yarn-cache # use this to check for `cache-hit` (`steps.yarn-cache.outputs.cache-hit != 'true'`)
with:
path: ${{ steps.yarn-cache-dir-path.outputs.dir }}
key: ${{ runner.os }}-yarn-automations-${{ hashFiles('yarn.lock', 'automations/yarn.lock') }}
restore-keys: |
${{ runner.os }}-yarn-automations-
${{ runner.os }}-yarn-
- name: Install dependencies
run: |
yarn install
cd automations
yarn install --frozen-lockfile
- name: Lint
run: |
yarn lint automations
- name: Test
run: |
cd automations
yarn test
env:
TEST_MONGO_URL: mongodb://localhost/test
DOMAIN: http://localhost:4000
MAIN_APP_DOMAIN: http://localhost:4000

- name: Build
if: github.event_name == 'push' && ( github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop' )
run: |
cd automations
rm -rf node_modules
yarn install --frozen-lockfile --production
yarn build
- name: Build docker image
if: github.event_name == 'push' && ( github.ref == 'refs/heads/master' || github.ref == 'refs/heads/develop' )
run: |
cd automations
echo ${{ secrets.DOCKERHUB_TOKEN }} | docker login -u ${{ secrets.DOCKERHUB_USERNAME }} --password-stdin
docker build -t erxes/erxes-automations:${GITHUB_REF#refs/heads/} -f Dockerfile .
docker push erxes/erxes-automations:${GITHUB_REF#refs/heads/}
1 change: 1 addition & 0 deletions api/.env.sample
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,7 @@ INTEGRATIONS_API_DOMAIN=http://localhost:3400
DASHBOARD_DOMAIN=http://localhost:4200
CLIENT_PORTAL_DOMAIN=http://localhost:4300
ENGAGES_API_DOMAIN=http://localhost:3900
AUTOMATIONS_API_DOMAIN=http://localhost:4000
CLIENT_PORTAL_MN_DOMAIN=http://localhost:5300
LOGS_API_DOMAIN=http://localhost:3800

Expand Down
2 changes: 2 additions & 0 deletions api/jest.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ module.exports = {
modulePathIgnorePatterns: [
'utils.ts',
'setup.ts',
'esMappings.ts',
'conversationCronJob.test.ts',
'coverage/'
],
Expand All @@ -19,6 +20,7 @@ module.exports = {
'!src/db/models/Robot.ts',
'!src/db/models/definitions/**',
'src/data/resolvers/**',
'src/data/modules/segments/**',
'!src/data/resolvers/customScalars.ts',
'!src/data/resolvers/mutations/robot.ts',
'!src/data/resolvers/queries/robot.ts',
Expand Down
1 change: 1 addition & 0 deletions api/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
"addMiddleName": "node_modules/.bin/ts-node src/commands/addMiddleName.ts",
"removeUnusedFields": "node_modules/.bin/ts-node src/commands/removeUnusedFields.ts",
"migrateKnowledgeBase": "node_modules/.bin/ts-node src/commands/migrateKnowledgeBase.ts",
"migrateSegment": "node_modules/.bin/ts-node src/commands/segmentMigration.ts",
"changeToSubscribed": "node_modules/.bin/ts-node src/commands/changeToSubscribed.ts",
"fixCompanyScopeBrandIds": "node_modules/.bin/ts-node src/commands/fixCompanyScopeBrandIds.ts"
},
Expand Down
30 changes: 30 additions & 0 deletions api/src/__tests__/activityLogQueries.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@ import {
integrationFactory,
internalNoteFactory,
stageFactory,
tagsFactory,
taskFactory,
ticketFactory,
userFactory
Expand Down Expand Up @@ -467,4 +468,33 @@ describe('activityLogQueries', () => {

spy.mockRestore();
});

test('Activity log tagged', async () => {
const customer = await customerFactory();
const tag = await tagsFactory();

const doc = {
contentId: customer._id,
contentType: 'customer',
action: 'tagged',
content: {
tagIds: [tag._id]
}
};

const spy = jest.spyOn(logUtils, 'fetchLogs');
spy.mockImplementation(async () => [await activityLogFactory(doc)]);

const args = { contentId: customer._id, contentType: 'customer' };

const response = await graphqlRequest(
qryActivityLogs,
'activityLogs',
args
);

expect(response.length).toBe(1);

spy.mockRestore();
});
});
Loading

0 comments on commit 984a418

Please sign in to comment.