-
Notifications
You must be signed in to change notification settings - Fork 56
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(orga): create statistics component
Co-authored-by: Vincent Hardouin <[email protected]>
- Loading branch information
1 parent
a9feeb6
commit 8c8f5af
Showing
7 changed files
with
187 additions
and
0 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,47 @@ | ||
import { t } from 'ember-intl'; | ||
|
||
import Header from '../table/header'; | ||
import CoverRateGauge from './cover-rate-gauge'; | ||
import TagLevel from './tag-level'; | ||
|
||
const analysisByTubes = (model) => { | ||
return model.data.sort( | ||
(a, b) => a.competence_code.localeCompare(b.competence_code) || a.sujet.localeCompare(b.sujet), | ||
); | ||
}; | ||
|
||
<template> | ||
<div class="statistics-page-header"> | ||
<h1 class="page-title">{{t "pages.statistics.title"}}</h1> | ||
</div> | ||
|
||
<section class="statistics"> | ||
<table class="panel"> | ||
<caption class="screen-reader-only">{{t "pages.statistics.table.caption"}}</caption> | ||
<thead> | ||
<tr> | ||
<Header @size="wide" scope="col">{{t "pages.statistics.table.headers.skills"}}</Header> | ||
<Header @size="medium" scope="col">{{t "pages.statistics.table.headers.subjects"}}</Header> | ||
<Header @size="medium" @align="center" scope="col">{{t "pages.statistics.table.headers.cover-rate"}}</Header> | ||
<Header @align="center" @size="medium" scope="col">{{t | ||
"pages.statistics.table.headers.reached-level" | ||
}}</Header> | ||
</tr> | ||
</thead> | ||
<tbody> | ||
{{#each (analysisByTubes @model) as |line|}} | ||
<tr> | ||
<td>{{line.competence_code}} {{line.competence}}</td> | ||
<td>{{line.sujet}}</td> | ||
<td> | ||
<CoverRateGauge @userLevel={{line.niveau_par_user}} @tubeLevel={{line.niveau_par_sujet}} /> | ||
</td> | ||
<td class="table__column--center"> | ||
<TagLevel @level={{line.niveau_par_user}} /> | ||
</td> | ||
</tr> | ||
{{/each}} | ||
</tbody> | ||
</table> | ||
</section> | ||
</template> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,15 @@ | ||
.statistics-page-header { | ||
display: flex; | ||
gap: var(--pix-spacing-2x); | ||
align-items: baseline; | ||
|
||
&__date { | ||
@extend %pix-body-xs; | ||
} | ||
} | ||
|
||
tbody > tr { | ||
&:nth-child(odd) { | ||
background-color: var(--pix-neutral-20); | ||
} | ||
} |
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,3 @@ | ||
{{page-title (t "pages.statistics.title")}} | ||
|
||
<Statistics::Index @model={{this.model}} /> |
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
import { visit } from '@1024pix/ember-testing-library'; | ||
import { 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'; | ||
import { module, test } from 'qunit'; | ||
|
||
import authenticateSession from '../helpers/authenticate-session'; | ||
import setupIntl from '../helpers/setup-intl'; | ||
import { createPrescriberForOrganization } from '../helpers/test-init'; | ||
|
||
module('Acceptance | Statistics', function (hooks) { | ||
setupApplicationTest(hooks); | ||
setupMirage(hooks); | ||
setupIntl(hooks); | ||
|
||
module('When prescriber is not logged in', function () { | ||
test('it should not be accessible by an unauthenticated prescriber', async function (assert) { | ||
// when | ||
await visit('/statistiques'); | ||
|
||
// then | ||
assert.deepEqual(currentURL(), '/connexion'); | ||
}); | ||
}); | ||
|
||
module('When prescriber is logged in and has cover rate feature', function () { | ||
test('user should access to page', async function (assert) { | ||
// given | ||
const user = createPrescriberForOrganization({ lang: 'fr', pixOrgaTermsOfServiceAccepted: true }, {}, 'ADMIN', { | ||
COVER_RATE: true, | ||
}); | ||
await authenticateSession(user.id); | ||
|
||
// when | ||
const screen = await visit('/statistiques'); | ||
|
||
// then | ||
assert.dom(screen.getByRole('heading', { level: 1, name: t('pages.statistics.title') })).exists(); | ||
assert.dom(screen.getByRole('table')).exists(); | ||
assert.ok(screen.getAllByRole('cell')); | ||
}); | ||
}); | ||
}); |
62 changes: 62 additions & 0 deletions
62
orga/tests/integration/components/statistics/index-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,62 @@ | ||
import { render } from '@1024pix/ember-testing-library'; | ||
import { t } from 'ember-intl/test-support'; | ||
import Statistics from 'pix-orga/components/statistics/index'; | ||
import { module, test } from 'qunit'; | ||
|
||
import setupIntlRenderingTest from '../../../helpers/setup-intl-rendering'; | ||
|
||
module('Integration | Component | Statistics | Index', function (hooks) { | ||
setupIntlRenderingTest(hooks); | ||
|
||
test('it should display title', async function (assert) { | ||
//given | ||
const model = { | ||
data: [], | ||
}; | ||
|
||
//when | ||
const screen = await render(<template><Statistics @model={{model}} /></template>); | ||
|
||
//then | ||
assert.ok(screen.getByText(t('pages.statistics.title'))); | ||
}); | ||
|
||
test('it should display table headers', async function (assert) { | ||
//given | ||
const model = { | ||
data: [], | ||
}; | ||
|
||
//when | ||
const screen = await render(<template><Statistics @model={{model}} /></template>); | ||
|
||
//then | ||
assert.ok(screen.getByRole('columnheader', { name: t('pages.statistics.table.headers.skills') })); | ||
assert.ok(screen.getByRole('columnheader', { name: t('pages.statistics.table.headers.subjects') })); | ||
assert.ok(screen.getByRole('columnheader', { name: t('pages.statistics.table.headers.reached-level') })); | ||
assert.ok(screen.getByRole('columnheader', { name: t('pages.statistics.table.headers.cover-rate') })); | ||
}); | ||
|
||
test('it should display rows data', async function (assert) { | ||
//given | ||
const model = { | ||
data: [ | ||
{ | ||
competence_code: '2.1', | ||
competence: 'Interagir', | ||
sujet: 'Gérer ses contacts', | ||
niveau_par_user: '1.30', | ||
niveau_par_sujet: '1.50', | ||
}, | ||
], | ||
}; | ||
|
||
//when | ||
const screen = await render(<template><Statistics @model={{model}} /></template>); | ||
|
||
//then | ||
assert.ok(screen.getByRole('cell', { name: '2.1 Interagir' })); | ||
assert.ok(screen.getByRole('cell', { name: 'Gérer ses contacts' })); | ||
assert.ok(screen.getByRole('cell', { name: t('pages.statistics.level.novice') })); | ||
}); | ||
}); |