add more tests

This commit is contained in:
Timo K.
2026-08-25 23:30:22 +02:00
parent 5399f14012
commit 2b5979162a

View File

@@ -9,6 +9,7 @@ import { afterEach, describe, expect, it, type Mock, vi } from "vitest";
import { render, waitFor, screen } from "@testing-library/react";
import userEvent from "@testing-library/user-event";
import { TooltipProvider } from "@vector-im/compound-web";
import { BehaviorSubject } from "rxjs";
import type { MatrixClient } from "matrix-js-sdk";
import type { Room as LivekitRoom } from "livekit-client";
@@ -412,4 +413,73 @@ describe("DeveloperSettingsTab", () => {
},
);
});
describe("KeyRotationStatus", () => {
it("displays active status when key rotation is not suppressed", async () => {
const client = createMockMatrixClient();
const mockVm = {
keyRotationSuppressed$: new BehaviorSubject(false),
participantCount$: new BehaviorSubject(5),
} as unknown as any;
render(
<TooltipProvider>
<DeveloperSettingsTab
client={client}
env={{} as unknown as ImportMetaEnv}
vm={mockVm}
/>
</TooltipProvider>,
);
await waitFor(() =>
expect(client.doesServerSupportUnstableFeature).toHaveBeenCalled(),
);
expect(screen.getByText(/Media key rotation: active \(5 participants\)/)).toBeInTheDocument();
});
it("displays suppressed status when key rotation is suppressed", async () => {
const client = createMockMatrixClient();
const mockVm = {
keyRotationSuppressed$: new BehaviorSubject(true),
participantCount$: new BehaviorSubject(50),
} as unknown as any;
render(
<TooltipProvider>
<DeveloperSettingsTab
client={client}
env={{} as unknown as ImportMetaEnv}
vm={mockVm}
/>
</TooltipProvider>,
);
await waitFor(() =>
expect(client.doesServerSupportUnstableFeature).toHaveBeenCalled(),
);
expect(screen.getByText(/Media key rotation: suppressed, participant limit reached \(50 participants\)/)).toBeInTheDocument();
});
it("does not render KeyRotationStatus when vm is not provided", async () => {
const client = createMockMatrixClient();
render(
<TooltipProvider>
<DeveloperSettingsTab
client={client}
env={{} as unknown as ImportMetaEnv}
/>
</TooltipProvider>,
);
await waitFor(() =>
expect(client.doesServerSupportUnstableFeature).toHaveBeenCalled(),
);
expect(screen.queryByText(/Media key rotation:/)).not.toBeInTheDocument();
});
});
});