@@ -9,7 +9,7 @@ describeForEachAutoAdapter("AutoButton", ({ name, adapter: { AutoButton }, wrapp
9
9
} ) ;
10
10
11
11
it ( "shows a button, runs a create action with no variables, and reports success" , ( ) => {
12
- cy . mountWithWrapper ( < AutoButton action = { api . widget . create } /> , wrapper ) ;
12
+ cy . mountWithWrapper ( < AutoButton id = "auto" action = { api . widget . create } /> , wrapper ) ;
13
13
cy . contains ( "Create Widget" ) ;
14
14
15
15
cy . intercept ( "POST" , `${ api . connection . options . endpoint } ?operation=createWidget` , {
@@ -23,7 +23,7 @@ describeForEachAutoAdapter("AutoButton", ({ name, adapter: { AutoButton }, wrapp
23
23
} ,
24
24
} ) . as ( "createWidget" ) ;
25
25
26
- cy . get ( "button " ) . click ( ) ;
26
+ cy . get ( "#auto " ) . click ( ) ;
27
27
28
28
cy . wait ( "@createWidget" ) ;
29
29
cy . get ( "@createWidget" ) . its ( "request.body.variables" ) . should ( "deep.equal" , { widget : { } } ) ;
@@ -32,7 +32,7 @@ describeForEachAutoAdapter("AutoButton", ({ name, adapter: { AutoButton }, wrapp
32
32
} ) ;
33
33
34
34
it ( "shows a button, runs a create action with variables, and reports success" , ( ) => {
35
- cy . mountWithWrapper ( < AutoButton action = { api . widget . create } variables = { { widget : { name : "foobar" } } } /> , wrapper ) ;
35
+ cy . mountWithWrapper ( < AutoButton id = "auto" action = { api . widget . create } variables = { { widget : { name : "foobar" } } } /> , wrapper ) ;
36
36
cy . contains ( "Create Widget" ) ;
37
37
38
38
cy . intercept ( "POST" , `${ api . connection . options . endpoint } ?operation=createWidget` , {
@@ -46,7 +46,7 @@ describeForEachAutoAdapter("AutoButton", ({ name, adapter: { AutoButton }, wrapp
46
46
} ,
47
47
} ) . as ( "createWidget" ) ;
48
48
49
- cy . get ( "button " ) . click ( ) ;
49
+ cy . get ( "#auto " ) . click ( ) ;
50
50
51
51
cy . wait ( "@createWidget" ) ;
52
52
cy . get ( "@createWidget" )
@@ -59,22 +59,22 @@ describeForEachAutoAdapter("AutoButton", ({ name, adapter: { AutoButton }, wrapp
59
59
} ) ;
60
60
61
61
it ( "shows a button, runs a create action with no variables, and reports an error if the network call fails" , ( ) => {
62
- cy . mountWithWrapper ( < AutoButton action = { api . widget . create } /> , wrapper ) ;
62
+ cy . mountWithWrapper ( < AutoButton id = "auto" action = { api . widget . create } /> , wrapper ) ;
63
63
cy . contains ( "Create Widget" ) ;
64
64
65
65
cy . intercept ( "POST" , `${ api . connection . options . endpoint } ?operation=createWidget` , {
66
66
forceNetworkError : true ,
67
67
} ) . as ( "createWidget" ) ;
68
68
69
- cy . get ( "button " ) . click ( ) ;
69
+ cy . get ( "#auto " ) . click ( ) ;
70
70
71
71
cy . wait ( "@createWidget" ) ;
72
72
73
73
cy . contains ( "Create Widget encountered an error:" ) ;
74
74
} ) ;
75
75
76
76
it ( "shows a button, runs an update action with variables, and reports success" , ( ) => {
77
- cy . mountWithWrapper ( < AutoButton action = { api . widget . update } variables = { { id : "123" , widget : { name : "foobar" } } } /> , wrapper ) ;
77
+ cy . mountWithWrapper ( < AutoButton id = "auto" action = { api . widget . update } variables = { { id : "123" , widget : { name : "foobar" } } } /> , wrapper ) ;
78
78
cy . contains ( "Update Widget" ) ;
79
79
80
80
cy . intercept ( "POST" , `${ api . connection . options . endpoint } ?operation=updateWidget` , {
@@ -88,7 +88,7 @@ describeForEachAutoAdapter("AutoButton", ({ name, adapter: { AutoButton }, wrapp
88
88
} ,
89
89
} ) . as ( "updateWidget" ) ;
90
90
91
- cy . get ( "button " ) . click ( ) ;
91
+ cy . get ( "#auto " ) . click ( ) ;
92
92
93
93
cy . wait ( "@updateWidget" ) ;
94
94
cy . get ( "@updateWidget" )
@@ -102,14 +102,20 @@ describeForEachAutoAdapter("AutoButton", ({ name, adapter: { AutoButton }, wrapp
102
102
} ) ;
103
103
104
104
it ( "allows overriding the label" , ( ) => {
105
- cy . mountWithWrapper ( < AutoButton action = { api . widget . create } > Whizbang the flimflam</ AutoButton > , wrapper ) ;
105
+ cy . mountWithWrapper (
106
+ < AutoButton id = "auto" action = { api . widget . create } >
107
+ Whizbang the flimflam
108
+ </ AutoButton > ,
109
+ wrapper
110
+ ) ;
106
111
cy . contains ( "Whizbang the flimflam" ) ;
107
112
} ) ;
108
113
109
114
it ( "allows overriding the onSuccess behaviour" , ( ) => {
110
115
let onSuccessCalled = false ;
111
116
cy . mountWithWrapper (
112
117
< AutoButton
118
+ id = "auto"
113
119
action = { api . widget . update }
114
120
variables = { { id : "123" , widget : { name : "foobar" } } }
115
121
onSuccess = { ( result : any ) => {
@@ -131,7 +137,7 @@ describeForEachAutoAdapter("AutoButton", ({ name, adapter: { AutoButton }, wrapp
131
137
} ,
132
138
} ) . as ( "updateWidget" ) ;
133
139
134
- cy . get ( "button " ) . click ( ) ;
140
+ cy . get ( "#auto " ) . click ( ) ;
135
141
136
142
cy . wait ( "@updateWidget" ) . then ( ( ) => {
137
143
expect ( onSuccessCalled ) . to . be . true ;
@@ -142,6 +148,7 @@ describeForEachAutoAdapter("AutoButton", ({ name, adapter: { AutoButton }, wrapp
142
148
let onErrorCalled = false ;
143
149
cy . mountWithWrapper (
144
150
< AutoButton
151
+ id = "auto"
145
152
action = { api . widget . update }
146
153
variables = { { id : "123" , widget : { name : "foobar" } } }
147
154
onError = { ( error : Error ) => {
@@ -157,15 +164,15 @@ describeForEachAutoAdapter("AutoButton", ({ name, adapter: { AutoButton }, wrapp
157
164
forceNetworkError : true ,
158
165
} ) . as ( "updateWidget" ) ;
159
166
160
- cy . get ( "button " ) . click ( ) ;
167
+ cy . get ( "#auto " ) . click ( ) ;
161
168
162
169
cy . wait ( "@updateWidget" ) . then ( ( ) => {
163
170
expect ( onErrorCalled ) . to . be . true ;
164
171
} ) ;
165
172
} ) ;
166
173
167
174
it ( "shows a button, runs an global action with no variables, and reports success" , ( ) => {
168
- cy . mountWithWrapper ( < AutoButton action = { api . flipAll } /> , wrapper ) ;
175
+ cy . mountWithWrapper ( < AutoButton id = "auto" action = { api . flipAll } /> , wrapper ) ;
169
176
cy . contains ( "Flip all" ) ;
170
177
171
178
cy . intercept ( "POST" , `${ api . connection . options . endpoint } ?operation=flipAll` , {
@@ -176,7 +183,7 @@ describeForEachAutoAdapter("AutoButton", ({ name, adapter: { AutoButton }, wrapp
176
183
} ,
177
184
} ) . as ( "flipAll" ) ;
178
185
179
- cy . get ( "button " ) . click ( ) ;
186
+ cy . get ( "#auto " ) . click ( ) ;
180
187
181
188
cy . wait ( "@flipAll" ) ;
182
189
cy . get ( "@flipAll" ) . its ( "request.body.variables" ) . should ( "deep.equal" , { } ) ;
0 commit comments