feat: show call participants in room list (Discord-style)
Docker / Docker Buildx (push) Has been cancelled
Build Debian package / Build package (release) Has been cancelled
Build and Deploy / prepare (release) Has been cancelled
Deploy release / Deploy to Cloudflare Pages (release) Has been cancelled
Build and Deploy / Trigger Pro pipeline (release) Has been cancelled
Build and Deploy / Windows arm64 (release) Has been cancelled
Build and Deploy / Windows x64 (release) Has been cancelled
Build and Deploy / macOS (release) Has been cancelled
Build and Deploy / Linux amd64 (sqlcipher static) (release) Has been cancelled
Build and Deploy / Linux arm64 (sqlcipher static) (release) Has been cancelled
Build and Deploy / ${{ needs.prepare.outputs.deploy == 'true' && 'Deploy' || 'Deploy (dry-run)' }} (release) Has been cancelled
Build and Deploy / Deploy builds to ESS (release) Has been cancelled

This commit is contained in:
sorB
2026-05-10 14:25:35 +02:00
parent b797925316
commit 3da363517f
4610 changed files with 827237 additions and 1 deletions
@@ -0,0 +1,129 @@
/*
Copyright 2024 New Vector Ltd.
Copyright 2024 The Matrix.org Foundation C.I.C.
SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Commercial
Please see LICENSE files in the repository root for full details.
*/
import React from "react";
import { act, render, screen } from "jest-matrix-react";
import { type MatrixClient, MatrixEvent, type Terms, ThreepidMedium } from "matrix-js-sdk/src/matrix";
import { mocked } from "jest-mock";
import userEvent from "@testing-library/user-event";
import { DiscoverySettings } from "../../../../../../src/components/views/settings/discovery/DiscoverySettings";
import { stubClient } from "../../../../../test-utils";
import MatrixClientContext from "../../../../../../src/contexts/MatrixClientContext";
import defaultDispatcher from "../../../../../../src/dispatcher/dispatcher";
const mockGetAccessToken = jest.fn().mockResolvedValue("$$getAccessToken");
jest.mock("../../../../../../src/IdentityAuthClient", () =>
jest.fn().mockImplementation(() => ({
getAccessToken: mockGetAccessToken,
})),
);
const sampleTerms = {
policies: {
terms: { version: "alpha", en: { name: "No ball games", url: "https://foobar" } },
},
} satisfies Terms;
const invalidTerms = {
policies: {
terms: { version: "invalid" },
},
} satisfies Terms;
describe("DiscoverySettings", () => {
let client: MatrixClient;
beforeEach(() => {
client = stubClient();
});
afterEach(() => {
jest.restoreAllMocks();
});
const DiscoveryWrapper = (props = {}) => <MatrixClientContext.Provider value={client} {...props} />;
it("displays alert if an identity server needs terms accepting", async () => {
mocked(client).getIdentityServerUrl.mockReturnValue("https://example.com");
mocked(client).getTerms.mockResolvedValue(sampleTerms);
render(<DiscoverySettings />, { wrapper: DiscoveryWrapper });
expect(await screen.findByText("Let people find you")).toBeInTheDocument();
expect(screen.getByRole("link")).toHaveAttribute("href", "https://foobar");
});
it("button to accept terms is disabled if checkbox not checked", async () => {
mocked(client).getIdentityServerUrl.mockReturnValue("https://example.com");
mocked(client).getTerms.mockResolvedValue(sampleTerms);
render(<DiscoverySettings />, { wrapper: DiscoveryWrapper });
const acceptCheckbox = await screen.findByRole("checkbox", { name: "Accept" });
const continueButton = screen.getByRole("button", { name: "Continue" });
expect(acceptCheckbox).toBeInTheDocument();
expect(continueButton).toHaveAttribute("aria-disabled", "true");
await userEvent.click(acceptCheckbox);
expect(continueButton).not.toHaveAttribute("aria-disabled", "true");
});
it("updates if ID server is changed", async () => {
render(<DiscoverySettings />, { wrapper: DiscoveryWrapper });
mocked(client).getThreePids.mockClear();
act(() => {
defaultDispatcher.dispatch(
{
action: "id_server_changed",
},
true,
);
});
expect(client.getThreePids).toHaveBeenCalled();
});
it("should not disable share button if terms accepted", async () => {
mocked(client).getThreePids.mockResolvedValue({
threepids: [
{
medium: ThreepidMedium.Email,
address: "test@email.com",
bound: false,
added_at: 123,
validated_at: 234,
},
],
});
mocked(client).getIdentityServerUrl.mockReturnValue("https://example.com");
mocked(client).getTerms.mockResolvedValue(sampleTerms);
mocked(client).getAccountData.mockReturnValue(
new MatrixEvent({
content: { accepted: [sampleTerms.policies["terms"]["en"].url] },
}),
);
render(<DiscoverySettings />, { wrapper: DiscoveryWrapper });
const shareButton = await screen.findByRole("button", { name: "Share" });
expect(shareButton).not.toHaveAttribute("aria-disabled", "true");
});
it("should not show invalid terms", async () => {
mocked(client).getIdentityServerUrl.mockReturnValue("https://example.com");
mocked(client).getTerms.mockResolvedValue(invalidTerms);
render(<DiscoverySettings />, { wrapper: DiscoveryWrapper });
expect(await screen.findByText("Let people find you")).toBeInTheDocument();
expect(screen.queryByRole("link")).not.toBeInTheDocument();
});
});