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> </MenuItem>
<Export /> <Export />
<MoveToTrash <MoveToTrash
testId="editor-option-menu-delete" data-testid="editor-option-menu-delete"
onItemClick={() => { onItemClick={() => {
setOpenConfirm(true); setOpenConfirm(true);
}} }}

View File

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

View File

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

View File

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

View File

@ -1,7 +1,8 @@
import type { HTMLAttributes } from 'react';
export type CommonMenuItemProps<SelectParams = undefined> = { 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 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; onItemClick?: () => void;
// onSelect is triggered when the item is selected, it's the final callback for the item click // onSelect is triggered when the item is selected, it's the final callback for the item click
onSelect?: (params?: SelectParams) => void; onSelect?: (params?: SelectParams) => void;
testId?: string; } & HTMLAttributes<HTMLButtonElement>;
};