* add row colums styling to organisation settings fields * add tests to make sure the grid layout is rendered * added margin to make spacing look similar to before * remove negative margin and reduce width * added jest tests to make sure component mounts and that it has correct styles * revert unnecessary changes related to cypress tests * added strict checking for null to avoid ts errors * use early returns on file empty Co-authored-by: Hetu Nandu <hetunandu@gmail.com> * use early returns on file empty Co-authored-by: Hetu Nandu <hetunandu@gmail.com> * fixed typo * added findbytext for sync call * removed unused imports Co-authored-by: Hetu Nandu <hetunandu@gmail.com>
This commit is contained in:
parent
41e44eed30
commit
c37adc0a4d
|
|
@ -194,9 +194,10 @@ const FilePickerComponent = (props: FilePickerProps) => {
|
||||||
function onDrop(monitor: DropTargetMonitor) {
|
function onDrop(monitor: DropTargetMonitor) {
|
||||||
if (monitor) {
|
if (monitor) {
|
||||||
const files = monitor.getItem().files;
|
const files = monitor.getItem().files;
|
||||||
if (files) {
|
if (!files) {
|
||||||
handleFileUpload(files);
|
return;
|
||||||
}
|
}
|
||||||
|
handleFileUpload(files);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
@ -221,10 +222,11 @@ const FilePickerComponent = (props: FilePickerProps) => {
|
||||||
const file = files && files[0];
|
const file = files && files[0];
|
||||||
let fileSize = 0;
|
let fileSize = 0;
|
||||||
|
|
||||||
if (file) {
|
if (!file) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
fileSize = Math.floor(file.size / 1024);
|
fileSize = Math.floor(file.size / 1024);
|
||||||
setFileInfo({ name: file.name, size: fileSize });
|
setFileInfo({ name: file.name, size: fileSize });
|
||||||
}
|
|
||||||
|
|
||||||
if (fileSize < 250) {
|
if (fileSize < 250) {
|
||||||
if (bgRef.current) {
|
if (bgRef.current) {
|
||||||
|
|
|
||||||
|
|
@ -24,7 +24,7 @@ import FilePicker, {
|
||||||
import { getIsFetchingApplications } from "selectors/applicationSelectors";
|
import { getIsFetchingApplications } from "selectors/applicationSelectors";
|
||||||
|
|
||||||
const InputLabelWrapper = styled.div`
|
const InputLabelWrapper = styled.div`
|
||||||
width: 200px;
|
width: 150px;
|
||||||
display: flex;
|
display: flex;
|
||||||
align-items: center;
|
align-items: center;
|
||||||
`;
|
`;
|
||||||
|
|
@ -54,6 +54,18 @@ const FilePickerLoader = styled.div`
|
||||||
border-radius: 0;
|
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() {
|
export function GeneralSettings() {
|
||||||
const { orgId } = useParams<{ orgId: string }>();
|
const { orgId } = useParams<{ orgId: string }>();
|
||||||
const dispatch = useDispatch();
|
const dispatch = useDispatch();
|
||||||
|
|
@ -121,11 +133,19 @@ export function GeneralSettings() {
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
<SettingsHeading type={TextType.H2}>General</SettingsHeading>
|
<SettingsHeading type={TextType.H2}>
|
||||||
|
<Row>
|
||||||
|
<Col>General</Col>
|
||||||
|
</Row>
|
||||||
|
</SettingsHeading>
|
||||||
<SettingWrapper>
|
<SettingWrapper>
|
||||||
|
<Row>
|
||||||
|
<Col>
|
||||||
<InputLabelWrapper>
|
<InputLabelWrapper>
|
||||||
<Text type={TextType.H4}>Organization Name</Text>
|
<Text type={TextType.H4}>Organization Name</Text>
|
||||||
</InputLabelWrapper>
|
</InputLabelWrapper>
|
||||||
|
</Col>
|
||||||
|
<Col>
|
||||||
{isFetchingApplications && (
|
{isFetchingApplications && (
|
||||||
<Loader className={Classes.SKELETON}></Loader>
|
<Loader className={Classes.SKELETON}></Loader>
|
||||||
)}
|
)}
|
||||||
|
|
@ -138,12 +158,18 @@ export function GeneralSettings() {
|
||||||
cypressSelector="t--org-name-input"
|
cypressSelector="t--org-name-input"
|
||||||
></TextInput>
|
></TextInput>
|
||||||
)}
|
)}
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
</SettingWrapper>
|
</SettingWrapper>
|
||||||
|
|
||||||
<SettingWrapper>
|
<SettingWrapper>
|
||||||
|
<Row className="t--organization-settings-filepicker">
|
||||||
|
<Col>
|
||||||
<InputLabelWrapper>
|
<InputLabelWrapper>
|
||||||
<Text type={TextType.H4}>Upload Logo</Text>
|
<Text type={TextType.H4}>Upload Logo</Text>
|
||||||
</InputLabelWrapper>
|
</InputLabelWrapper>
|
||||||
|
</Col>
|
||||||
|
<Col>
|
||||||
{isFetchingOrg && (
|
{isFetchingOrg && (
|
||||||
<FilePickerLoader className={Classes.SKELETON}></FilePickerLoader>
|
<FilePickerLoader className={Classes.SKELETON}></FilePickerLoader>
|
||||||
)}
|
)}
|
||||||
|
|
@ -155,12 +181,18 @@ export function GeneralSettings() {
|
||||||
logoUploadError={logoUploadError.message}
|
logoUploadError={logoUploadError.message}
|
||||||
/>
|
/>
|
||||||
)}
|
)}
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
</SettingWrapper>
|
</SettingWrapper>
|
||||||
|
|
||||||
<SettingWrapper>
|
<SettingWrapper>
|
||||||
|
<Row>
|
||||||
|
<Col>
|
||||||
<InputLabelWrapper>
|
<InputLabelWrapper>
|
||||||
<Text type={TextType.H4}>Website</Text>
|
<Text type={TextType.H4}>Website</Text>
|
||||||
</InputLabelWrapper>
|
</InputLabelWrapper>
|
||||||
|
</Col>
|
||||||
|
<Col>
|
||||||
{isFetchingApplications && (
|
{isFetchingApplications && (
|
||||||
<Loader className={Classes.SKELETON}></Loader>
|
<Loader className={Classes.SKELETON}></Loader>
|
||||||
)}
|
)}
|
||||||
|
|
@ -172,12 +204,18 @@ export function GeneralSettings() {
|
||||||
cypressSelector="t--org-website-input"
|
cypressSelector="t--org-website-input"
|
||||||
></TextInput>
|
></TextInput>
|
||||||
)}
|
)}
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
</SettingWrapper>
|
</SettingWrapper>
|
||||||
|
|
||||||
<SettingWrapper>
|
<SettingWrapper>
|
||||||
|
<Row>
|
||||||
|
<Col>
|
||||||
<InputLabelWrapper>
|
<InputLabelWrapper>
|
||||||
<Text type={TextType.H4}>Email</Text>
|
<Text type={TextType.H4}>Email</Text>
|
||||||
</InputLabelWrapper>
|
</InputLabelWrapper>
|
||||||
|
</Col>
|
||||||
|
<Col>
|
||||||
{isFetchingApplications && (
|
{isFetchingApplications && (
|
||||||
<Loader className={Classes.SKELETON}></Loader>
|
<Loader className={Classes.SKELETON}></Loader>
|
||||||
)}
|
)}
|
||||||
|
|
@ -190,6 +228,8 @@ export function GeneralSettings() {
|
||||||
cypressSelector="t--org-email-input"
|
cypressSelector="t--org-email-input"
|
||||||
></TextInput>
|
></TextInput>
|
||||||
)}
|
)}
|
||||||
|
</Col>
|
||||||
|
</Row>
|
||||||
</SettingWrapper>
|
</SettingWrapper>
|
||||||
</>
|
</>
|
||||||
);
|
);
|
||||||
|
|
|
||||||
|
|
@ -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(<GeneralSettings />);
|
||||||
|
|
||||||
|
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;
|
||||||
|
});
|
||||||
|
});
|
||||||
Loading…
Reference in New Issue
Block a user