Browse Source

pass data-testid

Yuki Takei 2 years ago
parent
commit
7e538e831a
1 changed files with 7 additions and 3 deletions
  1. 7 3
      apps/app/src/components/Sidebar/Sidebar.tsx

+ 7 - 3
apps/app/src/components/Sidebar/Sidebar.tsx

@@ -143,15 +143,19 @@ const CollapsibleContainer = memo((props: CollapsibleContainerProps): JSX.Elemen
 
 
 });
 });
 
 
+// for data-* attributes
+type HTMLElementProps = JSX.IntrinsicElements &
+  Record<keyof JSX.IntrinsicElements, { [p: `data-${string}`]: string | number }>;
 
 
 type DrawableContainerProps = {
 type DrawableContainerProps = {
+  divProps?: HTMLElementProps['div'],
   className?: string,
   className?: string,
   children?: React.ReactNode,
   children?: React.ReactNode,
 }
 }
 
 
 const DrawableContainer = memo((props: DrawableContainerProps): JSX.Element => {
 const DrawableContainer = memo((props: DrawableContainerProps): JSX.Element => {
 
 
-  const { className, children } = props;
+  const { divProps, className, children } = props;
 
 
   const { data: isDrawerOpened, mutate } = useDrawerOpened();
   const { data: isDrawerOpened, mutate } = useDrawerOpened();
 
 
@@ -159,7 +163,7 @@ const DrawableContainer = memo((props: DrawableContainerProps): JSX.Element => {
 
 
   return (
   return (
     <>
     <>
-      <div className={`${className} ${openClass}`}>
+      <div {...divProps} className={`${className} ${openClass}`}>
         {children}
         {children}
       </div>
       </div>
       { isDrawerOpened && (
       { isDrawerOpened && (
@@ -201,7 +205,7 @@ export const Sidebar = (): JSX.Element => {
         </DrawerToggler>
         </DrawerToggler>
       ) }
       ) }
       { sidebarMode != null && !isDockMode() && <AppTitleOnSubnavigation /> }
       { sidebarMode != null && !isDockMode() && <AppTitleOnSubnavigation /> }
-      <DrawableContainer className={`${grwSidebarClass} ${modeClass} border-end flex-expand-vh-100`} data-testid="grw-sidebar">
+      <DrawableContainer className={`${grwSidebarClass} ${modeClass} border-end flex-expand-vh-100`} divProps={{ 'data-testid': 'grw-sidebar' }}>
         <ResizableContainer>
         <ResizableContainer>
           { sidebarMode != null && !isCollapsedMode() && <AppTitleOnSidebarHead /> }
           { sidebarMode != null && !isCollapsedMode() && <AppTitleOnSidebarHead /> }
           <SidebarHead />
           <SidebarHead />