-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(orga): display different button label in action bar
when organization has GAR as identity provider
- Loading branch information
Showing
6 changed files
with
125 additions
and
11 deletions.
There are no files selected for viewing
10 changes: 0 additions & 10 deletions
10
orga/app/components/sco-organization-participant/action-bar.hbs
This file was deleted.
Oops, something went wrong.
23 changes: 23 additions & 0 deletions
23
orga/app/components/sco-organization-participant/list-action-bar.gjs
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,23 @@ | ||
import PixButton from '@1024pix/pix-ui/components/pix-button'; | ||
import { t } from 'ember-intl'; | ||
|
||
import ActionBar from '../ui/action-bar'; | ||
|
||
<template> | ||
<ActionBar> | ||
<:information> | ||
{{t "pages.sco-organization-participants.action-bar.information" count=@count}} | ||
</:information> | ||
<:actions> | ||
{{#if @isGarIdentityProvider}} | ||
<PixButton @triggerAction={{@openGenerateUsernamePasswordModal}}> | ||
{{t "pages.sco-organization-participants.action-bar.generate-username-password-button"}} | ||
</PixButton> | ||
{{else}} | ||
<PixButton @triggerAction={{@openResetPasswordModal}}> | ||
{{t "pages.sco-organization-participants.action-bar.reset-password-button"}} | ||
</PixButton> | ||
{{/if}} | ||
</:actions> | ||
</ActionBar> | ||
</template> |
98 changes: 98 additions & 0 deletions
98
orga/tests/integration/components/sco-organization-participant/list-action-bar-test.gjs
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,98 @@ | ||
import { render } from '@1024pix/ember-testing-library'; | ||
import { click } from '@ember/test-helpers'; | ||
import { t } from 'ember-intl/test-support'; | ||
import ListActionBar from 'pix-orga/components/sco-organization-participant/list-action-bar'; | ||
import { module, test } from 'qunit'; | ||
import sinon from 'sinon'; | ||
|
||
import setupIntlRenderingTest from '../../../helpers/setup-intl-rendering'; | ||
|
||
module('Integration | Component | ScoOrganizationParticipant::ListActionBar', function (hooks) { | ||
setupIntlRenderingTest(hooks); | ||
|
||
const openGenerateUsernamePasswordModal = sinon.stub(); | ||
const openResetPasswordModal = sinon.stub(); | ||
|
||
module('when rendering the component', function () { | ||
test('displays student count', async function (assert) { | ||
// given | ||
const count = 1; | ||
|
||
// when | ||
const screen = await render( | ||
<template> | ||
<ListActionBar | ||
@count={{count}} | ||
@openGenerateUsernamePasswordModal={{openGenerateUsernamePasswordModal}} | ||
@openResetPasswordModal={{openResetPasswordModal}} | ||
/> | ||
</template>, | ||
); | ||
|
||
// then | ||
assert.ok(screen.getByText(t('pages.sco-organization-participants.action-bar.information', { count }))); | ||
}); | ||
}); | ||
|
||
module('When isGarIdentityProvider arg is at true', function () { | ||
const isGarIdentityProvider = true; | ||
|
||
test('displays generates username password button and it works correctly', async function (assert) { | ||
// given | ||
const count = 1; | ||
|
||
// when | ||
const screen = await render( | ||
<template> | ||
<ListActionBar | ||
@count={{count}} | ||
@isGarIdentityProvider={{isGarIdentityProvider}} | ||
@openGenerateUsernamePasswordModal={{openGenerateUsernamePasswordModal}} | ||
@openResetPasswordModal={{this.noop}} | ||
/> | ||
</template>, | ||
); | ||
|
||
const button = screen.getByRole('button', { | ||
name: t('pages.sco-organization-participants.action-bar.generate-username-password-button'), | ||
}); | ||
await click(button); | ||
assert.dom(button).exists(); | ||
|
||
// then | ||
sinon.assert.called(openGenerateUsernamePasswordModal); | ||
assert.ok(true); | ||
}); | ||
}); | ||
|
||
module('When isGarIdentityProvider arg is at false', function () { | ||
const isGarIdentityProvider = false; | ||
|
||
test('displays reset passwords button and it works correctly', async function (assert) { | ||
// given | ||
const count = 1; | ||
|
||
// when | ||
const screen = await render( | ||
<template> | ||
<ListActionBar | ||
@count={{count}} | ||
@isGarIdentityProvider={{isGarIdentityProvider}} | ||
@openGenerateUsernamePasswordModal={{openGenerateUsernamePasswordModal}} | ||
@openResetPasswordModal={{openResetPasswordModal}} | ||
/> | ||
</template>, | ||
); | ||
|
||
const button = screen.getByRole('button', { | ||
name: t('pages.sco-organization-participants.action-bar.reset-password-button'), | ||
}); | ||
assert.dom(button).exists(); | ||
|
||
await click(button); | ||
|
||
// then | ||
sinon.assert.called(openResetPasswordModal); | ||
}); | ||
}); | ||
}); |
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