Port location unit tests from enzyme to react-testing-library (#10181)

* SmartMarker test to rtl

* LocationPicker to rtl

* LocationViewDialog to rtl

* LocationShareMenu to rtl

* use toBeDisabled assertion
This commit is contained in:
Kerry 2023-02-21 07:35:39 +13:00 committed by GitHub
parent a06163ee98
commit 3fafa4b58d
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
16 changed files with 290 additions and 613 deletions

View file

@ -29,7 +29,7 @@ interface Props {
export const EnableLiveShare: React.FC<Props> = ({ onSubmit }) => {
const [isEnabled, setEnabled] = useState(false);
return (
<div data-test-id="location-picker-enable-live-share" className="mx_EnableLiveShare">
<div data-testid="location-picker-enable-live-share" className="mx_EnableLiveShare">
<StyledLiveBeaconIcon className="mx_EnableLiveShare_icon" />
<Heading className="mx_EnableLiveShare_heading" size="h3">
{_t("Live location sharing")}
@ -43,13 +43,13 @@ export const EnableLiveShare: React.FC<Props> = ({ onSubmit }) => {
)}
</p>
<LabelledToggleSwitch
data-test-id="enable-live-share-toggle"
data-testid="enable-live-share-toggle"
value={isEnabled}
onChange={setEnabled}
label={_t("Enable live location sharing")}
/>
<AccessibleButton
data-test-id="enable-live-share-submit"
data-testid="enable-live-share-submit"
className="mx_EnableLiveShare_button"
element="button"
kind="primary"

View file

@ -62,7 +62,7 @@ const LiveDurationDropdown: React.FC<Props> = ({ timeout, onChange }) => {
return (
<Dropdown
id="live-duration"
data-test-id="live-duration-dropdown"
data-testid="live-duration-dropdown"
label={getLabel(timeout)}
value={timeout.toString()}
onOptionChange={onOptionChange}

View file

@ -231,7 +231,7 @@ class LocationPicker extends React.Component<ILocationPickerProps, IState> {
<LiveDurationDropdown onChange={this.onTimeoutChange} timeout={this.state.timeout} />
)}
<AccessibleButton
data-test-id="location-picker-submit-button"
data-testid="location-picker-submit-button"
type="submit"
element="button"
kind="primary"

View file

@ -33,7 +33,7 @@ export interface MapErrorProps {
export const MapError: React.FC<MapErrorProps> = ({ error, isMinimised, className, onFinished, onClick }) => (
<div
data-test-id="map-rendering-error"
data-testid="map-rendering-error"
className={classNames("mx_MapError", className, { mx_MapError_isMinimised: isMinimised })}
onClick={onClick}
>

View file

@ -19,6 +19,7 @@ import React from "react";
import AccessibleButton from "../elements/AccessibleButton";
import { Icon as BackIcon } from "../../../../res/img/element-icons/caret-left.svg";
import { Icon as CloseIcon } from "../../../../res/img/element-icons/cancel-rounded.svg";
import { _t } from "../../../languageHandler";
interface Props {
onCancel: () => void;
@ -32,7 +33,8 @@ const ShareDialogButtons: React.FC<Props> = ({ onBack, onCancel, displayBack })
{displayBack && (
<AccessibleButton
className="mx_ShareDialogButtons_button left"
data-test-id="share-dialog-buttons-back"
data-testid="share-dialog-buttons-back"
aria-label={_t("Back")}
onClick={onBack}
element="button"
>
@ -41,7 +43,8 @@ const ShareDialogButtons: React.FC<Props> = ({ onBack, onCancel, displayBack })
)}
<AccessibleButton
className="mx_ShareDialogButtons_button right"
data-test-id="share-dialog-buttons-cancel"
data-testid="share-dialog-buttons-cancel"
aria-label={_t("Close")}
onClick={onCancel}
element="button"
>