fix: Mute action execution errors when error callback is present (#9366)

This commit is contained in:
Hetu Nandu 2021-11-25 15:28:04 +05:30 committed by GitHub
parent 41c7c344b4
commit 5d7f68a031
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 68 additions and 11 deletions

View File

@ -0,0 +1,65 @@
const commonlocators = require("../../../../locators/commonlocators.json");
const dsl = require("../../../../fixtures/buttonApiDsl.json");
const widgetsPage = require("../../../../locators/Widgets.json");
const publishPage = require("../../../../locators/publishWidgetspage.json");
describe("Test Create Api and Bind to Table widget", function() {
before(() => {
cy.addDsl(dsl);
});
it("Test_Add users api and execute api", function() {
cy.createAndFillApi(this.data.userApi, "/random");
cy.RunAPI();
});
it("Call the api without error handling", () => {
cy.SearchEntityandOpen("Button1");
cy.get(widgetsPage.toggleOnClick)
.invoke("attr", "class")
.then((classes) => {
if (classes.includes("is-active")) {
cy.get(widgetsPage.toggleOnClick).click();
}
});
cy.get(widgetsPage.toggleOnClick).click();
cy.get(".t--property-control-onclick").then(($el) => {
cy.updateCodeInput($el, "{{Api1.run()}}");
});
cy.PublishtheApp();
cy.get(publishPage.buttonWidget).click();
cy.wait("@postExecute").should(
"have.nested.property",
"response.body.responseMeta.status",
200,
);
cy.get(commonlocators.toastAction)
.should("have.length", 1)
.should("contain.text", "failed to execute");
cy.get(publishPage.backToEditor).click({ force: true });
});
it("Call the api with error handling", () => {
cy.SearchEntityandOpen("Button1");
cy.get(".t--property-control-onclick").then(($el) => {
cy.updateCodeInput($el, "{{Api1.run(() => {}, () => {})}}");
});
cy.PublishtheApp();
cy.get(publishPage.buttonWidget).click();
cy.wait("@postExecute").should(
"have.nested.property",
"response.body.responseMeta.status",
200,
);
cy.get(commonlocators.toastAction).should("not.exist");
});
});

View File

@ -66,7 +66,6 @@ export function* executeActionTriggers(
executePluginActionTriggerSaga,
trigger.payload,
eventType,
triggerMeta,
);
break;
case ActionTriggerType.CLEAR_PLUGIN_ACTION:

View File

@ -86,7 +86,6 @@ import { RunPluginActionDescription } from "entities/DataTree/actionTriggers";
import { APP_MODE } from "entities/App";
import { FileDataTypes } from "widgets/constants";
import { hideDebuggerErrors } from "actions/debuggerActions";
import { TriggerMeta } from "sagas/ActionExecution/ActionExecutionSagas";
import {
PluginTriggerFailureError,
PluginActionExecutionError,
@ -243,7 +242,6 @@ function* confirmRunActionSaga() {
export default function* executePluginActionTriggerSaga(
pluginAction: RunPluginActionDescription["payload"],
eventType: EventType,
triggerMeta: TriggerMeta,
) {
const { actionId, params } = pluginAction;
PerformanceTracker.startAsyncTracking(
@ -310,7 +308,6 @@ export default function* executePluginActionTriggerSaga(
throw new PluginTriggerFailureError(
createMessage(ERROR_PLUGIN_ACTION_EXECUTE, action.name),
[payload.body, params],
triggerMeta,
);
} else {
AppsmithConsole.info({

View File

@ -58,15 +58,11 @@ export const logActionExecutionError = (
});
};
export class PluginTriggerFailureError extends TriggerFailureError {
export class PluginTriggerFailureError extends Error {
responseData: unknown[] = [];
constructor(
reason: string,
responseData: unknown[],
triggerMeta: TriggerMeta,
) {
super(reason, triggerMeta);
constructor(reason: string, responseData: unknown[]) {
super(reason);
this.responseData = responseData;
}
}