Skip to content

Commit

Permalink
Merge pull request #5 from hopetambala/master
Browse files Browse the repository at this point in the history
Merge main into open-source main
  • Loading branch information
hopetambala committed Sep 5, 2023
2 parents 8cc6bee + 96f58f5 commit b75cf92
Show file tree
Hide file tree
Showing 30 changed files with 4,896 additions and 3,639 deletions.
9 changes: 8 additions & 1 deletion .env.dev
Original file line number Diff line number Diff line change
@@ -1,4 +1,11 @@
PARSE_SERVER_ALLOW_ORIGIN="*"
PARSE_ENV=dev
PARSE_APP_ID="myAppId"
PARSE_JAVASCRIPT_KEY=_PLACEHOLDER_
PARSE_SERVER_URL="http://localhost:1337/parse"
PARSE_SERVER_URL="http://localhost:1337/parse"
PUENTE_SMS_EMAIL_API_URL=http://puentes-messaging-microservice.com
PUENTE_MANAGE_URL=https://sample-puente-manage.app/"

SLACK_TOKEN=""
SLACK_DEV_CHANNEL=""
SLACK_PROD_CHANNEL=""
4 changes: 0 additions & 4 deletions .env.staging

This file was deleted.

59 changes: 32 additions & 27 deletions .github/workflows/jest.yaml
Original file line number Diff line number Diff line change
@@ -1,48 +1,53 @@
name: Jest Tests

env:
PARSE_ENV : "dev"
PARSE_APP_ID : "myAppId"
PARSE_JAVASCRIPT_KEY : "_PLACEHOLDER_"
PARSE_SERVER_URL : "http://localhost:1337/parse"
PARSE_ENV: "dev"
PARSE_APP_ID: "myAppId"
PARSE_JAVASCRIPT_KEY: "_PLACEHOLDER_"
PARSE_SERVER_URL: "http://localhost:1337/parse"
PUENTE_ENV: "dev"
PUENTE_SMS_EMAIL_API_URL: "http://puentes-messaging-microservice.com"
PUENTE_MANAGE_URL: "https://sample-puente-manage.app/"
SLACK_TOKEN: ""
SLACK_DEV_CHANNEL: ""
SLACK_PROD_CHANNEL: ""

on:
push:
branches:
branches:
- master
- dev
pull_request:
branches:
- master
- dev
branches:
- master
- dev
jobs:
jest-testing:
runs-on: ubuntu-latest
strategy:
matrix:
node-version: [12.x,14.x]
node-version: [14.x, 16.x]
services:
mongodb:
image: mongo:4.4
ports:
- 27017:27017
steps:
- name: Checkout
uses: actions/checkout@v2

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install Puente CloudCode Dependencies
run: |
npm install
- name: Lint
run: |
npm run lint
- name: Start App and Test Jest
run: |
npm run start &
sleep 40 &&
npm run test-github-actions
- name: Checkout
uses: actions/checkout@v2

- name: Setup Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v1
with:
node-version: ${{ matrix.node-version }}
- name: Install Puente CloudCode Dependencies
run: |
npm install
- name: Lint
run: |
npm run lint
- name: Start App and Test Jest
run: |
npm run start &
sleep 40 &&
npm run test-github-actions
2 changes: 2 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ logs
*.DS_Store
/coverage
.parse.local
.env.staging
.env.prod

1 change: 1 addition & 0 deletions .nvmrc
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
v14.20.1
51 changes: 51 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,57 @@

All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.

### [1.10.2](https://github.com/hopetambala/puente-node-cloudcode/compare/v1.10.1...v1.10.2) (2022-12-14)

### [1.10.1](https://github.com/hopetambala/puente-node-cloudcode/compare/v1.10.0...v1.10.1) (2022-12-13)

## [1.10.0](https://github.com/hopetambala/puente-node-cloudcode/compare/v1.9.0...v1.10.0) (2022-12-13)


### Features

* add slackbot to posting ([b5a9af4](https://github.com/hopetambala/puente-node-cloudcode/commit/b5a9af4ea4843e7339532dfb4ed896abb71804be))


### Bug Fixes

* offline post survey hook ([33db521](https://github.com/hopetambala/puente-node-cloudcode/commit/33db521fa976f1f0f8fe322f8c4449d9a1ab25be))
* return statement if no data ([47db31d](https://github.com/hopetambala/puente-node-cloudcode/commit/47db31db0f0975c8c2b2c683fd3388d05337aa74))

## [1.9.0](https://github.com/hopetambala/puente-node-cloudcode/compare/v1.5.0...v1.9.0) (2022-10-10)


### Features

* add deep linking betweent user and survey ([4b78dc5](https://github.com/hopetambala/puente-node-cloudcode/commit/4b78dc5213ffae6d65f751c47054153488cf63df))
* add deleteUser function ([a63bf26](https://github.com/hopetambala/puente-node-cloudcode/commit/a63bf26b32b3986e1c3844324001bf49c7cfe9b7))
* add send message api ([e5fc96b](https://github.com/hopetambala/puente-node-cloudcode/commit/e5fc96bdc3a447a66202a4a1347a370aff5a05de))
* add text messaging ([0603393](https://github.com/hopetambala/puente-node-cloudcode/commit/06033934b9e8ceb9a0f8ada266970062927ef357))
* add update user and retrieveUserByObjectId ([4c51560](https://github.com/hopetambala/puente-node-cloudcode/commit/4c51560a442e1e5acbccbe0999c56b9547150ee6))
* added expoPushToken function to udpate user ([87b2f1b](https://github.com/hopetambala/puente-node-cloudcode/commit/87b2f1b2a0415b5872ee541d7b23ae6273458a11))
* count service to get unqiue surrveydata created ([89337d0](https://github.com/hopetambala/puente-node-cloudcode/commit/89337d0bfa0b65c7b138afce978143ef0069a713))
* handle looped form submission ([80d5741](https://github.com/hopetambala/puente-node-cloudcode/commit/80d5741e8b2982138ee4b877466e030822598cd7))
* offline moved to node cloud ([30944b3](https://github.com/hopetambala/puente-node-cloudcode/commit/30944b3ca3536ef04763f77f6514d76eaba1ac20))
* OFFLINE UPLOADER :tada: ([1374ef8](https://github.com/hopetambala/puente-node-cloudcode/commit/1374ef83fb9a5419ed8546960f7dbe44b7c52343))
* pictures on any forms work ([79d0a3d](https://github.com/hopetambala/puente-node-cloudcode/commit/79d0a3d0dc9a0954e68549523c5806dd6a1ce37d))
* refactor loop portion of crud to utils ([799837b](https://github.com/hopetambala/puente-node-cloudcode/commit/799837b1cf1354f394ee643e3c36d3dbb9016335))
* update all dependencies! ([eab407c](https://github.com/hopetambala/puente-node-cloudcode/commit/eab407c0a9332736d906c3ecbf1bc99be119897e))
* updated count service to include other parse models ([d5a393a](https://github.com/hopetambala/puente-node-cloudcode/commit/d5a393acd84708fc8559e5d91ecd2001d4441214))


### Bug Fixes

* tests PLATFORM-332 ([a494930](https://github.com/hopetambala/puente-node-cloudcode/commit/a4949300a30c3aa264043acfa2b033e828762a97))
* add afterSurveyHouseholdHook ([d260799](https://github.com/hopetambala/puente-node-cloudcode/commit/d26079979e814d051d164597cbb2d5bf4776f0f2))
* checking if key is a photo ([6fdd4fd](https://github.com/hopetambala/puente-node-cloudcode/commit/6fdd4fdada93163489e16ad111f054fe62346f0e))
* **deps:** update dependency lodash to v4.17.21 [security] ([ea8908a](https://github.com/hopetambala/puente-node-cloudcode/commit/ea8908a6b8349b16ee55f7275d6f27bf94648881))
* lodash require ([0187a33](https://github.com/hopetambala/puente-node-cloudcode/commit/0187a337d815eb5d3af87228475089f4485fdbb2))
* package.json & package-lock.json to reduce vulnerabilities ([7f43954](https://github.com/hopetambala/puente-node-cloudcode/commit/7f4395439f3cb7b61ed005aa476817ba814dea42))
* reason why tests were always failing ([c820b93](https://github.com/hopetambala/puente-node-cloudcode/commit/c820b936dc00e4e6d17bcffd9c75f18a243ce7a3))
* remove all .includes from codebase ([467caca](https://github.com/hopetambala/puente-node-cloudcode/commit/467cacaeea27dcf64f5dcfbb4b36d11046adf3e2))
* sort basic query results ([c20a12a](https://github.com/hopetambala/puente-node-cloudcode/commit/c20a12a37debffa8edbf585b982a9e0ba8dc53be))
* testing ([2fdb6cd](https://github.com/hopetambala/puente-node-cloudcode/commit/2fdb6cd2663725b0a938573dee968fee8eae5641))

## [1.8.0](https://github.com/hopetambala/puente-node-cloudcode/compare/v1.5.0...v1.8.0) (2021-12-18)


Expand Down
35 changes: 35 additions & 0 deletions _tests_/integration/auth.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ describe('role testing', () => {
let db;
let adminRoleID;
let contribRoleID;
let rollingUserObject;

beforeAll(async () => {
connection = await MongoClient.connect(process.env.MONGO_URL, {
Expand All @@ -22,6 +23,9 @@ describe('role testing', () => {
password: 'dracarys',
email: '[email protected]',
organization: 'got',
restParams: {
runMessaging: false,
},
};
return cloudFunctions.signup(credentials).then((result) => {
const jsonString = JSON.stringify(result);
Expand Down Expand Up @@ -59,6 +63,10 @@ describe('role testing', () => {
email: '[email protected]',
organization: 'got',
phonenumber: 1234567890,
restParams: {
runMessaging: false,
path: 'email',
},
};
return cloudFunctions.signup(credentials).then((result) => {
const jsonString = JSON.stringify(result);
Expand Down Expand Up @@ -106,6 +114,7 @@ describe('role testing', () => {
return cloudFunctions.signin(credentials).then((result) => {
const jsonString = JSON.stringify(result);
const jsonValues = JSON.parse(jsonString);
rollingUserObject = jsonValues;

expect(jsonValues.firstname).toEqual('Jon');
expect(jsonValues.lastname).toEqual('Snow');
Expand All @@ -118,6 +127,32 @@ describe('role testing', () => {
});
});

it('should update the user', async () => {
const originalUserObject = rollingUserObject;

const params = {
objectId: originalUserObject.objectId,
userObject: {
firstname: 'Ron',
lastname: 'Flow',
},
};

return cloudFunctions.updateUser(params).then((result) => {
const jsonString = JSON.stringify(result);
const jsonValues = JSON.parse(jsonString);

expect(jsonValues.firstname).toEqual('Ron');
expect(jsonValues.lastname).toEqual('Flow');
expect(jsonValues.username).toEqual('1234567890');
expect(jsonValues.email).toEqual('[email protected]');
expect(jsonValues.organization).toEqual('got');
expect(jsonValues.role).toEqual('contributor');
expect(jsonValues.adminVerified).toEqual(false);
expect(jsonValues.objectId).toEqual(contribRoleID);
});
});

it('should delete all users', async () => {
const removeParams = [
{
Expand Down
27 changes: 26 additions & 1 deletion _tests_/integration/crud.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,32 @@ describe('crud testing', () => {
});
});

it('should post an object to class with relation to original post with a variety of classes', async () => {
it('should post object to Supplementary Class with Relation to SurveyData', async () => {
const postParams = {
parseParentClass: 'SurveyData',
parseParentClassID: postID1,
parseClass: 'Vitals',
signature: 'Test',
photoFile: 'TestPicture',
parseUser: 'undefined',
localObject: {
height: '6',
weight: '2',
bmi: '30',
bloodPressure: '100/100',
latitude: 4,
longitude: 5,
surveyingOrganization: 'Puente',
},
};
return cloudFunctions.postObjectsToClassWithRelation(postParams).then((result) => {
expect(result.get('height')).toEqual('6');
expect(result.get('weight')).toEqual('2');
expect(result.get('bloodPressure')).toEqual('100/100');
});
});

it('should post an obj to class with relation to post with variety of classes', async () => {
const postParams = {
parseParentClass: 'SurveyData',
parseParentClassID: postID1,
Expand Down
29 changes: 29 additions & 0 deletions _tests_/integration/error.test.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
const { MongoClient } = require('mongodb');
const { cloudFunctions } = require('../run-cloud');

describe('crud testing', () => {
let connection;
let db;

beforeAll(async () => {
connection = await MongoClient.connect(process.env.MONGO_URL, {
useNewUrlParser: true,
useUnifiedTopology: true,
});
db = await connection.db();
});

afterAll(async () => {
await connection.close();
await db.close();
});

it('Test error response in SurveyData post when empy params', async () => {
const postParams = {
};
return cloudFunctions.postObjectsToClass(postParams).then((result) => {
const err = 'Error: no request params';
expect(result).toEqual(err);
});
});
});
8 changes: 8 additions & 0 deletions _tests_/integration/roles.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,10 @@ describe('role testing', () => {
password: 'leia',
email: '[email protected]',
organization: 'star-wars',
restParams: {
runMessaging: false,
path: 'email',
},
};
return cloudFunctions.signup(credentials).then((result) => {
const jsonString = JSON.stringify(result);
Expand All @@ -94,6 +98,10 @@ describe('role testing', () => {
email: '[email protected]',
organization: 'star-wars',
phonenumber: '1234567373',
restParams: {
runMessaging: false,
path: 'email',
},
};
return cloudFunctions.signup(credentials).then((result) => {
const jsonString = JSON.stringify(result);
Expand Down
3 changes: 3 additions & 0 deletions _tests_/run-cloud.js
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,9 @@ const cloudFunctions = {
addUserPushToken: (params) => Parse.Cloud
.run('addUserPushToken', params)
.then((response) => response),
updateUser: (params) => Parse.Cloud
.run('updateUser', params)
.then((response) => response),
};

module.exports = { cloudFunctions };
5 changes: 5 additions & 0 deletions cloud/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,3 +22,8 @@ require('./src/definer/verification.definer');
* Roles Creator and Manager
******************************************** */
require('./src/definer/roles.definer');

/** ********************************************
* Offline Uploader and Manager
******************************************** */
require('./src/definer/offline.definer');
7 changes: 7 additions & 0 deletions cloud/package.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"dependencies": {
"@slack/web-api": "^6.8.0",
"axios": "^0.27.2",
"lodash": "^4.17.19"
}
}
14 changes: 7 additions & 7 deletions cloud/src/_utils/loop/loop.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ const Loop = {
];
},

postLoopedForm: function postLoopedForm(loopedJson, newFieldsArray, request, mainObject) {
postLoopedForm: function postLoopedForm(loopedJson, newFieldsArray, requestParams, mainObject) {
return new Promise((resolve, reject) => {
Object.entries(loopedJson).forEach(([key, value]) => { // eslint-disable-line
// get looped data and adjust the fields Array for each loopp
Expand All @@ -34,14 +34,14 @@ const Loop = {
element.answer = value[element.title]; // eslint-disable-line
}
});
const newLocalObject = request.params.localObject;
const newLocalObject = requestParams.localObject;
newLocalObject.fields = newFieldsArray;
const postParams = {
parseParentClassID: request.params.parseParentClassID,
parseParentClass: request.params.parseParentClass,
parseUser: request.params.parseUser,
parseClass: request.params.parseClass,
photoFile: request.params.photoFile,
parseParentClassID: requestParams.parseParentClassID,
parseParentClass: requestParams.parseParentClass,
parseUser: requestParams.parseUser,
parseClass: requestParams.parseClass,
photoFile: requestParams.photoFile,
localObject: newLocalObject,
loop: false,
loopParentID: JSON.parse(JSON.stringify(mainObject)).objectId,
Expand Down
Loading

0 comments on commit b75cf92

Please sign in to comment.