From 523c95447ca38ec7cee786d22c608f0481d0b6cb Mon Sep 17 00:00:00 2001 From: William Grant Date: Mon, 20 May 2024 16:22:09 +1000 Subject: [PATCH] feat: added datatestids to avatarplaceholder and member placeholder --- .../avatar/AvatarPlaceHolder/AvatarPlaceHolder.tsx | 10 +++++++--- ts/components/icon/MemberAvatarPlaceHolder.tsx | 4 ++-- 2 files changed, 9 insertions(+), 5 deletions(-) diff --git a/ts/components/avatar/AvatarPlaceHolder/AvatarPlaceHolder.tsx b/ts/components/avatar/AvatarPlaceHolder/AvatarPlaceHolder.tsx index 6c8059fca..811567d53 100644 --- a/ts/components/avatar/AvatarPlaceHolder/AvatarPlaceHolder.tsx +++ b/ts/components/avatar/AvatarPlaceHolder/AvatarPlaceHolder.tsx @@ -8,6 +8,7 @@ type Props = { diameter: number; name: string; pubkey: string; + dataTestId?: string; }; const sha512FromPubkeyOneAtAtime = async (pubkey: string) => { @@ -20,6 +21,9 @@ const sha512FromPubkeyOneAtAtime = async (pubkey: string) => { }); }; +// for testing purposes only +export const AvatarPlaceHolderUtils = { sha512FromPubkeyOneAtAtime }; + // do not do this on every avatar, just cache the values so we can reuse them across the app // key is the pubkey, value is the hash const cachedHashes = new Map(); @@ -74,7 +78,7 @@ function useHashBasedOnPubkey(pubkey: string) { } export const AvatarPlaceHolder = (props: Props) => { - const { pubkey, diameter, name } = props; + const { pubkey, diameter, name, dataTestId } = props; const { hash, loading } = useHashBasedOnPubkey(pubkey); @@ -85,7 +89,7 @@ export const AvatarPlaceHolder = (props: Props) => { if (loading || !hash) { // return avatar placeholder circle - return ; + return ; } const initials = getInitials(name); @@ -97,7 +101,7 @@ export const AvatarPlaceHolder = (props: Props) => { const bgColor = avatarPlaceholderColors[bgColorIndex]; return ( - + { +export const MemberAvatarPlaceHolder = ({ dataTestId }: { dataTestId?: string }) => { return ( - +