Skip to content

Commit

Permalink
fix: thumbnail url json response was malformed (apache#29938)
Browse files Browse the repository at this point in the history
  • Loading branch information
eschutho authored Aug 19, 2024
1 parent 955db48 commit 7e88649
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 7 deletions.
10 changes: 4 additions & 6 deletions superset-frontend/src/features/dashboards/DashboardCard.test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
*/

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 { render, screen, waitFor } from 'spec/helpers/testing-library';
Expand Down Expand Up @@ -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 () => {
const mockGet = jest.spyOn(SupersetClient, 'get').mockResolvedValue({
response: new Response(
JSON.stringify({ thumbnail_url: '/new-thumbnail.png' }),
),
json: () => Promise.resolve({ thumbnail_url: '/new-thumbnail.png' }),
});
json: { result: { thumbnail_url: '/new-thumbnail.png' } },
} as unknown as JsonResponse);

const { rerender } = render(
<DashboardCard
dashboard={{
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ function DashboardCard({
SupersetClient.get({
endpoint: `/api/v1/dashboard/${dashboard.id}`,
}).then(({ json = {} }) => {
setThumbnailUrl(json.thumbnail_url || '');
setThumbnailUrl(json.result?.thumbnail_url || '');
setFetchingThumbnail(false);
});
}
Expand Down

0 comments on commit 7e88649

Please sign in to comment.