fixed fieldType constant
This commit is contained in:
parent
fca5524751
commit
68858ca1a3
9 changed files with 84 additions and 39 deletions
1
.gitignore
vendored
1
.gitignore
vendored
|
@ -1,3 +1,4 @@
|
|||
selenium
|
||||
dist
|
||||
.vagrant
|
||||
npm-debug.*
|
||||
|
|
|
@ -21,21 +21,14 @@ module.exports = {
|
|||
'date',
|
||||
'email',
|
||||
'legal',
|
||||
'url',
|
||||
'textarea',
|
||||
'link',
|
||||
'statement',
|
||||
'welcome',
|
||||
'thankyou',
|
||||
'file',
|
||||
'dropdown',
|
||||
'scale',
|
||||
'rating',
|
||||
'radio',
|
||||
'checkbox',
|
||||
'hidden',
|
||||
'yes_no',
|
||||
'natural',
|
||||
'stripe',
|
||||
'number'
|
||||
],
|
||||
|
||||
|
|
|
@ -40,8 +40,8 @@ describe('Form Model Unit Tests:', function() {
|
|||
language: 'en',
|
||||
form_fields: [
|
||||
{'fieldType':'textfield', title:'First Name', 'fieldValue': ''},
|
||||
{'fieldType':'checkbox', title:'nascar', 'fieldValue': ''},
|
||||
{'fieldType':'checkbox', title:'hockey', 'fieldValue': ''}
|
||||
{'fieldType':'legal', title:'nascar', 'fieldValue': ''},
|
||||
{'fieldType':'legal', title:'hockey', 'fieldValue': ''}
|
||||
]
|
||||
});
|
||||
done();
|
||||
|
|
|
@ -24,6 +24,17 @@ var credentials = {
|
|||
password: 'password'
|
||||
};
|
||||
|
||||
var sampleVisitorData = [{
|
||||
socketId: 'ntneooe8989eotnoeeo',
|
||||
referrer: 'http://google.com',
|
||||
timeElapsed: 89898989,
|
||||
isSubmitted: true,
|
||||
language: 'en',
|
||||
ipAddr: '192.168.1.1',
|
||||
deviceType: 'desktop',
|
||||
userAgent: 'Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/41.0.2228.0 Safari/537.36'
|
||||
}]
|
||||
|
||||
/**
|
||||
* Form routes tests
|
||||
*/
|
||||
|
@ -50,8 +61,8 @@ describe('Form Routes Unit tests', function() {
|
|||
admin: user.id,
|
||||
form_fields: [
|
||||
new Field({'fieldType':'textfield', 'title':'First Name', 'fieldValue': ''}),
|
||||
new Field({'fieldType':'checkbox', 'title':'nascar', 'fieldValue': ''}),
|
||||
new Field({'fieldType':'checkbox', 'title':'hockey', 'fieldValue': ''})
|
||||
new Field({'fieldType':'legal', 'title':'nascar', 'fieldValue': ''}),
|
||||
new Field({'fieldType':'legal', 'title':'hockey', 'fieldValue': ''})
|
||||
],
|
||||
isLive: true
|
||||
};
|
||||
|
@ -315,8 +326,8 @@ describe('Form Routes Unit tests', function() {
|
|||
admin: user.id,
|
||||
form_fields: [
|
||||
new Field({'fieldType':'textfield', 'title':'First Name', 'fieldValue': ''}),
|
||||
new Field({'fieldType':'checkbox', 'title':'nascar', 'fieldValue': ''}),
|
||||
new Field({'fieldType':'checkbox', 'title':'hockey', 'fieldValue': ''})
|
||||
new Field({'fieldType':'legal', 'title':'nascar', 'fieldValue': ''}),
|
||||
new Field({'fieldType':'legal', 'title':'hockey', 'fieldValue': ''})
|
||||
],
|
||||
isLive: true
|
||||
};
|
||||
|
@ -327,8 +338,8 @@ describe('Form Routes Unit tests', function() {
|
|||
admin: user.id,
|
||||
form_fields: [
|
||||
new Field({'fieldType':'textfield', 'title':'Last Name', 'fieldValue': ''}),
|
||||
new Field({'fieldType':'checkbox', 'title':'formula one', 'fieldValue': ''}),
|
||||
new Field({'fieldType':'checkbox', 'title':'football', 'fieldValue': ''})
|
||||
new Field({'fieldType':'legal', 'title':'formula one', 'fieldValue': ''}),
|
||||
new Field({'fieldType':'legal', 'title':'football', 'fieldValue': ''})
|
||||
],
|
||||
isLive: true
|
||||
};
|
||||
|
@ -364,6 +375,63 @@ describe('Form Routes Unit tests', function() {
|
|||
});
|
||||
});
|
||||
|
||||
it(' > should preserve visitor data when updating a Form', function(done) {
|
||||
// Create new Form model instance
|
||||
|
||||
var formObject = {
|
||||
title: 'First Form',
|
||||
language: 'en',
|
||||
admin: user.id,
|
||||
form_fields: [
|
||||
new Field({'fieldType':'textfield', 'title':'First Name', 'fieldValue': ''}),
|
||||
new Field({'fieldType':'legal', 'title':'nascar', 'fieldValue': ''}),
|
||||
new Field({'fieldType':'legal', 'title':'hockey', 'fieldValue': ''})
|
||||
],
|
||||
isLive: true,
|
||||
analytics: {
|
||||
gaCode: '',
|
||||
visitors: sampleVisitorData
|
||||
}
|
||||
};
|
||||
|
||||
var formUpdateObject = {
|
||||
title: 'Second Form',
|
||||
language: 'en',
|
||||
admin: user.id,
|
||||
form_fields: [
|
||||
new Field({'fieldType':'textfield', 'title':'Last Name', 'fieldValue': ''}),
|
||||
new Field({'fieldType':'legal', 'title':'formula one', 'fieldValue': ''}),
|
||||
new Field({'fieldType':'legal', 'title':'football', 'fieldValue': ''})
|
||||
],
|
||||
isLive: true
|
||||
};
|
||||
|
||||
var CurrentForm = new Form(formObject);
|
||||
|
||||
// Save the Form
|
||||
CurrentForm.save(function(err, form) {
|
||||
if(err) return done(err);
|
||||
|
||||
loginSession.post('/forms/' + form._id)
|
||||
.send(formUpdateObject)
|
||||
.expect(200)
|
||||
.end(function(FormSaveErr) {
|
||||
|
||||
should.not.exist(FormSaveErr);
|
||||
|
||||
Form.findById(form._id, function (FormFindErr, UpdatedForm){
|
||||
should.not.exist(FormFindErr);
|
||||
should.exist(UpdatedForm);
|
||||
|
||||
UpdatedForm.toObject().visitors.should.deepEqual(sampleVisitorData);
|
||||
|
||||
done(FormFindErr);
|
||||
});
|
||||
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
afterEach('should be able to signout user', function(done){
|
||||
authenticatedSession.get('/auth/signout')
|
||||
.expect(200)
|
||||
|
|
|
@ -54,8 +54,8 @@ describe('Form Submission Routes Unit tests', function() {
|
|||
admin: user._id,
|
||||
form_fields: [
|
||||
new Field({'fieldType':'textfield', 'title':'First Name', 'fieldValue': ''}),
|
||||
new Field({'fieldType':'checkbox', 'title':'nascar', 'fieldValue': ''}),
|
||||
new Field({'fieldType':'checkbox', 'title':'hockey', 'fieldValue': ''})
|
||||
new Field({'fieldType':'legal', 'title':'nascar', 'fieldValue': ''}),
|
||||
new Field({'fieldType':'legal', 'title':'hockey', 'fieldValue': ''})
|
||||
],
|
||||
selfNotifications: {
|
||||
fromField: mongoose.Types.ObjectId(),
|
||||
|
@ -81,8 +81,8 @@ describe('Form Submission Routes Unit tests', function() {
|
|||
form: form._id,
|
||||
form_fields: [
|
||||
{'fieldType':'textfield', 'title':'First Name', 'fieldValue': 'David', _id: '', isSubmission: false, deletePreserved: false},
|
||||
{'fieldType':'checkbox', 'title':'nascar', 'fieldValue': true, _id: '', isSubmission: false, deletePreserved: true},
|
||||
{'fieldType':'checkbox', 'title':'hockey', 'fieldValue': false, _id: '', isSubmission: false, deletePreserved: false}
|
||||
{'fieldType':'legal', 'title':'nascar', 'fieldValue': true, _id: '', isSubmission: false, deletePreserved: true},
|
||||
{'fieldType':'legal', 'title':'hockey', 'fieldValue': false, _id: '', isSubmission: false, deletePreserved: false}
|
||||
],
|
||||
percentageComplete: 100,
|
||||
timeElapsed: 11.55,
|
||||
|
@ -101,8 +101,8 @@ describe('Form Submission Routes Unit tests', function() {
|
|||
_id: form._id,
|
||||
form_fields: [
|
||||
{'fieldType':'textfield', 'title':'First Name', 'fieldValue': 'David', _id: '', isSubmission: false, deletePreserved: false},
|
||||
{'fieldType':'checkbox', 'title':'nascar', 'fieldValue': true, _id: '', isSubmission: false, deletePreserved: true},
|
||||
{'fieldType':'checkbox', 'title':'hockey', 'fieldValue': false, _id: '', isSubmission: false, deletePreserved: false}
|
||||
{'fieldType':'legal', 'title':'nascar', 'fieldValue': true, _id: '', isSubmission: false, deletePreserved: true},
|
||||
{'fieldType':'legal', 'title':'hockey', 'fieldValue': false, _id: '', isSubmission: false, deletePreserved: false}
|
||||
],
|
||||
percentageComplete: 100,
|
||||
timeElapsed: 11.55,
|
||||
|
|
2
config/env/all.js
vendored
2
config/env/all.js
vendored
|
@ -10,8 +10,6 @@ module.exports = {
|
|||
db: {
|
||||
uri: process.env.MONGOLAB_URI || process.env.MONGODB_URI || 'mongodb://'+ (process.env.DB_PORT_27017_TCP_ADDR || '127.0.0.1') + '/mean',
|
||||
options: {
|
||||
user: '',
|
||||
pass: '',
|
||||
useMongoClient: true
|
||||
}
|
||||
},
|
||||
|
|
2
config/env/development.js
vendored
2
config/env/development.js
vendored
|
@ -6,8 +6,6 @@ module.exports = {
|
|||
db: {
|
||||
uri: process.env.MONGODB_URI || 'mongodb://'+( process.env.DB_PORT_27017_TCP_ADDR || '127.0.0.1') +'/mean',
|
||||
options: {
|
||||
user: '',
|
||||
pass: '',
|
||||
useMongoClient: true
|
||||
}
|
||||
},
|
||||
|
|
2
config/env/test.js
vendored
2
config/env/test.js
vendored
|
@ -5,8 +5,6 @@ module.exports = {
|
|||
db: {
|
||||
uri: 'mongodb://localhost/mean-test',
|
||||
options: {
|
||||
user: '',
|
||||
pass: '',
|
||||
useMongoClient: true
|
||||
}
|
||||
},
|
||||
|
|
|
@ -207,22 +207,11 @@ angular.module('forms').controller('AdminFormController', ['$rootScope', '$windo
|
|||
if(dataToSend.analytics && dataToSend.analytics.visitors){
|
||||
delete dataToSend.analytics.visitors;
|
||||
}
|
||||
if(dataToSend.submissions){
|
||||
delete dataToSend.submissions;
|
||||
}
|
||||
|
||||
if(dataToSend.visible_form_fields){
|
||||
delete dataToSend.visible_form_fields;
|
||||
}
|
||||
|
||||
if(dataToSend.analytics){
|
||||
delete dataToSend.analytics.visitors;
|
||||
delete dataToSend.analytics.fields;
|
||||
delete dataToSend.analytics.submissions;
|
||||
delete dataToSend.analytics.views;
|
||||
delete dataToSend.analytics.conversionRate;
|
||||
}
|
||||
|
||||
delete dataToSend.created;
|
||||
delete dataToSend.lastModified;
|
||||
delete dataToSend.__v;
|
||||
|
|
Loading…
Reference in a new issue