From 2b808797f5e73f6216871b8012ce6f069a06d1b3 Mon Sep 17 00:00:00 2001 From: devrk96 Date: Mon, 14 Sep 2020 22:28:54 +0530 Subject: [PATCH] Cypress selector added in component system (#534) * cypress-selector added in component system * unused import removed --- app/client/src/components/ads/AppIcon.tsx | 9 +++++++-- app/client/src/components/ads/Checkbox.tsx | 2 +- app/client/src/components/ads/ColorSelector.tsx | 2 +- app/client/src/components/ads/Dropdown.tsx | 6 +++++- app/client/src/components/ads/EditableText.tsx | 5 +++-- app/client/src/components/ads/IconSelector.tsx | 2 +- app/client/src/components/ads/Menu.tsx | 2 +- app/client/src/components/ads/MenuItem.tsx | 6 +++++- app/client/src/components/ads/Radio.tsx | 1 + app/client/src/components/ads/SearchInput.tsx | 1 + app/client/src/components/ads/TableDropdown.tsx | 1 + app/client/src/components/ads/Tabs.tsx | 9 ++++++--- app/client/src/components/ads/Text.tsx | 7 ++++--- app/client/src/components/ads/TextInput.tsx | 2 +- app/client/src/components/ads/Toggle.tsx | 1 + app/client/src/components/ads/Tooltip.tsx | 2 +- app/client/src/components/stories/Radio.stories.tsx | 8 +------- app/client/src/components/stories/Tooltip.stories.tsx | 1 - 18 files changed, 41 insertions(+), 26 deletions(-) diff --git a/app/client/src/components/ads/AppIcon.tsx b/app/client/src/components/ads/AppIcon.tsx index d3bee95975..82a321fdab 100644 --- a/app/client/src/components/ads/AppIcon.tsx +++ b/app/client/src/components/ads/AppIcon.tsx @@ -14,6 +14,7 @@ import { ReactComponent as FlightIcon } from "assets/icons/ads/flight.svg"; import styled from "styled-components"; import { Size } from "./Button"; +import { CommonComponentProps } from "./common"; export const AppIconCollection = [ "bag", @@ -80,7 +81,7 @@ const IconWrapper = styled.div` background-color: ${props => props.color}; `; -export type AppIconProps = { +export type AppIconProps = CommonComponentProps & { size: Size; color: string; name: AppIconName; @@ -132,7 +133,11 @@ const AppIcon = (props: AppIconProps) => { break; } return returnIcon ? ( - + {returnIcon} ) : null; diff --git a/app/client/src/components/ads/Checkbox.tsx b/app/client/src/components/ads/Checkbox.tsx index 8221668fa6..19e6400bec 100644 --- a/app/client/src/components/ads/Checkbox.tsx +++ b/app/client/src/components/ads/Checkbox.tsx @@ -82,7 +82,7 @@ const Checkbox = (props: CheckboxProps) => { }; return ( - + {props.label} { const [selected, setSelected] = useState(appColorPalette[0]); return ( - + {props.colorPalette && props.colorPalette.map((hex: string, index: number) => { return ( diff --git a/app/client/src/components/ads/Dropdown.tsx b/app/client/src/components/ads/Dropdown.tsx index d7e91c022f..fa98463c94 100644 --- a/app/client/src/components/ads/Dropdown.tsx +++ b/app/client/src/components/ads/Dropdown.tsx @@ -127,7 +127,11 @@ export default function Dropdown(props: DropdownProps) { }, []); return ( - setIsOpen(false)}> + setIsOpen(false)} + data-cy={props.cypressSelector} + > void; placeholder: string; @@ -246,6 +246,7 @@ export const EditableText = (props: EditableTextProps) => { return ( { }, [props.selectedIcon]); return ( - + {props.iconPalette && props.iconPalette.map((iconName: AppIconName, index: number) => { return ( diff --git a/app/client/src/components/ads/Menu.tsx b/app/client/src/components/ads/Menu.tsx index 8f89cd01d3..e53e1f4c37 100644 --- a/app/client/src/components/ads/Menu.tsx +++ b/app/client/src/components/ads/Menu.tsx @@ -28,7 +28,7 @@ const MenuOption = styled.div` const Menu = (props: MenuProps) => { return ( - + {props.target} {props.children.map((el, index) => { diff --git a/app/client/src/components/ads/MenuItem.tsx b/app/client/src/components/ads/MenuItem.tsx index 7107f2f04b..0c3e0de70c 100644 --- a/app/client/src/components/ads/MenuItem.tsx +++ b/app/client/src/components/ads/MenuItem.tsx @@ -51,7 +51,11 @@ const IconContainer = styled.div` function MenuItem(props: MenuItemProps) { return ( - + {props.icon ? : null} {props.text ? ( diff --git a/app/client/src/components/ads/Radio.tsx b/app/client/src/components/ads/Radio.tsx index 7486b67c82..d79b2b63bc 100644 --- a/app/client/src/components/ads/Radio.tsx +++ b/app/client/src/components/ads/Radio.tsx @@ -127,6 +127,7 @@ export default function RadioComponent(props: RadioProps) { return ( onChangeHandler(e.target.value)} > diff --git a/app/client/src/components/ads/SearchInput.tsx b/app/client/src/components/ads/SearchInput.tsx index eb1e04c775..c3b43c3030 100644 --- a/app/client/src/components/ads/SearchInput.tsx +++ b/app/client/src/components/ads/SearchInput.tsx @@ -115,6 +115,7 @@ const SearchInput = forwardRef( return ( { return ( props.theme.typography.h4.letterSpacing}px; `; -type TabbedViewComponentType = { +type TabbedViewComponentType = CommonComponentProps & { tabs: Array; selectedIndex?: number; onSelect?: Function; @@ -114,7 +114,10 @@ type TabbedViewComponentType = { export const TabComponent = (props: TabbedViewComponentType) => { return ( - + { diff --git a/app/client/src/components/ads/Text.tsx b/app/client/src/components/ads/Text.tsx index cd3cd83ed2..d3c3922349 100644 --- a/app/client/src/components/ads/Text.tsx +++ b/app/client/src/components/ads/Text.tsx @@ -1,5 +1,5 @@ import styled from "styled-components"; -import { ThemeProp, Classes } from "./common"; +import { ThemeProp, Classes, CommonComponentProps } from "./common"; export enum TextType { P1 = "p1", @@ -24,7 +24,7 @@ export enum FontWeight { NORMAL = "normal", } -export type TextProps = { +export type TextProps = CommonComponentProps & { type: TextType; underline?: boolean; italic?: boolean; @@ -52,8 +52,9 @@ const typeSelector = (props: TextProps & ThemeProp): string => { return color; }; -const Text = styled.span.attrs(() => ({ +const Text = styled.span.attrs((props: TextProps) => ({ className: Classes.TEXT, + "data-cy": props.cypressSelector, }))` text-decoration: ${props => (props.underline ? "underline" : "unset")}; font-style: ${props => (props.italic ? "italic" : "normal")}; diff --git a/app/client/src/components/ads/TextInput.tsx b/app/client/src/components/ads/TextInput.tsx index e4bb8b9cd4..60cf33319b 100644 --- a/app/client/src/components/ads/TextInput.tsx +++ b/app/client/src/components/ads/TextInput.tsx @@ -155,7 +155,7 @@ const TextInput = forwardRef( ); return ( - + ` const TooltipComponent = (props: TooltipProps) => { return ( - +