@@ -139,69 +139,4 @@ describe("DatasetPreviewDialog", () => {
139139
140140 expect ( mockOnClose ) . toHaveBeenCalledTimes ( 1 ) ;
141141 } ) ;
142-
143- describe ( "Image Dataset Preview" , ( ) => {
144- const imageBase64 =
145- "data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAUA AAAFCAYAAACNbyblAAAAHElEQVQI12P4//8/w38GIAXDIBKE0DHxgljNBAAO 9TXL0Y4OHwAAAABJRU5ErkJggg==" ;
146- const imageUrl = "https://example.com/image1.jpg" ;
147-
148- it ( "renders images correctly from URLs and base64 strings" , async ( ) => {
149- const imageData = {
150- type : "image" as const ,
151- data : [ imageUrl , imageBase64 ] ,
152- } ;
153- ( mockPreviewDataset as Mock ) . mockResolvedValue ( imageData ) ;
154- renderDialog ( ) ;
155-
156- await waitFor ( ( ) => {
157- expect ( screen . getAllByRole ( "img" ) ) . toHaveLength ( 2 ) ;
158- } ) ;
159-
160- const images = screen . getAllByRole ( "img" ) ;
161- expect ( images [ 0 ] ) . toHaveAttribute ( "src" , imageUrl ) ;
162- expect ( images [ 0 ] ) . toHaveAttribute ( "alt" , "Preview 1" ) ;
163- expect ( screen . getByText ( "image1.jpg" ) ) . toBeInTheDocument ( ) ;
164-
165- expect ( images [ 1 ] ) . toHaveAttribute ( "src" , imageBase64 ) ;
166- expect ( images [ 1 ] ) . toHaveAttribute ( "alt" , "Preview 2" ) ;
167- expect ( screen . getByText ( "Image 2" ) ) . toBeInTheDocument ( ) ; // Generic name for base64
168- } ) ;
169-
170- it ( "handles empty image list" , async ( ) => {
171- const emptyImageData = {
172- type : "image" as const ,
173- data : [ ] ,
174- } ;
175- ( mockPreviewDataset as Mock ) . mockResolvedValue ( emptyImageData ) ;
176- renderDialog ( ) ;
177-
178- await waitFor ( ( ) => {
179- expect (
180- screen . getByText (
181- "Preview for this data type is not yet implemented or the data is empty/invalid." ,
182- ) ,
183- ) . toBeInTheDocument ( ) ;
184- } ) ;
185- expect ( screen . queryAllByRole ( "img" ) ) . toHaveLength ( 0 ) ;
186- } ) ;
187-
188- it ( "shows loading state for image preview" , async ( ) => {
189- ( mockPreviewDataset as Mock ) . mockReturnValue ( new Promise ( ( ) => { } ) ) ; // Never resolves
190- renderDialog ( ) ;
191- // Check for DialogTitle to ensure dialog is attempting to render
192- expect ( screen . getByText ( "Dataset Preview" ) ) . toBeInTheDocument ( ) ;
193- // Check for presence of skeleton loaders (assuming they use 'animate-pulse')
194- const skeletons = document . querySelectorAll ( ".animate-pulse" ) ;
195- expect ( skeletons . length ) . toBeGreaterThan ( 0 ) ; // Or a more specific count if known
196- } ) ;
197-
198- it ( "shows error state if fetching image data fails" , async ( ) => {
199- const errorMessage = "Failed to fetch image dataset." ;
200- ( mockPreviewDataset as Mock ) . mockRejectedValue ( new Error ( errorMessage ) ) ;
201- renderDialog ( ) ;
202- await waitFor ( ( ) => {
203- expect ( screen . getByText ( `Error: ${ errorMessage } ` ) ) . toBeInTheDocument ( ) ;
204- } ) ;
205- } ) ;
206- } ) ;
207142} ) ;
0 commit comments