fix: thumbnail url json response was malformed (#29938)

This commit is contained in:
Elizabeth Thompson 2024-08-19 11:08:39 -07:00 committed by GitHub
parent 955db48c59
commit 7e88649730
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 5 additions and 7 deletions

View File

@ -18,7 +18,7 @@
*/ */
import { MemoryRouter } from 'react-router-dom'; import { MemoryRouter } from 'react-router-dom';
import { FeatureFlag, SupersetClient } from '@superset-ui/core'; import { FeatureFlag, JsonResponse, SupersetClient } from '@superset-ui/core';
import * as uiCore from '@superset-ui/core'; import * as uiCore from '@superset-ui/core';
import { render, screen, waitFor } from 'spec/helpers/testing-library'; import { render, screen, waitFor } from 'spec/helpers/testing-library';
@ -101,11 +101,9 @@ it('Renders the modified date', () => {
it('should fetch thumbnail when dashboard has no thumbnail URL and feature flag is enabled', async () => { it('should fetch thumbnail when dashboard has no thumbnail URL and feature flag is enabled', async () => {
const mockGet = jest.spyOn(SupersetClient, 'get').mockResolvedValue({ const mockGet = jest.spyOn(SupersetClient, 'get').mockResolvedValue({
response: new Response( json: { result: { thumbnail_url: '/new-thumbnail.png' } },
JSON.stringify({ thumbnail_url: '/new-thumbnail.png' }), } as unknown as JsonResponse);
),
json: () => Promise.resolve({ thumbnail_url: '/new-thumbnail.png' }),
});
const { rerender } = render( const { rerender } = render(
<DashboardCard <DashboardCard
dashboard={{ dashboard={{

View File

@ -91,7 +91,7 @@ function DashboardCard({
SupersetClient.get({ SupersetClient.get({
endpoint: `/api/v1/dashboard/${dashboard.id}`, endpoint: `/api/v1/dashboard/${dashboard.id}`,
}).then(({ json = {} }) => { }).then(({ json = {} }) => {
setThumbnailUrl(json.thumbnail_url || ''); setThumbnailUrl(json.result?.thumbnail_url || '');
setFetchingThumbnail(false); setFetchingThumbnail(false);
}); });
} }