@@ -3,12 +3,13 @@ import { GraphQLError } from "graphql";
3
3
import userEvent from "@testing-library/user-event" ;
4
4
import { base2 } from "mocks/bases" ;
5
5
import { organisation1 , organisation2 } from "mocks/organisations" ;
6
- import { screen , render , waitFor } from "tests/test-utils" ;
6
+ import { screen , render , waitFor , within } from "tests/test-utils" ;
7
7
import { generateMoveBoxRequest } from "queries/dynamic-mutations" ;
8
8
import { ErrorBoundary } from "@sentry/react" ;
9
9
import { AlertWithoutAction } from "components/Alerts" ;
10
10
import { TableSkeleton } from "components/Skeletons" ;
11
11
import { Suspense } from "react" ;
12
+ import { cache } from "queries/cache" ;
12
13
import Boxes , { ACTION_OPTIONS_FOR_BOXESVIEW_QUERY , BOXES_FOR_BOXESVIEW_QUERY } from "./BoxesView" ;
13
14
14
15
const boxesQuery = {
@@ -356,7 +357,7 @@ const actionsQuery = {
356
357
} ,
357
358
} ;
358
359
359
- const gqlRequestPrep = generateMoveBoxRequest ( [ "4495955 " , "1481666" ] , 17 ) ;
360
+ const gqlRequestPrep = generateMoveBoxRequest ( [ "8650860 " , "1481666" ] , 17 ) ;
360
361
361
362
const moveBoxesMutation = {
362
363
request : {
@@ -366,9 +367,9 @@ const moveBoxesMutation = {
366
367
result : {
367
368
data : {
368
369
// TODO: the data should be placed in the mocks
369
- moveBox4495955 : {
370
+ moveBox8650860 : {
370
371
__typename : "Box" ,
371
- labelIdentifier : "4495955 " ,
372
+ labelIdentifier : "8650860 " ,
372
373
location : {
373
374
__typename : "ClassicLocation" ,
374
375
id : "17" ,
@@ -436,6 +437,7 @@ describe("4.8.1 - Initial load of Page", () => {
436
437
routePath : "/bases/:baseId/boxes" ,
437
438
initialUrl : "/bases/2/boxes" ,
438
439
mocks : [ boxesQuery , actionsQuery ] ,
440
+ cache,
439
441
addTypename : true ,
440
442
globalPreferences : {
441
443
dispatch : vi . fn ( ) ,
@@ -478,6 +480,7 @@ describe("4.8.1 - Initial load of Page", () => {
478
480
routePath : "/bases/:baseId/boxes" ,
479
481
initialUrl : "/bases/2/boxes" ,
480
482
mocks,
483
+ cache,
481
484
addTypename : true ,
482
485
globalPreferences : {
483
486
dispatch : vi . fn ( ) ,
@@ -511,6 +514,7 @@ describe("4.8.1 - Initial load of Page", () => {
511
514
routePath : "/bases/:baseId/boxes" ,
512
515
initialUrl : "/bases/2/boxes" ,
513
516
mocks : [ boxesQuery , actionsQuery ] ,
517
+ cache,
514
518
addTypename : true ,
515
519
globalPreferences : {
516
520
dispatch : vi . fn ( ) ,
@@ -545,6 +549,7 @@ describe("4.8.2 - Selecting rows and performing bulk actions", () => {
545
549
routePath : "/bases/:baseId/boxes" ,
546
550
initialUrl : "/bases/2/boxes" ,
547
551
mocks : [ boxesQuery , actionsQuery , moveBoxesMutation ] ,
552
+ cache,
548
553
addTypename : true ,
549
554
globalPreferences : {
550
555
dispatch : vi . fn ( ) ,
@@ -558,14 +563,15 @@ describe("4.8.2 - Selecting rows and performing bulk actions", () => {
558
563
) ;
559
564
560
565
// Test case 4.8.2.1 - Select two checkboxes and perform bulk moves
561
-
562
566
const row1 = await screen . findByRole ( "row" , { name : / 8 6 5 0 8 6 0 / i } , { timeout : 5000 } ) ;
563
- // eslint-disable-next-line testing-library/no-node-access
564
- const checkbox1 = row1 . querySelector ( 'input[type="checkbox"]' ) ;
567
+ const checkbox1 = within ( row1 ) . getByRole ( "checkbox" , {
568
+ name : / t o g g l e r o w s e l e c t e d / i,
569
+ } ) ;
565
570
566
571
const row2 = await screen . findByRole ( "row" , { name : / 1 4 8 1 6 6 6 / i } ) ;
567
- // eslint-disable-next-line testing-library/no-node-access
568
- const checkbox2 = row2 . querySelector ( 'input[type="checkbox"]' ) ;
572
+ const checkbox2 = within ( row2 ) . getByRole ( "checkbox" , {
573
+ name : / t o g g l e r o w s e l e c t e d / i,
574
+ } ) ;
569
575
570
576
if ( checkbox1 && checkbox2 ) {
571
577
expect ( checkbox1 ) . not . toBeChecked ( ) ;
@@ -576,25 +582,26 @@ describe("4.8.2 - Selecting rows and performing bulk actions", () => {
576
582
await user . click ( checkbox2 ) ;
577
583
await waitFor ( ( ) => expect ( checkbox2 ) . toBeChecked ( ) ) ;
578
584
579
- const moveBoxesButton = screen . getByRole ( "button" , {
585
+ const moveBoxesButton = await screen . findByRole ( "button" , {
580
586
name : / m o v e t o / i,
581
587
} ) ;
582
588
583
589
await user . click ( moveBoxesButton ) ;
584
590
585
591
expect (
586
592
await screen . findByRole ( "menuitem" , {
587
- name : / w h 2 / i,
593
+ name : / w h 1 / i,
588
594
} ) ,
589
595
) . toBeInTheDocument ( ) ;
590
596
591
597
await user . click (
592
598
screen . getByRole ( "menuitem" , {
593
- name : / w h 2 / i,
599
+ name : / w h 1 / i,
594
600
} ) ,
595
601
) ;
596
602
597
- expect ( ( await screen . findAllByText ( / w h 2 / i) ) . length ) . toBe ( 2 ) ;
603
+ expect ( await within ( row1 ) . findByText ( / w h 1 / i) ) . toBeInTheDocument ( ) ;
604
+ expect ( await within ( row2 ) . findByText ( / w h 1 / i) ) . toBeInTheDocument ( ) ;
598
605
}
599
606
} , 15000 ) ;
600
607
} ) ;
0 commit comments