File tree Expand file tree Collapse file tree 2 files changed +54
-1
lines changed
webview/src/plots/components Expand file tree Collapse file tree 2 files changed +54
-1
lines changed Original file line number Diff line number Diff line change @@ -1788,6 +1788,50 @@ describe('App', () => {
17881788
17891789 expect ( multiImgRow . draggable ) . toBe ( true )
17901790 } )
1791+
1792+ it ( 'should handle when a revision contains less images than before' , ( ) => {
1793+ renderAppWithOptionalData ( {
1794+ comparison : comparisonTableFixture
1795+ } )
1796+
1797+ const mainImgs = comparisonTableFixture . plots [ 3 ] . revisions . main . imgs
1798+
1799+ const multiImgPlots = screen . getAllByTestId ( 'multi-image-cell' )
1800+ const slider = within ( multiImgPlots [ 1 ] ) . getByRole ( 'slider' )
1801+
1802+ fireEvent . change ( slider , { target : { value : 14 } } )
1803+
1804+ expect ( within ( multiImgPlots [ 1 ] ) . getByRole ( 'img' ) ) . toHaveAttribute (
1805+ 'src' ,
1806+ mainImgs [ 14 ] . url
1807+ )
1808+
1809+ const dataWithLessMainImages = {
1810+ comparison : {
1811+ ...comparisonTableFixture ,
1812+ plots : comparisonTableFixture . plots . map ( plot =>
1813+ plot . path . includes ( 'image' )
1814+ ? {
1815+ ...plot ,
1816+ revisions : {
1817+ ...plot . revisions ,
1818+ main : {
1819+ ...plot . revisions . main ,
1820+ imgs : plot . revisions . main . imgs . slice ( 0 , 7 )
1821+ }
1822+ }
1823+ }
1824+ : plot
1825+ )
1826+ }
1827+ }
1828+
1829+ sendSetDataMessage ( dataWithLessMainImages )
1830+
1831+ expect (
1832+ within ( multiImgPlots [ 1 ] ) . queryByRole ( 'img' )
1833+ ) . not . toBeInTheDocument ( )
1834+ } )
17911835 } )
17921836
17931837 describe ( 'Virtualization' , ( ) => {
Original file line number Diff line number Diff line change @@ -24,7 +24,16 @@ export const ComparisonTableMultiCell: React.FC<{
2424 < div data-testid = "multi-image-cell" className = { styles . multiImageWrapper } >
2525 < ComparisonTableCell
2626 path = { path }
27- plot = { { id : plot . id , imgs : [ plot . imgs [ currentStep ] ] } }
27+ plot = { {
28+ id : plot . id ,
29+ imgs : [
30+ plot . imgs [ currentStep ] || {
31+ errors : undefined ,
32+ loading : false ,
33+ url : undefined
34+ }
35+ ]
36+ } }
2837 imgAlt = { `${ currentStep } of ${ path } (${ plot . id } )` }
2938 />
3039 < div
You can’t perform that action at this time.
0 commit comments