Skip to content

Commit

Permalink
Merge pull request #2086 from thostetler/fix-failing-test
Browse files Browse the repository at this point in the history
fix feedback endpoint test
  • Loading branch information
thostetler committed Nov 19, 2020
2 parents a1723ff + f8d0576 commit 06a3d1d
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 17 deletions.
11 changes: 6 additions & 5 deletions src/js/react/LibraryCollaborators/reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,11 @@ define(['underscore', 'redux', './constants', './actions'], function(
const getPermissionType = (type) => {
if (type.includes('admin')) {
return Permissions.ADMIN;
} else if (type.includes('write')) {
}
if (type.includes('write')) {
return Permissions.WRITE;
} else {
return Permissions.READ;
}
return Permissions.READ;
};

const requestState = {
Expand All @@ -31,7 +31,8 @@ define(['underscore', 'redux', './constants', './actions'], function(
error,
},
};
} else if (/_RESET$/.test(action.type)) {
}
if (/_RESET$/.test(action.type)) {
const scope = action.type.replace('_RESET', '');
return {
...state,
Expand All @@ -47,7 +48,7 @@ define(['underscore', 'redux', './constants', './actions'], function(
owner: null,
};
const library = (state = libraryState, action) => {
if (action.type === SET_LIBRARY_DATA && action.result) {
if (action.type === SET_LIBRARY_DATA && action.payload) {
return {
id: action.payload.id || state.id,
name: action.payload.name || state.name,
Expand Down
26 changes: 14 additions & 12 deletions test/mocha/js/widgets/navbar_widget.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ define([
$('#test').empty();
});

//orcid accounts
// orcid accounts

it('should query initial logged in / logged out orcid states in order to render the correct values', function() {
var minsub = new (MinSub.extend({
Expand Down Expand Up @@ -65,14 +65,14 @@ define([

$('#test').append(n.render().el);

//orcid signed in, orcid mode on automatically
// orcid signed in, orcid mode on automatically

expect($('.orcid-dropdown h4').text()).to.eql(
' Signed in to ORCID as Testy Tester'
);
expect($('input.orcid-mode').is(':checked')).to.eql(true);

//orcid signed in, orcid mode off
// orcid signed in, orcid mode off

n.view.model.set('orcidModeOn', false);

Expand Down Expand Up @@ -132,7 +132,7 @@ define([
n.getPubSub().publish = sinon.spy();
$('#test').append(n.render().el);

//show active view
// show active view
$('#test')
.find('.orcid-sign-in')
.click();
Expand All @@ -147,7 +147,7 @@ define([
]);
});

//ADS user accounts
// ADS user accounts

it('should query initial user logged in/logged out state and show the correct options', function() {
/*
Expand Down Expand Up @@ -209,7 +209,7 @@ define([
.replace(/\W+/g, ' ')
).to.eql('You are signed in as bumblebee');

//lack of username indicates user is logged out
// lack of username indicates user is logged out
u.setUser(undefined);

minsub.publish(
Expand Down Expand Up @@ -284,7 +284,7 @@ define([
expect(publishSpy.args[1][1]).to.eql('authentication-page');
expect(publishSpy.args[1][2].subView).to.eql('register');

//now show navbar in logged in state
// now show navbar in logged in state
u.setUser('foo');
minsub.publish(
minsub.pubsub.USER_ANNOUNCEMENT,
Expand All @@ -302,13 +302,13 @@ define([
'index-page',
]);

//calls session logout method explicitly
// calls session logout method explicitly
expect(s.logout.callCount).to.eql(1);
expect(orcidSignOutSpy.callCount).to.eql(1);
});

it('should have a feedback form modal appended to body only 1x, and triggered from navbar', function() {
//not sure why i have to call this when we have afterEach
// not sure why i have to call this when we have afterEach
$('#feedback-modal').remove();

var n = new NavBarWidget();
Expand Down Expand Up @@ -368,7 +368,9 @@ define([
'<input type="hidden" name="g-recaptcha-response" value="success"></input>'
);
$('form.feedback-form').submit();
expect(requestStub.args[0][0].toJSON().target).to.eql('feedback/slack');
expect(requestStub.args[0][0].toJSON().target).to.eql(
'feedback/userfeedback'
);
expect(requestStub.args[0][0].toJSON().options.dataType).to.eql('json');

expect(requestStub.args[0][0].toJSON().options.method).to.eql('POST');
Expand All @@ -379,9 +381,9 @@ define([
).to.exist;
$('#feedback-modal').trigger('hidden.bs.modal');

//form should be emptied
// form should be emptied
expect($('form.feedback-form textarea').val()).to.eql('');
//modal should be closed
// modal should be closed
expect($('#feedback-modal').is(':visible')).to.be.false;

requestStub.restore();
Expand Down

0 comments on commit 06a3d1d

Please sign in to comment.