-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
06f4d42
commit 1cf7f20
Showing
2 changed files
with
54 additions
and
2 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
import * as React from "react"; | ||
import {screen, waitFor} from "@testing-library/react"; | ||
|
||
import QuicksightDashboard from "../../../src/components/QuicksightDashboard"; | ||
import {LibrariesData, LibraryData} from "../../../src/interfaces"; | ||
import buildStore, {RootState} from "../../../src/store" | ||
import {setupServer} from "msw/node"; | ||
import {rest} from "msw"; | ||
import renderWithContext from "../testUtils/renderWithContext"; | ||
|
||
const libraries: LibrariesData = {libraries: [{uuid: "my-uuid"}]}; | ||
const dashboardId = "test"; | ||
const embedUrl = "http://embedUrl" | ||
const dashboardUrlData = {embedUrl: embedUrl} | ||
|
||
describe("QuicksightDashboard", () => { | ||
const server = setupServer( | ||
rest.get("*/admin/libraries", (req, res, ctx) => res(ctx.json(libraries))), | ||
|
||
rest.get("*/admin/quicksight_embed/" + dashboardId + "?libraryUuids=" + libraries["libraries"][0]["uuid"], (req, res, ctx) => res(ctx.json(dashboardUrlData))) | ||
); | ||
|
||
beforeAll(() => { | ||
server.listen(); | ||
}); | ||
|
||
afterAll(() => { | ||
server.close(); | ||
}); | ||
|
||
it("embed url is retrieved and set in iframe", async () => { | ||
|
||
const contextProviderProps = { | ||
csrfToken: "", | ||
roles: [{role: "system"}], | ||
|
||
}; | ||
|
||
renderWithContext( | ||
<QuicksightDashboard | ||
dashboardId={dashboardId} | ||
store={buildStore()} | ||
/>, | ||
contextProviderProps | ||
); | ||
|
||
await waitFor(() => { | ||
expect(screen.getByRole('iframe')).toHaveAttribute("src", embedUrl) | ||
}); | ||
}); | ||
}); |