-
Notifications
You must be signed in to change notification settings - Fork 356
/
Copy pathduallistselectorwithactions.spec.ts
134 lines (116 loc) · 7.12 KB
/
duallistselectorwithactions.spec.ts
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
describe('Dual List Selector deprecated With Actions Demo Test', () => {
it('Navigate to demo section', () => {
cy.visit('http://localhost:3000/dual-list-selector-with-actions-demo-nav-link');
});
it('Verify existence', () => {
cy.get('.pf-v6-c-dual-list-selector').should('exist');
});
it('Verify default value content', () => {
cy.get('.pf-v6-c-dual-list-selector__list').first().should('have.value', '');
cy.get('.pf-v6-c-dual-list-selector__list li').should('have.length', 4);
});
it('Verify custom aria-labels, status, and titles', () => {
cy.get('.pf-m-available .pf-v6-c-dual-list-selector__title-text').contains('Available options');
cy.get('.pf-m-available .pf-v6-c-dual-list-selector__status-text').contains('0 of 4 options selected');
cy.get('.pf-m-available .pf-v6-c-dual-list-selector__tools-filter input').should(
'have.attr',
'aria-label',
'Search input'
);
cy.get('.pf-m-available .pf-v6-c-dual-list-selector__list').should('have.attr', 'aria-labelledby');
cy.get('.pf-v6-c-dual-list-selector__controls-item button').eq(1).should('have.attr', 'aria-label', 'Add all');
cy.get('.pf-v6-c-dual-list-selector__controls-item button')
.eq(0)
.should('have.attr', 'aria-label', 'Add selected')
.and('have.attr', 'disabled');
cy.get('.pf-v6-c-dual-list-selector__controls-item button')
.eq(3)
.should('have.attr', 'aria-label', 'Remove selected')
.and('have.attr', 'disabled');
cy.get('.pf-v6-c-dual-list-selector__controls-item button')
.eq(2)
.should('have.attr', 'aria-label', 'Remove all')
.and('have.attr', 'disabled');
cy.get('.pf-m-chosen .pf-v6-c-dual-list-selector__title-text').contains('Chosen options');
cy.get('.pf-m-chosen .pf-v6-c-dual-list-selector__status-text').contains('0 of 0 options selected');
cy.get('.pf-m-chosen .pf-v6-c-dual-list-selector__tools-filter input').should(
'have.attr',
'aria-label',
'Search input'
);
});
it('Verify selecting options', () => {
cy.get('.pf-v6-c-dual-list-selector__list-item .pf-m-selected').should('not.exist');
cy.get('.pf-v6-c-dual-list-selector__list-item').eq(0).click();
cy.get('.pf-v6-c-dual-list-selector__list-item .pf-m-selected').should('exist');
cy.get('.pf-v6-c-dual-list-selector__list-item').eq(1).click();
cy.get('.pf-v6-c-dual-list-selector__list-item .pf-m-selected').should('have.length', 2);
cy.get('.pf-v6-c-dual-list-selector__list-item').eq(0).click();
cy.get('.pf-v6-c-dual-list-selector__list-item .pf-m-selected').should('have.length', 1);
});
it('Verify selecting and choosing options', () => {
cy.get('.pf-v6-c-dual-list-selector__controls-item').eq(0).click();
cy.get('.pf-v6-c-dual-list-selector__list').eq(0).find('li').should('have.length', 3);
cy.get('.pf-v6-c-dual-list-selector__list').eq(1).find('li').should('have.length', 1);
cy.get('.pf-v6-c-dual-list-selector__list-item').eq(1).click();
cy.get('.pf-v6-c-dual-list-selector__controls-item').eq(0).click();
cy.get('.pf-m-available .pf-v6-c-dual-list-selector__status-text').contains('0 of 2 options selected');
cy.get('.pf-m-chosen .pf-v6-c-dual-list-selector__status-text').contains('0 of 2 options selected');
cy.get('.pf-v6-c-dual-list-selector__list').eq(0).find('li').should('have.length', 2);
cy.get('.pf-v6-c-dual-list-selector__list').eq(1).find('li').should('have.length', 2);
cy.get('.pf-v6-c-dual-list-selector__list-item').eq(0).click();
cy.get('.pf-m-available .pf-v6-c-dual-list-selector__status-text').contains('1 of 2 options selected');
cy.get('.pf-v6-c-dual-list-selector__list-item').eq(0).click();
});
it('Verify removing all options', () => {
cy.get('.pf-v6-c-dual-list-selector__controls-item').eq(2).click();
cy.get('.pf-v6-c-dual-list-selector__menu').eq(0).find('li').should('have.length', 4);
cy.get('.pf-v6-c-dual-list-selector__menu').eq(1).find('li').should('have.length', 0);
cy.get('.pf-m-available .pf-v6-c-dual-list-selector__status-text').contains('0 of 4 options selected');
cy.get('.pf-m-chosen .pf-v6-c-dual-list-selector__status-text').contains('0 of 0 options selected');
});
it('Verify choosing all options', () => {
cy.get('.pf-v6-c-dual-list-selector__controls-item').eq(1).click();
cy.get('.pf-v6-c-dual-list-selector__menu').eq(0).find('li').should('have.length', 0);
cy.get('.pf-v6-c-dual-list-selector__menu').eq(1).find('li').should('have.length', 4);
cy.get('.pf-m-available .pf-v6-c-dual-list-selector__status-text').contains('0 of 0 options selected');
cy.get('.pf-m-chosen .pf-v6-c-dual-list-selector__status-text').contains('0 of 4 options selected');
});
it('Verify sort works', () => {
cy.get('.pf-m-chosen .pf-v6-c-dual-list-selector__list-item').last().contains('Option 4');
cy.get('.pf-m-chosen .pf-v6-c-dual-list-selector__tools-actions button').first().click();
cy.get('.pf-m-chosen .pf-v6-c-dual-list-selector__list-item').last().contains('Option 1');
cy.get('.pf-m-chosen .pf-v6-c-dual-list-selector__list-item').first().contains('Option 4');
cy.get('.pf-m-chosen .pf-v6-c-dual-list-selector__tools-actions button').first().click();
cy.get('.pf-m-chosen .pf-v6-c-dual-list-selector__list-item').last().contains('Option 4');
cy.get('.pf-m-chosen .pf-v6-c-dual-list-selector__list-item').first().contains('Option 1');
});
it('Verify chosen search works', () => {
cy.get('.pf-v6-c-dual-list-selector__list').eq(1).find('li').should('have.length', 4);
cy.get('.pf-v6-c-dual-list-selector__tools-filter input').eq(1).type('Option 1');
cy.get('.pf-v6-c-dual-list-selector__list').eq(1).find('li').should('have.length', 1);
});
it('Verify removing all options', () => {
cy.get('.pf-v6-c-dual-list-selector__tools-filter input')
.eq(1)
.type('{Backspace}{Backspace}{Backspace}{Backspace}{Backspace}{Backspace}{Backspace}{Backspace}');
cy.get('.pf-v6-c-dual-list-selector__controls-item').eq(2).click();
cy.get('.pf-v6-c-dual-list-selector__menu').eq(0).find('li').should('have.length', 4);
cy.get('.pf-v6-c-dual-list-selector__menu').eq(1).find('li').should('have.length', 0);
});
it('Verify available search works', () => {
cy.get('.pf-v6-c-dual-list-selector__list').eq(0).find('li').should('have.length', 4);
cy.get('.pf-v6-c-dual-list-selector__tools-filter input').eq(0).type('Option 3');
cy.get('.pf-v6-c-dual-list-selector__list').eq(0).find('li').should('have.length', 1);
});
it('Verify adding all filtered options', () => {
cy.get('.pf-v6-c-dual-list-selector__list').eq(0).find('li').should('have.length', 1);
cy.get('.pf-v6-c-dual-list-selector__controls-item').eq(1).click();
cy.get('.pf-v6-c-dual-list-selector__list').eq(0).find('li').should('have.length', 0);
cy.get('.pf-v6-c-dual-list-selector__list').eq(1).find('li').should('have.length', 1);
cy.get('.pf-v6-c-dual-list-selector__tools-filter input')
.eq(0)
.type('{Backspace}{Backspace}{Backspace}{Backspace}{Backspace}{Backspace}{Backspace}{Backspace}');
cy.get('.pf-v6-c-dual-list-selector__list').eq(0).find('li').should('have.length', 3);
});
});