mirror of
https://github.com/Novaloop-AG/healthchat-web.git
synced 2026-12-04 16:53:09 +00:00
Add config param to disable client wellknown fetch (#34084)
* Add enable_client_well_known_lookups config option Signed-off-by: David Langley <langley.dave@gmail.com> * Gate client .well-known poll on enable_client_well_known_lookups Signed-off-by: David Langley <langley.dave@gmail.com> * Gate MatrixRTC foci well-known fallback on enable_client_well_known_lookups Signed-off-by: David Langley <langley.dave@gmail.com> --------- Signed-off-by: David Langley <langley.dave@gmail.com> Co-authored-by: David Langley <langley.dave@gmail.com>
This commit is contained in:
@@ -15,6 +15,7 @@ import fetchMock from "@fetch-mock/vitest";
|
||||
import { advanceDateAndTime, stubClient, createTestClient } from "test-utils";
|
||||
|
||||
import { type IMatrixClientPeg, MatrixClientPeg as peg } from "./MatrixClientPeg";
|
||||
import SdkConfig from "./SdkConfig";
|
||||
|
||||
vi.useFakeTimers();
|
||||
|
||||
@@ -116,5 +117,30 @@ describe("MatrixClientPeg", () => {
|
||||
await testPeg.start();
|
||||
expect(mockInitRustCrypto).toHaveBeenCalledTimes(1);
|
||||
});
|
||||
|
||||
it("should poll the client well-known by default", async () => {
|
||||
vi.spyOn(testPeg.safeGet(), "initRustCrypto").mockResolvedValue(undefined);
|
||||
const startClient = vi.spyOn(testPeg.safeGet(), "startClient").mockResolvedValue(undefined);
|
||||
|
||||
await testPeg.start();
|
||||
|
||||
const opts = startClient.mock.calls[0][0];
|
||||
expect(opts?.clientWellKnownPollPeriod).toBe(2 * 60 * 60);
|
||||
});
|
||||
|
||||
it("should not poll the client well-known when enable_client_well_known_lookups is false", async () => {
|
||||
const sdkConfigGet = SdkConfig.get;
|
||||
vi.spyOn(SdkConfig, "get").mockImplementation((key?: any, altCaseName?: string): any => {
|
||||
if (key === "enable_client_well_known_lookups") return false;
|
||||
return sdkConfigGet(key, altCaseName);
|
||||
});
|
||||
vi.spyOn(testPeg.safeGet(), "initRustCrypto").mockResolvedValue(undefined);
|
||||
const startClient = vi.spyOn(testPeg.safeGet(), "startClient").mockResolvedValue(undefined);
|
||||
|
||||
await testPeg.start();
|
||||
|
||||
const opts = startClient.mock.calls[0][0];
|
||||
expect(opts?.clientWellKnownPollPeriod).toBeUndefined();
|
||||
});
|
||||
});
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user