Support Matrix 1.1 (drop legacy r0 versions) (#9819)
Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
parent
f9e79fd5d6
commit
180fcaa70f
32 changed files with 712 additions and 440 deletions
|
@ -42,7 +42,6 @@ describe("<EmailAddress/>", () => {
|
|||
const mockClient = getMockClientWithEventEmitter({
|
||||
getIdentityServerUrl: jest.fn().mockReturnValue("https://fake-identity-server"),
|
||||
generateClientSecret: jest.fn(),
|
||||
doesServerSupportSeparateAddAndBind: jest.fn(),
|
||||
requestEmailToken: jest.fn(),
|
||||
bindThreePid: jest.fn(),
|
||||
});
|
||||
|
@ -74,7 +73,6 @@ describe("<EmailAddress/>", () => {
|
|||
describe("Email verification share phase", () => {
|
||||
it("shows translated error message", async () => {
|
||||
render(<EmailAddress email={emailThreepidFixture} />);
|
||||
mockClient.doesServerSupportSeparateAddAndBind.mockResolvedValue(true);
|
||||
mockClient.requestEmailToken.mockRejectedValue(
|
||||
new MatrixError(
|
||||
{ errcode: "M_THREEPID_IN_USE", error: "Some fake MatrixError occured" },
|
||||
|
@ -94,7 +92,6 @@ describe("<EmailAddress/>", () => {
|
|||
// Start these tests out at the "Complete" phase
|
||||
render(<EmailAddress email={emailThreepidFixture} />);
|
||||
mockClient.requestEmailToken.mockResolvedValue({ sid: "123-fake-sid" } satisfies IRequestTokenResponse);
|
||||
mockClient.doesServerSupportSeparateAddAndBind.mockResolvedValue(true);
|
||||
fireEvent.click(screen.getByText("Share"));
|
||||
// Then wait for the completion screen to come up
|
||||
await screen.findByText("Complete");
|
||||
|
|
|
@ -15,38 +15,47 @@ limitations under the License.
|
|||
*/
|
||||
|
||||
import React from "react";
|
||||
import { render, screen } from "@testing-library/react";
|
||||
import { fireEvent, render, screen, waitFor } from "@testing-library/react";
|
||||
import { IThreepid, ThreepidMedium } from "matrix-js-sdk/src/@types/threepids";
|
||||
import userEvent from "@testing-library/user-event";
|
||||
import { mocked } from "jest-mock";
|
||||
|
||||
import PhoneNumbers, { PhoneNumber } from "../../../../../src/components/views/settings/discovery/PhoneNumbers";
|
||||
import { stubClient } from "../../../../test-utils";
|
||||
|
||||
const msisdn: IThreepid = {
|
||||
medium: ThreepidMedium.Phone,
|
||||
address: "+441111111111",
|
||||
address: "441111111111",
|
||||
validated_at: 12345,
|
||||
added_at: 12342,
|
||||
bound: false,
|
||||
};
|
||||
describe("<PhoneNumber/>", () => {
|
||||
it("should track props.msisdn.bound changes", async () => {
|
||||
const { rerender } = render(<PhoneNumber msisdn={msisdn} />);
|
||||
const { rerender } = render(<PhoneNumber msisdn={{ ...msisdn }} />);
|
||||
await screen.findByText("Share");
|
||||
|
||||
msisdn.bound = true;
|
||||
rerender(<PhoneNumber msisdn={{ ...msisdn }} />);
|
||||
rerender(<PhoneNumber msisdn={{ ...msisdn, bound: true }} />);
|
||||
await screen.findByText("Revoke");
|
||||
});
|
||||
});
|
||||
|
||||
const mockGetAccessToken = jest.fn().mockResolvedValue("$$getAccessToken");
|
||||
jest.mock("../../../../../src/IdentityAuthClient", () =>
|
||||
jest.fn().mockImplementation(() => ({
|
||||
getAccessToken: mockGetAccessToken,
|
||||
})),
|
||||
);
|
||||
|
||||
describe("<PhoneNumbers />", () => {
|
||||
it("should render a loader while loading", async () => {
|
||||
const { container } = render(<PhoneNumbers msisdns={[msisdn]} isLoading={true} />);
|
||||
const { container } = render(<PhoneNumbers msisdns={[{ ...msisdn }]} isLoading={true} />);
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("should render phone numbers", async () => {
|
||||
const { container } = render(<PhoneNumbers msisdns={[msisdn]} isLoading={false} />);
|
||||
const { container } = render(<PhoneNumbers msisdns={[{ ...msisdn }]} isLoading={false} />);
|
||||
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
@ -56,4 +65,37 @@ describe("<PhoneNumbers />", () => {
|
|||
|
||||
expect(container).toMatchSnapshot();
|
||||
});
|
||||
|
||||
it("should allow binding msisdn", async () => {
|
||||
const cli = stubClient();
|
||||
const { getByText, getByLabelText, asFragment } = render(
|
||||
<PhoneNumbers msisdns={[{ ...msisdn }]} isLoading={false} />,
|
||||
);
|
||||
|
||||
mocked(cli.requestMsisdnToken).mockResolvedValue({
|
||||
sid: "SID",
|
||||
msisdn: "+447900111222",
|
||||
submit_url: "https://server.url",
|
||||
success: true,
|
||||
intl_fmt: "no-clue",
|
||||
});
|
||||
|
||||
fireEvent.click(getByText("Share"));
|
||||
await waitFor(() =>
|
||||
expect(cli.requestMsisdnToken).toHaveBeenCalledWith(
|
||||
null,
|
||||
"+441111111111",
|
||||
"t35tcl1Ent5ECr3T",
|
||||
1,
|
||||
undefined,
|
||||
"$$getAccessToken",
|
||||
),
|
||||
);
|
||||
expect(asFragment()).toMatchSnapshot();
|
||||
|
||||
const verificationCodeField = getByLabelText("Verification code");
|
||||
await userEvent.type(verificationCodeField, "123666{Enter}");
|
||||
|
||||
expect(cli.submitMsisdnToken).toHaveBeenCalledWith("SID", "t35tcl1Ent5ECr3T", "123666", "$$getAccessToken");
|
||||
});
|
||||
});
|
||||
|
|
|
@ -1,5 +1,67 @@
|
|||
// Jest Snapshot v1, https://goo.gl/fbAQLP
|
||||
|
||||
exports[`<PhoneNumbers /> should allow binding msisdn 1`] = `
|
||||
<DocumentFragment>
|
||||
<div
|
||||
class="mx_SettingsSubsection"
|
||||
data-testid="mx_DiscoveryPhoneNumbers"
|
||||
>
|
||||
<div
|
||||
class="mx_SettingsSubsectionHeading"
|
||||
>
|
||||
<h3
|
||||
class="mx_Heading_h4 mx_SettingsSubsectionHeading_heading"
|
||||
>
|
||||
Phone numbers
|
||||
</h3>
|
||||
</div>
|
||||
<div
|
||||
class="mx_SettingsSubsection_content mx_SettingsSubsection_contentStretch"
|
||||
>
|
||||
<div
|
||||
class="mx_GeneralUserSettingsTab_section--discovery_existing"
|
||||
>
|
||||
<span
|
||||
class="mx_GeneralUserSettingsTab_section--discovery_existing_address"
|
||||
>
|
||||
+441111111111
|
||||
</span>
|
||||
<span
|
||||
class="mx_GeneralUserSettingsTab_section--discovery_existing_verification"
|
||||
>
|
||||
<span>
|
||||
Please enter verification code sent via text.
|
||||
<br />
|
||||
</span>
|
||||
<form
|
||||
autocomplete="off"
|
||||
novalidate=""
|
||||
>
|
||||
<div
|
||||
class="mx_Field mx_Field_input"
|
||||
>
|
||||
<input
|
||||
autocomplete="off"
|
||||
id="mx_Field_1"
|
||||
label="Verification code"
|
||||
placeholder="Verification code"
|
||||
type="text"
|
||||
value=""
|
||||
/>
|
||||
<label
|
||||
for="mx_Field_1"
|
||||
>
|
||||
Verification code
|
||||
</label>
|
||||
</div>
|
||||
</form>
|
||||
</span>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</DocumentFragment>
|
||||
`;
|
||||
|
||||
exports[`<PhoneNumbers /> should handle no numbers 1`] = `
|
||||
<div>
|
||||
<div
|
||||
|
@ -85,14 +147,14 @@ exports[`<PhoneNumbers /> should render phone numbers 1`] = `
|
|||
class="mx_GeneralUserSettingsTab_section--discovery_existing_address"
|
||||
>
|
||||
+
|
||||
+441111111111
|
||||
441111111111
|
||||
</span>
|
||||
<div
|
||||
class="mx_AccessibleButton mx_GeneralUserSettingsTab_section--discovery_existing_button mx_AccessibleButton_hasKind mx_AccessibleButton_kind_danger_sm"
|
||||
class="mx_AccessibleButton mx_GeneralUserSettingsTab_section--discovery_existing_button mx_AccessibleButton_hasKind mx_AccessibleButton_kind_primary_sm"
|
||||
role="button"
|
||||
tabindex="0"
|
||||
>
|
||||
Revoke
|
||||
Share
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue