Support Matrix 1.1 (drop legacy r0 versions) (#9819)

Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Travis Ralston 2023-08-14 02:25:13 -06:00 committed by GitHub
parent f9e79fd5d6
commit 180fcaa70f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
32 changed files with 712 additions and 440 deletions

View file

@ -0,0 +1,67 @@
/*
Copyright 2023 The Matrix.org Foundation C.I.C.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/
import React from "react";
import { render } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { mocked } from "jest-mock";
import PhoneNumbers from "../../../../../src/components/views/settings/account/PhoneNumbers";
import { stubClient } from "../../../../test-utils";
import SdkConfig from "../../../../../src/SdkConfig";
describe("<PhoneNumbers />", () => {
it("should allow a phone number to be added", async () => {
SdkConfig.add({
default_country_code: "GB",
});
const cli = stubClient();
const onMsisdnsChange = jest.fn();
const { asFragment, getByLabelText, getByText } = render(
<PhoneNumbers msisdns={[]} onMsisdnsChange={onMsisdnsChange} />,
);
mocked(cli.requestAdd3pidMsisdnToken).mockResolvedValue({
sid: "SID",
msisdn: "447900111222",
submit_url: "https://server.url",
success: true,
intl_fmt: "no-clue",
});
mocked(cli.submitMsisdnTokenOtherUrl).mockResolvedValue({ success: true });
mocked(cli.addThreePidOnly).mockResolvedValue({});
const phoneNumberField = getByLabelText("Phone Number");
await userEvent.type(phoneNumberField, "7900111222");
await userEvent.click(getByText("Add"));
expect(cli.requestAdd3pidMsisdnToken).toHaveBeenCalledWith("GB", "7900111222", "t35tcl1Ent5ECr3T", 1);
expect(asFragment()).toMatchSnapshot();
const verificationCodeField = getByLabelText("Verification code");
await userEvent.type(verificationCodeField, "123666");
await userEvent.click(getByText("Continue"));
expect(cli.submitMsisdnTokenOtherUrl).toHaveBeenCalledWith(
"https://server.url",
"SID",
"t35tcl1Ent5ECr3T",
"123666",
);
expect(onMsisdnsChange).toHaveBeenCalledWith([{ address: "447900111222", medium: "msisdn" }]);
});
});

View file

@ -0,0 +1,110 @@
// Jest Snapshot v1, https://goo.gl/fbAQLP
exports[`<PhoneNumbers /> should allow a phone number to be added 1`] = `
<DocumentFragment>
<form
autocomplete="off"
class="mx_PhoneNumbers_new"
novalidate=""
>
<div
class="mx_PhoneNumbers_input"
>
<div
class="mx_Field mx_Field_input mx_Field_labelAlwaysTopLeft"
>
<span
class="mx_Field_prefix"
>
<div
class="mx_Dropdown mx_PhoneNumbers_country mx_CountryDropdown mx_Dropdown_disabled"
>
<div
aria-describedby="mx_CountryDropdown_value"
aria-disabled="true"
aria-expanded="false"
aria-haspopup="listbox"
aria-label="Country Dropdown"
aria-owns="mx_CountryDropdown_input"
class="mx_AccessibleButton mx_Dropdown_input mx_no_textinput mx_AccessibleButton_disabled"
disabled=""
role="button"
tabindex="0"
>
<div
class="mx_Dropdown_option"
id="mx_CountryDropdown_value"
>
<span
class="mx_CountryDropdown_shortOption"
>
<div
class="mx_Dropdown_option_emoji"
>
🇬🇧
</div>
+44
</span>
</div>
<span
class="mx_Dropdown_arrow"
/>
</div>
</div>
</span>
<input
autocomplete="tel-national"
disabled=""
id="mx_Field_1"
label="Phone Number"
placeholder="Phone Number"
type="text"
value="7900111222"
/>
<label
for="mx_Field_1"
>
Phone Number
</label>
</div>
</div>
</form>
<div>
<div>
A text message has been sent to +447900111222. Please enter the verification code it contains.
<br />
</div>
<form
autocomplete="off"
novalidate=""
>
<div
class="mx_Field mx_Field_input"
>
<input
autocomplete="off"
id="mx_Field_2"
label="Verification code"
placeholder="Verification code"
type="text"
value=""
/>
<label
for="mx_Field_2"
>
Verification code
</label>
</div>
<div
aria-disabled="true"
class="mx_AccessibleButton mx_AccessibleButton_hasKind mx_AccessibleButton_kind_primary mx_AccessibleButton_disabled"
disabled=""
role="button"
tabindex="0"
>
Continue
</div>
</form>
</div>
</DocumentFragment>
`;