@@ -13,9 +13,16 @@ import constructDownloadableFile from '@/js/utils/constructDownloadableFile'
1313
1414import { GET_TOOL_DRAFTS } from '@/js/operations/queries/getToolDrafts'
1515import { GET_COLLECTION_DRAFTS } from '@/js/operations/queries/getCollectionDrafts'
16+ import { GET_VISUALIZATION_DRAFTS } from '@/js/operations/queries/getVisualizationDrafts'
1617
1718import ErrorBoundary from '@/js/components/ErrorBoundary/ErrorBoundary'
1819
20+ import {
21+ mockCollectionDrafts ,
22+ mockToolDrafts ,
23+ mockVisualizationDrafts
24+ } from './__mocks__/DraftListMocks'
25+
1926import DraftList from '../DraftList'
2027
2128vi . mock ( 'react-bootstrap/Placeholder' , ( ) => ( { default : vi . fn ( ) } ) )
@@ -27,124 +34,6 @@ vi.mock('react-router-dom', async () => ({
2734 useParams : vi . fn ( ) . mockImplementation ( ( ) => ( { draftType : 'tools' } ) )
2835} ) )
2936
30- const mockToolDrafts = {
31- count : 3 ,
32- items : [
33- {
34- conceptId : 'TD1200000092-MMT_2' ,
35- revisionDate : '2023-12-08T17:56:09.385Z' ,
36- revisionId : '1' ,
37- ummMetadata : {
38- Name : 'Tool TD1200000092 short name' ,
39- LongName : 'Tool TD1200000092 long name'
40- } ,
41- name : 'Tool TD1200000092 short name' ,
42- previewMetadata : {
43- conceptId : 'TD1200000092-MMT_2' ,
44- revisionId : '1' ,
45- name : 'Tool TD1200000092 short name' ,
46- longName : 'Tool TD1200000092 long name' ,
47- __typename : 'Tool'
48- } ,
49- providerId : 'MMT_2' ,
50- __typename : 'Draft'
51- } ,
52- {
53- conceptId : 'TD1200000093-MMT_2' ,
54- revisionDate : '2023-11-08T17:56:09.385Z' ,
55- revisionId : '1' ,
56- ummMetadata : { } ,
57- previewMetadata : {
58- conceptId : 'TD1200000093-MMT_2' ,
59- revisionId : '1' ,
60- name : null ,
61- longName : null ,
62- __typename : 'Tool'
63- } ,
64- providerId : 'MMT_2' ,
65- __typename : 'Draft'
66- } ,
67- {
68- conceptId : 'TD1200000094-MMT_2' ,
69- revisionDate : '2023-10-08T17:56:09.385Z' ,
70- revisionId : '1' ,
71- ummMetadata : {
72- Name : 'Tool TD1200000094 short name' ,
73- LongName : 'Tool TD1200000094 long name'
74- } ,
75- previewMetadata : {
76- conceptId : 'TD1200000094-MMT_2' ,
77- revisionId : '1' ,
78- name : null ,
79- longName : null ,
80- __typename : 'Tool'
81- } ,
82- providerId : 'MMT_2' ,
83- __typename : 'Draft'
84- }
85- ] ,
86- __typename : 'DraftList'
87- }
88-
89- const mockCollectionDrafts = {
90- count : 3 ,
91- items : [
92- {
93- conceptId : 'CD1200000092-MMT_2' ,
94- revisionDate : '2023-12-08T17:56:09.385Z' ,
95- revisionId : '1' ,
96- ummMetadata : {
97- ShortName : 'Collection CD1200000092 short name' ,
98- EntryTitle : 'Collection CD1200000092 entry title'
99- } ,
100- shortName : 'Collection CD1200000092 short name' ,
101- previewMetadata : {
102- conceptId : 'CD1200000092-MMT_2' ,
103- revisionId : '1' ,
104- shortName : 'Collection CD1200000092 short name' ,
105- entryTitle : 'Collection CD1200000092 entry title' ,
106- __typename : 'Collection'
107- } ,
108- providerId : 'MMT_2' ,
109- __typename : 'Draft'
110- } ,
111- {
112- conceptId : 'CD1200000093-MMT_2' ,
113- revisionDate : '2023-11-08T17:56:09.385Z' ,
114- revisionId : '1' ,
115- ummMetadata : { } ,
116- previewMetadata : {
117- conceptId : 'CD1200000093-MMT_2' ,
118- revisionId : '1' ,
119- shortName : null ,
120- entryTitle : null ,
121- __typename : 'Collection'
122- } ,
123- providerId : 'MMT_2' ,
124- __typename : 'Draft'
125- } ,
126- {
127- conceptId : 'CD1200000094-MMT_2' ,
128- revisionDate : '2023-10-08T17:56:09.385Z' ,
129- revisionId : '1' ,
130- ummMetadata : {
131- ShortName : 'Collection CD1200000094 short name' ,
132- EntryTitle : 'Collection CD1200000094 entry title'
133- } ,
134- previewMetadata : {
135- conceptId : 'CD1200000094-MMT_2' ,
136- revisionId : '1' ,
137- shortName : null ,
138- entryTitle : null ,
139- __typename : 'Collection'
140- } ,
141- providerId : 'MMT_2' ,
142- __typename : 'Draft'
143- }
144- ] ,
145- __typename : 'DraftList'
146- }
147-
14837const setup = ( { overrideMocks = false } ) => {
14938 const mocks = [ {
15039 request : {
@@ -335,4 +224,51 @@ describe('DraftList', () => {
335224 )
336225 } )
337226 } )
227+
228+ describe ( 'when draft type Visualization is given' , ( ) => {
229+ test ( 'renders Visualization draft list' , async ( ) => {
230+ useParams . mockImplementation ( ( ) => ( { draftType : 'visualizations' } ) )
231+
232+ setup ( {
233+ overrideMocks : [ {
234+ request : {
235+ query : GET_VISUALIZATION_DRAFTS ,
236+ variables : {
237+ params : {
238+ conceptType : 'Visualization' ,
239+ limit : 20 ,
240+ offset : 0 ,
241+ sortKey : [ '-revision_date' ]
242+ }
243+ }
244+ } ,
245+ result : {
246+ data : {
247+ drafts : mockVisualizationDrafts
248+ }
249+ }
250+ } ]
251+ } )
252+
253+ const rows = await screen . findAllByRole ( 'row' )
254+
255+ expect ( within ( rows [ 1 ] ) . getByRole ( 'cell' , { name : 'Short Name 1' } ) ) . toBeInTheDocument ( )
256+ expect ( within ( rows [ 1 ] ) . getByRole ( 'cell' , { name : 'Long Name 1' } ) ) . toBeInTheDocument ( )
257+ expect ( within ( rows [ 1 ] ) . getByRole ( 'cell' , { name : 'Friday, April 25, 2025 5:26 PM' } ) ) . toBeInTheDocument ( )
258+ expect ( within ( rows [ 1 ] ) . getByRole ( 'cell' , { name : 'MMT_1' } ) ) . toBeInTheDocument ( )
259+ expect ( within ( rows [ 1 ] ) . getByRole ( 'button' , { name : / D o w n l o a d J S O N / } ) ) . toBeInTheDocument ( )
260+
261+ expect ( within ( rows [ 2 ] ) . getByRole ( 'cell' , { name : '<Blank Name>' } ) ) . toBeInTheDocument ( )
262+ expect ( within ( rows [ 2 ] ) . getByRole ( 'cell' , { name : '<Blank Long Name>' } ) ) . toBeInTheDocument ( )
263+ expect ( within ( rows [ 2 ] ) . getByRole ( 'cell' , { name : 'Thursday, May 15, 2025 10:30 AM' } ) ) . toBeInTheDocument ( )
264+ expect ( within ( rows [ 2 ] ) . getByRole ( 'cell' , { name : 'MMT_1' } ) ) . toBeInTheDocument ( )
265+ expect ( within ( rows [ 2 ] ) . getByRole ( 'button' , { name : / D o w n l o a d J S O N / } ) ) . toBeInTheDocument ( )
266+
267+ expect ( within ( rows [ 3 ] ) . getByRole ( 'cell' , { name : 'Short Name 3' } ) ) . toBeInTheDocument ( )
268+ expect ( within ( rows [ 3 ] ) . getByRole ( 'cell' , { name : 'Long Name 3' } ) ) . toBeInTheDocument ( )
269+ expect ( within ( rows [ 3 ] ) . getByRole ( 'cell' , { name : 'Thursday, June 5, 2025 2:45 PM' } ) ) . toBeInTheDocument ( )
270+ expect ( within ( rows [ 3 ] ) . getByRole ( 'cell' , { name : 'MMT_1' } ) ) . toBeInTheDocument ( )
271+ expect ( within ( rows [ 3 ] ) . getByRole ( 'button' , { name : / D o w n l o a d J S O N / } ) ) . toBeInTheDocument ( )
272+ } )
273+ } )
338274} )
0 commit comments