fix: allow updating computed values of table widget in view mode (#9817)

* fix: allow updating computed values of table widget in view mode
* cypress tests
This commit is contained in:
balajisoundar 2021-12-28 12:45:28 +05:30 committed by GitHub
parent 703d47f7b1
commit 8c6bae6f71
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 79 additions and 2 deletions

View File

@ -3,6 +3,7 @@ const widgetsPage = require("../../../../locators/Widgets.json");
const commonlocators = require("../../../../locators/commonlocators.json");
const publish = require("../../../../locators/publishWidgetspage.json");
const dsl = require("../../../../fixtures/tableWidgetDsl.json");
const explorer = require("../../../../locators/explorerlocators.json");
describe("Table Widget Functionality", function() {
before(() => {
@ -359,6 +360,7 @@ describe("Table Widget Functionality", function() {
});
});
*/
afterEach(() => {
// put your clean up code if any
});

View File

@ -0,0 +1,62 @@
const explorer = require("../../../../locators/explorerlocators.json");
import homePage from "../../../../locators/HomePage.json";
const publish = require("../../../../locators/publishWidgetspage.json");
describe("Table Widget", function() {
it("1. Table Widget Functionality To Check with changing schema of tabledata", () => {
let jsContext = `{{Switch1.isSwitchedOn?[{name: "joe"}]:[{employee_name: "john"}];}}`;
cy.NavigateToHome();
cy.get(homePage.createNew)
.first()
.click({ force: true });
cy.wait("@createNewApplication").should(
"have.nested.property",
"response.body.responseMeta.status",
201,
);
cy.get(explorer.addWidget).click();
cy.dragAndDropToCanvas("switchwidget", { x: 200, y: 200 });
cy.dragAndDropToCanvas("tablewidget", { x: 200, y: 300 });
cy.wait(1000);
cy.wait("@updateLayout");
cy.get(".t--property-control-tabledata").then(($el) => {
cy.updateCodeInput($el, jsContext);
});
cy.PublishtheApp();
cy.getTableDataSelector("0", "0").then((element) => {
cy.get(element, { timeout: 10000 }).should("be.visible");
});
cy.readTabledataPublish("0", "0").then((value) => {
expect(value).to.be.equal("joe");
});
cy.get(".t--switch-widget-active")
.first()
.click();
cy.wait(1000);
cy.getTableDataSelector("0", "0").then((element) => {
cy.get(element, { timeout: 10000 }).should("be.visible");
});
cy.readTabledataPublish("0", "0").then((value) => {
expect(value).to.be.equal("john");
});
cy.get(".t--switch-widget-inactive")
.first()
.click();
cy.wait(1000);
cy.getTableDataSelector("0", "0").then((element) => {
cy.get(element, { timeout: 10000 }).should("be.visible");
});
cy.readTabledataPublish("0", "0").then((value) => {
expect(value).to.be.equal("joe");
});
cy.get(publish.backToEditor)
.first()
.click()
.wait(1000);
cy.selectEntityByName("Widgets");
cy.deleteEntitybyName("Switch1");
cy.deleteEntitybyName("Table1");
});
});

View File

@ -18,7 +18,11 @@ import {
import { getIsInitialized } from "selectors/appViewSelectors";
import { executeTrigger } from "actions/widgetActions";
import { ExecuteTriggerPayload } from "constants/AppsmithActionConstants/ActionConstants";
import { updateWidgetPropertyRequest } from "actions/controlActions";
import {
BatchPropertyUpdatePayload,
batchUpdateWidgetProperty,
updateWidgetPropertyRequest,
} from "actions/controlActions";
import { EditorContext } from "components/editorComponents/EditorContextProvider";
import AppViewerPageContainer from "./AppViewerPageContainer";
import {
@ -86,6 +90,10 @@ export type AppViewerProps = {
resetChildrenMetaProperty: (widgetId: string) => void;
pages: PageListPayload;
lightTheme: Theme;
batchUpdateWidgetProperty: (
widgetId: string,
updates: BatchPropertyUpdatePayload,
) => void;
} & RouteComponentProps<BuilderRouteParams>;
type Props = AppViewerProps & RouteComponentProps<AppViewerRouteParams>;
@ -150,6 +158,7 @@ class AppViewer extends Component<Props> {
executeAction: this.props.executeAction,
updateWidgetMetaProperty: this.props.updateWidgetMetaProperty,
resetChildrenMetaProperty: this.props.resetChildrenMetaProperty,
batchUpdateWidgetProperty: this.props.batchUpdateWidgetProperty,
}}
>
<ContainerWithComments>
@ -217,6 +226,10 @@ const mapDispatchToProps = (dispatch: any) => ({
payload: params,
});
},
batchUpdateWidgetProperty: (
widgetId: string,
updates: BatchPropertyUpdatePayload,
) => dispatch(batchUpdateWidgetProperty(widgetId, updates)),
});
export default withRouter(

View File

@ -582,7 +582,7 @@ class TableWidget extends BaseWidget<TableWidgetProps, WidgetState> {
// If the user has changed the tableData OR
// The binding has returned a new value
if (tableDataModified && this.props.renderMode === RenderModes.CANVAS) {
if (tableDataModified) {
// Set filter to default
const defaultFilter = [
{