Skip to content

Commit

Permalink
fix(orga): add test on user logged menu without externalId
Browse files Browse the repository at this point in the history
  • Loading branch information
xav-car authored Dec 11, 2024
1 parent eba907a commit 2827ab7
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 49 deletions.
20 changes: 14 additions & 6 deletions orga/app/components/layout/user-logged-menu.gjs
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
import PixButtonLink from '@1024pix/pix-ui/components/pix-button-link';
import PixStructureSwitcher from '@1024pix/pix-ui/components/pix-structure-switcher';
import { action } from '@ember/object';
import { service } from '@ember/service';
import Component from '@glimmer/component';
import PixStructureSwitcher from '@1024pix/pix-ui/components/pix-structure-switcher';
import PixButtonLink from '@1024pix/pix-ui/components/pix-button-link';
import { t } from 'ember-intl';

export default class UserLoggedMenu extends Component {
Expand All @@ -25,10 +25,18 @@ export default class UserLoggedMenu extends Component {
}
return memberships
.slice()
.map((membership) => ({
label: `${membership.organization.get('name')} (${membership.organization.get('externalId')})`,
value: membership.organization.get('id'),
}))
.map((membership) => {
let label = `${membership.organization.get('name')}`;

if (membership.organization.get('externalId')) {
label = label.concat(` (${membership.organization.get('externalId')})`);
}

return {
label,
value: membership.organization.get('id'),
};
})
.sort((a, b) => a.label.localeCompare(b.label));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ module('Integration | Component | Layout::UserLoggedMenu', function () {
}),
});
organization2 = Object.create({ id: '2', name: 'Organization 2', externalId: 'EXT2' });
organization3 = Object.create({ id: '3', name: 'Organization 3', externalId: 'EXT3' });
organization3 = Object.create({ id: '3', name: 'Organization 3' });
loadStub = sinon.stub();

class CurrentUserStub extends Service {
Expand Down Expand Up @@ -75,7 +75,7 @@ module('Integration | Component | Layout::UserLoggedMenu', function () {

// then
assert.ok(await screen.findByRole('option', { name: `${organization2.name} (${organization2.externalId})` }));
assert.ok(await screen.findByRole('option', { name: `${organization3.name} (${organization3.externalId})` }));
assert.ok(await screen.findByRole('option', { name: `${organization3.name}` }));
});

test('should redirect to authenticated route before reload the current user', async function (assert) {
Expand Down
41 changes: 0 additions & 41 deletions orga/tests/unit/components/user-logged-menu-test.js

This file was deleted.

0 comments on commit 2827ab7

Please sign in to comment.