Skip to content

Commit

Permalink
Merge pull request #242 from zimmerman-team/fix/duplicate-asset-undef…
Browse files Browse the repository at this point in the history
…ined

fix: Duplicating an asset in detail page leads to undefined route
  • Loading branch information
Psami-wondah authored Oct 1, 2024
2 parents 03ad7e2 + 9ee1a5f commit d1cdfad
Show file tree
Hide file tree
Showing 5 changed files with 8 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ test("clicking duplicate button should duplicate chart", async () => {
const mockedAxios = axios.get as jest.Mock;
mockedAxios
.mockResolvedValueOnce({
data: { id: "chart-id" },
data: { data: { id: "chart-id" } },
} as AxiosResponse<any>)
.mockResolvedValueOnce({ data: mockChartList });
jest
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -252,7 +252,7 @@ export function ChartSubheaderToolbar(
storeInCrudData: true,
filterString: "filter[order]=updatedDate desc",
});
setDuplicatedChartId(response.data.id);
setDuplicatedChartId(response.data?.data?.id);
setSnackbarState({
...snackbarState,
open: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -110,7 +110,7 @@ export default function DatasetSubHeaderToolbar(
onTryAgain: () => {},
});
}
setDuplicatedDatasetId(response.data.id);
setDuplicatedDatasetId(response.data?.data?.id);
setSnackbarState({
...snackbarState,
open: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -414,8 +414,10 @@ describe("Tests for tablet and desktop view", () => {
const axiosMock = axios.get as jest.Mock;

axiosMock
.mockResolvedValueOnce({ data: { id: "12345" } } as AxiosResponse<any>)
.mockResolvedValueOnce({ data: [] });
.mockResolvedValueOnce({
data: { data: { id: "12345" } },
} as AxiosResponse<any>)
.mockResolvedValueOnce({ data: { data: [] } });
jest
.spyOn(Router, "useParams")
.mockReturnValue({ page: "12345", view: undefined });
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ export function ReportSubheaderToolbar(
storeInCrudData: true,
filterString: "filter[order]=updatedDate desc",
});
setDuplicatedReportId(response.data.id);
setDuplicatedReportId(response.data?.data?.id);
setSnackbarState({
...snackbarState,
open: true,
Expand Down

0 comments on commit d1cdfad

Please sign in to comment.