Skip to content

Commit

Permalink
Remove autofilled campus on page load
Browse files Browse the repository at this point in the history
  • Loading branch information
caleballdrin committed Nov 8, 2023
1 parent 2ccb91d commit 46cec6b
Show file tree
Hide file tree
Showing 5 changed files with 55 additions and 0 deletions.
8 changes: 8 additions & 0 deletions app/scripts/directives/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,14 @@ angular
return campusNames.data;
});
};
if ($scope.answer.value) {
$scope.searchingCampuses = true;
$scope.searchCampuses($scope.answer.value).then((data) => {
if (!data.length) {
$scope.answer.value = '';
}
});
}
},
};
});
Expand Down
6 changes: 6 additions & 0 deletions app/scripts/services/validateRegistrant.js
Original file line number Diff line number Diff line change
Expand Up @@ -335,6 +335,12 @@ angular
return;
}
break;
case 'campusQuestion':
if (_.isEmpty(answer)) {
invalidBlocks.push(block.id);
return;
}
break;
case 'addressQuestion':
if (
answer.country !== 'US' &&
Expand Down
10 changes: 10 additions & 0 deletions test/spec/directives/block.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -199,6 +199,16 @@ describe('Directive: blocks', () => {

expect($scope.params.includeInternational).not.toBeDefined();
});

it('checks the campus database if a answer is present on page load', () => {
expect($scope.searchingCampuses).toBe(undefined);

$scope.answer = { value: 'SFSU' };
$compile('<campus-question></campus-question>')($scope);
$scope.$digest();

expect($scope.searchingCampuses).toBe(true);
});
});

describe('ethnicityQuestion', () => {
Expand Down
10 changes: 10 additions & 0 deletions test/spec/services/validateRegistrant.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,16 @@ describe('Service: validateRegistrant', function () {
expect(validateRegistrant.validate(conference, registrant).length).toBe(1);
});

it('empty campus name should not be valid', function () {
const conference = angular.copy(testData.conference);
conference.registrationPages[1].blocks[13].required = true;

const registrant = angular.copy(testData.registration.registrants[0]);
registrant.answers[12].value = '';

expect(validateRegistrant.validate(conference, registrant).length).toBe(1);
});

it('empty address fields should not be valid when missing address1, state, zip or city', function () {
var conference = angular.copy(testData.conference);
conference.registrationPages[1].blocks[7].required = true;
Expand Down
21 changes: 21 additions & 0 deletions test/spec/testData.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -396,6 +396,19 @@ angular.module('confRegistrationWebApp').service('testData', function () {
title: 'Child',
type: 'checkboxQuestion',
},
{
id: '0556295a-3c4d-45b2-a00e-42b1fe188421',
pageId: '7b4c19df-7377-4d37-90fb-5b262bb66d1a',
title: 'Campus',
exportFieldTitle: null,
type: 'campusQuestion',
required: false,
position: 2,
content: '',
profileType: null,
registrantTypes: [],
rules: [],
},
],
},
],
Expand Down Expand Up @@ -691,6 +704,14 @@ angular.module('confRegistrationWebApp').service('testData', function () {
amount: 0.0,
lastUpdatedTimestamp: '2001-07-10T15:06:05.383Z',
},
{
id: '6e52f066-f894-43ac-b9c0-bfbfbfbfdfdf',
registrantId: '6bd0f946-b010-4ef5-83f0-51c17449baf3',
blockId: '0556295a-3c4d-45b2-a00e-42b1fe188421',
value: '',
amount: 0.0,
lastUpdatedTimestamp: '2001-07-10T15:06:05.383Z',
},
],
firstName: 'Test',
lastName: 'Person',
Expand Down

0 comments on commit 46cec6b

Please sign in to comment.