-
Notifications
You must be signed in to change notification settings - Fork 381
Expand file tree
/
Copy pathpagination.spec.ts
More file actions
160 lines (149 loc) · 7.56 KB
/
pagination.spec.ts
File metadata and controls
160 lines (149 loc) · 7.56 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
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
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
describe('Pagination Demo Test', () => {
it('Navigate to Pagination section', () => {
cy.visit('http://localhost:3000/pagination-demo-nav-link');
});
it('should be disabled when flag is present', () => {
cy.get('.pagination-options-menu-disabled')
.find('.pf-v6-c-menu-toggle__text')
.then((toggleText) => expect(toggleText).to.have.text('1 - 20 of 523 '));
cy.get('.pagination-options-menu-disabled')
.find('button[data-action="first"]')
.then((button) => expect(button).to.be.disabled);
cy.get('.pagination-options-menu-disabled')
.find('button[data-action="previous"]')
.then((button) => expect(button).to.be.disabled);
cy.get('.pagination-options-menu-disabled')
.find('button[data-action="next"]')
.then((button) => expect(button).to.be.disabled);
cy.get('.pagination-options-menu-disabled')
.find('button[data-action="last"]')
.then((button) => expect(button).to.be.disabled);
cy.get('.pagination-options-menu-disabled .pf-v6-c-menu-toggle').then((button) => expect(button).to.be.disabled);
});
it('should be sticky when flag is present', () => {
cy.get('.pagination-options-menu-sticky').should('have.class', 'pf-m-sticky');
});
it('Verify initial state', () => {
cy.get('.pf-v6-c-pagination').should('have.length', 5);
cy.get('.pagination-options-menu-bottom.pf-v6-c-pagination.pf-m-bottom').should('exist');
cy.get('.pagination-options-menu-top')
.find('.pf-v6-c-menu-toggle__text')
.then((toggleText) => expect(toggleText).to.have.text('1 - 20 of 523 '));
cy.get('.pagination-options-menu-top')
.find('button[data-action="first"]')
.then((button) => expect(button).to.be.disabled);
cy.get('.pagination-options-menu-top')
.find('button[data-action="previous"]')
.then((button) => expect(button).to.be.disabled);
cy.get('.pagination-options-menu-top')
.find('button[data-action="next"]')
.then((button) => expect(button).not.to.be.disabled);
cy.get('.pagination-options-menu-top')
.find('button[data-action="last"]')
.then((button) => expect(button).not.to.be.disabled);
cy.get('.pagination-options-menu-top')
.find('.pf-v6-c-pagination__nav-page-select input')
.then((input) => expect(input).to.have.value('1'));
cy.get('.pagination-options-menu-top')
.find('.pf-v6-c-pagination__nav-page-select')
.then((navPageSelect) => expect(navPageSelect).to.have.text('of 27'));
});
it('Verify event handlers fire correctly', () => {
cy.get('.pagination-options-menu-top')
.find('.pf-v6-c-menu-toggle')
.then((toggleButton: JQuery<HTMLButtonElement>) => {
cy.wrap(toggleButton).click();
cy.get('.pf-v6-c-menu-toggle.pf-m-expanded').should('exist');
cy.get('li[data-action="per-page-10"]').then((firstMenuItem: JQuery<HTMLButtonElement>) => {
cy.wrap(firstMenuItem).click();
cy.get('.pf-v6-c-menu-toggle.pf-m-expanded').should('not.exist');
cy.get('.pagination-options-menu-top')
.find('.pf-v6-c-menu-toggle__text')
.then((toggleText) => expect(toggleText).to.have.text('1 - 10 of 523 '));
cy.get('.pagination-options-menu-top')
.find('.pf-v6-c-pagination__nav-page-select')
.then((navPageSelect) => expect(navPageSelect).to.have.text('of 53'));
cy.get('.pagination-options-menu-bottom')
.find('.pf-v6-c-menu-toggle__text')
.then((toggleText) => expect(toggleText).to.have.text('1 - 10 of 523 '));
cy.get('.pagination-options-menu-bottom')
.find('.pf-v6-c-pagination__nav-page-select')
.then((navPageSelect) => expect(navPageSelect).to.have.text('of 53'));
});
});
cy.get('.pagination-options-menu-top')
.find('button[data-action="next"]')
.then((button: JQuery<HTMLButtonElement>) => {
cy.wrap(button).click();
cy.get('.pagination-options-menu-top')
.find('button[data-action="first"]')
.then((firstButton) => expect(firstButton).not.to.be.disabled);
cy.get('.pagination-options-menu-top')
.find('button[data-action="previous"]')
.then((previousButton) => expect(previousButton).not.to.be.disabled);
cy.get('.pagination-options-menu-top')
.find('.pf-v6-c-menu-toggle__text')
.then((toggleText) => expect(toggleText).to.have.text('11 - 20 of 523 '));
cy.get('.pagination-options-menu-top')
.find('.pf-v6-c-pagination__nav-page-select input')
.then((input) => expect(input).to.have.value('2'));
});
cy.get('.pagination-options-menu-bottom')
.find('button[data-action="next"]')
.then((button: JQuery<HTMLButtonElement>) => {
cy.wrap(button).click();
cy.get('.pagination-options-menu-bottom')
.find('button[data-action="first"]')
.then((firstButton) => expect(firstButton).not.to.be.disabled);
cy.get('.pagination-options-menu-bottom')
.find('button[data-action="previous"]')
.then((previousButton) => expect(previousButton).not.to.be.disabled);
cy.get('.pagination-options-menu-bottom')
.find('.pf-v6-c-menu-toggle__text')
.then((toggleText) => expect(toggleText).to.have.text('11 - 20 of 523 '));
cy.get('.pagination-options-menu-bottom')
.find('.pf-v6-c-pagination__nav-page-select input')
.then((input) => expect(input).to.have.value('2'));
});
cy.get('.pagination-options-menu-default-fullpage')
.find('button[data-action="next"]')
.then((button: JQuery<HTMLButtonElement>) => {
cy.wrap(button).click();
cy.get('.pagination-options-menu-default-fullpage')
.find('button[data-action="first"]')
.then((firstButton) => expect(firstButton).not.to.be.disabled);
cy.get('.pagination-options-menu-default-fullpage')
.find('button[data-action="previous"]')
.then((previousButton) => expect(previousButton).not.to.be.disabled);
cy.get('.pagination-options-menu-default-fullpage')
.find('.pf-v6-c-menu-toggle__text')
.then((toggleText) => expect(toggleText).to.have.text('11 - 20 of 523 '));
cy.get('.pagination-options-menu-default-fullpage')
.find('.pf-v6-c-pagination__nav-page-select input')
.then((input) => expect(input).to.have.value('2'));
});
});
it('Verify isLastFullPageShown works correctly', () => {
cy.get('.pagination-options-menu-default-fullpage')
.find('button[data-action="last"]')
.then((button: JQuery<HTMLButtonElement>) => {
cy.wrap(button).click();
cy.get('.pagination-options-menu-default-fullpage')
.find('.pf-v6-c-menu-toggle')
.then((toggleButton: JQuery<HTMLButtonElement>) => {
cy.wrap(toggleButton).click();
cy.get('.pf-v6-c-menu-toggle.pf-m-expanded').should('exist');
cy.get('li[data-action="per-page-100"]').then((lastMenuItem: JQuery<HTMLButtonElement>) => {
cy.wrap(lastMenuItem).click();
cy.get('.pf-v6-c-menu-toggle.pf-m-expanded').should('not.exist');
cy.get('.pagination-options-menu-default-fullpage')
.find('.pf-v6-c-menu-toggle__text')
.then((toggleText) => expect(toggleText).to.have.text('401 - 500 of 523 '));
cy.get('.pagination-options-menu-default-fullpage')
.find('.pf-v6-c-form-control input')
.then((currentPage) => expect(currentPage).to.have.value('5'));
});
});
});
});
});