Files
metabase/e2e/support/helpers/api/updateDashboardCards.ts
Kamil Mielnik 5a1d677444 RFC 118. Prettier - arrowParens: “always” (#55807)
* Update .prettierrc
- remove "arrowParens": "avoid" so that it defaults to "always" instead

* Run "yarn prettier"
2025-03-27 09:18:07 +00:00

29 lines
759 B
TypeScript

import type { Dashboard, DashboardCard, DashboardId } from "metabase-types/api";
export const DEFAULT_CARD = {
id: -1,
row: 0,
col: 0,
size_x: 11,
size_y: 8,
visualization_settings: {},
parameter_mappings: [],
};
/**
* Replaces all the cards on a dashboard with the array given in the `cards` parameter.
* Can be used to remove cards (exclude from array), or add/update them.
*/
export function updateDashboardCards({
dashboard_id,
cards,
}: {
dashboard_id: DashboardId;
cards: Partial<DashboardCard>[];
}): Cypress.Chainable<Cypress.Response<Dashboard>> {
let id = -1;
return cy.request<Dashboard>("PUT", `/api/dashboard/${dashboard_id}`, {
dashcards: cards.map((card) => ({ ...DEFAULT_CARD, id: id--, ...card })),
});
}