Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

No-Jira Fix Campus #847

Merged
merged 9 commits into from
Nov 9, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions app/scripts/directives/blocks.js
Original file line number Diff line number Diff line change
Expand Up @@ -251,6 +251,13 @@ angular
return campusNames.data;
});
};
if ($scope.answer.value) {
$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
1 change: 1 addition & 0 deletions app/views/blocks/campusQuestion.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
type="text"
ng-model="answer.value"
placeholder=""
name="campus"
autocomplete="off"
aria-autocomplete="none"
class="form-control"
Expand Down
19 changes: 18 additions & 1 deletion test/spec/directives/block.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -159,16 +159,18 @@ describe('Directive: blocks', () => {
});

describe('campusQuestion', () => {
let $compile, $rootScope, $scope;
let $compile, $rootScope, $scope, $httpBackend;
beforeEach(inject((
_$compile_,
_$rootScope_,
_$timeout_,
$templateCache,
testData,
_$httpBackend_,
) => {
$compile = _$compile_;
$rootScope = _$rootScope_;
$httpBackend = _$httpBackend_;

$scope = $rootScope.$new();
$templateCache.put('views/blocks/campusQuestion.html', '');
Expand Down Expand Up @@ -199,6 +201,21 @@ describe('Directive: blocks', () => {

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

it('checks the campus database if a answer is present on page load', () => {
caleballdrin marked this conversation as resolved.
Show resolved Hide resolved
$httpBackend
.whenGET('campuses/SFSU?includeInternational=true&limit=15')
.respond(() => [200, []]);

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

$httpBackend.flush();
$httpBackend.verifyNoOutstandingExpectation();
$httpBackend.verifyNoOutstandingRequest();

expect($scope.answer.value).toBe('');
});
});

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

it('marks an empty campus name as invalid', 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('doesnt mark as invalid a campusQuestion field that is filled in', 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 = 'San Francisco State University';

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

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
Loading