Skip to content

Commit

Permalink
feat(orga): fixed tests
Browse files Browse the repository at this point in the history
feat(orga): fixed test on nav

feat(orga): removed useless code

feat(orga): removed renaming out of scope
  • Loading branch information
alicegoarnisson committed Dec 3, 2024
1 parent a1ba6c7 commit f6f8b87
Show file tree
Hide file tree
Showing 14 changed files with 56 additions and 86 deletions.
6 changes: 3 additions & 3 deletions admin/app/components/common/tubes-details/area.gjs
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
import PixAccordions from '@1024pix/pix-ui/components/pix-accordions';
import PixCollapsible from '@1024pix/pix-ui/components/pix-collapsible';

import Competence from '../tubes-details/competence';

<template>
<div class="area-border-container">
<div class="area-border {{@color}}"></div>
<PixAccordions class="{{@color}} list-competences">
<PixCollapsible class="{{@color}} list-competences">
<:title>{{@title}}</:title>
<:content>
{{#each @competences as |competence|}}
Expand All @@ -17,6 +17,6 @@ import Competence from '../tubes-details/competence';
/>
{{/each}}
</:content>
</PixAccordions>
</PixCollapsible>
</div>
</template>
6 changes: 3 additions & 3 deletions admin/app/components/common/tubes-details/competence.gjs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import PixAccordions from '@1024pix/pix-ui/components/pix-accordions';
import PixCollapsible from '@1024pix/pix-ui/components/pix-collapsible';
import { eq } from 'ember-truth-helpers';

import Header from '../../table/header';
Expand All @@ -7,7 +7,7 @@ import Tube from '../tubes-details/tube';

<template>
<div class="competence-container">
<PixAccordions>
<PixCollapsible>
<:title>{{@title}}</:title>
<:content>
<div class="panel">
Expand Down Expand Up @@ -56,6 +56,6 @@ import Tube from '../tubes-details/tube';
</table>
</div>
</:content>
</PixAccordions>
</PixCollapsible>
</div>
</template>
6 changes: 3 additions & 3 deletions admin/app/components/common/tubes-selection/areas.gjs
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
import PixAccordions from '@1024pix/pix-ui/components/pix-accordions';
import PixCollapsible from '@1024pix/pix-ui/components/pix-collapsible';

import Competence from './competence';

<template>
{{#each @areas as |area|}}
<div class="area-border-container">
<div class="area-border {{area.color}}"></div>
<PixAccordions class="{{area.color}} list-competences">
<PixCollapsible class="{{area.color}} list-competences">
<:title>{{area.code}} · {{area.title}}</:title>
<:content>
{{#each area.sortedCompetences as |competence|}}
Expand All @@ -22,7 +22,7 @@ import Competence from './competence';
/>
{{/each}}
</:content>
</PixAccordions>
</PixCollapsible>
</div>
{{/each}}
</template>
6 changes: 3 additions & 3 deletions admin/app/components/common/tubes-selection/competence.gjs
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import PixCheckbox from '@1024pix/pix-ui/components/pix-checkbox';
import PixAccordions from '@1024pix/pix-ui/components/pix-accordions';
import PixCollapsible from '@1024pix/pix-ui/components/pix-collapsible';
import { on } from '@ember/modifier';
import { action } from '@ember/object';
import Component from '@glimmer/component';
Expand Down Expand Up @@ -47,7 +47,7 @@ export default class Competence extends Component {

<template>
<div class="competence-container">
<PixAccordions>
<PixCollapsible>
<:title>{{@competence.index}} {{@competence.name}}</:title>
<:content>
<div class="panel">
Expand Down Expand Up @@ -110,7 +110,7 @@ export default class Competence extends Component {
</table>
</div>
</:content>
</PixAccordions>
</PixCollapsible>
</div>
</template>
}
8 changes: 4 additions & 4 deletions certif/app/components/import/step-two-section.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@
{{t "pages.sessions.import.step-two.blocking-errors.information"}}
</span>
<div>
<PixAccordions
<PixCollapsible
@iconName="error"
@plainIcon={{true}}
@tagContent={{t
Expand Down Expand Up @@ -63,7 +63,7 @@
{{/each}}
</ul>
</:content>
</PixAccordions>
</PixCollapsible>
</div>
{{/if}}
{{#if (gt this.nonBlockingErrorReportsCount 0)}}
Expand All @@ -74,7 +74,7 @@
}}
</span>
<div>
<PixAccordions
<PixCollapsible
@iconName="warning"
@plainIcon={{true}}
@tagContent={{t
Expand Down Expand Up @@ -104,7 +104,7 @@
{{/each}}
</ul>
</:content>
</PixAccordions>
</PixCollapsible>
</div>
{{/if}}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,6 @@ When(`je me déconnecte`, () => {
});

When(`je me déconnecte de Pix Orga`, () => {
cy.get('[aria-label="Ouvrir le menu utilisateur"]').click();
cy.contains("Se déconnecter").click();
});

Expand Down
4 changes: 2 additions & 2 deletions mon-pix/app/components/user-tutorials/filters/sidebar.hbs
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
{{#each this.sortedAreas as |area|}}
<div class="area-border-container">
<div class="area-border {{area.color}}"></div>
<PixAccordions class="tutorials-filters__areas {{area.color}}">
<PixCollapsible class="tutorials-filters__areas {{area.color}}">
<:title>{{area.title}}</:title>
<:content>
<ul class="tutorials-filters-areas__competences">
Expand All @@ -22,7 +22,7 @@
{{/each}}
</ul>
</:content>
</PixAccordions>
</PixCollapsible>
</div>
{{/each}}
</:content>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import PixIcon from '@1024pix/pix-ui/components/pix-icon';
import PixTooltip from '@1024pix/pix-ui/components/pix-tooltip';
import { LinkTo } from '@ember/routing';
import { service } from '@ember/service';
import Component from '@glimmer/component';
import { t } from 'ember-intl';
Expand Down
30 changes: 0 additions & 30 deletions orga/app/components/layout/user-logged-menu.hbs
Original file line number Diff line number Diff line change
@@ -1,31 +1,3 @@
{{!-- <button
type="button"
{{on "click" this.toggleUserMenu}}
aria-haspopup="listbox"
aria-expanded="{{this.isMenuOpen}}"
aria-label={{t "navigation.user-logged-menu.button"}}
class="user-logged-button"
...attributes
>
<span class="user-logged-button__text">
<span>{{this.currentUser.prescriber.firstName}} {{this.currentUser.prescriber.lastName}}</span>
<span>{{this.organizationNameAndExternalId}}</span>
</span>
<PixIcon @name={{if this.isMenuOpen "chevronTop" "chevronBottom"}} />
</button>
<Dropdown::Content @display={{this.isMenuOpen}} @close={{this.closeMenu}} class="user-logged-menu">
{{#each this.eligibleOrganizations as |organization|}}
<Dropdown::Item @onClick={{fn this.onOrganizationChange organization}}>
{{organization.name}}
{{#if organization.externalId}}({{organization.externalId}}){{/if}}
</Dropdown::Item>
{{/each}}
<Dropdown::ItemLink @linkTo="logout">
<PixIcon @name="logout" class="user-logged-menu__icon" />
{{t "navigation.user-logged-menu.logout"}}
</Dropdown::ItemLink>
</Dropdown::Content> --}}
<p>
<strong>
{{this.currentUser.prescriber.firstName}}
Expand All @@ -40,6 +12,4 @@
@label={{t "navigation.user-logged-menu.button"}}
@onChange={{this.onOrganizationChange}}
/>
{{log this.eligibleOrganizations}}
{{log this.currentUser.organization.id}}
<PixButtonLink @variant="tertiary" class="" @route="logout">{{t "navigation.user-logged-menu.logout"}}</PixButtonLink>
1 change: 0 additions & 1 deletion orga/app/components/layout/user-logged-menu.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,6 @@ export default class UserLoggedMenu extends Component {
if (!memberships) {
return [];
}
console.log(this.currentUser.organization.id);
return memberships
.slice()
.map((membership) => ({
Expand Down
6 changes: 0 additions & 6 deletions orga/app/templates/authenticated.hbs
Original file line number Diff line number Diff line change
@@ -1,17 +1,11 @@
<PixAppLayout @variant="orga" class="app">
<Layout::Sidebar @placesCount={{@model.available}} @onChangeOrganization={{this.onChangeOrganization}} />
{{! <div class="main-content"> }}
{{! <header>
TODO: remove component and merge tests
<Layout::Topbar />
</header> }}

<main class="main-content__body page">
<Banner::TopBanners />
{{outlet}}
<Layout::Footer />
</main>

{{! </div> }}
</PixAppLayout>
<NotificationContainer @position="bottom-right" />
16 changes: 10 additions & 6 deletions orga/tests/acceptance/authentication-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { clickByName, fillByLabel, visit } from '@1024pix/ember-testing-library';
import { currentURL } from '@ember/test-helpers';
import { click, currentURL } from '@ember/test-helpers';
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
import { t } from 'ember-intl/test-support';
import { setupApplicationTest } from 'ember-qunit';
Expand Down Expand Up @@ -277,7 +277,8 @@ module('Acceptance | authentication', function (hooks) {
test('should display session status', async function (assert) {
const now = new Date(2024, 5, 12, 14);
const sessionExpirationDate = new Date(2024, 5, 12, 16);
clock = sinon.useFakeTimers({ now, toFake: ['Date'] });
console.log(now);
clock = sinon.useFakeTimers({ now, shouldAdvanceTime: true, toFake: ['Date'] });
const user = createPrescriberForOrganization(
{ lang: 'fr', pixOrgaTermsOfServiceAccepted: true },
{
Expand All @@ -298,8 +299,9 @@ module('Acceptance | authentication', function (hooks) {
});

test('should handle starting session', async function (assert) {
const now = new Date(2024, 5, 12, 14);
clock = sinon.useFakeTimers({ now, toFake: ['Date'] });
const now = Date.parse(new Date(2024, 5, 12, 14));
console.log(now);
clock = sinon.useFakeTimers({ now, shouldAdvanceTime: true, toFake: ['Date'] });
const user = createPrescriberForOrganization(
{ lang: 'fr', pixOrgaTermsOfServiceAccepted: true },
{
Expand All @@ -313,8 +315,10 @@ module('Acceptance | authentication', function (hooks) {
);
await authenticateSession(user.id);
const screen = await visit('/');
await clickByName(t('navigation.school-sessions.activate-button'));

const activateButton = await screen.findByRole('button', {
name: t('navigation.school-sessions.activate-button'),
});
await click(activateButton);
assert.ok(
screen.getByText(t('navigation.school-sessions.status.active-label', { sessionExpirationDate: '18:00' })),
);
Expand Down
2 changes: 1 addition & 1 deletion orga/tests/acceptance/campaign-creation-test.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { clickByName, fillByLabel, visit, within } from '@1024pix/ember-testing-library';
import { click, currentURL, pauseTest } from '@ember/test-helpers';
import { click, currentURL } from '@ember/test-helpers';
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
import { t } from 'ember-intl/test-support';
import { setupApplicationTest } from 'ember-qunit';
Expand Down
49 changes: 27 additions & 22 deletions orga/tests/acceptance/switch-organization-test.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { clickByName, visit } from '@1024pix/ember-testing-library';
import { visit } from '@1024pix/ember-testing-library';
import { click } from '@ember/test-helpers';
import { currentURL } from '@ember/test-helpers';
import setupMirage from 'ember-cli-mirage/test-support/setup-mirage';
Expand Down Expand Up @@ -43,42 +43,44 @@ module('Acceptance | Switch Organization', function (hooks) {

test('should have an organization in menu', async function (assert) {
// when
await visit('/');
await clickByName("Changer d'organisation");

const screen = await visit('/');
const button = screen.getByRole('button', { name: "Changer d'organisation" });
await click(button);
// then
assert.dom('.pix-select_list > li').exists({ count: 3 });
assert
.dom('.pix-select_list > li:not(.pix-select-list-category__option--hidden)')
.hasText('BRO & Evil Associates');
const listbox = await screen.findAllByRole('option');
assert.strictEqual(listbox.length, 2);
assert.ok(await screen.findByRole('option', { name: 'BRO & Evil Associates' }));
});

module('When prescriber click on an organization', function () {
test('should find the selected organization in list', async function (assert) {
// when
const screen = await visit('/');

await clickByName("Changer d'organisation");
await click(screen.getByText('My Heaven Company'));
const button = screen.getByRole('button', { name: "Changer d'organisation" });
await click(button);
const organizationSelected = await screen.findByRole('option', { name: 'My Heaven Company' });
await click(organizationSelected);

//TODO: rendre plus précis ?
// then
assert.ok(screen.getByText('My Heaven Company (HEAVEN)'));
assert.ok(organizationSelected);
});

test('should have the old main organization in the menu after switching', async function (assert) {
// when
const screen = await visit('/');

await clickByName("Changer d'organisation");
const button = screen.getByRole('button', { name: "Changer d'organisation" });
await click(button);

const oldOrganization = await screen.findByRole('option', { name: 'My Heaven Company' });
await click(screen.getByText('My Heaven Company'));
await clickByName("Changer d'organisation");
await click(button);
const listbox = await screen.findAllByRole('option');

// then
assert.dom('.pix-select_list > li').exists({ count: 3 });
assert
.dom('.pix-select_list > li:not(.pix-select-list-category__option--hidden):last-of-type')
.hasText('My Heaven Company');
//then
assert.strictEqual(listbox.length, 2);
assert.ok(oldOrganization);
});

module('When prescriber is on campaign page with pagination', function () {
Expand All @@ -87,8 +89,10 @@ module('Acceptance | Switch Organization', function (hooks) {
const screen = await visit('/campagnes/les-miennes?pageNumber=2&pageSize=10&name=test&status=archived');

// when
await clickByName("Changer d'organisation");
await click(screen.getByText('My Heaven Company'));
const button = screen.getByRole('button', { name: "Changer d'organisation" });
await click(button);
const oldOrganization = await screen.findByRole('option', { name: 'My Heaven Company' });
await click(oldOrganization);

// then
assert.strictEqual(currentURL(), '/campagnes/les-miennes');
Expand All @@ -102,7 +106,8 @@ module('Acceptance | Switch Organization', function (hooks) {
// when
const screen = await visit('/');

await clickByName("Changer d'organisation");
const button = screen.getByRole('button', { name: "Changer d'organisation" });
await click(button);
await click(screen.getByText('My Heaven Company'));

// then
Expand Down

0 comments on commit f6f8b87

Please sign in to comment.