Skip to content

Commit

Permalink
Changing data-testId props
Browse files Browse the repository at this point in the history
  • Loading branch information
stairaku committed Dec 23, 2024
1 parent 0b97e70 commit e552cf1
Show file tree
Hide file tree
Showing 19 changed files with 37 additions and 49 deletions.
22 changes: 9 additions & 13 deletions source/frontend/src/components/common/buttons/EditButton.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -7,26 +7,22 @@ interface IEditButtonProps {
onClick: () => void;
title?: string;
icon?: React.ReactNode;
dataTestId?: string | null;
'data-testId'?: string;
style?: CSSProperties | null;
}

export const EditButton: React.FunctionComponent<React.PropsWithChildren<IEditButtonProps>> = ({
onClick,
title,
icon,
dataTestId,
style,
}) => {
export const EditButton: React.FunctionComponent<
React.PropsWithChildren<IEditButtonProps>
> = props => {
return (
<StyledIconButton
variant="primary"
title={title ?? 'edit'}
onClick={onClick}
data-testid={dataTestId ?? 'edit-button'}
style={style}
title={props.title ?? 'edit'}
onClick={props.onClick}
data-testid={props['data-testId'] ?? 'edit-button'}
style={props.style}
>
{icon ?? <FaEdit size={22} />}
{props.icon ?? <FaEdit size={22} />}
</StyledIconButton>
);
};
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ interface IViewButtonProps extends ButtonProps {
onClick: () => void;
title?: string;
icon?: React.ReactNode;
dataTestId?: string | null;
'data-testId'?: string;
style?: CSSProperties | null;
}

Expand Down
2 changes: 1 addition & 1 deletion source/frontend/src/features/leases/add/RenewalSubForm.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -86,7 +86,7 @@ export const RenewalSubForm: React.FunctionComponent<IRenewalSubFormProps> = ({
</Col>
<Col xs="2" className="pt-2">
<RemoveButton
dataTestId={`renewal.${index}.remove-button`}
data-testId={`renewal.${index}.remove-button`}
onRemove={() => {
setModalContent({
...getDeleteModalProps(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ const UpdateAcquisitionOwnersSubForm: React.FC<{ isSubFile?: boolean }> = ({
<ButtonDiv>
<RemoveButton
label={isSubFile ? 'Remove Sub-interest' : 'Remove Owner'}
dataTestId={`owners[${index}]-remove-button`}
data-testId={`owners[${index}]-remove-button`}
onRemove={() => {
setRemoveIndex(index);
setShowRemoveModal(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export const UpdateAcquisitionTeamSubForm: React.FunctionComponent<
</Col>
<Col xs="auto" xl="2" className="pl-0 mt-2">
<RemoveButton
dataTestId={`team.${index}.remove-button`}
data-testId={`team.${index}.remove-button`}
onRemove={() => {
setRemoveIndex(index);
setShowRemoveMemberModal(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,15 @@ export const AgreementView: React.FunctionComponent<IAgreementViewProps> = ({
<>
<EditButton
title="Edit Agreement"
dataTestId={`agreements[${index}].edit-btn`}
data-testId={`agreements[${index}].edit-btn`}
onClick={() =>
history.push(`${match.url}/${agreement.agreementId}/update`)
}
icon={<FaEdit size={'2rem'} />}
/>
<RemoveIconButton
title="Delete Agreement"
dataTestId={`agreements[${index}].delete-btn`}
data-testId={`agreements[${index}].delete-btn`}
icon={<FaTrash size={'1.75rem'} />}
onRemove={() => {
setModalContent({
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ export const Form8PaymentItemsSubForm: React.FunctionComponent<IForm8PaymentItem
<label>Payment Item {index + 1}</label>
<RemoveIconButton
title="Delete Payment Item"
dataTestId={`paymentItems[${index}].delete-button`}
data-testId={`paymentItems[${index}].delete-button`}
onRemove={() => {
setModalContent({
...getDeleteModalProps(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,13 +63,13 @@ export const ExpropriationForm8Details: React.FunctionComponent<
<>
<EditButton
title="Edit form 8"
dataTestId={`form8[${form8Index}].edit-form8`}
data-testId={`form8[${form8Index}].edit-form8`}
onClick={() => history.push(`${match.url}/${form8.id}`)}
style={{ float: 'right' }}
/>
<RemoveIconButton
title="Delete Form 8"
dataTestId={`form8[${form8Index}].delete-form8`}
data-testId={`form8[${form8Index}].delete-form8`}
onRemove={() => {
setModalContent({
...getDeleteModalProps(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ export function createCompensationTableColumns(
<StyledDiv className="no-gutters">
{hasClaim(Claims.COMPENSATION_REQUISITION_VIEW) && (
<ViewButton
dataTestId={`compensation-view-${cellProps.row.id}`}
data-testId={`compensation-view-${cellProps.row.id}`}
title="Compensation view details"
id={`compensation-view-${cellProps.row.id}`}
onClick={() => cellProps.row.original.id && onShow(cellProps.row.original.id)}
Expand All @@ -108,7 +108,7 @@ export function createCompensationTableColumns(
canEditDetails(cellProps.row.original.isDraft) && (
<RemoveIconButton
id={`compensation-delete-${cellProps.row.id}`}
dataTestId={`compensation-delete-${cellProps.row.id}`}
data-testId={`compensation-delete-${cellProps.row.id}`}
onRemove={() => cellProps.row.original.id && onDelete(cellProps.row.original.id)}
title="Delete Compensation"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export const FinancialActivitiesSubForm: React.FunctionComponent<
<label>Activity {index + 1}</label>
<RemoveIconButton
title="Delete Financial Activity"
dataTestId={`activity[${index}].delete-button`}
data-testId={`activity[${index}].delete-button`}
onRemove={() => {
setRowToDelete(index);
setShowModal(true);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ const DispositionTeamSubForm: React.FunctionComponent<React.PropsWithChildren<un
</Col>
<Col xs="auto" xl="2" className="pl-0 mt-2">
<RemoveButton
dataTestId={`team.${index}.remove-button`}
data-testId={`team.${index}.remove-button`}
onRemove={() => {
setModalContent({
...getDeleteModalProps(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,7 @@ const OffersAndSaleView: React.FunctionComponent<IOffersAndSaleViewProps> = ({
{keycloak.hasClaim(Claims.DISPOSITION_EDIT) && canEditDetails() && (
<EditButton
title="Edit Appraisal"
dataTestId={`appraisal-edit-btn`}
data-testId={`appraisal-edit-btn`}
onClick={() => {
history.push(`${match.url}/appraisal/update`);
}}
Expand Down Expand Up @@ -166,7 +166,7 @@ const OffersAndSaleView: React.FunctionComponent<IOffersAndSaleViewProps> = ({
{keycloak.hasClaim(Claims.DISPOSITION_EDIT) && canEditDetails() && (
<EditButton
title="Edit Sale"
dataTestId={`sale-edit-btn`}
data-testId={`sale-edit-btn`}
onClick={() => {
history.push(`${match.url}/sale/update`);
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,12 @@ const DispositionOfferDetails: React.FunctionComponent<IDispositionOfferDetailsP
<>
<EditButton
title="Edit Offer"
dataTestId={`Offer[${index}].edit-btn`}
data-testId={`Offer[${index}].edit-btn`}
onClick={() => history.push(`${match.url}/offers/${dispositionOffer.id}/update`)}
/>
<RemoveIconButton
title="Delete Offer"
dataTestId={`Offer[${index}].delete-btn`}
data-testId={`Offer[${index}].delete-btn`}
onRemove={() => {
setModalContent({
...getDeleteModalProps(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ const DispositionSalePurchaserSubForm: React.FunctionComponent<
<Col xs="auto" xl="2" className="pl-3 mt-2">
<RemoveIconButton
title="Remove Purchaser"
dataTestId={`dispositionPurchasers.${index}.remove-button`}
data-testId={`dispositionPurchasers.${index}.remove-button`}
onRemove={() => {
setModalContent({
...getDeleteModalProps(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -108,7 +108,7 @@ export const ConsultationListView: React.FunctionComponent<IConsultationListView
<Col xs="auto" className="px-1">
<RemoveIconButton
title="Delete Consultation"
dataTestId={`consultations[${index}].delete-btn`}
data-testId={`consultations[${index}].delete-btn`}
onRemove={() => {
setModalContent({
...getDeleteModalProps(),
Expand All @@ -134,7 +134,7 @@ export const ConsultationListView: React.FunctionComponent<IConsultationListView
<StyledButtonContainer>
<EditButton
title="Edit Consultation"
dataTestId={`consultations[${index}].edit-btn`}
data-testId={`consultations[${index}].edit-btn`}
onClick={() => onEdit(consultation.id)}
/>
</StyledButtonContainer>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ export const UpdateHistoricalNumbersSubForm: React.FC<IUpdateHistoricalNumbersSu
</Col>
<Col xs="auto" xl="2" className="pl-0">
<RemoveButton
dataTestId={`historical-number-remove-button-${index}`}
data-testId={`historical-number-remove-button-${index}`}
onRemove={() => {
arrayHelpers.remove(index);
}}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -89,7 +89,7 @@ export function createTableColumns(
<StyledDiv>
{hasClaim(Claims.MANAGEMENT_VIEW) && (
<ViewButton
dataTestId={`activity-view-${activityRow.id}`}
data-testId={`activity-view-${activityRow.id}`}
onClick={() => activityRow?.id && onView(activityRow.activityId)}
id={`activity-view-${cellProps.row.id}`}
title="property-activity view details"
Expand All @@ -100,7 +100,7 @@ export function createTableColumns(
PropertyManagementActivityStatusTypes.NOTSTARTED ? (
<RemoveIconButton
id={`activity-delete-${cellProps.row.id}`}
dataTestId={`activity-delete-${activityRow.id}`}
data-testId={`activity-delete-${activityRow.id}`}
onRemove={() => activityRow.id && onDelete(activityRow.id)}
title="Delete"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -116,7 +116,7 @@ export function createContactTableColumns(
{hasClaim(Claims.PROPERTY_EDIT) && (
<RemoveIconButton
id={`contact-delete-${cellProps.row.id}`}
dataTestId={`contact-delete-${cellProps.row.id}`}
data-testId={`contact-delete-${cellProps.row.id}`}
onRemove={() => cellProps.row.original.id && onDelete(cellProps.row.original.id)}
title="Delete contact"
/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -509,9 +509,7 @@ exports[`Note Results Table > matches snapshot 1`] = `
>
<div
class="p-0 col-1"
>
</div>
/>
<div
class="p-0 col-1"
>
Expand Down Expand Up @@ -587,9 +585,7 @@ exports[`Note Results Table > matches snapshot 1`] = `
>
<div
class="p-0 col-1"
>
</div>
/>
<div
class="p-0 col-1"
>
Expand Down Expand Up @@ -665,9 +661,7 @@ exports[`Note Results Table > matches snapshot 1`] = `
>
<div
class="p-0 col-1"
>
</div>
/>
<div
class="p-0 col-1"
>
Expand Down Expand Up @@ -743,9 +737,7 @@ exports[`Note Results Table > matches snapshot 1`] = `
>
<div
class="p-0 col-1"
>
</div>
/>
<div
class="p-0 col-1"
>
Expand Down

0 comments on commit e552cf1

Please sign in to comment.