fix: Promises in Table buttons (#11239)
This commit is contained in:
parent
59c0d94ade
commit
06bf4696b4
|
|
@ -91,7 +91,7 @@ describe("Chart Widget Skeleton Loading Functionality", function() {
|
|||
cy.reload();
|
||||
|
||||
//Step12:
|
||||
cy.wait(2000);
|
||||
cy.wait(1000);
|
||||
cy.get(".t--widget-chartwidget div[class*='bp3-skeleton']").should("exist");
|
||||
|
||||
//Step13:
|
||||
|
|
|
|||
|
|
@ -40,8 +40,36 @@ describe("Table Widget property pane feature validation", function() {
|
|||
.last()
|
||||
.invoke("text")
|
||||
.then((text) => {
|
||||
const someText = text;
|
||||
expect(someText).to.equal("Successful tobias.funke@reqres.in");
|
||||
expect(text).to.equal("Successful tobias.funke@reqres.in");
|
||||
});
|
||||
|
||||
// Open column details of "id".
|
||||
cy.editColumn("id");
|
||||
|
||||
cy.get(widgetsPage.toggleOnClick).click({ force: true });
|
||||
cy.get(".t--property-control-onclick").then(($el) => {
|
||||
cy.updateCodeInput(
|
||||
$el,
|
||||
"{{showAlert('Successful' + currentRow.email).then(() => showAlert('second alert')) }}",
|
||||
);
|
||||
});
|
||||
|
||||
cy.get(commonlocators.editPropBackButton).click({
|
||||
force: true,
|
||||
});
|
||||
|
||||
// Validating the button action by clicking
|
||||
cy.get(widgetsPage.tableBtn)
|
||||
.last()
|
||||
.click({ force: true });
|
||||
// eslint-disable-next-line cypress/no-unnecessary-waiting
|
||||
cy.wait(3000);
|
||||
|
||||
cy.get(widgetsPage.toastActionText)
|
||||
.last()
|
||||
.invoke("text")
|
||||
.then((text) => {
|
||||
expect(text).to.equal("second alert");
|
||||
});
|
||||
});
|
||||
it("2. Table Button color validation", function() {
|
||||
|
|
|
|||
|
|
@ -893,7 +893,7 @@ class TableWidget extends BaseWidget<TableWidgetProps, WidgetState> {
|
|||
);
|
||||
const { jsSnippets } = getDynamicBindings(action);
|
||||
const modifiedAction = jsSnippets.reduce((prev: string, next: string) => {
|
||||
return prev + `{{(currentRow) => { ${next} }}} `;
|
||||
return prev + `{{(currentRow) => { return (${next}) }}} `;
|
||||
}, "");
|
||||
if (modifiedAction) {
|
||||
super.executeAction({
|
||||
|
|
|
|||
|
|
@ -23,6 +23,7 @@ export type EvalResult = {
|
|||
export enum EvaluationScriptType {
|
||||
EXPRESSION = "EXPRESSION",
|
||||
ANONYMOUS_FUNCTION = "ANONYMOUS_FUNCTION",
|
||||
ASYNC_ANONYMOUS_FUNCTION = "ASYNC_ANONYMOUS_FUNCTION",
|
||||
TRIGGERS = "TRIGGERS",
|
||||
}
|
||||
|
||||
|
|
@ -44,6 +45,14 @@ export const EvaluationScripts: Record<EvaluationScriptType, string> = {
|
|||
}
|
||||
callback(${ScriptTemplate})
|
||||
`,
|
||||
[EvaluationScriptType.ASYNC_ANONYMOUS_FUNCTION]: `
|
||||
async function callback (script) {
|
||||
const userFunction = script;
|
||||
const result = await userFunction?.apply(THIS_CONTEXT, ARGUMENTS);
|
||||
return result;
|
||||
}
|
||||
callback(${ScriptTemplate})
|
||||
`,
|
||||
[EvaluationScriptType.TRIGGERS]: `
|
||||
async function closedFunction () {
|
||||
const result = await ${ScriptTemplate};
|
||||
|
|
@ -58,9 +67,11 @@ const getScriptType = (
|
|||
isTriggerBased = false,
|
||||
): EvaluationScriptType => {
|
||||
let scriptType = EvaluationScriptType.EXPRESSION;
|
||||
if (evalArgumentsExist) {
|
||||
if (evalArgumentsExist && isTriggerBased) {
|
||||
scriptType = EvaluationScriptType.ASYNC_ANONYMOUS_FUNCTION;
|
||||
} else if (evalArgumentsExist && !isTriggerBased) {
|
||||
scriptType = EvaluationScriptType.ANONYMOUS_FUNCTION;
|
||||
} else if (isTriggerBased) {
|
||||
} else if (isTriggerBased && !evalArgumentsExist) {
|
||||
scriptType = EvaluationScriptType.TRIGGERS;
|
||||
}
|
||||
return scriptType;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user