-
Notifications
You must be signed in to change notification settings - Fork 353
/
Copy pathslider.spec.ts
137 lines (124 loc) · 5.3 KB
/
slider.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
135
136
137
describe('Slider Demo Test', () => {
it('Navigate to Slider section', () => {
cy.visit('http://localhost:3000/slider-demo-nav-link');
});
xit('changes discrete slider value when dragged', () => {
cy.get('#discrete-slider').should('exist');
cy.get('#discrete-slider')
.invoke('attr', 'style')
.should(
'match',
/--pf-v6-c-slider--value:\s*62\.5%\s*;?\s*--pf-v6-c-slider__value--c-form-control--width-chars:\s*1\s*;/
);
cy.get('#discrete-slider > .pf-v6-c-slider__main > .pf-v6-c-slider__thumb')
.trigger('mousedown', { which: 1 })
.trigger('mousemove', 150, 10, { force: true })
.trigger('mouseup', { force: true });
cy.get('#discrete-slider')
.invoke('attr', 'style')
.should(
'match',
/--pf-v6-c-slider--value:\s*75%\s*;?\s*--pf-v6-c-slider__value--c-form-control--width-chars:\s*1\s*;/
);
});
xit('changes discrete slider value using keyboard', () => {
cy.get('#discrete-slider > .pf-v6-c-slider__main > .pf-v6-c-slider__thumb').focus();
cy.get('#discrete-slider > .pf-v6-c-slider__main > .pf-v6-c-slider__thumb').trigger('keydown', { keyCode: 39 });
cy.wait(50);
cy.get('#discrete-slider > .pf-v6-c-slider__main > .pf-v6-c-slider__thumb').trigger('keyup', { keyCode: 39 });
cy.get('#discrete-slider')
.invoke('attr', 'style')
.should(
'match',
/--pf-v6-c-slider--value:\s*87\.5%\s*;?\s*--pf-v6-c-slider__value--c-form-control--width-chars:\s*1\s*;/
);
});
it('changes continuous slider value when dragged', () => {
cy.get('#continuous-slider').should('exist');
cy.get('#continuous-slider')
.invoke('attr', 'style')
.should(
'match',
/--pf-v6-c-slider--value:\s*50%\s*;?\s*--pf-v6-c-slider__value--c-form-control--width-chars:\s*2\s*;/
);
cy.get('#continuous-slider > .pf-v6-c-slider__main > .pf-v6-c-slider__thumb')
.trigger('mousedown', { which: 1 })
.trigger('mousemove', 430, 10, { force: true })
.trigger('mouseup', { force: true });
cy.get('#continuous-slider')
.invoke('attr', 'style')
.should(
'match',
/--pf-v6-c-slider--value:\s*100%\s*;?\s*--pf-v6-c-slider__value--c-form-control--width-chars:\s*3\s*;/
);
});
it('changes continuous slider value using keyboard', () => {
cy.get('#continuous-slider > .pf-v6-c-slider__main > .pf-v6-c-slider__thumb').focus();
cy.get('#continuous-slider > .pf-v6-c-slider__main > .pf-v6-c-slider__thumb').trigger('keydown', { keyCode: 37 });
cy.wait(100);
cy.get('#continuous-slider > .pf-v6-c-slider__main > .pf-v6-c-slider__thumb').trigger('keyup', { keyCode: 37 });
cy.get('#continuous-slider')
.invoke('attr', 'style')
.should(
'not.match',
/--pf-v6-c-slider--value:\s*100%\s*;?\s*--pf-v6-c-slider__value--c-form-control--width-chars:\s*3\s*;/
);
});
it('disabled slider value does not change when dragged', () => {
cy.get('#disabled-slider').should('exist');
cy.get('#disabled-slider')
.invoke('attr', 'style')
.should(
'match',
/--pf-v6-c-slider--value:\s*20%\s*;?\s*--pf-v6-c-slider__value--c-form-control--width-chars:\s*1\s*;/
);
cy.get('#disabled-slider').should('have.class', 'pf-m-disabled');
cy.get('#disabled-slider > .pf-v6-c-slider__main > .pf-v6-c-slider__thumb')
.trigger('mousedown', { which: 1 })
.trigger('mousemove', 430, 10, { force: true })
.trigger('mouseup', { force: true });
cy.get('#disabled-slider')
.invoke('attr', 'style')
.should(
'match',
/--pf-v6-c-slider--value:\s*20%\s*;?\s*--pf-v6-c-slider__value--c-form-control--width-chars:\s*1\s*;/
);
});
it('changes custom steps slider value when dragged', () => {
cy.get('#custom-steps-slider').should('exist');
cy.get('#custom-steps-slider')
.invoke('attr', 'style')
.should(
'match',
/--pf-v6-c-slider--value:\s*20%\s*;?\s*--pf-v6-c-slider__value--c-form-control--width-chars:\s*1\s*;/
);
cy.get('#custom-steps-slider > .pf-v6-c-slider__main > .pf-v6-c-slider__thumb')
.trigger('mousedown', { which: 1 })
.trigger('mousemove', -200, 10, { force: true })
.trigger('mouseup', { force: true });
cy.get('#custom-steps-slider')
.invoke('attr', 'style')
.should(
'match',
/--pf-v6-c-slider--value:\s*0%\s*;?\s*--pf-v6-c-slider__value--c-form-control--width-chars:\s*1\s*;/
);
});
it('changes custom steps slider value using keyboard', () => {
cy.get('#custom-steps-slider')
.invoke('attr', 'style')
.should(
'match',
/--pf-v6-c-slider--value:\s*0%\s*;?\s*--pf-v6-c-slider__value--c-form-control--width-chars:\s*1\s*;/
);
cy.get('#custom-steps-slider > .pf-v6-c-slider__main > .pf-v6-c-slider__thumb').focus();
cy.get('#custom-steps-slider > .pf-v6-c-slider__main > .pf-v6-c-slider__thumb').trigger('keydown', { keyCode: 39 });
cy.wait(100);
cy.get('#custom-steps-slider > .pf-v6-c-slider__main > .pf-v6-c-slider__thumb').trigger('keyup', { keyCode: 39 });
cy.get('#custom-steps-slider')
.invoke('attr', 'style')
.should(
'match',
/--pf-v6-c-slider--value:\s*20%\s*;?\s*--pf-v6-c-slider__value--c-form-control--width-chars:\s*1\s*;/
);
});
});