Skip to content

Commit

Permalink
feat(orga): display different button label in action bar
Browse files Browse the repository at this point in the history
when organization has GAR as identity provider
  • Loading branch information
er-lim committed Sep 18, 2024
1 parent 2fbaf23 commit 1face50
Show file tree
Hide file tree
Showing 6 changed files with 125 additions and 11 deletions.
10 changes: 0 additions & 10 deletions orga/app/components/sco-organization-participant/action-bar.hbs

This file was deleted.

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>
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);
});
});
});
3 changes: 2 additions & 1 deletion orga/translations/en.json
Original file line number Diff line number Diff line change
Expand Up @@ -1208,6 +1208,7 @@
"sco-organization-participants": {
"title": "{count, plural, =0 {Students} =1 {Student ({count})} other {Students ({count})}}",
"action-bar": {
"generate-username-password-button": "Generate logins and/or passwords for selected students",
"information": "{count, plural, =1 {{count} student selected} other {{count} students selected}}",
"reset-password-button": "Reset passwords for selected students"
},
Expand Down Expand Up @@ -1246,10 +1247,10 @@
"students-count": "{count, plural, =0 {0 students} =1 {1 student} other {{count} students}}"
},
"generate-username-password-modal": {
"title": "Generate logins and/or passwords for selected students",
"content-message-1": "Students who do not yet have a login method must go through a campaign at your school to create their PIX account.",
"content-message-2": "A CSV file containing login details and one-time passwords will be generated.",
"content-message-3": "Give these new one-time passwords to the students. When they log in with this password, Pix will ask them to enter a new one.",
"title": "Generate logins and/or passwords for selected students",
"warning-message": "A login and password will be generated for students who have access to the Mediacentre and/or an e-mail address. Students who already have a login will have their password reset."
},
"manage-authentication-method-modal": {
Expand Down
1 change: 1 addition & 0 deletions orga/translations/fr.json
Original file line number Diff line number Diff line change
Expand Up @@ -1216,6 +1216,7 @@
"sco-organization-participants": {
"title": "{count, plural, =0 {Élèves} =1 {Élève ({count})} other {Élèves ({count})}}",
"action-bar": {
"generate-username-password-button": "Générer les identifiants et/ou les mots de passe des élèves sélectionnés",
"information": "{count, plural, =1 {{count} élève sélectionné} other {{count} élèves sélectionnés}}",
"reset-password-button": "Réinitialiser les mots de passe des élèves sélectionnés"
},
Expand Down
1 change: 1 addition & 0 deletions orga/translations/nl.json
Original file line number Diff line number Diff line change
Expand Up @@ -1241,6 +1241,7 @@
"sco-organization-participants": {
"action-bar": {
"information": "{count, plural, =1 {{count} geselecteerde student} other {{count} geselecteerde studenten}}",
"generate-username-password-button": "Generate logins and/or passwords for selected students",
"reset-password-button": "Reset de wachtwoorden van geselecteerde studenten"
},
"actions": {
Expand Down

0 comments on commit 1face50

Please sign in to comment.