@@ -154,7 +154,6 @@ describe("Validation step tests", () => {
154154
155155 // don't really know another way to select an empty cell
156156 const emptyCell = screen . getAllByRole ( "gridcell" , { name : undefined } ) [ 1 ]
157- console . log ( emptyCell )
158157 userEvent . click ( emptyCell )
159158
160159 await userEvent . keyboard ( FINAL_NAME + "{enter}" )
@@ -328,6 +327,72 @@ describe("Validation step tests", () => {
328327 expect ( validRow ) . toBeInTheDocument ( )
329328 } )
330329
330+ test ( "Deletes selected rows, changes the last one" , async ( ) => {
331+ const FIRST_DELETE = "first"
332+ const SECOND_DELETE = "second"
333+ const THIRD = "third"
334+ const THIRD_CHANGED = "third_changed"
335+
336+ const initialData = [
337+ {
338+ name : FIRST_DELETE ,
339+ } ,
340+ {
341+ name : SECOND_DELETE ,
342+ } ,
343+ {
344+ name : THIRD ,
345+ } ,
346+ ]
347+ const fields = [
348+ {
349+ label : "Name" ,
350+ key : "name" ,
351+ fieldType : {
352+ type : "input" ,
353+ } ,
354+ } ,
355+ ] as const
356+ render (
357+ < Providers theme = { defaultTheme } rsiValues = { { ...mockValues , fields } } >
358+ < ModalWrapper isOpen = { true } onClose = { ( ) => { } } >
359+ < ValidationStep initialData = { initialData } />
360+ </ ModalWrapper >
361+ </ Providers > ,
362+ )
363+
364+ const allRowsWithHeader = await screen . findAllByRole ( "row" )
365+ expect ( allRowsWithHeader ) . toHaveLength ( 4 )
366+
367+ const switchFilters = screen . getAllByRole ( "checkbox" , {
368+ name : "Select" ,
369+ } )
370+
371+ userEvent . click ( switchFilters [ 0 ] )
372+ userEvent . click ( switchFilters [ 1 ] )
373+
374+ const discardButton = screen . getByRole ( "button" , {
375+ name : "Discard selected rows" ,
376+ } )
377+
378+ userEvent . click ( discardButton )
379+
380+ const filteredRowsWithHeader = await screen . findAllByRole ( "row" )
381+ expect ( filteredRowsWithHeader ) . toHaveLength ( 2 )
382+
383+ const nameCell = screen . getByRole ( "gridcell" , {
384+ name : THIRD ,
385+ } )
386+
387+ userEvent . click ( nameCell )
388+
389+ screen . getByRole < HTMLInputElement > ( "textbox" )
390+ await userEvent . keyboard ( THIRD_CHANGED + "{enter}" )
391+
392+ const validRow = screen . getByText ( THIRD_CHANGED )
393+ expect ( validRow ) . toBeInTheDocument ( )
394+ } )
395+
331396 test ( "All inputs change values" , async ( ) => {
332397 const NAME = "John"
333398 const NEW_NAME = "Johnny"
0 commit comments