forked from patternfly/patternfly-react
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathduallistselectorwithactions.spec.ts
130 lines (114 loc) · 6.62 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
describe('Dual List Selector 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('#dual-list-selector-demo').should('exist');
});
it('Verify default value content', () => {
cy.get('.pf-v5-c-dual-list-selector__list').first().should('have.value', '');
cy.get('.pf-v5-c-dual-list-selector__list li').should('have.length', 4);
});
it('Verify custom aria-labels, status, and titles', () => {
cy.get('.pf-m-available .pf-v5-c-dual-list-selector__title-text').contains('Demo available options');
cy.get('.pf-m-available .pf-v5-c-dual-list-selector__status-text').contains('4 available');
cy.get('.pf-m-available .pf-v5-c-dual-list-selector__tools-filter input').should(
'have.attr',
'aria-label',
'Demo available options search'
);
cy.get('.pf-m-available .pf-v5-c-dual-list-selector__list').should(
'have.attr',
'aria-labelledby',
'dual-list-selector-demo-available-pane-status'
);
cy.get('.pf-v5-c-dual-list-selector__controls-item button').eq(1).should('have.attr', 'aria-label', 'Demo add all');
cy.get('.pf-v5-c-dual-list-selector__controls-item button')
.eq(0)
.should('have.attr', 'aria-label', 'Demo add selected')
.and('have.attr', 'disabled');
cy.get('.pf-v5-c-dual-list-selector__controls-item button')
.eq(3)
.should('have.attr', 'aria-label', 'Demo remove selected')
.and('have.attr', 'disabled');
cy.get('.pf-v5-c-dual-list-selector__controls-item button')
.eq(2)
.should('have.attr', 'aria-label', 'Demo remove all')
.and('have.attr', 'disabled');
cy.get('.pf-m-chosen .pf-v5-c-dual-list-selector__title-text').contains('Demo chosen options');
cy.get('.pf-m-chosen .pf-v5-c-dual-list-selector__status-text').contains('0 chosen');
cy.get('.pf-m-chosen .pf-v5-c-dual-list-selector__tools-filter input').should(
'have.attr',
'aria-label',
'Demo chosen options search'
);
cy.get('.pf-m-chosen .pf-v5-c-dual-list-selector__list').should('not.have.attr', 'aria-labelledby');
});
it('Verify selecting options', () => {
cy.get('.pf-v5-c-dual-list-selector__list-item .pf-m-selected').should('not.exist');
cy.get('.pf-v5-c-dual-list-selector__list-item').eq(0).click();
cy.get('.pf-v5-c-dual-list-selector__list-item .pf-m-selected').should('exist');
cy.get('.pf-v5-c-dual-list-selector__list-item').eq(1).click();
cy.get('.pf-v5-c-dual-list-selector__list-item .pf-m-selected').should('have.length', 2);
cy.get('.pf-v5-c-dual-list-selector__list-item').eq(0).click();
cy.get('.pf-v5-c-dual-list-selector__list-item .pf-m-selected').should('have.length', 1);
});
it('Verify selecting and choosing options', () => {
cy.get('.pf-v5-c-dual-list-selector__controls-item').eq(0).click();
cy.get('.pf-v5-c-dual-list-selector__list').eq(0).find('li').should('have.length', 3);
cy.get('.pf-v5-c-dual-list-selector__list').eq(1).find('li').should('have.length', 1);
cy.get('.pf-v5-c-dual-list-selector__list-item').eq(1).click();
cy.get('.pf-v5-c-dual-list-selector__controls-item').eq(0).click();
cy.get('.pf-m-available .pf-v5-c-dual-list-selector__status-text').contains('2 available');
cy.get('.pf-m-chosen .pf-v5-c-dual-list-selector__status-text').contains('2 chosen');
cy.get('.pf-v5-c-dual-list-selector__list').eq(0).find('li').should('have.length', 2);
cy.get('.pf-v5-c-dual-list-selector__list').eq(1).find('li').should('have.length', 2);
});
it('Verify removing all options', () => {
cy.get('.pf-v5-c-dual-list-selector__controls-item').eq(2).click();
cy.get('.pf-v5-c-dual-list-selector__list').eq(0).find('li').should('have.length', 4);
cy.get('.pf-v5-c-dual-list-selector__list').eq(1).find('li').should('have.length', 0);
cy.get('.pf-m-available .pf-v5-c-dual-list-selector__status-text').contains('4 available');
cy.get('.pf-m-chosen .pf-v5-c-dual-list-selector__status-text').contains('0 chosen');
});
it('Verify choosing all options', () => {
cy.get('.pf-v5-c-dual-list-selector__controls-item').eq(1).click();
cy.get('.pf-v5-c-dual-list-selector__list').eq(0).find('li').should('have.length', 0);
cy.get('.pf-v5-c-dual-list-selector__list').eq(1).find('li').should('have.length', 4);
cy.get('.pf-m-available .pf-v5-c-dual-list-selector__status-text').contains('0 available');
cy.get('.pf-m-chosen .pf-v5-c-dual-list-selector__status-text').contains('4 chosen');
});
it('Verify sort works', () => {
cy.get('.pf-m-chosen .pf-v5-c-dual-list-selector__list-item').last().contains('Option 3');
cy.get('.pf-m-chosen .pf-v5-c-dual-list-selector__tools-actions button').first().click();
cy.get('.pf-m-chosen .pf-v5-c-dual-list-selector__list-item').last().contains('Option 4');
});
it('Verify chosen search works', () => {
cy.get('.pf-v5-c-dual-list-selector__list').eq(1).find('li').should('have.length', 4);
cy.get('.pf-v5-c-dual-list-selector__tools-filter input').eq(1).type('Option 1');
cy.get('.pf-v5-c-dual-list-selector__list').eq(1).find('li').should('have.length', 1);
});
it('Verify removing all options', () => {
cy.get('.pf-v5-c-dual-list-selector__tools-filter input')
.eq(1)
.type('{Backspace}{Backspace}{Backspace}{Backspace}{Backspace}{Backspace}{Backspace}{Backspace}');
cy.get('.pf-v5-c-dual-list-selector__controls-item').eq(2).click();
cy.get('.pf-v5-c-dual-list-selector__list').eq(0).find('li').should('have.length', 4);
cy.get('.pf-v5-c-dual-list-selector__list').eq(1).find('li').should('have.length', 0);
});
it('Verify available search works', () => {
cy.get('.pf-v5-c-dual-list-selector__list').eq(0).find('li').should('have.length', 4);
cy.get('.pf-v5-c-dual-list-selector__tools-filter input').eq(0).type('Option 3');
cy.get('.pf-v5-c-dual-list-selector__list').eq(0).find('li').should('have.length', 1);
});
xit('Verify adding all filtered options', () => {
cy.get('.pf-v5-c-dual-list-selector__list').eq(0).find('li').should('have.length', 1);
cy.get('.pf-v5-c-dual-list-selector__controls-item').eq(1).click();
cy.get('.pf-v5-c-dual-list-selector__list').eq(0).find('li').should('have.length', 0);
cy.get('.pf-v5-c-dual-list-selector__list').eq(1).find('li').should('have.length', 1);
cy.get('.pf-v5-c-dual-list-selector__tools-filter input')
.eq(0)
.type('{Backspace}{Backspace}{Backspace}{Backspace}{Backspace}{Backspace}{Backspace}{Backspace}');
cy.get('.pf-v5-c-dual-list-selector__list').eq(0).find('li').should('have.length', 3);
});
});