Skip to content
This repository was archived by the owner on Oct 22, 2024. It is now read-only.
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 15 additions & 6 deletions test/components/views/settings/AddRemoveThreepids-test.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only
Please see LICENSE files in the repository root for full details.
*/

import { render, screen } from "@testing-library/react";
import { render, screen, waitFor } from "@testing-library/react";
import { MatrixClient, ThreepidMedium } from "matrix-js-sdk/src/matrix";
import React from "react";
import userEvent from "@testing-library/user-event";
Expand Down Expand Up @@ -218,23 +218,32 @@ describe("AddRemoveThreepids", () => {
await userEvent.type(input, PHONE1_LOCALNUM);

const addButton = screen.getByRole("button", { name: "Add" });
await userEvent.click(addButton);
userEvent.click(addButton);

const continueButton = await screen.findByRole("button", { name: "Continue" });

await expect(continueButton).toHaveAttribute("aria-disabled", "true");

await expect(
await screen.findByText(
`A text message has been sent to +${PHONE1.address}. Please enter the verification code it contains.`,
),
).toBeInTheDocument();

expect(client.requestAdd3pidMsisdnToken).toHaveBeenCalledWith(
"GB",
PHONE1_LOCALNUM,
client.generateClientSecret(),
1,
);
const continueButton = screen.getByRole("button", { name: "Continue" });

expect(continueButton).toHaveAttribute("aria-disabled", "true");

const verificationInput = screen.getByRole("textbox", { name: "Verification code" });
await userEvent.type(verificationInput, "123456");

expect(continueButton).not.toHaveAttribute("aria-disabled", "true");
await userEvent.click(continueButton);
userEvent.click(continueButton);

await waitFor(() => expect(continueButton).toHaveAttribute("aria-disabled", "true"));

expect(client.addThreePidOnly).toHaveBeenCalledWith({
client_secret: client.generateClientSecret(),
Expand Down
Loading