-
Notifications
You must be signed in to change notification settings - Fork 356
/
Copy pathduallistselectordeprecatedbasic.spec.ts
133 lines (113 loc) · 7.31 KB
/
duallistselectordeprecatedbasic.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
describe('Dual List Selector deprecated BasicDemo Test', () => {
it('Navigate to demo section', () => {
cy.visit('http://localhost:3000/dual-list-selector-deprecated-basic-demo-nav-link');
});
it('Verify existence', () => {
cy.get('.pf-v6-c-dual-list-selector').should('exist');
});
it('Verify default 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 items selected');
cy.get('.pf-m-available .pf-v6-c-dual-list-selector__tools-filter input').should(
'have.attr',
'aria-label',
'Available search input'
);
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 items selected');
cy.get('.pf-m-chosen .pf-v6-c-dual-list-selector__tools-filter input').should(
'have.attr',
'aria-label',
'Chosen search input'
);
});
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 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__controls-item button').eq(0).and('not.have.attr', 'disabled');
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-m-available .pf-v6-c-dual-list-selector__status-text').contains('2 of 4 items selected');
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);
cy.get('.pf-m-available .pf-v6-c-dual-list-selector__status-text').contains('1 of 4 items selected');
});
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 button').eq(1).should('not.have.attr', 'disabled');
cy.get('.pf-v6-c-dual-list-selector__controls-item button').eq(0).should('not.have.attr', 'disabled');
cy.get('.pf-v6-c-dual-list-selector__controls-item button').eq(3).should('have.attr', 'disabled');
cy.get('.pf-v6-c-dual-list-selector__controls-item button').eq(2).should('not.have.attr', 'disabled');
cy.get('.pf-m-available .pf-v6-c-dual-list-selector__status-text').contains('1 of 3 items selected');
cy.get('.pf-m-chosen .pf-v6-c-dual-list-selector__status-text').contains('0 of 1 items selected');
cy.get('.pf-v6-c-dual-list-selector__controls-item').eq(0).click();
cy.get('.pf-v6-c-tooltip').should('exist');
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-m-available .pf-v6-c-dual-list-selector__status-text').contains('0 of 2 items selected');
cy.get('.pf-m-chosen .pf-v6-c-dual-list-selector__status-text').contains('0 of 2 items selected');
});
it('Verify removing all options', () => {
cy.get('.pf-v6-c-dual-list-selector__controls-item').eq(2).click();
cy.get('.pf-v6-c-tooltip').should('exist');
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__list').eq(1).find('li').should('have.length', 0);
});
it('Verify choosing all options', () => {
cy.get('.pf-v6-c-dual-list-selector__controls-item').eq(1).click();
cy.get('.pf-v6-c-tooltip').should('exist');
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', 4);
cy.get('.pf-v6-c-dual-list-selector__controls-item button').eq(1).should('have.attr', 'disabled');
cy.get('.pf-v6-c-dual-list-selector__controls-item button').eq(0).should('have.attr', 'disabled');
cy.get('.pf-v6-c-dual-list-selector__controls-item button').eq(3).should('have.attr', 'disabled');
cy.get('.pf-v6-c-dual-list-selector__controls-item button').eq(2).should('not.have.attr', 'disabled');
cy.get('.pf-m-available .pf-v6-c-dual-list-selector__status-text').contains('0 of 0 items selected');
cy.get('.pf-m-chosen .pf-v6-c-dual-list-selector__status-text').contains('0 of 4 items selected');
});
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__list').eq(0).find('li').should('have.length', 4);
cy.get('.pf-v6-c-dual-list-selector__list').eq(1).find('li').should('have.length', 0);
cy.get('.pf-v6-c-dual-list-selector__controls-item button').eq(1).should('not.have.attr', 'disabled');
cy.get('.pf-v6-c-dual-list-selector__controls-item button').eq(0).should('have.attr', 'disabled');
cy.get('.pf-v6-c-dual-list-selector__controls-item button').eq(3).should('have.attr', 'disabled');
cy.get('.pf-v6-c-dual-list-selector__controls-item button').eq(2).should('have.attr', 'disabled');
cy.get('.pf-m-available .pf-v6-c-dual-list-selector__status-text').contains('0 of 4 items selected');
cy.get('.pf-m-chosen .pf-v6-c-dual-list-selector__status-text').contains('0 of 0 items selected');
});
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);
});
});