-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(admin): Add a button to send a new organization invitation
- Loading branch information
1 parent
be65a3d
commit 15e55f6
Showing
8 changed files
with
111 additions
and
11 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,13 +2,15 @@ import { render } from '@1024pix/ember-testing-library'; | |
import Service from '@ember/service'; | ||
import { click } from '@ember/test-helpers'; | ||
import dayjs from 'dayjs'; | ||
import { setupIntl } from 'ember-intl/test-support'; | ||
import { setupRenderingTest } from 'ember-qunit'; | ||
import Invitations from 'pix-admin/components/organizations/invitations'; | ||
import { module, test } from 'qunit'; | ||
import sinon from 'sinon'; | ||
|
||
module('Integration | Component | organization-invitations', function (hooks) { | ||
setupRenderingTest(hooks); | ||
setupIntl(hooks, 'fr'); | ||
|
||
module('when the admin member have access to organization scope', function (hooks) { | ||
hooks.beforeEach(function () { | ||
|
@@ -40,18 +42,21 @@ module('Integration | Component | organization-invitations', function (hooks) { | |
{ | ||
email: '[email protected]', | ||
role: 'ADMIN', | ||
lang: 'fr', | ||
roleInFrench: 'Administrateur', | ||
updatedAt: dayjs('2019-10-08T10:50:00Z').utcOffset(2), | ||
}, | ||
{ | ||
email: '[email protected]', | ||
role: 'MEMBER', | ||
roleInFrench: 'Membre', | ||
lang: 'en', | ||
updatedAt: dayjs('2019-10-08T10:50:00Z').utcOffset(2), | ||
}, | ||
{ | ||
email: '[email protected]', | ||
role: null, | ||
lang: 'nl', | ||
roleInFrench: '-', | ||
updatedAt: dayjs('2019-10-08T10:50:00Z').utcOffset(2), | ||
}, | ||
|
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 |
---|---|---|
|
@@ -96,4 +96,48 @@ module('Unit | Controller | authenticated/organizations/get/invitations', functi | |
assert.ok(notifyStub.calledWithExactly(anError, customErrors)); | ||
}); | ||
}); | ||
|
||
module('#sendNewInvitation', function () { | ||
test('sends a new invitation', function (assert) { | ||
// given | ||
const queryRecordStub = sinon.stub(); | ||
store.queryRecord = queryRecordStub; | ||
controller.model = { organization: { id: 1 } }; | ||
const organizationInvitation = { email: '[email protected]', lang: 'en', role: 'MEMBER' }; | ||
|
||
// when | ||
controller.sendNewInvitation(organizationInvitation); | ||
|
||
// then | ||
assert.ok( | ||
queryRecordStub.calledWith('organization-invitation', { | ||
...organizationInvitation, | ||
organizationId: 1, | ||
}), | ||
); | ||
}); | ||
|
||
test('When an error occurs, it should send a notification error', async function (assert) { | ||
// given | ||
const controller = this.owner.lookup('controller:authenticated/organizations/get/invitations'); | ||
const store = this.owner.lookup('service:store'); | ||
const anError = Symbol('an error'); | ||
store.queryRecord = sinon.stub().rejects(anError); | ||
const notifyStub = sinon.stub(); | ||
class ErrorResponseHandler extends Service { | ||
notify = notifyStub; | ||
} | ||
this.owner.register('service:error-response-handler', ErrorResponseHandler); | ||
const customErrors = Symbol('custom errors'); | ||
controller.CUSTOM_ERROR_MESSAGES = customErrors; | ||
controller.model = { organization: { id: 1 } }; | ||
const organizationInvitation = { email: '[email protected]', lang: 'en', role: 'MEMBER' }; | ||
|
||
// when | ||
await controller.sendNewInvitation(organizationInvitation); | ||
|
||
// then | ||
assert.ok(notifyStub.calledWithExactly(anError, customErrors)); | ||
}); | ||
}); | ||
}); |
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