Skip to content

Commit

Permalink
Iterate
Browse files Browse the repository at this point in the history
Signed-off-by: Michael Telatynski <[email protected]>
  • Loading branch information
t3chguy committed Oct 18, 2024
1 parent 8bd3f5a commit 0f52667
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,9 @@

import React from "react";
import { MatrixClient } from "matrix-js-sdk/src/matrix";
import { render, screen } from "jest-matrix-react";
import { render, screen, act } from "jest-matrix-react";
import { waitFor } from "@testing-library/dom";
import userEvent from "@testing-library/user-event";
import { act } from "@testing-library/react-hooks/dom";

import NewRecoveryMethodDialog from "../../../../../src/async-components/views/dialogs/security/NewRecoveryMethodDialog";
import { createTestClient } from "../../../../test-utils";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,9 @@ describe("ExportE2eKeysDialog", () => {
const cli = createTestClient();
const onFinished = jest.fn();

const { container } = render(<ExportE2eKeysDialog matrixClient={cli} onFinished={onFinished} />);
render(<ExportE2eKeysDialog matrixClient={cli} onFinished={onFinished} />);
const input = screen.getByLabelText("Enter passphrase");
await userEvent.type(input, "password");
fireEvent.click(container.querySelector("[type=submit]")!);
await expect(screen.findByText("This is a top-10 common password")).resolves.toBeInTheDocument();

Check failure on line 41 in test/unit-tests/components/views/dialogs/security/ExportE2eKeysDialog-test.tsx

View workflow job for this annotation

GitHub Actions / Jest (2)

ExportE2eKeysDialog › should complain about weak passphrases

expect(received).resolves.toBeInTheDocument() Received promise rejected instead of resolved Rejected to value: [TestingLibraryElementError: Unable to find an element with the text: This is a top-10 common password. This could be because the text is broken up by multiple elements. In this case, you can provide a function for your text matcher to make your matcher more flexible.· Ignored nodes: comments, script, style <body> <div> <div data-focus-guard="true" style="width: 1px; height: 0px; padding: 0px; overflow: hidden; position: fixed; top: 1px; left: 1px;" tabindex="0" /> <div aria-labelledby="mx_BaseDialog_title" class="mx_exportE2eKeysDialog mx_Dialog_fixedWidth" data-focus-lock-disabled="false" role="dialog" > <div class="mx_Dialog_header" > <h1 class="mx_Heading_h3 mx_Dialog_title" id="mx_BaseDialog_title" > Export room keys </h1> </div> <form> <div class="mx_Dialog_content" > <p> This process allows you to export the keys for messages you have received in encrypted rooms to a local file. You will then be able to import the file into another Matrix client in the future, so that client will also be able to decrypt these messages. </p> <p> The exported file will allow anyone who can read it to decrypt any encrypted messages that you can see, so you should be careful to keep it secure. To help with this, you should enter a unique passphrase below, which will only be used to encrypt the exported data. It will only be possible to import the data by using the same passphrase. </p> <div class="error" /> <div class="mx_E2eKeysDialog_inputTable" > <div class="mx_E2eKeysDialog_inputRow" > <div class="mx_Field mx_Field_input mx_PassphraseField" > <input autocomplete="new-password" id="mx_Field_5" label="Enter passphrase" placeholder="Enter passphrase" type="password" value="password" /> <label for="mx_Field_5" > Enter passphrase </label> </div> </div> <div class="mx_E2eKeysDialog_inputRow" > <div class="mx_Field mx_Field_input" > <input autocomplete="new-password" id="mx_Field_6" label="Confirm passphrase" placeholder="Confirm passphrase" type="password" value="" /> <label for="mx_Field_6" > Confirm passphrase </label> </div> </div> </div> </div> <div class="mx_Dialog_buttons" > <input class="mx_Dialog_primary" type="submit" value="Export" /> <button> Cancel </button> </div> </form> <div aria-label="Close dialog" class="mx_AccessibleButton mx_Dialog_cancelButton" role="button" tabindex="0" /> </div> <div data-focus-guard="true" style="width: 1px; height: 0px; padding: 0px; overflow: hidden; position: fixed; top: 1px; left: 1px;" tabindex="0" /> </div> </body>· Ignored nodes: comments, script, style <body> <div> <div data-focus-guard="true" style="width: 1px; height: 0px; padding: 0px; overflow: hidden; position: fixed; top: 1px; left: 1px;" tabindex="0" /> <div aria-labelledby="mx_BaseDialog_title" class="mx_exportE2eK
});

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Please see LICENSE files in the repository root for full details.
*/

import React from "react";
import { render } from "jest-matrix-react";
import { render, waitFor } from "jest-matrix-react";
import { MatrixClient } from "matrix-js-sdk/src/matrix";
import { mocked } from "jest-mock";

Expand All @@ -28,7 +28,7 @@ describe("CryptographyPanel", () => {
mocked(client.getCrypto()!.getOwnDeviceKeys).mockResolvedValue({ ed25519: sessionKey, curve25519: "1234" });

// When we render the CryptographyPanel
const rendered = render(<CryptographyPanel />);
const rendered = render(<CryptographyPanel />, { legacyRoot: true });

// Then it displays info about the user's session
const codes = rendered.container.querySelectorAll("code");
Expand All @@ -39,8 +39,7 @@ describe("CryptographyPanel", () => {
expect(codes[1].innerHTML).toEqual("<strong>...</strong>");

// Then the actual key
await TestUtils.flushPromises();
expect(codes[1].innerHTML).toEqual(sessionKeyFormatted);
await waitFor(() => expect(codes[1].innerHTML).toEqual(sessionKeyFormatted));
});

it("handles errors fetching session key", async () => {
Expand Down

0 comments on commit 0f52667

Please sign in to comment.