11describe ( 'Delete pizza' , ( ) => {
22 beforeEach ( ( ) => {
3- cy . fixture ( 'pizzas' ) . as ( 'pizzasAPI' ) ;
3+
4+ cy . fixture ( 'pizzas' ) . then ( ( pizzas ) => {
5+ cy . intercept ( {
6+ method : 'DELETE' ,
7+ url : '/api/pizzas/*'
8+ } , pizzas ) . as ( 'deletePizza' ) ;
9+
10+ cy . intercept ( {
11+ method : 'GET' ,
12+ url : '/api/pizzas'
13+ } , pizzas ) . as ( 'getPizzas' ) ;
14+ } ) ;
415 cy . fixture ( 'addTopping' ) . as ( 'addToppingAPI' ) ;
5- cy . intercept ( 'DELETE' , '/api/pizzas/*' , { } ) . as ( 'deletePizza' ) ;
6- cy . intercept ( 'GET' , '/api/pizzas' , { fixture : 'pizzas' } ) . as ( 'getPizzas' ) ;
716
817 cy . visit ( '' ) ;
918 } ) ;
1019
1120 it ( 'should delete a pizza' , ( ) => {
1221 cy . wait ( 5000 ) ;
22+
1323 cy . get ( '.pizza-item' )
1424 . contains ( `Seaside Surfin'` )
1525 . within ( ( ) => {
@@ -20,27 +30,6 @@ describe('Delete pizza', () => {
2030 . contains ( 'Delete Pizza' )
2131 . click ( ) ;
2232
23- cy . wait ( '@deletePizza' ) . should ( interception => {
24- expect ( interception . response . statusCode ) . to . equal ( 200 ) ;
25- } ) ;
33+ cy . wait ( '@deletePizza' ) . its ( 'response.statusCode' ) . should ( 'eq' , 200 )
2634 } ) ;
27-
28- describe ( 'Nested pizza deletion' , ( ) => {
29- it ( 'should delete a nested pizza' , ( ) => {
30- cy . wait ( 5000 ) ;
31- cy . get ( '.pizza-item' )
32- . contains ( `Seaside Surfin'` )
33- . within ( ( ) => {
34- cy . get ( '.btn.btn__ok' ) . click ( ) ;
35- } ) ;
36-
37- cy . get ( '.btn.btn__warning' )
38- . contains ( 'Delete Pizza' )
39- . click ( ) ;
40-
41- cy . wait ( '@deletePizza' ) . should ( interception => {
42- expect ( interception . response . statusCode ) . to . equal ( 200 ) ;
43- } ) ;
44- } ) ;
45- } )
4635} ) ;
0 commit comments