From f337b311ac29e83ae11e3e21bb4f72ead8e1a0ee Mon Sep 17 00:00:00 2001 From: Geoffroy Begouaussel Date: Fri, 10 Jan 2025 16:53:19 +0100 Subject: [PATCH] feat(admin): add autonomous courses list filters --- .../autonomous-courses/list/index.gjs | 110 ++++++++++++------ .../autonomous-courses/list/index-test.gjs | 53 +++++++++ 2 files changed, 129 insertions(+), 34 deletions(-) diff --git a/admin/app/components/autonomous-courses/list/index.gjs b/admin/app/components/autonomous-courses/list/index.gjs index e8ee051a28e..f4e7298072e 100644 --- a/admin/app/components/autonomous-courses/list/index.gjs +++ b/admin/app/components/autonomous-courses/list/index.gjs @@ -1,39 +1,81 @@ +import PixInput from '@1024pix/pix-ui/components/pix-input'; +import { fn } from '@ember/helper'; +import { action } from '@ember/object'; +import Component from '@glimmer/component'; +import { tracked } from '@glimmer/tracking'; import { t } from 'ember-intl'; import ListItem from './item'; - +} diff --git a/admin/tests/integration/components/autonomous-courses/list/index-test.gjs b/admin/tests/integration/components/autonomous-courses/list/index-test.gjs index e4834f91b4b..6ce92fb0776 100644 --- a/admin/tests/integration/components/autonomous-courses/list/index-test.gjs +++ b/admin/tests/integration/components/autonomous-courses/list/index-test.gjs @@ -1,4 +1,5 @@ import { render } from '@1024pix/ember-testing-library'; +import { fillIn } from '@ember/test-helpers'; import List from 'pix-admin/components/autonomous-courses/list'; import { module, test } from 'qunit'; @@ -59,4 +60,56 @@ module('Integration | Component | AutonomousCourses | List', function (hooks) { // then assert.dom(screen.getByText('Archivé')).exists(); }); + + module('filterable columns', function () { + test('it should be possible to filter ID column', async function (assert) { + // given + const autonomousCoursesList = [ + { + id: '1002', + name: 'Parcours autonome qui va être filtré', + createdAt: new Date('2023-01-01'), + }, + { + id: '999', + name: 'Parcours autonome avec un 9 dedans', + createdAt: new Date('2023-01-01'), + archivedAt: new Date('2023-02-02'), + }, + ]; + + // when + const screen = await render(); + await fillIn(screen.getByPlaceholderText('Filtrer par ID'), 9); + + // then + assert.dom(screen.getByText('Parcours autonome avec un 9 dedans')).exists(); + assert.dom(screen.queryByText('Parcours autonome qui va être filtré')).doesNotExist(); + }); + + test('it should be possible to filter name column', async function (assert) { + // given + const autonomousCoursesList = [ + { + id: '1002', + name: 'Parcours autonome qui va être filtré', + createdAt: new Date('2023-01-01'), + }, + { + id: '999', + name: 'Parcours autonome avec un 9 dedans', + createdAt: new Date('2023-01-01'), + archivedAt: new Date('2023-02-02'), + }, + ]; + + // when + const screen = await render(); + await fillIn(screen.getByPlaceholderText('Filtrer par nom'), 'qui va être filtré'); + + // then + assert.dom(screen.getByText('Parcours autonome qui va être filtré')).exists(); + assert.dom(screen.queryByText('Parcours autonome avec un 9 dedans')).doesNotExist(); + }); + }); });