Fix share button in discovery settings being disabled incorrectly (#29151)

* Fix share button in discovery settings being disabled incorrectly

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Improve types & add tests

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Iterate

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Iterate

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Improve coverage

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Add missing snapshot

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

---------

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
This commit is contained in:
Michael Telatynski
2025-02-03 08:48:02 +00:00
committed by GitHub
parent aa01b17f9e
commit 4f1eac67a8
13 changed files with 332 additions and 94 deletions
@@ -10,10 +10,12 @@ import React from "react";
import { render, screen, waitFor, act, fireEvent } from "jest-matrix-react";
import { AuthType } from "matrix-js-sdk/src/interactive-auth";
import userEvent from "@testing-library/user-event";
import { Policy } from "matrix-js-sdk/src/matrix";
import {
EmailIdentityAuthEntry,
MasUnlockCrossSigningAuthEntry,
TermsAuthEntry,
} from "../../../../../src/components/views/auth/InteractiveAuthEntryComponents";
import { createTestClient } from "../../../../test-utils";
@@ -99,3 +101,38 @@ describe("<MasUnlockCrossSigningAuthEntry/>", () => {
expect(submitAuthDict).toHaveBeenCalledWith({});
});
});
describe("<TermsAuthEntry/>", () => {
const renderAuth = (policy: Policy, props = {}) => {
const matrixClient = createTestClient();
return render(
<TermsAuthEntry
matrixClient={matrixClient}
loginType={AuthType.Email}
onPhaseChange={jest.fn()}
submitAuthDict={jest.fn()}
fail={jest.fn()}
clientSecret="my secret"
showContinue={true}
stageParams={{
policies: {
test_policy: policy,
},
}}
{...props}
/>,
);
};
test("should render", () => {
const { container } = renderAuth({
version: "alpha",
en: {
name: "Test Policy",
url: "https://example.com/en",
},
});
expect(container).toMatchSnapshot();
});
});
@@ -82,3 +82,38 @@ exports[`<MasUnlockCrossSigningAuthEntry/> should render 1`] = `
</div>
</div>
`;
exports[`<TermsAuthEntry/> should render 1`] = `
<div>
<div
class="mx_InteractiveAuthEntryComponents"
>
<p>
Please review and accept the policies of this homeserver:
</p>
<label
class="mx_InteractiveAuthEntryComponents_termsPolicy"
>
<input
type="checkbox"
/>
<a
href="https://example.com/en"
rel="noreferrer noopener"
target="_blank"
>
Test Policy
</a>
</label>
<div
aria-disabled="true"
class="mx_AccessibleButton mx_InteractiveAuthEntryComponents_termsSubmit mx_AccessibleButton_hasKind mx_AccessibleButton_kind_primary mx_AccessibleButton_disabled"
disabled=""
role="button"
tabindex="0"
>
Accept
</div>
</div>
</div>
`;