fix: use data-testid (#2487)

This commit is contained in:
Himself65 2023-05-22 17:36:52 +08:00 committed by GitHub
parent f01997f8ee
commit ef0a20b358
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
5 changed files with 10 additions and 9 deletions

View File

@ -109,7 +109,7 @@ const PageMenu = () => {
</MenuItem>
<Export />
<MoveToTrash
testId="editor-option-menu-delete"
data-testid="editor-option-menu-delete"
onItemClick={() => {
setOpenConfirm(true);
}}

View File

@ -47,7 +47,7 @@ export const OperationCell: React.FC<OperationCellProps> = ({
<>
{isPublic && (
<DisablePublicSharing
testId="disable-public-sharing"
data-testid="disable-public-sharing"
onItemClick={() => {
setOpenDisableShared(true);
}}
@ -71,7 +71,7 @@ export const OperationCell: React.FC<OperationCellProps> = ({
</MenuItem>
)}
<MoveToTrash
testId="move-to-trash"
data-testid="move-to-trash"
onItemClick={() => {
setOpen(true);
}}

View File

@ -26,13 +26,13 @@ const StyledMenuItem = styled(MenuItem)(({ theme }) => {
export const DisablePublicSharing = ({
onSelect,
onItemClick,
testId,
...props
}: CommonMenuItemProps) => {
const t = useAFFiNEI18N();
return (
<>
<StyledMenuItem
data-testid={testId}
{...props}
onClick={() => {
onItemClick?.();
onSelect?.();

View File

@ -8,14 +8,14 @@ import type { CommonMenuItemProps } from './types';
export const MoveToTrash = ({
onSelect,
onItemClick,
testId,
...props
}: CommonMenuItemProps) => {
const t = useAFFiNEI18N();
return (
<>
<MenuItem
data-testid={testId}
{...props}
onClick={() => {
onItemClick?.();
onSelect?.();

View File

@ -1,7 +1,8 @@
import type { HTMLAttributes } from 'react';
export type CommonMenuItemProps<SelectParams = undefined> = {
// onItemClick is triggered when the item is clicked, sometimes after item click, it still has some internal logic to run(like popover a new menu), so we need to have a separate callback for that
onItemClick?: () => void;
// onSelect is triggered when the item is selected, it's the final callback for the item click
onSelect?: (params?: SelectParams) => void;
testId?: string;
};
} & HTMLAttributes<HTMLButtonElement>;