Skip to content
This repository was archived by the owner on Dec 14, 2023. It is now read-only.

Commit 00cf283

Browse files
WardormeurDanielBrierton
authored andcommitted
Test/e2e data test (#225)
* e2e Data test * remove deprecated script * Remove extra console * unify network to oebject notation * Add readme to find the proper user to use while testing * Add places for champions to fill the profile add dob for kids * Add cdf admin account [email protected]
1 parent 2200612 commit 00cf283

File tree

13 files changed

+663
-174
lines changed

13 files changed

+663
-174
lines changed

config/config.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ var generator = require('xoauth2').createXOAuth2Generator({
88
refreshToken: process.env.GMAIL_REFRESH_TOKEN
99
});
1010

11-
module.exports = function () {
11+
module.exports = function (options) {
1212
function pgConfig () {
1313
return {
1414
name: process.env.POSTGRES_NAME,
@@ -53,12 +53,12 @@ module.exports = function () {
5353
}
5454
}
5555
},
56-
'recaptcha_secret_key': process.env.RECAPTCHA_SECRET_KEY,
56+
'recaptcha_secret_key': process.env.RECAPTCHA_SECRET_KEY || '6LeIxAcTAAAAAGG-vFI1TnRWxMZNFuojJ4WifJWe',
5757
transport: {
5858
type: 'web',
5959
web: {
6060
timeout: 120000,
61-
port: 10303
61+
port: options && options.port ? options.port : 10303
6262
}
6363
},
6464
oauth2: {

network.js

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,8 @@
1+
'use strict';
2+
3+
module.exports = function (seneca) {
4+
seneca.listen()
5+
.client({type: 'web', port: 10304, pin: {role: 'cd-salesforce', cmd: '*'}})
6+
.client({type: 'web', port: 10301, pin: {role: 'cd-dojos', cmd: '*'}})
7+
.client({type: 'web', port: 10305, pin: {role: 'cd-badges', cmd: '*'}});
8+
};

scripts/insert-test-users.js

Lines changed: 0 additions & 48 deletions
This file was deleted.

scripts/load_test_data.sh

Lines changed: 0 additions & 25 deletions
This file was deleted.

service.js

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,9 +8,11 @@ var config = require('./config/config.js')();
88
var seneca = require('seneca')(config);
99
var _ = require('lodash');
1010
var store = require('seneca-postgresql-store');
11-
var log = require('cp-logs-lib')({name: 'cp-users-service', level: 'warn'});
11+
var service = 'cp-users-service';
12+
var log = require('cp-logs-lib')({name: service, level: 'warn'});
1213
config.log = log.log;
1314
var util = require('util');
15+
var dgram = require('dgram');
1416

1517
seneca.log.info('using config', JSON.stringify(config, null, 4));
1618

@@ -23,6 +25,25 @@ if (process.env.MAILTRAP_ENABLED === 'true') {
2325
seneca.use('mail', config.gmail);
2426
}
2527

28+
function shutdown (err) {
29+
if (err !== void 0 && err.stack !== void 0) {
30+
console.error(new Date().toString() + ' FATAL: UncaughtException, please report: ' + util.inspect(err));
31+
console.error(util.inspect(err.stack));
32+
console.trace();
33+
}
34+
process.exit(0);
35+
}
36+
37+
seneca.ready(function (err) {
38+
if (err) return shutdown(err);
39+
var message = new Buffer(service);
40+
var client = dgram.createSocket('udp4');
41+
client.send(message, 0, message.length, 11404, 'localhost', function (err, bytes) {
42+
if (err) return shutdown(err);
43+
client.close();
44+
});
45+
});
46+
2647
require('./migrate-psql-db.js')(function (err) {
2748
if (err) {
2849
console.error(err);
@@ -67,10 +88,7 @@ require('./migrate-psql-db.js')(function (err) {
6788
process.exit(0);
6889
}
6990

70-
seneca.listen()
71-
.client({ type: 'web', port: 10304, pin: { role: 'cd-salesforce', cmd: '*' } })
72-
.client({ type: 'web', port: 10301, pin: 'role:cd-dojos,cmd:*' })
73-
.client({ type: 'web', port: 10305, pin: {role: 'cd-badges', cmd: '*'} });
91+
require('./network.js')(seneca);
7492

7593
seneca.ready(function () {
7694
var escape = require('seneca-postgresql-store/lib/relational-util').escapeStr;

test/config/config.js

Lines changed: 0 additions & 30 deletions
This file was deleted.

test/fixtures/e2e/README.md

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
## E2E data test
2+
Emails on {user}@example.com, password as test{user}. The name describe the role (parent-parent, champion-champion of a dojo (often the same number), etc.
3+
### users.json
4+
* parent1
5+
* child1 - u13
6+
* child2 - o13 (w/ pwd "imakitten")
7+
* parent2
8+
* child3 - o13 (w/o pwd)
9+
* mentor[1-2]
10+
* champion[1-6]
11+
* 1-2 have a dojo
12+
* 3-6 have a lead

test/fixtures/e2e/children.json

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
[{
2+
"parentEmail": "[email protected]",
3+
"data": {
4+
"name": "child1",
5+
"alias": "nick1",
6+
"dob": "2010-01-31T22:00:00.000Z",
7+
"email": "",
8+
"userTypes": ["attendee-u13"],
9+
"requiredFieldsComplete": false,
10+
"password": ""
11+
}
12+
},
13+
{
14+
"parentEmail": "[email protected]",
15+
"data": {
16+
"name": "child2",
17+
"alias": "nick2",
18+
"dob": "2002-01-31T22:00:00.000Z",
19+
"email": "[email protected]",
20+
"userTypes": ["attendee-o13"],
21+
"requiredFieldsComplete": false,
22+
"password": "imakitten"
23+
}
24+
},
25+
{
26+
"parentEmail": "[email protected]",
27+
"data": {
28+
"name": "child3",
29+
"alias": "nick3",
30+
"dob": "2010-01-31T22:00:00.000Z",
31+
"email": "[email protected]",
32+
"userTypes": ["attendee-o13"],
33+
"password": ""
34+
}
35+
}]

0 commit comments

Comments
 (0)