Skip to content
Snippets Groups Projects
Commit 622abd06 authored by Kamil Mielnik's avatar Kamil Mielnik
Browse files

Remove old definitions

parent 5d5938ba
Branches
No related tags found
No related merge requests found
import type {
CreateDashboardRequest,
Dashboard,
DashboardCard,
DashboardId,
DashCardId,
......@@ -10,73 +8,6 @@ import type {
import { visitDashboard } from "./e2e-misc-helpers";
import { menu, popover, sidebar } from "./e2e-ui-elements-helpers";
interface DashboardDetails extends Omit<CreateDashboardRequest, "name"> {
name?: string;
auto_apply_filters?: Dashboard["auto_apply_filters"];
enable_embedding?: Dashboard["enable_embedding"];
embedding_params?: Dashboard["embedding_params"];
dashcards?: Partial<DashboardCard>[];
}
interface Options {
/**
* Whether to wrap a dashboard id, to make it available outside of this scope.
* Defaults to false.
*/
wrapId?: boolean;
/**
* Alias a dashboard id in order to use it later with `cy.get("@" + alias).
* Defaults to "dashboardId".
*/
idAlias?: string;
}
export const createDashboard = (
dashboardDetails: DashboardDetails = {},
options: Options = {},
): Cypress.Chainable<Cypress.Response<Dashboard>> => {
const {
name = "Test Dashboard",
auto_apply_filters,
enable_embedding,
embedding_params,
dashcards,
...restDashboardDetails
} = dashboardDetails;
const { wrapId = false, idAlias = "dashboardId" } = options;
cy.log(`Create a dashboard: ${name}`);
// For all the possible keys, refer to `src/metabase/api/dashboard.clj`
return cy
.request("POST", "/api/dashboard", { name, ...restDashboardDetails })
.then(({ body }) => {
if (wrapId) {
cy.wrap(body.id).as(idAlias);
}
if (
enable_embedding != null ||
auto_apply_filters != null ||
Array.isArray(dashcards)
) {
cy.request("PUT", `/api/dashboard/${body.id}`, {
auto_apply_filters,
enable_embedding,
embedding_params,
dashcards,
});
}
});
};
export const archiveDashboard = (id: DashboardId) => {
cy.log(`Archiving a dashboard with id: ${id}`);
return cy.request("PUT", `/api/dashboard/${id}`, {
archived: true,
});
};
// Metabase utility functions for commonly-used patterns
export function selectDashboardFilter(
selection: Cypress.Chainable<JQuery<HTMLElement>>,
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment