1
1
import { ButtonsPo } from '../support/buttons.po' ;
2
2
3
- // need to refactor tests for making them faster
4
3
describe ( 'Buttons page test suite' , ( ) => {
5
4
const buttons = new ButtonsPo ( ) ;
6
- const buttonTitles = buttons . exampleTitlesArr ;
7
5
const buttonDemos = buttons . exampleDemosArr ;
8
6
7
+ const buttonNames = [ 'Left' , 'Middle' , 'Right' ] ;
8
+ const buttonOutput = [ 'left' , 'middle' , 'right' ] ;
9
+
9
10
beforeEach ( ( ) => buttons . navigateTo ( ) ) ;
10
11
11
12
it ( 'buttons page loads and displays it\'s content' , ( ) => {
@@ -47,46 +48,27 @@ describe('Buttons page test suite', () => {
47
48
48
49
49
50
it ( 'checkbox example contains checkboxes, that can be checked or unchecked' , ( ) => {
50
- // let btnTextTempl: string;
51
- // setting all checkboxes to unchecked
52
- // cy.get(buttonDemos[1]).as('checkboxes').find('.btn').as('btnBlock').eq(1).click();
53
-
54
- buttons . clickByText ( buttonDemos [ 1 ] , 'Middle' ) ;
55
- cy . get ( buttonDemos [ 1 ] ) . children ( '.card-header' ) . should ( 'to.contain' , `"middle": false` ) ;
56
-
57
- // cy.get(buttonDemos[1]).find('.btn').as('checkbox').each(($btn, i) => {
58
- // cy.get('@checkbox').eq(i).invoke('text').then(btnText => {
59
- // btnTextTempl = btnText.toString().toLowerCase();
60
- //
61
- // cy.get('@checkbox').eq(i).click();
62
- // cy.get('@checkboxes').children('.card-header')
63
- // .should('to.contain', `"${ btnTextTempl }": true`);
64
- //
65
- // cy.get('@checkbox').eq(i).click();
66
- // cy.get('@checkboxes').children('.card-header')
67
- // .should('to.contain', `"${ btnTextTempl }": false`);
68
- // });
69
- // });
51
+ buttons . clickByText ( buttonDemos [ 1 ] , buttonNames [ 0 ] ) ;
52
+ buttons . clickByText ( buttonDemos [ 1 ] , buttonNames [ 1 ] ) ;
53
+
54
+ cy . get ( buttonDemos [ 1 ] ) . children ( '.card-header' ) . as ( 'output' )
55
+ . should ( 'to.contain' , `"${ buttonOutput [ 0 ] } ": true` ) ;
56
+ cy . get ( '@output' )
57
+ . should ( 'to.contain' , `"${ buttonOutput [ 1 ] } ": false` ) ;
70
58
} ) ;
71
59
72
60
it ( 'checkbox example contains checkboxes, that can be checked or unchecked and reactive form' , ( ) => {
73
- let btnTextTempl : string ;
74
- // setting all checkboxes to unchecked
75
- cy . get ( buttonDemos [ 2 ] ) . as ( 'checkboxesForm' ) . find ( '.btn' ) . eq ( 1 ) . click ( ) ;
76
-
77
- cy . get ( buttonDemos [ 2 ] ) . find ( '.btn' ) . as ( 'checkbox' ) . each ( ( $btn , i ) => {
78
- cy . get ( '@checkbox' ) . eq ( i ) . invoke ( 'text' ) . then ( btnText => {
79
- btnTextTempl = btnText . toString ( ) . toLowerCase ( ) ;
80
-
81
- cy . get ( '@checkbox' ) . eq ( i ) . click ( ) ;
82
- cy . get ( '@checkboxesForm' ) . children ( '.card-header' )
83
- . should ( 'to.contain' , `"${ btnTextTempl } ": true` ) ;
84
-
85
- cy . get ( '@checkbox' ) . eq ( i ) . click ( ) ;
86
- cy . get ( '@checkboxesForm' ) . children ( '.card-header' )
87
- . should ( 'to.contain' , `"${ btnTextTempl } ": false` ) ;
88
- } ) ;
89
- } ) ;
61
+ buttons . clickByText ( buttonDemos [ 2 ] , buttonNames [ 1 ] ) ;
62
+ buttons . clickByText ( buttonDemos [ 2 ] , buttonNames [ 2 ] ) ;
63
+
64
+ cy . get ( buttonDemos [ 2 ] ) . children ( '.card-header' ) . as ( 'output' )
65
+ . should ( 'to.contain' , `"${ buttonOutput [ 1 ] } ": false` ) ;
66
+ cy . get ( '@output' )
67
+ . should ( 'to.contain' , `"${ buttonOutput [ 2 ] } ": true` ) ;
68
+
69
+ buttons . clickByText ( buttonDemos [ 2 ] , buttonNames [ 1 ] ) ;
70
+ cy . get ( '@output' )
71
+ . should ( 'to.contain' , `"${ buttonOutput [ 1 ] } ": true` ) ;
90
72
} ) ;
91
73
92
74
it ( 'Radio and Uncheckable Radio example contains checkboxes and radioButtons' , ( ) => {
@@ -118,7 +100,6 @@ describe('Buttons page test suite', () => {
118
100
} ) ;
119
101
} ) ;
120
102
121
-
122
103
it ( 'disabled buttons examples contains button, that can be disabled' , ( ) => {
123
104
cy . get ( buttonDemos [ 5 ] ) . as ( 'disabledButton' )
124
105
. should ( 'to.have.descendants' , '.btn-primary' )
@@ -129,18 +110,4 @@ describe('Buttons page test suite', () => {
129
110
cy . get ( '@disabledButton' ) . contains ( 'Button' )
130
111
. should ( 'not.to.be.enabled' ) ;
131
112
} ) ;
132
-
133
- it ( 'each demo examples are not mixed up with each other and contains code examples' , ( ) => {
134
- cy . get ( 'examples' ) . find ( 'h3' ) . as ( 'exampleTitles' ) . each ( ( $title , i ) => {
135
- expect ( $title ) . to . contain ( buttonTitles [ i ] ) ;
136
-
137
- cy . get ( '@exampleTitles' ) . contains ( buttonTitles [ i ] ) . parent ( ) . as ( 'currentBlock' ) ;
138
-
139
- cy . get ( '@currentBlock' ) . find ( buttonDemos [ i ] )
140
- . should ( 'to.exist' ) ;
141
- cy . get ( '@currentBlock' ) . find ( '.section' ) . eq ( 1 )
142
- . should ( 'be.visible' )
143
- . and ( 'not.to.be.empty' ) ;
144
- } ) ;
145
- } ) ;
146
113
} ) ;
0 commit comments