Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
…41238) * Restore tabs display for embedded dashboard without title * Add unit test * Remove empty file --------- Co-authored-by: Denis Berezin <denis.berezin@metabase.com> Co-authored-by: Mahatthana Nomsawadi <mahatthana.n@gmail.com>
- Loading branch information
1 parent
519d6a8
commit 0fdefcf
Showing
9 changed files
with
76 additions
and
8 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
File renamed without changes.
57 changes: 57 additions & 0 deletions
57
frontend/src/metabase/public/containers/PublicDashboard/PublicDashboard.unit.spec.tsx
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,57 @@ | ||
import { Route } from "react-router"; | ||
|
||
import { setupEmbedDashboardEndpoints } from "__support__/server-mocks/embed"; | ||
import { renderWithProviders, screen } from "__support__/ui"; | ||
import { | ||
createMockDashboard, | ||
createMockDashboardTab, | ||
} from "metabase-types/api/mocks"; | ||
import { createMockState } from "metabase-types/store/mocks"; | ||
|
||
import { PublicDashboard } from "./PublicDashboard"; | ||
|
||
const MOCK_TOKEN = | ||
"eyJhbGciOiJIUzI1NiJ9.eyJyZXNvdXJjZSI6eyJkYXNoYm9hcmQiOjExfSwicGFyYW1zIjp7fSwiaWF0IjoxNzEyNjg0NTA1LCJfZW1iZWRkaW5nX3BhcmFtcyI6e319.WbZTB-cQYh4gjh61ZzoLOcFbJ6j6RlOY3GS4fwzv3W4"; | ||
const DASHBOARD_TITLE = '"My test dash"'; | ||
|
||
const DASHBOARD_WITH_TABS = createMockDashboard({ | ||
id: 1, | ||
name: DASHBOARD_TITLE, | ||
parameters: [], | ||
dashcards: [], | ||
tabs: [ | ||
createMockDashboardTab({ id: 1, name: "Tab 1" }), | ||
createMockDashboardTab({ id: 2, name: "Tab 2" }), | ||
], | ||
}); | ||
|
||
describe("PublicDashboard", () => { | ||
it("should display dashboard tabs", async () => { | ||
await setup(); | ||
|
||
expect(screen.getByText("Tab 1")).toBeInTheDocument(); | ||
expect(screen.getByText("Tab 2")).toBeInTheDocument(); | ||
}); | ||
|
||
it("should display dashboard tabs if title is disabled (metabase#41195)", async () => { | ||
await setup({ hash: "titled=false" }); | ||
|
||
expect(screen.getByText("Tab 1")).toBeInTheDocument(); | ||
expect(screen.getByText("Tab 2")).toBeInTheDocument(); | ||
}); | ||
}); | ||
|
||
async function setup({ hash }: { hash?: string } = {}) { | ||
setupEmbedDashboardEndpoints(MOCK_TOKEN, DASHBOARD_WITH_TABS); | ||
|
||
renderWithProviders( | ||
<Route path="embed/dashboard/:token" component={PublicDashboard} />, | ||
{ | ||
storeInitialState: createMockState(), | ||
withRouter: true, | ||
initialRoute: `embed/dashboard/${MOCK_TOKEN}${hash ? "#" + hash : ""}`, | ||
}, | ||
); | ||
|
||
expect(await screen.findByTestId("dashboard-grid")).toBeInTheDocument(); | ||
} |
1 change: 1 addition & 0 deletions
1
frontend/src/metabase/public/containers/PublicDashboard/index.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
export { PublicDashboard } from "./PublicDashboard"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import fetchMock from "fetch-mock"; | ||
|
||
import type { Dashboard } from "metabase-types/api"; | ||
|
||
export function setupEmbedDashboardEndpoints( | ||
uuid: string, | ||
dashboard: Dashboard, | ||
) { | ||
fetchMock.get(`path:/api/embed/dashboard/${uuid}`, dashboard); | ||
} |