@@ -14,6 +14,7 @@ const CONTINUE_BUTTON = "Next"
1414const ERROR_MESSAGE = "Something happened"
1515const RAW_DATE = "2020-03-03"
1616const FORMATTED_DATE = "2020/03/03"
17+ const TRAILING_CELL = "trailingcell"
1718
1819test ( "Select header row and click next" , async ( ) => {
1920 const data = [
@@ -168,3 +169,33 @@ test("dateFormat property should be applied to dates read from xlsx files", asyn
168169 const el = await screen . findByText ( FORMATTED_DATE , undefined , { timeout : 10000 } )
169170 expect ( el ) . toBeInTheDocument ( )
170171} )
172+
173+ test (
174+ "trailing (not under a header) cells should be rendered in SelectHeaderStep table, " +
175+ "but not in MatchColumnStep if a shorter row is selected as a header" ,
176+ async ( ) => {
177+ const selectHeaderStepHook = jest . fn ( async ( headerValues , data ) => {
178+ return { headerValues, data }
179+ } )
180+ render ( < ReactSpreadsheetImport { ...mockRsiValues } selectHeaderStepHook = { selectHeaderStepHook } /> )
181+ const uploader = screen . getByTestId ( "rsi-dropzone" )
182+ const data = readFileSync ( __dirname + "/../../../../static/TrailingCellsWorkbook.xlsx" )
183+ fireEvent . drop ( uploader , {
184+ target : {
185+ files : [
186+ new File ( [ data ] , "testFile.xlsx" , {
187+ type : "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet" ,
188+ } ) ,
189+ ] ,
190+ } ,
191+ } )
192+ const trailingCell = await screen . findByText ( TRAILING_CELL , undefined , { timeout : 10000 } )
193+ expect ( trailingCell ) . toBeInTheDocument ( )
194+ const nextButton = screen . getByRole ( "button" , {
195+ name : "Next" ,
196+ } )
197+ userEvent . click ( nextButton )
198+ const trailingCellNextPage = await screen . findByText ( TRAILING_CELL , undefined , { timeout : 10000 } )
199+ expect ( trailingCellNextPage ) . not . toBeInTheDocument ( )
200+ } ,
201+ )
0 commit comments