Skip to content

Commit

Permalink
Merge pull request #42 from topcoder-platform/feature/admin-app
Browse files Browse the repository at this point in the history
Implement features for the admin app
  • Loading branch information
rootelement authored Oct 5, 2020
2 parents a915589 + cbba215 commit 2982bf0
Show file tree
Hide file tree
Showing 39 changed files with 1,976 additions and 346 deletions.
86 changes: 0 additions & 86 deletions Verification.md
Original file line number Diff line number Diff line change
@@ -1,94 +1,9 @@
<<<<<<< .mine
# Topcoder Terms API

## Postman test
- import Postman collection and environment file in the docs folder to Postman
- Refer `ReadMe.md` to start the app and postgres database
- run `npm run init-db` and then `npm run test-data` to clear and insert test data before testing.
- Before run testcase under `docusign callback`, you need to run testcase under `generate docusign view url` first in order to create DocusignEnvelope in database.
- for testing purpose, I use ethereal as smtp server, go to https://ethereal.email/ login with account `[email protected]`/`XYbcZ3ew1qBtcPeqHy`, after executing `callback fail` testcase you will find a new message in https://ethereal.email/messages indicate the email sent by the server

## Unit test Coverage
78 passing (2m)

File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
------------------------------------|----------|----------|----------|----------|-------------------|
All files | 89.49 | 79.81 | 88.46 | 89.79 | |
terms-service | 100 | 85.71 | 100 | 100 | |
app-bootstrap.js | 100 | 100 | 100 | 100 | |
app-constants.js | 100 | 85.71 | 100 | 100 | 18 |
terms-service/config | 100 | 88.89 | 100 | 100 | |
default.js | 100 | 88.89 | 100 | 100 | 9,10,37,49 |
test.js | 100 | 100 | 100 | 100 | |
terms-service/src/common | 66.89 | 49.18 | 72.73 | 68.03 | |
errors.js | 100 | 50 | 100 | 100 | 23 |
helper.js | 38.36 | 35.14 | 50 | 39.13 |... 11,212,213,217 |
logger.js | 92.65 | 72.73 | 100 | 92.65 | 31,57,62,86,120 |
terms-service/src/models | 100 | 100 | 100 | 100 | |
DocusignEnvelope.js | 100 | 100 | 100 | 100 | |
TermsForResource.js | 100 | 100 | 100 | 100 | |
TermsOfUse.js | 100 | 100 | 100 | 100 | |
TermsOfUseAgreeabilityType.js | 100 | 100 | 100 | 100 | |
TermsOfUseDependency.js | 100 | 100 | 100 | 100 | |
TermsOfUseDocusignTemplateXref.js | 100 | 100 | 100 | 100 | |
UserTermsOfUseBanXref.js | 100 | 100 | 100 | 100 | |
UserTermsOfUseXref.js | 100 | 100 | 100 | 100 | |
index.js | 100 | 100 | 100 | 100 | |
terms-service/src/services | 97.9 | 93.27 | 100 | 97.87 | |
DocusignService.js | 95.05 | 80.77 | 100 | 94.95 |... 80,227,255,256 |
TermsForResourceService.js | 100 | 95 | 100 | 100 | 195 |
TermsOfUseService.js | 99.08 | 98.28 | 100 | 99.07 | 187 |

## E2E test Coverage

141 passing (2m)

File | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s |
------------------------------------|----------|----------|----------|----------|-------------------|
All files | 95.27 | 85.56 | 97.22 | 95.17 | |
terms-service | 92.13 | 78.13 | 90.48 | 91.74 | |
app-bootstrap.js | 100 | 100 | 100 | 100 | |
app-constants.js | 100 | 85.71 | 100 | 100 | 18 |
app-routes.js | 86.49 | 88 | 85.71 | 86.49 | 24,64,65,66,68 |
app.js | 90.38 | 68.75 | 85.71 | 90.38 | 38,55,77,86,93 |
terms-service/config | 100 | 88.89 | 100 | 100 | |
default.js | 100 | 88.89 | 100 | 100 | 9,10,37,49 |
test.js | 100 | 100 | 100 | 100 | |
terms-service/src | 100 | 100 | 100 | 100 | |
routes.js | 100 | 100 | 100 | 100 | |
terms-service/src/common | 90.07 | 77.05 | 96.97 | 89.8 | |
errors.js | 100 | 50 | 100 | 100 | 23 |
helper.js | 86.3 | 78.38 | 94.44 | 85.51 |... 79,198,204,208 |
logger.js | 92.65 | 77.27 | 100 | 92.65 | 31,57,62,86,120 |
terms-service/src/controllers | 100 | 100 | 100 | 100 | |
DocusignController.js | 100 | 100 | 100 | 100 | |
TermsForResourceController.js | 100 | 100 | 100 | 100 | |
TermsOfUseController.js | 100 | 100 | 100 | 100 | |
terms-service/src/models | 100 | 100 | 100 | 100 | |
DocusignEnvelope.js | 100 | 100 | 100 | 100 | |
TermsForResource.js | 100 | 100 | 100 | 100 | |
TermsOfUse.js | 100 | 100 | 100 | 100 | |
TermsOfUseAgreeabilityType.js | 100 | 100 | 100 | 100 | |
TermsOfUseDependency.js | 100 | 100 | 100 | 100 | |
TermsOfUseDocusignTemplateXref.js | 100 | 100 | 100 | 100 | |
UserTermsOfUseBanXref.js | 100 | 100 | 100 | 100 | |
UserTermsOfUseXref.js | 100 | 100 | 100 | 100 | |
index.js | 100 | 100 | 100 | 100 | |
terms-service/src/services | 97.9 | 93.27 | 100 | 97.87 | |
DocusignService.js | 95.05 | 80.77 | 100 | 94.95 |... 80,227,255,256 |
TermsForResourceService.js | 100 | 95 | 100 | 100 | 195 |
TermsOfUseService.js | 99.08 | 98.28 | 100 | 99.07 | 187 |


=======
# Topcoder Terms API

## Postman test
- import Postman collection and environment file in the docs folder to Postman
- Refer `ReadMe.md` to start the app and postgres database
- run `npm run init-db` and then `npm run test-data` to clear and insert test data before testing.
- Before run testcase under `docusign callback`, you need to run testcase under `generate docusign view url` first in order to create DocusignEnvelope in database.
- for testing purpose, I use ethereal as smtp server, go to https://ethereal.email/ login with account `[email protected]`/`XYbcZ3ew1qBtcPeqHy`, after executing `callback fail` testcase you will find a new message in https://ethereal.email/messages indicate the email sent by the server
- Go to https://lauscher.topcoder-dev.com/, login with `tonyj/appirio123`, you can verify Kafka message have been sent to topic `test.new.bus.events`

## Unit test Coverage
Expand Down Expand Up @@ -162,4 +77,3 @@ All files | 95.68 | 86.87 | 98.17 | 95.59
DocusignService.js | 94.06 | 80.77 | 100 | 93.94 |... 80,227,255,256
TermsForResourceService.js | 100 | 95.83 | 100 | 100 | 198
TermsOfUseService.js | 99.11 | 98.41 | 100 | 99.1 | 193
>>>>>>> .theirs
2 changes: 1 addition & 1 deletion app-routes.js
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ module.exports = (app) => {
// Check if the route is not found or HTTP method is not supported
app.use('*', (req, res) => {
let url = req.baseUrl
if (url.indexOf(config.get('BASE_PATH')) == 0) {
if (url.indexOf(config.get('BASE_PATH')) === 0) {
url = url.substring(config.get('BASE_PATH').length)
}
const route = routes[url]
Expand Down
1 change: 0 additions & 1 deletion data_migration/src/common/utils.js
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,6 @@ function resolveAgreeabilityTypeId (column) {
}
}


module.exports = {
resolveTermsOfUseId,
resolveAgreeabilityTypeId
Expand Down
2 changes: 1 addition & 1 deletion data_migration/src/migrateTable.js
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ async function process (informixTableName, modelName, lastSkip) {
entities.push(entity)
}
// handle entities
await model.bulkCreate(entities, {raw: true})
await model.bulkCreate(entities, { raw: true })
skip += data.length

// write skip to file
Expand Down
4 changes: 2 additions & 2 deletions data_migration/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -30,11 +30,11 @@ async function sync () {
const startDate = '2000-01-01'
await syncService.migrateUserTerms(startDate)
// await syncService.migrateDocusignEnvelopes(startDate)
//get ids from UserTermsOfUseXref
// get ids from UserTermsOfUseXref
// look up in postres
// if not, add

//get ids from DocusignEnvelope
// get ids from DocusignEnvelope
// await syncService.docusignEnvelopes()
// look up in postgres
// if not, add
Expand Down
26 changes: 13 additions & 13 deletions data_migration/test/testData.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,33 +63,33 @@ async function generateTermsOfUseDependency () {

async function generateDocusignEnvelope () {
for (let i = 0; i < 9998; i++) {
let docusign_envelope_id = uuid()
let docusign_template_id = uuid()
let user_id = Math.floor(Math.random() * 1000) + 300000000
let is_completed = Math.round(Math.random())
await executeQueryAsync('informixoltp', `insert into docusign_envelope(docusign_envelope_id, docusign_template_id, user_id, is_completed) values("${docusign_envelope_id}", "${docusign_template_id}", ${user_id}, ${is_completed})`)
let docusignEnvelopeId = uuid()
let docusignTemplateId = uuid()
let userId = Math.floor(Math.random() * 1000) + 300000000
let isCompleted = Math.round(Math.random())
await executeQueryAsync('informixoltp', `insert into docusign_envelope(docusign_envelope_id, docusign_template_id, user_id, is_completed) values("${docusignEnvelopeId}", "${docusignTemplateId}", ${userId}, ${isCompleted})`)
}
}

async function generateDocusignTemplateXref () {
for (let i = 30001; i <= 30100; i += 5) {
let docusign_template_id = uuid()
await executeQueryAsync('common_oltp', `insert into terms_of_use_docusign_template_xref(terms_of_use_id, docusign_template_id) values(${i}, "${docusign_template_id}")`)
let docusignTemplateId = uuid()
await executeQueryAsync('common_oltp', `insert into terms_of_use_docusign_template_xref(terms_of_use_id, docusign_template_id) values(${i}, "${docusignTemplateId}")`)
}
}

async function generateUserTerms () {
for (let user_id = 300000000; user_id <= 300001000; user_id++) {
await executeQueryAsync('common_oltp', `insert into user(user_id, handle, status) values(${user_id}, "handle${user_id}", "A")`)
for (let userId = 300000000; userId <= 300001000; userId++) {
await executeQueryAsync('common_oltp', `insert into user(user_id, handle, status) values(${userId}, "handle${userId}", "A")`)
}
for (let i = 30001; i <= 30200; i++) {
const leap1 = Math.round(Math.random() * 9) + 10
for (let user_id = 300000000; user_id <= 300001000; user_id += leap1) {
await executeQueryAsync('common_oltp', `insert into user_terms_of_use_xref(user_id, terms_of_use_id) values(${user_id}, ${i})`)
for (let userId = 300000000; userId <= 300001000; userId += leap1) {
await executeQueryAsync('common_oltp', `insert into user_terms_of_use_xref(user_id, terms_of_use_id) values(${userId}, ${i})`)
}
const leap2 = Math.round(Math.random() * 50) + 200
for (let user_id = 300000000; user_id <= 300001000; user_id += leap2) {
await executeQueryAsync('common_oltp', `insert into user_terms_of_use_ban_xref(user_id, terms_of_use_id) values(${user_id}, ${i})`)
for (let userId = 300000000; userId <= 300001000; userId += leap2) {
await executeQueryAsync('common_oltp', `insert into user_terms_of_use_ban_xref(user_id, terms_of_use_id) values(${userId}, ${i})`)
}
}
}
Expand Down
Loading

0 comments on commit 2982bf0

Please sign in to comment.