From ff4350f44c01a903f0f92d20c8b2cfc77dad98f7 Mon Sep 17 00:00:00 2001 From: "D. Ror." Date: Tue, 27 Aug 2024 09:34:20 -0400 Subject: [PATCH] Add data-testid, aria-label to general buttons, dialogs (#3299) --- src/components/AppBar/NavigationButtons.tsx | 1 + src/components/Buttons/CloseButton.tsx | 6 +++++- .../Buttons/DeleteButtonWithDialog.tsx | 2 ++ src/components/Buttons/FileInputButton.tsx | 2 +- src/components/Buttons/FlagButton.tsx | 8 ++++++-- .../Buttons/IconButtonWithTooltip.tsx | 5 ++++- src/components/Buttons/NoteButton.tsx | 5 ++++- src/components/Buttons/PartOfSpeechButton.tsx | 2 ++ src/components/Buttons/UndoButton.tsx | 5 ++++- .../EntryCellComponents/DeleteEntry.tsx | 3 +++ src/components/Dialogs/ButtonConfirmation.tsx | 15 ++++++++++++--- .../Dialogs/CancelConfirmDialog.tsx | 11 ++++++++++- .../Dialogs/DeleteEditTextDialog.tsx | 19 +++++++++++++++++-- src/components/Dialogs/EditTextDialog.tsx | 11 ++++++++++- src/components/Dialogs/RecordAudioDialog.tsx | 8 +++++++- src/components/Dialogs/SubmitTextDialog.tsx | 11 ++++++++++- src/components/Dialogs/UploadImageDialog.tsx | 8 +++++++- src/components/Dialogs/ViewImageDialog.tsx | 14 +++++++++++--- src/components/GoalTimeline/GoalList.tsx | 2 +- src/components/LandingPage/LandingButtons.tsx | 11 +++++++---- src/components/ProjectExport/ExportButton.tsx | 2 +- 21 files changed, 125 insertions(+), 26 deletions(-) diff --git a/src/components/AppBar/NavigationButtons.tsx b/src/components/AppBar/NavigationButtons.tsx index e7fa37d740..39c5765840 100644 --- a/src/components/AppBar/NavigationButtons.tsx +++ b/src/components/AppBar/NavigationButtons.tsx @@ -74,6 +74,7 @@ function NavButton(props: NavButtonProps): ReactElement { return ( diff --git a/src/components/DataEntry/DataEntryTable/EntryCellComponents/DeleteEntry.tsx b/src/components/DataEntry/DataEntryTable/EntryCellComponents/DeleteEntry.tsx index 6b769482f2..49a3963ec7 100644 --- a/src/components/DataEntry/DataEntryTable/EntryCellComponents/DeleteEntry.tsx +++ b/src/components/DataEntry/DataEntryTable/EntryCellComponents/DeleteEntry.tsx @@ -8,6 +8,7 @@ import { CancelConfirmDialog } from "components/Dialogs"; interface DeleteEntryProps { removeEntry: () => void; buttonId: string; + buttonLabel?: string; // confirmId is the translation id for the text of the delete confirmation popup; // if no confirmId is specified, then there is no popup // and deletion will happen when the button is pressed @@ -34,6 +35,8 @@ export default function DeleteEntry(props: DeleteEntryProps): ReactElement { <> void | Promise; buttonIdClose?: string; buttonIdConfirm?: string; + buttonLabelClose?: string; + buttonLabelConfirm?: string; } /** @@ -52,16 +54,23 @@ export default function ButtonConfirmation( {t("buttons.confirm")} diff --git a/src/components/Dialogs/CancelConfirmDialog.tsx b/src/components/Dialogs/CancelConfirmDialog.tsx index a45585befa..5d3f427a27 100644 --- a/src/components/Dialogs/CancelConfirmDialog.tsx +++ b/src/components/Dialogs/CancelConfirmDialog.tsx @@ -18,6 +18,8 @@ interface CancelConfirmDialogProps { handleConfirm: () => Promise | void; buttonIdCancel?: string; buttonIdConfirm?: string; + buttonLabelCancel?: string; + buttonLabelConfirm?: string; } /** @@ -52,7 +54,9 @@ export default function CancelConfirmDialog( {t(props.buttonTextIdSave ?? "buttons.save")} diff --git a/src/components/Dialogs/EditTextDialog.tsx b/src/components/Dialogs/EditTextDialog.tsx index 0cbe009358..eae5a8c087 100644 --- a/src/components/Dialogs/EditTextDialog.tsx +++ b/src/components/Dialogs/EditTextDialog.tsx @@ -25,6 +25,7 @@ interface EditTextDialogProps { close: () => void; updateText: (newText: string) => void | Promise; buttonIdCancel?: string; + buttonIdClear?: string; buttonIdConfirm?: string; buttonTextIdCancel?: string; buttonTextIdConfirm?: string; @@ -73,7 +74,12 @@ export default function EditTextDialog( const endAdornment = ( - setText("")} size="large"> + setText("")} + size="large" + > @@ -91,6 +97,7 @@ export default function EditTextDialog( setText(event.target.value)} onKeyPress={confirmIfEnter} @@ -103,6 +110,7 @@ export default function EditTextDialog( onClick={onCancel} variant="outlined" color="primary" + data-testid={props.buttonIdCancel} id={props.buttonIdCancel} > {t(props.buttonTextIdCancel ?? "buttons.cancel")} @@ -111,6 +119,7 @@ export default function EditTextDialog( onClick={onConfirm} variant="outlined" color="primary" + data-testid={props.buttonIdConfirm} id={props.buttonIdConfirm} > {t(props.buttonTextIdConfirm ?? "buttons.confirm")} diff --git a/src/components/Dialogs/RecordAudioDialog.tsx b/src/components/Dialogs/RecordAudioDialog.tsx index 218ab759ce..a8e118a226 100644 --- a/src/components/Dialogs/RecordAudioDialog.tsx +++ b/src/components/Dialogs/RecordAudioDialog.tsx @@ -7,6 +7,8 @@ import AudioRecorder from "components/Pronunciations/AudioRecorder"; interface RecordAudioDialogProps { audioId: string; + buttonIdClose?: string; + buttonLabelClose?: string; close: () => void; open: boolean; titleId: string; @@ -23,7 +25,11 @@ export default function RecordAudioDialog( {t(props.titleId)} - + void; submitText: (newText: string) => void | Promise; buttonIdCancel?: string; + buttonIdClear?: string; buttonIdConfirm?: string; buttonTextIdCancel?: string; buttonTextIdConfirm?: string; @@ -62,7 +63,12 @@ export default function SubmitTextDialog( const endAdornment = ( - setText("")} size="large"> + setText("")} + size="large" + > @@ -80,6 +86,7 @@ export default function SubmitTextDialog( setText(event.target.value)} onKeyPress={confirmIfEnter} @@ -92,6 +99,7 @@ export default function SubmitTextDialog( onClick={onCancel} variant="outlined" color="primary" + data-testid={props.buttonIdCancel} id={props.buttonIdCancel} > {t(props.buttonTextIdCancel ?? "buttons.cancel")} @@ -100,6 +108,7 @@ export default function SubmitTextDialog( onClick={onConfirm} variant="outlined" color="primary" + data-testid={props.buttonIdConfirm} id={props.buttonIdConfirm} > {t(props.buttonTextIdConfirm ?? "buttons.confirm")} diff --git a/src/components/Dialogs/UploadImageDialog.tsx b/src/components/Dialogs/UploadImageDialog.tsx index ee928170cd..a9f59bee7d 100644 --- a/src/components/Dialogs/UploadImageDialog.tsx +++ b/src/components/Dialogs/UploadImageDialog.tsx @@ -6,6 +6,8 @@ import { CloseButton } from "components/Buttons"; import UploadImage from "components/Dialogs/UploadImage"; interface UploadImageDialogProps { + buttonIdClose?: string; + buttonLabelClose?: string; close: () => void; open: boolean; titleId: string; @@ -22,7 +24,11 @@ export default function UploadImageDialog( {t(props.titleId)} - + void; - deleteButtonId?: string; + buttonIdClose?: string; + buttonIdDelete?: string; + buttonLabelClose?: string; + buttonLabelDelete?: string; deleteImage?: () => void | Promise; deleteTextId?: string; imgSrc: string; @@ -28,14 +31,19 @@ export default function ViewImageDialog( {props.title} - + diff --git a/src/components/GoalTimeline/GoalList.tsx b/src/components/GoalTimeline/GoalList.tsx index 6817aef2a5..6108a53bb2 100644 --- a/src/components/GoalTimeline/GoalList.tsx +++ b/src/components/GoalTimeline/GoalList.tsx @@ -101,7 +101,7 @@ function buttonStyle(orientation: Orientation, size: number): CSSProperties { } interface GoalTileProps { - buttonProps?: ButtonProps; + buttonProps?: ButtonProps & { "data-testid"?: string }; goal?: Goal; orientation: Orientation; size: number; diff --git a/src/components/LandingPage/LandingButtons.tsx b/src/components/LandingPage/LandingButtons.tsx index 5295d8c34e..2ee53c862b 100644 --- a/src/components/LandingPage/LandingButtons.tsx +++ b/src/components/LandingPage/LandingButtons.tsx @@ -67,11 +67,12 @@ export function SignUpButton(props: SignUpButtonProps): ReactElement { } interface LandingButtonProps { - onClick: () => void; - textId: string; buttonId: string; + buttonLabel?: string; filled?: boolean; icon?: ReactElement; + onClick: () => void; + textId: string; } /** Button for the Landing Page. (Prop `icon` overrides `textId`.) */ @@ -80,14 +81,16 @@ function LandingButton(props: LandingButtonProps): ReactElement { return (