Skip to content
Snippets Groups Projects
Unverified Commit 11f8b036 authored by Kamil Mielnik's avatar Kamil Mielnik Committed by GitHub
Browse files

Fix - Can't subsequently run actions for different objects from dashboards (#33087)

* Fix initial values not reloading in the action modal

* Add a repro test for #33084

* Use cy.button helper
parent b220f902
No related branches found
No related tags found
No related merge requests found
......@@ -973,6 +973,11 @@ describe(
cy.intercept("GET", "/api/action").as("getActions");
cy.intercept("PUT", "/api/action/*").as("updateAction");
cy.intercept("GET", "/api/action?model-id=*").as("getModelActions");
cy.intercept(
"GET",
"/api/dashboard/*/dashcard/*/execute?parameters=*",
).as("executePrefetch");
});
describe("Inline action edit", () => {
......@@ -987,6 +992,55 @@ describe(
});
});
it("refetches form values when id changes (metabase#33084)", () => {
const actionName = "Update";
cy.get("@modelId").then(id => {
createImplicitAction({
kind: "update",
model_id: id,
});
});
createDashboardWithActionButton({
actionName,
idFilter: true,
});
filterWidget().click();
addWidgetStringFilter("5");
cy.button(actionName).click();
cy.wait("@executePrefetch");
modal().within(() => {
cy.findByPlaceholderText("Team Name").should(
"have.value",
"Energetic Elephants",
);
cy.findByPlaceholderText("Score").should("have.value", "30");
cy.icon("close").click();
});
filterWidget().click();
popover().find("input").first().type("{backspace}10");
cy.button("Update filter").click();
cy.button(actionName).click();
cy.wait("@executePrefetch");
modal().within(() => {
cy.findByPlaceholderText("Team Name").should(
"have.value",
"Jolly Jellyfish",
);
cy.findByPlaceholderText("Score").should("have.value", "60");
});
});
it("should reflect to updated action on mapping form", () => {
const ACTION_NAME = "Update Score";
......
......@@ -29,10 +29,10 @@ export const useActionInitialValues = ({
const hasPrefetchedValues = Object.keys(prefetchedInitialValues).length > 0;
useEffect(() => {
if (shouldPrefetch && !hasPrefetchedValues) {
if (shouldPrefetch) {
prefetchValues();
}
}, [shouldPrefetch, hasPrefetchedValues, prefetchValues]);
}, [shouldPrefetch, prefetchValues]);
return {
error,
......
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