Skip to content
Snippets Groups Projects
Unverified Commit ce406d24 authored by Nemanja Glumac's avatar Nemanja Glumac Committed by GitHub
Browse files

Add `editDashboardCard` Cypress custom command (#17493)

parent ef46b764
No related branches found
No related tags found
No related merge requests found
......@@ -3,6 +3,7 @@ import "./commands/ui/icon";
import "./commands/api/question";
import "./commands/api/dashboard";
import "./commands/api/dashboardCard";
import "./commands/api/dashboardFilters";
import "./commands/api/collection";
import "./commands/api/moderation";
......
import _ from "underscore";
Cypress.Commands.add("editDashboardCard", (oldCard, newCard) => {
const { id, dashboard_id } = oldCard;
const cleanOldCard = sanitizeCard(oldCard);
const updatedCard = Object.assign({}, cleanOldCard, newCard);
cy.log(`Edit dashboard card ${id}`);
cy.request("PUT", `/api/dashboard/${dashboard_id}/cards`, {
cards: [updatedCard],
});
});
/**
* Remove `created_at` and `updated_at` fields from the dashboard card that was previously added to the dashboard.
* We don't want to hard code these fields in the next request that we'll pass the card object to.
*
* @param {Object} card - "Old", or the existing dashboard card.
* @returns {Object}
*/
function sanitizeCard(card) {
return _.omit(card, ["created_at", "updated_at"]);
}
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment