@@ -1371,7 +1371,22 @@ Cypress.Commands.add("verifyNotificationIconType", (type) => {
1371
1371
Cypress . Commands . add ( "verifyCanvasTransform" , ( movString ) => {
1372
1372
cy . get ( "#canvas-div-0 .d3-canvas-group" )
1373
1373
. invoke ( "attr" , "transform" )
1374
- . should ( "eq" , movString ) ;
1374
+ . should ( ( actualTransformString ) => {
1375
+ // Verify the movString passed is a string
1376
+ if ( typeof movString === "string" ) {
1377
+ const expectedValues = parseTransformString ( movString ) ;
1378
+ const actualValues = parseTransformString ( actualTransformString ) ;
1379
+ // Compare each part of the transform with compareRange
1380
+ compareCloseTo ( actualValues . translateX , expectedValues . translateX ) ;
1381
+ compareCloseTo ( actualValues . translateY , expectedValues . translateY ) ;
1382
+ compareCloseTo ( actualValues . scale , expectedValues . scale ) ;
1383
+ } else if ( typeof movString === "undefined" ) {
1384
+ expect ( actualTransformString ) . to . be . undefined ;
1385
+ } else {
1386
+ throw new Error ( "Expected movString to be a string or undefined" ) ;
1387
+ }
1388
+ } ) ;
1389
+
1375
1390
} ) ;
1376
1391
1377
1392
Cypress . Commands . add ( "verifyNotificationCounter" , ( count ) => {
@@ -1427,7 +1442,7 @@ Cypress.Commands.add("verifyNotificationCenterDoesntExist", (hidden) => {
1427
1442
Cypress . Commands . add ( "verifyNotificationCenterContent" , ( id , content ) => {
1428
1443
if ( typeof content === "string" && content . length > 0 ) {
1429
1444
cy . get ( ".notification-panel-" + id ) . should ( "contain" , content ) ;
1430
- } else if ( typeof content === "string" && content . length === 0 ) {
1445
+ } else if ( typeof content === "string" && content . length === 0 ) {
1431
1446
cy . get ( ".notification-panel-" + id ) . should ( "be.empty" ) ;
1432
1447
} else {
1433
1448
cy . get ( ".notification-panel-" + id ) . should ( "not.exist" ) ;
@@ -1481,6 +1496,19 @@ function verifyPath(actualPath, expectedPath) {
1481
1496
}
1482
1497
}
1483
1498
1499
+ function parseTransformString ( transformString ) {
1500
+ const translateMatch = transformString . match ( / t r a n s l a t e \( ( [ ^ , ] + ) , ( [ ^ ) ] + ) \) / ) ;
1501
+ const scaleMatch = transformString . match ( / s c a l e \( ( [ ^ ) ] + ) \) / ) ;
1502
+ if ( ! translateMatch || ! scaleMatch ) {
1503
+ throw new Error ( "invalid string format" ) ;
1504
+ }
1505
+ return {
1506
+ translateX : parseFloat ( translateMatch [ 1 ] ) ,
1507
+ translateY : parseFloat ( translateMatch [ 2 ] ) ,
1508
+ scale : parseFloat ( scaleMatch [ 1 ] )
1509
+ } ;
1510
+ }
1511
+
1484
1512
function compareCloseTo ( value , compareValue ) {
1485
1513
expect ( Number ( value ) ) . to . be . closeTo ( Number ( compareValue ) , Cypress . env ( "compareRange" ) ) ;
1486
1514
}
0 commit comments