forked from patternfly/patternfly-react
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathselectfavorites.spec.ts
More file actions
84 lines (80 loc) · 3.65 KB
/
selectfavorites.spec.ts
File metadata and controls
84 lines (80 loc) · 3.65 KB
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
describe('Select Test', () => {
it('Navigate to demo section', () => {
cy.visit('http://localhost:3000/select-favorites-demo-nav-link');
});
it('Verify Single Select with Favorites', () => {
cy.get('#favorites-select').click();
cy.get('.pf-c-select__menu-group-title').should('not.exist');
cy.get('#option-1 > .pf-m-action').should('have.attr', 'aria-label', 'custom not starred');
cy.get('#option-1 > .pf-m-action').click();
cy.get('.pf-c-select__menu-group-title').should('exist');
cy.get('#option-1 > .pf-m-action').should('have.attr', 'aria-label', 'custom starred');
cy.get('#option-1 > .pf-m-action')
.first()
.click();
cy.get('#Favorites').should('not.exist');
});
it('Verify Single Grouped Select with Favorites', () => {
cy.get('#favorites-select-grouped').click();
cy.get('#My-Favorites').should('not.exist');
cy.get('#option-grouped-1 > .pf-m-action').should('have.attr', 'aria-label', 'not starred');
cy.get('#option-grouped-1 > .pf-m-action').click();
cy.get('#My-Favorites').should('exist');
cy.get('#option-grouped-1 > .pf-m-action').should('have.attr', 'aria-label', 'starred');
cy.get('#option-grouped-1 > .pf-m-action')
.first()
.click();
cy.get('#My-Favorites').should('not.exist');
// toggle closed
cy.get('#favorites-select-grouped').click();
});
it('Verify Typeahead Select with Favorites', () => {
cy.get('#typeahead-select').click();
cy.get('.pf-c-select__menu-group-title').should('not.exist');
cy.get('#typeahead-select-select-typeahead').should('have.value', '');
// Verify selections work
cy.get('#down-option').click();
cy.get('#typeahead-select-select-typeahead').should('have.value', 'Down');
cy.get('#typeahead-select').click();
// click on Running so it is added to favorites
cy.get('#running-option > .pf-m-action').click();
cy.get('.pf-c-select__menu-group-title').should('exist');
// filter so that Running is removed and favorites section therefore removed
cy.get('#typeahead-select-select-typeahead').type('h');
cy.get('.pf-c-select__menu-group-title').should('not.exist');
// Clear filter so Favorites shows again
cy.get('#typeahead-select-select-typeahead').clear();
cy.get('.pf-c-select__menu-group-title').should('exist');
cy.get('#running-option > .pf-m-action')
.first()
.click();
cy.get('#Favorites').should('not.exist');
});
it('Verify Multi Typeahead Select with Favorites', () => {
cy.get('#typeahead-multi-select').click();
cy.get('.pf-c-select__menu-group-title').should('not.exist');
cy.get('#typeahead-multi-select-select-multi-typeahead-typeahead').should('have.value', '');
// Verify selections work
cy.get('#grapes-option').click();
cy.get('.pf-c-chip')
.contains('grapes')
.should('exist');
cy.get('#pears-option').click();
cy.get('.pf-c-chip')
.contains('pears')
.should('exist');
// click on apples so it is added to favorites
cy.get('#apples-option > .pf-m-action').click();
cy.get('.pf-c-select__menu-group-title').should('exist');
// filter so that apples is removed and favorites section therefore removed
cy.get('#typeahead-multi-select-select-multi-typeahead-typeahead').type('h');
cy.get('.pf-c-select__menu-group-title').should('not.exist');
// Clear filter so Favorites shows again
cy.get('#typeahead-multi-select-select-multi-typeahead-typeahead').clear();
cy.get('.pf-c-select__menu-group-title').should('exist');
cy.get('#apples-option > .pf-m-action')
.first()
.click();
cy.get('.pf-c-select__menu-group-title').should('not.exist');
});
});