Skip to content
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
1 change: 1 addition & 0 deletions webview/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@
},
"dependencies": {
"@reduxjs/toolkit": "^1.8.2",
"@storybook/testing-library": "^0.0.13",
"@tippyjs/react": "^4.2.6",
"@vscode/webview-ui-toolkit": "^1.0.0",
"classnames": "^2.2.6",
Expand Down
10 changes: 3 additions & 7 deletions webview/src/stories/ComparisonTable.stories.tsx
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import { Meta, Story } from '@storybook/react/types-6-0'
import { configureStore } from '@reduxjs/toolkit'
import { within } from '@testing-library/react'
import { userEvent, within } from '@storybook/testing-library'
import React from 'react'
import { Provider, useDispatch } from 'react-redux'
import plotsRevisionsFixture from 'dvc/src/test/fixtures/plotsDiff/revisions'
Expand Down Expand Up @@ -59,15 +59,11 @@ const Template: Story = ({ plots, revisions }) => {
export const Basic = Template.bind({})

export const WithPinnedColumn = Template.bind({})
WithPinnedColumn.parameters = {
chromatic: { delay: 300 }
}
WithPinnedColumn.play = async ({ canvasElement }) => {
const canvas = within(canvasElement)
const mainHeader = await canvas.findByTestId('main-header')
const mainHeader = await within(canvasElement).findByTestId('main-header')
const pin = within(mainHeader).getByRole('button')

pin.click()
userEvent.click(pin)
}

const removeSingleImage = (
Expand Down
25 changes: 10 additions & 15 deletions webview/src/stories/Plots.stories.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ import { configureStore } from '@reduxjs/toolkit'
import React from 'react'
import { Provider, useDispatch } from 'react-redux'
import { Story, Meta } from '@storybook/react/types-6-0'
import { within, waitFor } from '@testing-library/react'
import { userEvent, within } from '@storybook/testing-library'
import {
PlotsData,
DEFAULT_SECTION_COLLAPSED,
Expand Down Expand Up @@ -193,25 +193,20 @@ VirtualizedPlots.args = {
VirtualizedPlots.parameters = chromaticParameters

export const ZoomedInPlot = Template.bind({})
ZoomedInPlot.parameters = {
chromatic: { delay: 300 }
}
ZoomedInPlot.play = async ({ canvasElement }) => {
const canvas = within(canvasElement)
const plots = await canvas.findAllByTestId(/^plot_/)
const plot = await waitFor(() => within(plots[0]).getByRole('button'))
const plots = await within(canvasElement).findAllByTestId(/^plot_/)
const plot = await within(plots[0]).findByRole('button')

plot.click()
userEvent.click(plot)
}

export const MultiviewZoomedInPlot = Template.bind({})
MultiviewZoomedInPlot.parameters = {
chromatic: { delay: 300 }
}
MultiviewZoomedInPlot.play = async ({ canvasElement }) => {
const canvas = within(canvasElement)
const plot = await canvas.findByTestId('plots-section_template-multi_1')
const plotButton = await waitFor(() => within(plot).getByRole('button'))
const plot = await within(canvasElement).findByTestId(
'plots-section_template-multi_1'
)
await within(plot).findByRole('graphics-document')
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This waits until the initial plot is rendered before we click on it, and fixes the weird Storybook issue we were having where the multiview plot disappeared. I think that bug was more due to vega instead of storybook, and the new Storybook config is just bringing a symptom to surface.

const plotButton = await within(plot).findByRole('button')

plotButton.click()
userEvent.click(plotButton)
}
24 changes: 21 additions & 3 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -2470,7 +2470,7 @@
ts-dedent "^2.0.0"
util-deprecate "^1.0.2"

"@storybook/client-logger@6.5.9":
"@storybook/client-logger@6.5.9", "@storybook/client-logger@^6.4.0":
version "6.5.9"
resolved "https://registry.yarnpkg.com/@storybook/client-logger/-/client-logger-6.5.9.tgz#dc1669abe8c45af1cc38f74c6f4b15ff33e63014"
integrity sha512-DOHL6p0uiDd3gV/Sb2FR+Vh6OiPrrf8BrA06uvXWsMRIIvEEvnparxv9EvPg7FlmUX0T3nq7d3juwjx4F8Wbcg==
Expand Down Expand Up @@ -2682,7 +2682,7 @@
lodash "^4.17.21"
regenerator-runtime "^0.13.7"

"@storybook/instrumenter@6.5.9":
"@storybook/instrumenter@6.5.9", "@storybook/instrumenter@^6.4.0":
version "6.5.9"
resolved "https://registry.yarnpkg.com/@storybook/instrumenter/-/instrumenter-6.5.9.tgz#885d9dec31b7b7fa6ea29b446105480450e527b8"
integrity sha512-I2nu/6H0MAy8d+d3LY/G6oYEFyWlc8f2Qs2DhpYh5FiCgIpzvY0DMN05Lf8oaXdKHL3lPF/YLJH17FttekXs1w==
Expand Down Expand Up @@ -2962,6 +2962,17 @@
read-pkg-up "^7.0.1"
regenerator-runtime "^0.13.7"

"@storybook/testing-library@^0.0.13":
version "0.0.13"
resolved "https://registry.yarnpkg.com/@storybook/testing-library/-/testing-library-0.0.13.tgz#417c87d4ea62895092ec5fdf67027ae201254f45"
integrity sha512-vRMeIGer4EjJkTgI8sQyK9W431ekPWYCWL//OmSDJ64IT3h7FnW7Xg6p+eqM3oII98/O5pcya5049GxnjaPtxw==
dependencies:
"@storybook/client-logger" "^6.4.0"
"@storybook/instrumenter" "^6.4.0"
"@testing-library/dom" "^8.3.0"
"@testing-library/user-event" "^13.2.1"
ts-dedent "^2.2.0"

"@storybook/theming@6.5.9":
version "6.5.9"
resolved "https://registry.yarnpkg.com/@storybook/theming/-/theming-6.5.9.tgz#13f60a3a3cd73ceb5caf9f188e1627e79f1891aa"
Expand Down Expand Up @@ -3112,7 +3123,7 @@
dependencies:
defer-to-connect "^2.0.0"

"@testing-library/dom@^8.5.0":
"@testing-library/dom@^8.3.0", "@testing-library/dom@^8.5.0":
version "8.14.0"
resolved "https://registry.yarnpkg.com/@testing-library/dom/-/dom-8.14.0.tgz#c9830a21006d87b9ef6e1aae306cf49b0283e28e"
integrity sha512-m8FOdUo77iMTwVRCyzWcqxlEIk+GnopbrRI15a0EaLbpZSCinIVI4kSQzWhkShK83GogvEFJSsHF3Ws0z1vrqA==
Expand Down Expand Up @@ -3150,6 +3161,13 @@
"@testing-library/dom" "^8.5.0"
"@types/react-dom" "^18.0.0"

"@testing-library/user-event@^13.2.1":
version "13.5.0"
resolved "https://registry.yarnpkg.com/@testing-library/user-event/-/user-event-13.5.0.tgz#69d77007f1e124d55314a2b73fd204b333b13295"
integrity sha512-5Kwtbo3Y/NowpkbRuSepbyMFkZmHgD+vPzYB/RJ4oxt5Gj/avFFBYjhw27cqSVPVw/3a67NK1PbiIr9k4Gwmdg==
dependencies:
"@babel/runtime" "^7.12.5"

"@tippyjs/react@^4.2.6":
version "4.2.6"
resolved "https://registry.yarnpkg.com/@tippyjs/react/-/react-4.2.6.tgz#971677a599bf663f20bb1c60a62b9555b749cc71"
Expand Down