-
Notifications
You must be signed in to change notification settings - Fork 72
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat: Allow organization managers to resend invitations (#4371)
Co-authored-by: Sarah Rudder <[email protected]>
- Loading branch information
Showing
15 changed files
with
167 additions
and
35 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
import React from 'react'; | ||
import PropTypes from 'prop-types'; | ||
import { reduxForm } from 'redux-form'; | ||
import { IconEnvelope } from '../icons'; | ||
|
||
const ResendInviteForm = ({ | ||
handleSubmit, | ||
submitting, | ||
}) => ( | ||
<form onSubmit={handleSubmit}> | ||
<button | ||
type="submit" | ||
className="usa-button usa-button-secondary margin-0 small-button" | ||
disabled={submitting} | ||
> | ||
<IconEnvelope /> | ||
Resend invite | ||
</button> | ||
</form> | ||
); | ||
|
||
ResendInviteForm.propTypes = { | ||
// the following props are from reduxForm: | ||
handleSubmit: PropTypes.func.isRequired, | ||
submitting: PropTypes.bool.isRequired, | ||
}; | ||
|
||
export { ResendInviteForm }; | ||
|
||
export default reduxForm()(ResendInviteForm); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -17,6 +17,9 @@ | |
}, | ||
"hasGithubAuth": { | ||
"type": "boolean" | ||
}, | ||
"signedInAt": { | ||
"type": "date-time" | ||
} | ||
}, | ||
"not": { | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -154,7 +154,7 @@ describe('Organization API', () => { | |
validateAgainstJSONSchema('POST', '/organization/{id}/invite', 400, response.body); | ||
}); | ||
|
||
it('returns the member and the invitation details for cloud.gov origin', async () => { | ||
it('returns the member and the invitation details for cloud.gov origin upon invitation', async () => { | ||
const uaaEmail = '[email protected]'; | ||
const roleId = userRole.id; | ||
const origin = 'cloud.gov' | ||
|
@@ -201,6 +201,53 @@ describe('Organization API', () => { | |
); | ||
}); | ||
|
||
it('returns the member and the invitation details for cloud.gov origin upon resent invitation', async () => { | ||
const uaaEmail = '[email protected]'; | ||
const roleId = userRole.id; | ||
const origin = 'cloud.gov' | ||
const isResend = true; | ||
|
||
const [targetUser, org] = await Promise.all([ | ||
factory.user(), | ||
factory.organization.create(), | ||
]); | ||
|
||
await Promise.all([ | ||
currentUser.addOrganization(org, { through: { roleId: managerRole.id } }), | ||
targetUser.addOrganization(org, { through: { roleId } }), | ||
factory.uaaIdentity({ userId: currentUser.id }), | ||
factory.uaaIdentity({ userId: targetUser.id, email: uaaEmail }), | ||
]); | ||
|
||
const inviteLink = 'https://example.com'; | ||
|
||
sinon.stub(OrganizationService, 'resendInvite') | ||
.resolves({ | ||
email: uaaEmail, | ||
inviteLink, | ||
origin, | ||
}); | ||
|
||
sinon.stub(Mailer, 'sendUAAInvite').resolves(); | ||
|
||
const response = await authenticatedRequest | ||
.post(`/v0/organization/${org.id}/invite`) | ||
.set('x-csrf-token', csrfToken.getToken()) | ||
.send({ roleId, uaaEmail, isResend }); | ||
|
||
validateAgainstJSONSchema('POST', '/organization/{id}/invite', 200, response.body); | ||
const { invite } = response.body; | ||
expect(invite.email).to.eq(uaaEmail); | ||
sinon.assert.calledOnceWithExactly( | ||
Mailer.sendUAAInvite, | ||
uaaEmail, | ||
inviteLink, | ||
origin, | ||
org.name | ||
); | ||
}); | ||
|
||
|
||
it('returns a 400 error if the user is a manager of an inactive organization', async () => { | ||
const uaaEmail = '[email protected]'; | ||
const roleId = userRole.id; | ||
|
18 changes: 18 additions & 0 deletions
18
test/frontend/components/organization/ResendInviteForm.test.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import React from 'react'; | ||
import { shallow } from 'enzyme'; | ||
import { expect } from 'chai'; | ||
|
||
import { ResendInviteForm } from '../../../../frontend/components/organization/ResendInviteForm'; | ||
|
||
describe('<ResendInviteForm />', () => { | ||
it('renders', () => { | ||
const props = { | ||
handleSubmit: () => Promise.resolve(), | ||
submitting: false, | ||
}; | ||
|
||
const wrapper = shallow(<ResendInviteForm {...props} />); | ||
|
||
expect(wrapper.find('form')).to.have.lengthOf(1); | ||
}); | ||
}); |