Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix image by step plots breaking on nonexistent steps #4478

Merged
merged 6 commits into from
Aug 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 44 additions & 0 deletions webview/src/plots/components/App.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -1788,6 +1788,50 @@ describe('App', () => {

expect(multiImgRow.draggable).toBe(true)
})

it('should handle when a revision contains less images than before', () => {
renderAppWithOptionalData({
comparison: comparisonTableFixture
})

const mainImgs = comparisonTableFixture.plots[3].revisions.main.imgs

const multiImgPlots = screen.getAllByTestId('multi-image-cell')
const slider = within(multiImgPlots[1]).getByRole('slider')

fireEvent.change(slider, { target: { value: 14 } })

expect(within(multiImgPlots[1]).getByRole('img')).toHaveAttribute(
'src',
mainImgs[14].url
)

const dataWithLessMainImages = {
comparison: {
...comparisonTableFixture,
plots: comparisonTableFixture.plots.map(plot =>
plot.path.includes('image')
? {
...plot,
revisions: {
...plot.revisions,
main: {
...plot.revisions.main,
imgs: plot.revisions.main.imgs.slice(0, 7)
}
}
}
: plot
)
}
}

sendSetDataMessage(dataWithLessMainImages)

expect(
within(multiImgPlots[1]).queryByRole('img')
).not.toBeInTheDocument()
})
})

describe('Virtualization', () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,16 @@ export const ComparisonTableMultiCell: React.FC<{
<div data-testid="multi-image-cell" className={styles.multiImageWrapper}>
<ComparisonTableCell
path={path}
plot={{ id: plot.id, imgs: [plot.imgs[currentStep]] }}
plot={{
id: plot.id,
imgs: [
plot.imgs[currentStep] || {
Copy link
Contributor Author

@julieg18 julieg18 Aug 11, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Running experiments start off with the workspace's images than go on to hold their own created images (Is that normal or is there a bug with plot diff?). This means that an revision could start off with 20 images in the beginning of an experiment run if the workspace originally had 20 than less than 20 by the end.

A user could set a multi image slider to a step that doesn't actually exist within the experiment during the beginning of the experiment run. This would cause the plots to crash once the images get updated to a smaller length. This change handles this scenario and stops plots from crashing.

errors: undefined,
loading: false,
url: undefined
}
]
}}
imgAlt={`${currentStep} of ${path} (${plot.id})`}
/>
<div
Expand Down