Skip to content
Snippets Groups Projects
Unverified Commit 575fa4ed authored by Anton Kulyk's avatar Anton Kulyk Committed by GitHub
Browse files

Don't show "Download results" button until dashcard query is complete (#46060)

* Don't show "Download" button until query complete

* Fix `PublicOrEmbeddedDashboardPage` tests

* Add tests

* Remove redundant dataset error checks

* Revert "Remove redundant dataset error checks"

This reverts commit fc7810f0.
parent c24e4841
Branches
Tags
No related merge requests found
......@@ -174,7 +174,7 @@ DashCardMenu.shouldRender = ({
);
if (isPublicOrEmbedded) {
return downloadsEnabled;
return downloadsEnabled && !!result?.data && !result?.error;
}
return (
!isInternalQuery &&
......
......@@ -156,6 +156,15 @@ describe("DashCardMenu", () => {
expect(screen.getByText("Download full results")).toBeInTheDocument();
});
it("should not display query export options when query is running", async () => {
setup({ result: {} as any });
await userEvent.click(getIcon("ellipsis"));
expect(await screen.findByText("Edit question")).toBeInTheDocument();
expect(screen.queryByText("Download results")).not.toBeInTheDocument();
});
it("should not display query export options when there is a query error", async () => {
setup({ result: TEST_RESULT_ERROR });
......
......@@ -15,7 +15,7 @@ export const canEditQuestion = (question: Question) => {
export const canDownloadResults = (result?: Dataset) => {
return (
result != null &&
!!result?.data &&
!result.error &&
PLUGIN_FEATURE_LEVEL_PERMISSIONS.canDownloadResults(result)
);
......
......@@ -148,11 +148,23 @@ describe("DashCard", () => {
expect(screen.getByText("What a cool section")).toBeVisible();
});
it("should not display the ellipsis menu for (unsaved) xray dashboards (metabase#33637)", async () => {
it("should not display the ellipsis menu for (unsaved) xray dashboards (metabase#33637)", () => {
setup({ isXray: true });
expect(queryIcon("ellipsis")).not.toBeInTheDocument();
});
it("should not display the 'Download results' action when dashcard query is running", () => {
setup({ dashcardData: {} });
// in this case the dashcard menu would be empty so it's not rendered at all
expect(queryIcon("ellipsis")).not.toBeInTheDocument();
});
it("should not display the 'Download results' action when dashcard query is running in public/embedded dashboards", () => {
setup({ isPublicOrEmbedded: true, dashcardData: {} });
// in this case the dashcard menu would be empty so it's not rendered at all
expect(queryIcon("ellipsis")).not.toBeInTheDocument();
});
it("should show a link card", () => {
const linkCard = createMockLinkDashboardCard({
url: "https://xkcd.com/327",
......
......@@ -13,6 +13,7 @@ import {
waitForLoaderToBeRemoved,
} from "__support__/ui";
import { DASHBOARD_PDF_EXPORT_ROOT_ID } from "metabase/dashboard/constants";
import registerVisualizations from "metabase/visualizations/register";
import type { DashboardCard, DashboardTab } from "metabase-types/api";
import {
createMockCard,
......@@ -29,6 +30,8 @@ const MOCK_TOKEN =
"eyJhbGciOiJIUzI1NiJ9.eyJyZXNvdXJjZSI6eyJkYXNoYm9hcmQiOjExfSwicGFyYW1zIjp7fSwiaWF0IjoxNzEyNjg0NTA1LCJfZW1iZWRkaW5nX3BhcmFtcyI6e319.WbZTB-cQYh4gjh61ZzoLOcFbJ6j6RlOY3GS4fwzv3W4";
const DASHBOARD_TITLE = '"My test dash"';
registerVisualizations();
describe("PublicOrEmbeddedDashboardPage", () => {
beforeAll(() => {
mockSettings({
......
import fetchMock from "fetch-mock";
import type { Dashboard, DashboardCard } from "metabase-types/api";
import { createMockDataset } from "metabase-types/api/mocks";
export function setupEmbedDashboardEndpoints(
uuidOrToken: string,
......@@ -13,7 +14,7 @@ export function setupEmbedDashboardEndpoints(
dashcards.forEach(({ id, card_id }) => {
fetchMock.get(
`path:/api/embed/dashboard/${uuidOrToken}/dashcard/${id}/card/${card_id}`,
dashboard,
createMockDataset(),
);
});
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment