1
- import { render } from ' @1024pix/ember-testing-library' ;
1
+ import { render , within } from ' @1024pix/ember-testing-library' ;
2
2
import { fillIn } from ' @ember/test-helpers' ;
3
3
import List from ' pix-admin/components/autonomous-courses/list' ;
4
4
import { module , test } from ' qunit' ;
5
5
6
- import setupIntlRenderingTest from ' ../../../../helpers/setup-intl-rendering' ;
6
+ import setupIntlRenderingTest , { t } from ' ../../../../helpers/setup-intl-rendering' ;
7
7
8
8
module (' Integration | Component | AutonomousCourses | List' , function (hooks ) {
9
9
setupIntlRenderingTest (hooks);
@@ -27,20 +27,21 @@ module('Integration | Component | AutonomousCourses | List', function (hooks) {
27
27
const screen = await render (<template ><List @ items ={{autonomousCoursesList }} /></template >);
28
28
29
29
// then
30
- assert .dom (screen .getByText (' Id' )).exists ();
31
- assert .dom (screen .getByText (' 1002' )).exists ();
32
- assert .dom (screen .getByText (' 1001' )).exists ();
30
+ const table = screen .getByRole (' table' , { name: t (' components.autonomous-courses.list.title' ) });
31
+ assert .dom (within (table).getByRole (' columnheader' , { name: ' Id' })).exists ();
32
+ assert .dom (within (table).getByRole (' cell' , { name: ' 1002' })).exists ();
33
+ assert .dom (within (table).getByRole (' cell' , { name: ' 1001' })).exists ();
33
34
34
- assert .dom (screen . getByText ( ' Nom' )).exists ();
35
+ assert .dom (within (table). getByRole ( ' columnheader ' , { name : ' Nom' } )).exists ();
35
36
assert .dom (screen .getByRole (' link' , { name: ' Parcours autonome 2023' })).exists ();
36
37
assert .dom (screen .getByRole (' link' , { name: ' Parcours autonome 2020' })).exists ();
37
38
38
- assert .dom (screen . getByText ( ' Date de création' )).exists ();
39
- assert .dom (screen . getByText ( ' 01/01/2023' )).exists ();
40
- assert .dom (screen . getByText ( ' 01/01/2020' )).exists ();
39
+ assert .dom (within (table). getByRole ( ' columnheader ' , { name : ' Date de création' } )).exists ();
40
+ assert .dom (within (table). getByRole ( ' cell ' , { name : ' 01/01/2023' } )).exists ();
41
+ assert .dom (within (table). getByRole ( ' cell ' , { name : ' 01/01/2020' } )).exists ();
41
42
42
- assert .dom (screen . getByText ( ' Statut' )).exists ();
43
- assert .strictEqual (screen .getAllByText (' Actif' ).length , 2 );
43
+ assert .dom (within (table). getByRole ( ' columnheader ' , { name : ' Statut' } )).exists ();
44
+ assert .strictEqual (within (table) .getAllByText (' Actif' ).length , 2 );
44
45
});
45
46
46
47
test (' it should display a autonomous course with archived tag' , async function (assert ) {
@@ -80,7 +81,7 @@ module('Integration | Component | AutonomousCourses | List', function (hooks) {
80
81
81
82
// when
82
83
const screen = await render (<template ><List @ items ={{autonomousCoursesList }} /></template >);
83
- await fillIn (screen .getByPlaceholderText ( ' Filtrer par ID' ), 9 );
84
+ await fillIn (screen .getByRole ( ' textbox ' , { name : ' Filtrer par ID' } ), 9 );
84
85
85
86
// then
86
87
assert .dom (screen .getByText (' Parcours autonome avec un 9 dedans' )).exists ();
@@ -105,7 +106,7 @@ module('Integration | Component | AutonomousCourses | List', function (hooks) {
105
106
106
107
// when
107
108
const screen = await render (<template ><List @ items ={{autonomousCoursesList }} /></template >);
108
- await fillIn (screen .getByPlaceholderText ( ' Filtrer par nom' ), ' qui va être filtré' );
109
+ await fillIn (screen .getByRole ( ' textbox ' , { name : ' Filtrer par nom' } ), ' qui va être filtré' );
109
110
110
111
// then
111
112
assert .dom (screen .getByText (' Parcours autonome qui va être filtré' )).exists ();
0 commit comments