diff --git a/app/client/src/components/ads/FilePicker.tsx b/app/client/src/components/ads/FilePicker.tsx index c8cdf64cd0..9ca21e2956 100644 --- a/app/client/src/components/ads/FilePicker.tsx +++ b/app/client/src/components/ads/FilePicker.tsx @@ -194,9 +194,10 @@ const FilePickerComponent = (props: FilePickerProps) => { function onDrop(monitor: DropTargetMonitor) { if (monitor) { const files = monitor.getItem().files; - if (files) { - handleFileUpload(files); + if (!files) { + return; } + handleFileUpload(files); } } @@ -221,10 +222,11 @@ const FilePickerComponent = (props: FilePickerProps) => { const file = files && files[0]; let fileSize = 0; - if (file) { - fileSize = Math.floor(file.size / 1024); - setFileInfo({ name: file.name, size: fileSize }); + if (!file) { + return; } + fileSize = Math.floor(file.size / 1024); + setFileInfo({ name: file.name, size: fileSize }); if (fileSize < 250) { if (bgRef.current) { diff --git a/app/client/src/pages/organization/General.tsx b/app/client/src/pages/organization/General.tsx index 01b30d0185..406eece61a 100644 --- a/app/client/src/pages/organization/General.tsx +++ b/app/client/src/pages/organization/General.tsx @@ -24,7 +24,7 @@ import FilePicker, { import { getIsFetchingApplications } from "selectors/applicationSelectors"; const InputLabelWrapper = styled.div` - width: 200px; + width: 150px; display: flex; align-items: center; `; @@ -54,6 +54,18 @@ const FilePickerLoader = styled.div` border-radius: 0; `; +// testing +export const Row = styled.div` + margin: 0; + padding: 0; + display: flex; +`; + +export const Col = styled.div` + margin: 0; + padding: 0; +`; + export function GeneralSettings() { const { orgId } = useParams<{ orgId: string }>(); const dispatch = useDispatch(); @@ -121,75 +133,103 @@ export function GeneralSettings() { return ( <> - General + + + General + + - - Organization Name - - {isFetchingApplications && ( - - )} - {!isFetchingApplications && ( - - )} + + + + Organization Name + + + + {isFetchingApplications && ( + + )} + {!isFetchingApplications && ( + + )} + + - - Upload Logo - - {isFetchingOrg && ( - - )} - {!isFetchingOrg && ( - - )} + + + + Upload Logo + + + + {isFetchingOrg && ( + + )} + {!isFetchingOrg && ( + + )} + + - - Website - - {isFetchingApplications && ( - - )} - {!isFetchingApplications && ( - - )} + + + + Website + + + + {isFetchingApplications && ( + + )} + {!isFetchingApplications && ( + + )} + + - - Email - - {isFetchingApplications && ( - - )} - {!isFetchingApplications && ( - - )} + + + + Email + + + + {isFetchingApplications && ( + + )} + {!isFetchingApplications && ( + + )} + + ); diff --git a/app/client/src/pages/organization/__tests__/OrganizationSettingsForm.test.tsx b/app/client/src/pages/organization/__tests__/OrganizationSettingsForm.test.tsx new file mode 100644 index 0000000000..3c7bbb03e8 --- /dev/null +++ b/app/client/src/pages/organization/__tests__/OrganizationSettingsForm.test.tsx @@ -0,0 +1,28 @@ +import React from "react"; +import { unmountComponentAtNode } from "react-dom"; +import { render } from "test/testUtils"; +import "@testing-library/jest-dom"; +import { GeneralSettings } from "../General"; + +let container: any = null; +describe("Application Settings", () => { + beforeEach(async () => { + // setup a DOM element as a render target + container = document.createElement("div"); + document.body.appendChild(container); + }); + it("checks that organization settings have correct styling", async (done) => { + const { findByText } = render(); + + const orgNameField = await findByText("Organization Name"); + expect(orgNameField.closest("div")).toHaveStyle({ width: "150px;" }); + + await done(); + }); + afterEach(() => { + // cleanup on exiting + unmountComponentAtNode(container); + container.remove(); + container = null; + }); +});