Skip to content

Commit 133fd75

Browse files
MMT-4000: As a user, I can see the metadata preview for Visualizations on MMT (#1366)
* MMT-4000: Fix apollo errors on main for the collection test by adding associationDetails * MMT-4000: Adding cmr-preview for Visualization records * MMT-4000: Update MMT to include the latest cmr-preview page and the visualizations associated to the collection * MMT-4000: Bump express to match dependabot PR and run npm audit fix * MMT-4000: Add in `name` field to pass to vis preview
1 parent 898d1fb commit 133fd75

File tree

10 files changed

+372
-36
lines changed

10 files changed

+372
-36
lines changed

package-lock.json

Lines changed: 43 additions & 29 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

package.json

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,7 @@
1919
},
2020
"dependencies": {
2121
"@apollo/client": "^3.8.5",
22-
"@edsc/metadata-preview": "^1.3.19",
22+
"@edsc/metadata-preview": "^1.4.0-beta.2",
2323
"@node-saml/node-saml": "^4.0.5",
2424
"@rjsf/core": "^5.15.0",
2525
"@rjsf/utils": "^5.15.0",
@@ -96,7 +96,7 @@
9696
"eslint-plugin-jsx-a11y": "^6.7.1",
9797
"eslint-plugin-react": "^7.33.2",
9898
"eslint-plugin-react-hooks": "^4.6.0",
99-
"express": "^4.18.2",
99+
"express": "^4.19.2",
100100
"http": "^0.0.1-security",
101101
"http-proxy": "^1.18.1",
102102
"jsdom": "^22.1.0",

setup/setupCmr.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -580,7 +580,8 @@ const insertMetadata = async () => {
580580
let url
581581
const headers = {
582582
'Content-Type': contentType,
583-
Authorization: systemToken
583+
Authorization: systemToken,
584+
'Cmr-Validate-Keywords': 'false'
584585
}
585586

586587
if (collectionUri.includes('EDF_DEV06')) {

static/src/js/components/MetadataPreview/MetadataPreview.jsx

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@ import {
33
CollectionPreview,
44
ServicePreview,
55
ToolPreview,
6-
VariablePreview
6+
VariablePreview,
7+
VisualizationPreview
78
} from '@edsc/metadata-preview'
89
import { useParams } from 'react-router'
910
import { useSuspenseQuery } from '@apollo/client'
@@ -124,6 +125,16 @@ const MetadataPreview = ({
124125
/>
125126
)
126127
}
128+
{
129+
conceptType === 'Visualization' && (
130+
<VisualizationPreview
131+
cmrHost={cmrHost}
132+
visualization={concept}
133+
conceptId={conceptId}
134+
conceptType={type}
135+
/>
136+
)
137+
}
127138
</Col>
128139
</Row>
129140
)

static/src/js/components/MetadataPreview/__tests__/MetadataPreview.test.jsx

Lines changed: 71 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@ import {
22
CollectionPreview,
33
ServicePreview,
44
ToolPreview,
5-
VariablePreview
5+
VariablePreview,
6+
VisualizationPreview
67
} from '@edsc/metadata-preview'
78
import { render, waitFor } from '@testing-library/react'
89
import { userEvent } from '@testing-library/user-event'
@@ -24,7 +25,8 @@ import {
2425
mockCollectionWithAssociatedVariables,
2526
mockServiceDraft,
2627
mockToolDraft,
27-
mockVariableDraft
28+
mockVariableDraft,
29+
mockVisualizationDraft
2830
} from './__mocks__/MatadataPreviewMocks'
2931

3032
vi.mock('@edsc/metadata-preview')
@@ -236,6 +238,73 @@ describe('MetadataPreview', () => {
236238
})
237239
})
238240

241+
describe('when the conceptType is Visualization draft', () => {
242+
test('renders a Visualization Preview component', async () => {
243+
setup({
244+
overrideProps: {
245+
conceptId: 'VISD000000-MMT',
246+
conceptType: 'Visualization'
247+
},
248+
mock: [{
249+
request: {
250+
query: conceptTypeDraftQueries.Visualization,
251+
variables: {
252+
params: {
253+
conceptId: 'VISD000000-MMT',
254+
conceptType: 'Visualization'
255+
},
256+
variableParams: null
257+
}
258+
},
259+
result: {
260+
data: {
261+
draft: mockVisualizationDraft
262+
}
263+
}
264+
}],
265+
initialEntries: '/drafts/visualizations/VISD000000-MMT'
266+
})
267+
268+
await waitFor(() => {
269+
expect(VisualizationPreview).toHaveBeenCalledWith({
270+
cmrHost: 'http://example.com',
271+
conceptId: 'VISD000000-MMT',
272+
conceptType: 'visualization-draft',
273+
conceptUrlTemplate: '/{conceptType}/{conceptId}',
274+
isPlugin: true,
275+
visualization: {
276+
__typename: 'Visualization',
277+
conceptId: 'VISD0000000000-CMR',
278+
description: 'Draft test description',
279+
generation: {},
280+
identifier: 'Extra Data',
281+
metadataSpecification: {
282+
url: 'https://cdn.earthdata.nasa.gov/umm/visualization/v1.1.0',
283+
name: 'Visualization',
284+
version: '1.1.0'
285+
},
286+
pageTitle: 'Creating Test 3',
287+
name: 'Creating Test 3',
288+
nativeId: 'Visualization-1303',
289+
providerId: 'MMT_1',
290+
revisionDate: '2025-04-25T17:25:17.825Z',
291+
revisionId: '1',
292+
scienceKeywords: null,
293+
spatialExtent: null,
294+
specification: {},
295+
subtitle: null,
296+
temporalExtents: null,
297+
title: 'Draft test title',
298+
ummMetadata: null,
299+
visualizationType: 'tiles'
300+
}
301+
}, {})
302+
})
303+
304+
expect(VisualizationPreview).toHaveBeenCalledTimes(1)
305+
})
306+
})
307+
239308
describe('when the conceptType is Variable draft', () => {
240309
test('renders a Variable Preview component', async () => {
241310
setup({

0 commit comments

Comments
 (0)