-
Notifications
You must be signed in to change notification settings - Fork 55
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(api): use feature toggle for new sidebar in authenticated hbs
fixup! feat(api): use feature toggle for new sidebar in authenticated hbs
- Loading branch information
Showing
3 changed files
with
86 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import Controller from '@ember/controller'; | ||
import { service } from '@ember/service'; | ||
|
||
export default class AuthenticatedController extends Controller { | ||
@service featureToggles; | ||
|
||
get shouldDisplayNewSidebar() { | ||
return this.featureToggles.featureToggles?.isPixAdminNewSidebarEnabled; | ||
} | ||
} |
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 |
---|---|---|
@@ -1,3 +1,16 @@ | ||
<Layout> | ||
{{outlet}} | ||
</Layout> | ||
{{#if this.shouldDisplayNewSidebar}} | ||
<PixAppLayout @variant="primary"> | ||
<:navigation> | ||
<Layout::Sidebar /> | ||
</:navigation> | ||
<:main> | ||
<main> | ||
{{outlet}} | ||
</main> | ||
</:main> | ||
</PixAppLayout> | ||
{{else}} | ||
<Layout> | ||
{{outlet}} | ||
</Layout> | ||
{{/if}} |
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,60 @@ | ||
import { visit, within } from '@1024pix/ember-testing-library'; | ||
import Service from '@ember/service'; | ||
import { setupMirage } from 'ember-cli-mirage/test-support'; | ||
import { setupApplicationTest } from 'ember-qunit'; | ||
import { module, test } from 'qunit'; | ||
|
||
import { authenticateAdminMemberWithRole } from '../helpers/test-init'; | ||
|
||
module('Acceptance | Authenticated pages', function (hooks) { | ||
setupApplicationTest(hooks); | ||
setupMirage(hooks); | ||
|
||
module('When "isPixAdminNewSidebarEnabled" feature toggle has "false" value', function (hooks) { | ||
hooks.beforeEach(async function () { | ||
// given | ||
class FeatureTogglesStub extends Service { | ||
featureToggles = { isPixAdminNewSidebarEnabled: false }; | ||
|
||
load() {} | ||
} | ||
this.owner.register('service:featureToggles', FeatureTogglesStub); | ||
|
||
await authenticateAdminMemberWithRole({ isSuperAdmin: true })(server); | ||
}); | ||
|
||
test('it displays old layout with its menu-bar', async function (assert) { | ||
// when | ||
const screen = await visit('/'); | ||
|
||
// then | ||
assert.dom(screen.getByRole('navigation', { name: 'Navigation principale' })).exists(); | ||
}); | ||
}); | ||
|
||
module('When "isPixAdminNewSidebarEnabled" feature toggle has "true" value', function (hooks) { | ||
hooks.beforeEach(async function () { | ||
// given | ||
class FeatureTogglesStub extends Service { | ||
featureToggles = { isPixAdminNewSidebarEnabled: true }; | ||
|
||
load() {} | ||
} | ||
this.owner.register('service:featureToggles', FeatureTogglesStub); | ||
|
||
await authenticateAdminMemberWithRole({ isSuperAdmin: true })(server); | ||
}); | ||
|
||
test('it displays new layout', async function (assert) { | ||
// when | ||
const screen = await visit('/'); | ||
|
||
// then | ||
const navBar = screen.getByRole('complementary'); | ||
const footer = within(navBar).getByRole('contentinfo'); | ||
|
||
assert.dom(footer).exists(); | ||
assert.ok(within(footer).getByRole('link', { name: 'Se déconnecter' })); | ||
}); | ||
}); | ||
}); |