From 86e366150803d6002665680f150cde797f92bae7 Mon Sep 17 00:00:00 2001 From: lethemanh Date: Tue, 10 Dec 2024 21:59:55 +0700 Subject: [PATCH] Add more test id to elements based on test case e2e --- .../frontend/src/app/atoms/avatar/index.tsx | 12 ++++--- .../frontend/src/app/atoms/button/button.tsx | 4 ++- .../app/atoms/input/input-checkbox-slider.tsx | 3 +- .../src/app/atoms/input/input-text.tsx | 7 ++-- .../src/app/components/buttons/button.jsx | 5 ++- .../pending-file-row.tsx | 6 +++- .../src/app/components/inputs/input.jsx | 4 ++- .../app/components/menus/menu-component.jsx | 13 +++---- .../search-popup/parts/drive-item-result.tsx | 3 +- .../search-popup/parts/result-context.tsx | 2 +- .../components/search-popup/search-input.tsx | 1 + .../components/search-popup/search-popup.tsx | 2 +- .../components/search-popup/tabs/drive.tsx | 2 +- .../app/components/uploads/upload-zone.tsx | 2 +- .../components/access-level-dropdown.tsx | 5 ++- .../views/client/body/drive/context-menu.tsx | 34 +++++++++++++++++++ .../body/drive/documents/document-row.tsx | 6 ++-- .../body/drive/documents/folder-row.tsx | 6 ++-- .../drive/modals/confirm-delete/index.tsx | 2 +- .../body/drive/modals/confirm-move/index.tsx | 2 +- .../body/drive/modals/confirm-trash/index.tsx | 2 +- .../client/body/drive/modals/create/index.tsx | 6 ++-- .../body/drive/modals/properties/index.tsx | 2 +- .../body/drive/modals/public-link/index.tsx | 2 ++ .../body/drive/modals/update-access/index.tsx | 2 +- .../update-access/internal-users-access.tsx | 2 +- .../client/body/drive/modals/upload/index.tsx | 2 +- .../body/drive/modals/versions/index.tsx | 2 +- .../client/body/drive/shared-files-table.tsx | 2 +- .../app/views/client/body/drive/shared.tsx | 4 ++- .../src/app/views/client/common/account.tsx | 5 +++ .../src/app/views/client/common/app-grid.tsx | 3 +- .../app/views/client/common/disk-usage.tsx | 12 +++---- .../src/app/views/client/side-bar/actions.tsx | 4 +-- .../src/app/views/client/side-bar/index.tsx | 4 +++ .../app/views/client/viewer/drive-preview.tsx | 8 ++--- 36 files changed, 128 insertions(+), 55 deletions(-) diff --git a/tdrive/frontend/src/app/atoms/avatar/index.tsx b/tdrive/frontend/src/app/atoms/avatar/index.tsx index a8a09efa..961370e9 100644 --- a/tdrive/frontend/src/app/atoms/avatar/index.tsx +++ b/tdrive/frontend/src/app/atoms/avatar/index.tsx @@ -13,6 +13,7 @@ interface AvatarProps extends React.InputHTMLAttributes { icon?: JSX.Element | false; title?: string; nogradient?: boolean; + testClassId?: string; } const sizes = { xl: 24, lg: 14, md: 10, sm: 9, xs: 6 }; @@ -68,12 +69,13 @@ export default function Avatar(props: AvatarProps) { className += ' '; return (
{props.icon} @@ -83,18 +85,18 @@ export default function Avatar(props: AvatarProps) { if (props.avatar) { return ( -
+
{props.title}
); } return ( -
+
{letters.toUpperCase()}
); diff --git a/tdrive/frontend/src/app/atoms/button/button.tsx b/tdrive/frontend/src/app/atoms/button/button.tsx index 791fdfc8..e789e865 100644 --- a/tdrive/frontend/src/app/atoms/button/button.tsx +++ b/tdrive/frontend/src/app/atoms/button/button.tsx @@ -59,6 +59,8 @@ export const Button = (props: ButtonProps) => { else className = className + ' w-9 !p-0 justify-center'; } + const testId = props.testClassId ? `testid:${props.testClassId}` : ''; + return ( diff --git a/tdrive/frontend/src/app/components/search-popup/parts/result-context.tsx b/tdrive/frontend/src/app/components/search-popup/parts/result-context.tsx index 2376aa2e..f0452427 100644 --- a/tdrive/frontend/src/app/components/search-popup/parts/result-context.tsx +++ b/tdrive/frontend/src/app/components/search-popup/parts/result-context.tsx @@ -4,7 +4,7 @@ import { UserType } from '@features/users/types/user'; export default ({ user }: { user?: UserType }) => { return ( -
+
{!!user && <>{UsersService.getFullName(user)}}
); diff --git a/tdrive/frontend/src/app/components/search-popup/search-input.tsx b/tdrive/frontend/src/app/components/search-popup/search-input.tsx index b411bf55..cfedd404 100755 --- a/tdrive/frontend/src/app/components/search-popup/search-input.tsx +++ b/tdrive/frontend/src/app/components/search-popup/search-input.tsx @@ -38,6 +38,7 @@ export const SearchInput = () => { value={input.query} className={className} placeholder={Languages.t('scenes.app.mainview.quick_search_placeholder')} + testClassId="search-input-quick-search" /> )} /> diff --git a/tdrive/frontend/src/app/components/search-popup/search-popup.tsx b/tdrive/frontend/src/app/components/search-popup/search-popup.tsx index 0c28421a..dcd2cce7 100755 --- a/tdrive/frontend/src/app/components/search-popup/search-popup.tsx +++ b/tdrive/frontend/src/app/components/search-popup/search-popup.tsx @@ -8,7 +8,7 @@ export default () => { const { open, setOpen } = useSearchModal(); return ( - setOpen(false)} className="sm:w-[80vw] sm:max-w-4xl"> + setOpen(false)} className="sm:w-[80vw] sm:max-w-4xl testid:search-popup"> ); diff --git a/tdrive/frontend/src/app/components/search-popup/tabs/drive.tsx b/tdrive/frontend/src/app/components/search-popup/tabs/drive.tsx index 9301e939..61e5f3e8 100644 --- a/tdrive/frontend/src/app/components/search-popup/tabs/drive.tsx +++ b/tdrive/frontend/src/app/components/search-popup/tabs/drive.tsx @@ -16,7 +16,7 @@ export default () => { return (
{!!isRecent && ( - + {Languages.t('components.searchpopup.recent_files')} )} diff --git a/tdrive/frontend/src/app/components/uploads/upload-zone.tsx b/tdrive/frontend/src/app/components/uploads/upload-zone.tsx index ccb1115a..ba06bce8 100755 --- a/tdrive/frontend/src/app/components/uploads/upload-zone.tsx +++ b/tdrive/frontend/src/app/components/uploads/upload-zone.tsx @@ -191,7 +191,7 @@ export default class UploadZone extends React.Component {
node && (this.node = node)} style={this.props.style} - className={classNames('upload_drop_zone', this.props.className, `testid:${this.props.testClassId}`)} + className={classNames('upload_drop_zone', this.props.className, this.props.testClassId ? `testid:${this.props.testClassId}` : '')} onClick={() => { if (!this.props.disableClick) { this.open(); diff --git a/tdrive/frontend/src/app/views/client/body/drive/components/access-level-dropdown.tsx b/tdrive/frontend/src/app/views/client/body/drive/components/access-level-dropdown.tsx index 825cba64..3fe6fcfd 100644 --- a/tdrive/frontend/src/app/views/client/body/drive/components/access-level-dropdown.tsx +++ b/tdrive/frontend/src/app/views/client/body/drive/components/access-level-dropdown.tsx @@ -40,11 +40,14 @@ export const AccessLevelDropdown = ({ }) => { const createOption = (level: DriveFileAccessLevelOrRemove) => !hiddenLevels?.includes(level) && ; + + const testId = testClassId ? `testid:${testClassId}` : ''; + return (