@@ -4,6 +4,7 @@ import { faker } from "@faker-js/faker";
44
55describe ( "DeleteAction.cy.tsx" , ( ) => {
66 it ( "delete action works" , ( ) => {
7+ const buttonText = faker . random . word ( ) ;
78 const deleteButtonText = faker . random . word ( ) ;
89 const cancelButtonText = faker . random . word ( ) ;
910 const text = faker . random . words ( 10 ) ;
@@ -12,23 +13,24 @@ describe("DeleteAction.cy.tsx", () => {
1213 cy . mount (
1314 < DeleteAction
1415 onDelete = { cy . spy ( ) . as ( "onDelete" ) }
16+ buttonText = { buttonText }
1517 deleteButtonText = { deleteButtonText }
1618 cancelButtonText = { cancelButtonText }
1719 text = { text }
1820 title = { title }
19- iconOnly
2021 /> ,
2122 ) ;
2223
23- // Check if correct default icon is drawn, open dialog, check title and press close icon
24- cy . get ( "[data-cy-root] > svg" ) . should ( "have.class" , "fa-trash" ) . click ( ) ;
24+ // Check if correct default icon and text are drawn, open dialog, check title and press close icon
25+ cy . get ( "[data-cy-root]" ) . parents ( "body" ) . get ( ".btn-danger" ) . should ( "have.text" , buttonText ) ;
26+ cy . get ( "[data-cy-root] svg" ) . should ( "have.class" , "fa-trash" ) . click ( ) ;
2527 cy . get ( "[data-cy-root]" ) . parents ( "body" ) . get ( ".modal-dialog .modal-header h5" ) . should ( "have.text" , title ) ;
2628 cy . get ( "[data-cy-root]" ) . parents ( "body" ) . get ( ".modal-dialog .modal-header button.btn-close" ) . click ( ) ;
2729 cy . get ( "@onDelete" ) . should ( "not.be.calledOn" ) ;
2830 cy . get ( "[data-cy-root]" ) . parents ( "body" ) . get ( ".modal-dialog" ) . should ( "not.exist" ) ;
2931
3032 // Open dialog, check text, cancel button and press cancel button
31- cy . get ( "[data-cy-root] > svg" ) . should ( "have.class" , "fa-trash" ) . click ( ) ;
33+ cy . get ( "[data-cy-root] svg" ) . should ( "have.class" , "fa-trash" ) . click ( ) ;
3234 cy . get ( "[data-cy-root]" ) . parents ( "body" ) . get ( ".modal-dialog .modal-body" ) . should ( "have.text" , text ) ;
3335 cy . get ( "[data-cy-root]" )
3436 . parents ( "body" )
@@ -39,7 +41,7 @@ describe("DeleteAction.cy.tsx", () => {
3941 cy . get ( "[data-cy-root]" ) . parents ( "body" ) . get ( ".modal-dialog" ) . should ( "not.exist" ) ;
4042
4143 // Open dialog, check delete button and press delete button
42- cy . get ( "[data-cy-root] > svg" ) . should ( "have.class" , "fa-trash" ) . click ( ) ;
44+ cy . get ( "[data-cy-root] svg" ) . should ( "have.class" , "fa-trash" ) . click ( ) ;
4345 cy . get ( "[data-cy-root]" ) . parents ( "body" ) . get ( ".modal-dialog .modal-footer .btn-danger" ) . should ( "have.text" , deleteButtonText ) . click ( ) ;
4446 cy . get ( "@onDelete" ) . should ( "be.calledOnce" ) ;
4547 } ) ;
0 commit comments