Fixed account deletion test

pull/4500/head
zomars 2022-09-15 13:10:41 +01:00
parent 8da31cb293
commit 26e07bc2d8
3 changed files with 19 additions and 4 deletions

View File

@ -218,7 +218,11 @@ const ProfileView = () => {
{/* Delete account Dialog */}
<Dialog open={deleteAccountOpen} onOpenChange={setDeleteAccountOpen}>
<DialogTrigger asChild>
<Button color="destructive" className="mt-1 border-2" StartIcon={Icon.FiTrash2}>
<Button
color="destructive"
className="mt-1 border-2"
StartIcon={Icon.FiTrash2}
data-testid="delete-account">
{t("delete_account")}
</Button>
</DialogTrigger>
@ -227,6 +231,10 @@ const ProfileView = () => {
description={t("confirm_delete_account_modal")}
type="creation"
actionText={t("delete_my_account")}
actionProps={{
// @ts-expect-error data attributes aren't typed
"data-testid": "delete-account-confirm",
}}
Icon={Icon.FiAlertTriangle}
actionOnClick={(e) => e && onConfirmButton(e)}>
<>

View File

@ -65,6 +65,7 @@ export const Button = forwardRef<HTMLAnchorElement | HTMLButtonElement, ButtonPr
loading = false,
color = "primary",
size = "base",
type = "button",
StartIcon,
EndIcon,
shallow,
@ -82,6 +83,7 @@ export const Button = forwardRef<HTMLAnchorElement | HTMLButtonElement, ButtonPr
{
...passThroughProps,
disabled,
type: !isLink ? type : undefined,
ref: forwardedRef,
className: classNames(
// base styles independent what type of button it is

View File

@ -73,10 +73,11 @@ type DialogContentProps = React.ComponentProps<typeof DialogPrimitive["Content"]
useOwnActionButtons?: boolean;
actionOnClick?: (e: Event | React.MouseEvent<HTMLElement, MouseEvent>) => void;
actionOnClose?: () => void;
actionProps?: React.ComponentProps<typeof Button>;
};
export const DialogContent = React.forwardRef<HTMLDivElement, DialogContentProps>(
({ children, Icon, ...props }, forwardedRef) => (
({ children, Icon, actionProps, ...props }, forwardedRef) => (
<DialogPrimitive.Portal>
<DialogPrimitive.Overlay className="fadeIn fixed inset-0 z-40 bg-gray-500 bg-opacity-75 transition-opacity" />
{/*zIndex one less than Toast */}
@ -125,11 +126,15 @@ export const DialogContent = React.forwardRef<HTMLDivElement, DialogContentProps
</Button>
</DialogClose>
{props.actionOnClick ? (
<Button color="primary" disabled={props.actionDisabled} onClick={props.actionOnClick}>
<Button
color="primary"
disabled={props.actionDisabled}
onClick={props.actionOnClick}
{...actionProps}>
{props.actionText}
</Button>
) : (
<Button color="primary" type="submit" disabled={props.actionDisabled}>
<Button color="primary" type="submit" disabled={props.actionDisabled} {...actionProps}>
{props.actionText}
</Button>
)}