diff --git a/src/Explorer/Panes/Tables/EditTableEntityPanel.test.tsx b/src/Explorer/Panes/Tables/EditTableEntityPanel.test.tsx index 82aa0a211..75a28dd6e 100644 --- a/src/Explorer/Panes/Tables/EditTableEntityPanel.test.tsx +++ b/src/Explorer/Panes/Tables/EditTableEntityPanel.test.tsx @@ -15,11 +15,14 @@ describe("Excute Edit Table Entity Pane", () => { fakeTableEntityListViewModel.headers = []; fakeTableEntityListViewModel.selected = ko.observableArray([{}]); + const fakeSelectedItem = [{ PartitionKey: { _: "test", $: "String" } }]; const props = { tableDataClient: new TablesAPIDataClient(), queryTablesTab: fakeQueryTablesTab, tableEntityListViewModel: fakeTableEntityListViewModel, cassandraApiClient: fakeCassandraApiClient, + selectedEntity: fakeSelectedItem, + reloadEntities: () => "{}", }; it("should render Default properly", () => { @@ -29,13 +32,13 @@ describe("Excute Edit Table Entity Pane", () => { it("initially display 4 input field, 2 properties and 1 entity values", () => { const wrapper = mount(); - expect(wrapper.find("input[type='text']")).toHaveLength(0); + expect(wrapper.find("input[type='text']")).toHaveLength(1); }); it("add a new entity row", () => { const wrapper = mount(); wrapper.find(".addButtonEntiy").last().simulate("click"); - expect(wrapper.find("input[type='text']")).toHaveLength(1); + expect(wrapper.find("input[type='text']")).toHaveLength(2); }); it("remove a entity field", () => { @@ -43,6 +46,6 @@ describe("Excute Edit Table Entity Pane", () => { // Since default entity row doesn't have delete option, so added row then delete for test cases. wrapper.find(".addButtonEntiy").last().simulate("click"); wrapper.find("#deleteEntity").last().simulate("click"); - expect(wrapper.find("input[type='text']")).toHaveLength(0); + expect(wrapper.find("input[type='text']")).toHaveLength(1); }); }); diff --git a/src/Explorer/Panes/Tables/EditTableEntityPanel.tsx b/src/Explorer/Panes/Tables/EditTableEntityPanel.tsx index 2ab3dfd02..7adb9e9ca 100644 --- a/src/Explorer/Panes/Tables/EditTableEntityPanel.tsx +++ b/src/Explorer/Panes/Tables/EditTableEntityPanel.tsx @@ -81,15 +81,8 @@ export const EditTableEntityPanel: FunctionComponent // eslint-disable-next-line @typescript-eslint/no-explicit-any let originalDocument: { [key: string]: any } = {}; // eslint-disable-next-line @typescript-eslint/no-explicit-any - // const entityAttribute: any = tableEntityListViewModel.selected(); - // const entityFormattedAttribute = constructDisplayedAttributes(entityAttribute[0]); const entityAttribute: any = selectedEntity; - console.log("🚀 ~ file: EditTableEntityPanel.tsx ~ line 86 ~ useEffect ~ entityAttribute", entityAttribute); - const entityFormattedAttribute = constructDisplayedAttributes(entityAttribute[0]); - console.log( - "🚀 ~ file: EditTableEntityPanel.tsx ~ line 88 ~ useEffect ~ entityFormattedAttribute", - entityFormattedAttribute - ); + const entityFormattedAttribute = constructDisplayedAttributes(entityAttribute && entityAttribute[0]); setEntities(entityFormattedAttribute); if (userContext.apiType === "Tables") { diff --git a/src/Explorer/Panes/Tables/TableQuerySelectPanel/__snapshots__/TableQuerySelectPanel.test.tsx.snap b/src/Explorer/Panes/Tables/TableQuerySelectPanel/__snapshots__/TableQuerySelectPanel.test.tsx.snap index d83b5a138..3d429db4a 100644 --- a/src/Explorer/Panes/Tables/TableQuerySelectPanel/__snapshots__/TableQuerySelectPanel.test.tsx.snap +++ b/src/Explorer/Panes/Tables/TableQuerySelectPanel/__snapshots__/TableQuerySelectPanel.test.tsx.snap @@ -647,14 +647,14 @@ exports[`Table query select Panel should render Default properly 1`] = `