2022-11-01 18:27:03 +08:00
|
|
|
/*
|
|
|
|
Copyright 2022 The Matrix.org Foundation C.I.C.
|
|
|
|
|
|
|
|
Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
you may not use this file except in compliance with the License.
|
|
|
|
You may obtain a copy of the License at
|
|
|
|
|
|
|
|
http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
|
|
|
|
Unless required by applicable law or agreed to in writing, software
|
|
|
|
distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
See the License for the specific language governing permissions and
|
|
|
|
limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2022-12-12 19:24:14 +08:00
|
|
|
import { SlidingSync } from "matrix-js-sdk/src/sliding-sync";
|
|
|
|
import { mocked } from "jest-mock";
|
2024-05-04 02:45:26 +08:00
|
|
|
import { MatrixClient, MatrixEvent, Room } from "matrix-js-sdk/src/matrix";
|
2024-05-14 20:40:10 +08:00
|
|
|
import fetchMockJest from "fetch-mock-jest";
|
2022-11-01 18:27:03 +08:00
|
|
|
|
2022-12-12 19:24:14 +08:00
|
|
|
import { SlidingSyncManager } from "../src/SlidingSyncManager";
|
|
|
|
import { stubClient } from "./test-utils";
|
MSC3575 (Sliding Sync) add well-known proxy support (#12307)
* Initial commit
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove commented code
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Change function to reflect it's proxy not native support
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Re-add check for servers with native support
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add native support check back in
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Re-add endpoint health check function
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Use inbuilt `getWellKnown` function
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Change the error message to the correct function
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Stop storing the proxyurl in the settings for now
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Make the logger messages more useful
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Start moving the checking logic directly into the controller
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add missing import
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Get the client rather than passing it in to the functions
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* remove invalid `function` keyword
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Fix imports
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Our new functions are private
We shouldn't(?) have to use these check in future elsewhere
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Change our proxy check function to return a boolean
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Make `nativeSlidingSyncSupport` also return boolean, add in health check
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Disable the sliding sync option if the server doesn't support
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Only enable the setting if it passes (again)
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Update our comments to better match what's going on
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove unused dialog
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add a well-known check on start-up, if sliding sync has been enabled
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Check against the correct endpoint...
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Extract baseUrl as we'll reuse it
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Make the logs differentiate between the types of proxy
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Grab the client well-known directly for use
Can't use the client object at this point, it hasn't read in the well-known
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add myself to the copyright assignation
I wrote the majority of this file...
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Only return `true` if it's actually there
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Correct the `proxySlidingSyncSupport` function comment to match the code
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Correct the `nativeSlidingSyncSupport`function comment to match the code
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Another comment/functionality paring
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove duplicated types from the doc
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move await to the previous line
Removes brackets, and corrects `wellKnown` from being a `Promise`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* use `waitForClientWellKnown` to avoid a race condition with the request
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move getting the client out of the `if`, use `waitForClientWellKnown`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove `beforeChange` override
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move proxy setup logic into `SlidingSyncManager`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Swap `configure` to private, we call it from `setup` which handles proxy
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Promises are always `true`
TIL.
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* use `timeoutSignal`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Change message when there's no server support
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Refactor `slidingSyncHealthCheck`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Refactor `nativeSlidingSyncSupport` with try/catch
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Change comment to hotlink
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Try and make the toggle disabled when there's no endpoint
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move the if statement outside the refactored fn to avoid an await
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Revert "Swap `configure` to private, we call it from `setup` which handles proxy"
This reverts commit c80a00b50c261becc9ad58e08d2a893d572d8426.
* Remove unused import
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Further refactor `slidingSyncHealthCheck`
`proxySlidingSyncSupport` already checks the client well-known is there
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Make `proxySlidingSyncSupport` log on success
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Clarify log message for proxy being up
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move the logic into SlidingSyncManager
All so we can set a static variable because the disabled check isn't asynchronous :)
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Obviously this isn't a return so don't overwrite with false!
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove outdated comment
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* No need to pass in the client
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Activating SS should probably be info level logs
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* If we've not enabled sliding sync, push the logs down a bit
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Update i18n error message
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove unused i18n strings
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Correct log message
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Prettier
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove many of the log messages
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Short out of `checkSupport` if it's `true`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add the endpoint back into the log when we're enabling it
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Note in the comment that `feature_sliding_sync_proxy_url` is legacy
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Expand the well-known liveness check log
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* No need to stall the client waiting for sliding sync support
* `AutoDiscovery.findClientConfig` throws if the baseUrl is blank
* Fix `getProxyFromWellKnown` (?)
* Add missing semicolon
Sorry, linter!
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Pass our `MatrixClient` through instead of trying to grab it
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add missing return in function comment
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Actually pass through our Client, not the Peg object
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove SonarCube smell complaint
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Neew to make our other two methods public to test
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* First passing test
Hurrah!
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Two more tests, this time on `checkSupport`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Reset our `serverSupportsSlidingSync` between tests
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Check the static member is being set
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move the static assignation down to the relevant tests
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Pull getProxyFromWellKnown mocking up
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Check we /haven't/ shorted out
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move our spy up so we can reuse it
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Check spidering is being called
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Test the proxy is declared
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Test entered manually
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Sorry, linter
* I guess these strings are wrong?
* Replace any with string
Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
---------
Signed-off-by: Ed Geraghty <ed@geraghty.family>
Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
2024-05-01 02:11:11 +08:00
|
|
|
import SlidingSyncController from "../src/settings/controllers/SlidingSyncController";
|
|
|
|
import SettingsStore from "../src/settings/SettingsStore";
|
2022-11-01 18:27:03 +08:00
|
|
|
|
2022-12-12 19:24:14 +08:00
|
|
|
jest.mock("matrix-js-sdk/src/sliding-sync");
|
|
|
|
const MockSlidingSync = <jest.Mock<SlidingSync>>(<unknown>SlidingSync);
|
2022-11-01 18:27:03 +08:00
|
|
|
|
2022-12-12 19:24:14 +08:00
|
|
|
describe("SlidingSyncManager", () => {
|
2022-11-01 18:27:03 +08:00
|
|
|
let manager: SlidingSyncManager;
|
|
|
|
let slidingSync: SlidingSync;
|
2022-11-19 03:05:00 +08:00
|
|
|
let client: MatrixClient;
|
2022-11-01 18:27:03 +08:00
|
|
|
|
|
|
|
beforeEach(() => {
|
|
|
|
slidingSync = new MockSlidingSync();
|
|
|
|
manager = new SlidingSyncManager();
|
2022-11-19 03:05:00 +08:00
|
|
|
client = stubClient();
|
|
|
|
// by default the client has no rooms: stubClient magically makes rooms annoyingly.
|
|
|
|
mocked(client.getRoom).mockReturnValue(null);
|
|
|
|
manager.configure(client, "invalid");
|
2022-11-01 18:27:03 +08:00
|
|
|
manager.slidingSync = slidingSync;
|
2024-05-14 20:40:10 +08:00
|
|
|
fetchMockJest.reset();
|
|
|
|
fetchMockJest.get("https://proxy/client/server.json", {});
|
2022-11-01 18:27:03 +08:00
|
|
|
});
|
|
|
|
|
2022-11-19 03:05:00 +08:00
|
|
|
describe("setRoomVisible", () => {
|
|
|
|
it("adds a subscription for the room", async () => {
|
|
|
|
const roomId = "!room:id";
|
|
|
|
const subs = new Set<string>();
|
|
|
|
mocked(slidingSync.getRoomSubscriptions).mockReturnValue(subs);
|
|
|
|
mocked(slidingSync.modifyRoomSubscriptions).mockResolvedValue("yep");
|
|
|
|
await manager.setRoomVisible(roomId, true);
|
2023-03-01 23:23:35 +08:00
|
|
|
expect(slidingSync.modifyRoomSubscriptions).toHaveBeenCalledWith(new Set<string>([roomId]));
|
2022-11-19 03:05:00 +08:00
|
|
|
});
|
|
|
|
it("adds a custom subscription for a lazy-loadable room", async () => {
|
|
|
|
const roomId = "!lazy:id";
|
2023-02-15 21:36:22 +08:00
|
|
|
const room = new Room(roomId, client, client.getUserId()!);
|
2022-11-19 03:05:00 +08:00
|
|
|
room.getLiveTimeline().initialiseState([
|
|
|
|
new MatrixEvent({
|
|
|
|
type: "m.room.create",
|
|
|
|
state_key: "",
|
|
|
|
event_id: "$abc123",
|
2023-02-15 21:36:22 +08:00
|
|
|
sender: client.getUserId()!,
|
2022-11-19 03:05:00 +08:00
|
|
|
content: {
|
2023-02-16 17:38:44 +08:00
|
|
|
creator: client.getUserId()!,
|
2022-11-19 03:05:00 +08:00
|
|
|
},
|
|
|
|
}),
|
|
|
|
]);
|
2023-02-15 21:36:22 +08:00
|
|
|
mocked(client.getRoom).mockImplementation((r: string): Room | null => {
|
2022-11-19 03:05:00 +08:00
|
|
|
if (roomId === r) {
|
|
|
|
return room;
|
|
|
|
}
|
|
|
|
return null;
|
|
|
|
});
|
|
|
|
const subs = new Set<string>();
|
|
|
|
mocked(slidingSync.getRoomSubscriptions).mockReturnValue(subs);
|
|
|
|
mocked(slidingSync.modifyRoomSubscriptions).mockResolvedValue("yep");
|
|
|
|
await manager.setRoomVisible(roomId, true);
|
2023-03-01 23:23:35 +08:00
|
|
|
expect(slidingSync.modifyRoomSubscriptions).toHaveBeenCalledWith(new Set<string>([roomId]));
|
2022-11-19 03:05:00 +08:00
|
|
|
// we aren't prescriptive about what the sub name is.
|
2023-03-01 23:23:35 +08:00
|
|
|
expect(slidingSync.useCustomSubscription).toHaveBeenCalledWith(roomId, expect.anything());
|
2022-11-19 03:05:00 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2023-01-19 23:02:48 +08:00
|
|
|
describe("ensureListRegistered", () => {
|
|
|
|
it("creates a new list based on the key", async () => {
|
|
|
|
const listKey = "key";
|
|
|
|
mocked(slidingSync.getListParams).mockReturnValue(null);
|
|
|
|
mocked(slidingSync.setList).mockResolvedValue("yep");
|
|
|
|
await manager.ensureListRegistered(listKey, {
|
|
|
|
sort: ["by_recency"],
|
|
|
|
});
|
2023-03-01 23:23:35 +08:00
|
|
|
expect(slidingSync.setList).toHaveBeenCalledWith(
|
2023-01-19 23:02:48 +08:00
|
|
|
listKey,
|
|
|
|
expect.objectContaining({
|
|
|
|
sort: ["by_recency"],
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("updates an existing list based on the key", async () => {
|
|
|
|
const listKey = "key";
|
|
|
|
mocked(slidingSync.getListParams).mockReturnValue({
|
|
|
|
ranges: [[0, 42]],
|
|
|
|
});
|
|
|
|
mocked(slidingSync.setList).mockResolvedValue("yep");
|
|
|
|
await manager.ensureListRegistered(listKey, {
|
|
|
|
sort: ["by_recency"],
|
|
|
|
});
|
2023-03-01 23:23:35 +08:00
|
|
|
expect(slidingSync.setList).toHaveBeenCalledWith(
|
2023-01-19 23:02:48 +08:00
|
|
|
listKey,
|
|
|
|
expect.objectContaining({
|
|
|
|
sort: ["by_recency"],
|
|
|
|
ranges: [[0, 42]],
|
|
|
|
}),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
|
|
|
|
it("updates ranges on an existing list based on the key if there's no other changes", async () => {
|
|
|
|
const listKey = "key";
|
|
|
|
mocked(slidingSync.getListParams).mockReturnValue({
|
|
|
|
ranges: [[0, 42]],
|
|
|
|
});
|
|
|
|
mocked(slidingSync.setList).mockResolvedValue("yep");
|
|
|
|
await manager.ensureListRegistered(listKey, {
|
|
|
|
ranges: [[0, 52]],
|
|
|
|
});
|
2023-03-01 23:23:35 +08:00
|
|
|
expect(slidingSync.setList).not.toHaveBeenCalled();
|
|
|
|
expect(slidingSync.setListRanges).toHaveBeenCalledWith(listKey, [[0, 52]]);
|
2023-01-19 23:02:48 +08:00
|
|
|
});
|
|
|
|
|
|
|
|
it("no-ops for idential changes", async () => {
|
|
|
|
const listKey = "key";
|
|
|
|
mocked(slidingSync.getListParams).mockReturnValue({
|
|
|
|
ranges: [[0, 42]],
|
|
|
|
sort: ["by_recency"],
|
|
|
|
});
|
|
|
|
mocked(slidingSync.setList).mockResolvedValue("yep");
|
|
|
|
await manager.ensureListRegistered(listKey, {
|
|
|
|
ranges: [[0, 42]],
|
|
|
|
sort: ["by_recency"],
|
|
|
|
});
|
2023-03-01 23:23:35 +08:00
|
|
|
expect(slidingSync.setList).not.toHaveBeenCalled();
|
|
|
|
expect(slidingSync.setListRanges).not.toHaveBeenCalled();
|
2023-01-19 23:02:48 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
|
2022-11-01 18:27:03 +08:00
|
|
|
describe("startSpidering", () => {
|
|
|
|
it("requests in batchSizes", async () => {
|
|
|
|
const gapMs = 1;
|
|
|
|
const batchSize = 10;
|
|
|
|
mocked(slidingSync.setList).mockResolvedValue("yep");
|
|
|
|
mocked(slidingSync.setListRanges).mockResolvedValue("yep");
|
2023-01-19 19:15:08 +08:00
|
|
|
mocked(slidingSync.getListData).mockImplementation((key) => {
|
2022-11-01 18:27:03 +08:00
|
|
|
return {
|
|
|
|
joinedCount: 64,
|
|
|
|
roomIndexToRoomId: {},
|
|
|
|
};
|
|
|
|
});
|
|
|
|
await manager.startSpidering(batchSize, gapMs);
|
|
|
|
// we expect calls for 10,19 -> 20,29 -> 30,39 -> 40,49 -> 50,59 -> 60,69
|
|
|
|
const wantWindows = [
|
2022-12-12 19:24:14 +08:00
|
|
|
[10, 19],
|
|
|
|
[20, 29],
|
|
|
|
[30, 39],
|
|
|
|
[40, 49],
|
|
|
|
[50, 59],
|
|
|
|
[60, 69],
|
2022-11-01 18:27:03 +08:00
|
|
|
];
|
2023-03-01 23:23:35 +08:00
|
|
|
expect(slidingSync.getListData).toHaveBeenCalledTimes(wantWindows.length);
|
|
|
|
expect(slidingSync.setList).toHaveBeenCalledTimes(1);
|
|
|
|
expect(slidingSync.setListRanges).toHaveBeenCalledTimes(wantWindows.length - 1);
|
2022-11-01 18:27:03 +08:00
|
|
|
wantWindows.forEach((range, i) => {
|
|
|
|
if (i === 0) {
|
2023-03-07 21:58:10 +08:00
|
|
|
// eslint-disable-next-line jest/no-conditional-expect
|
2023-03-01 23:23:35 +08:00
|
|
|
expect(slidingSync.setList).toHaveBeenCalledWith(
|
2023-01-19 19:15:08 +08:00
|
|
|
SlidingSyncManager.ListSearch,
|
2023-03-07 21:58:10 +08:00
|
|
|
// eslint-disable-next-line jest/no-conditional-expect
|
2022-11-01 18:27:03 +08:00
|
|
|
expect.objectContaining({
|
2022-12-12 19:24:14 +08:00
|
|
|
ranges: [[0, batchSize - 1], range],
|
2022-11-01 18:27:03 +08:00
|
|
|
}),
|
|
|
|
);
|
|
|
|
return;
|
|
|
|
}
|
2023-03-01 23:23:35 +08:00
|
|
|
expect(slidingSync.setListRanges).toHaveBeenCalledWith(SlidingSyncManager.ListSearch, [
|
2023-01-19 20:49:20 +08:00
|
|
|
[0, batchSize - 1],
|
|
|
|
range,
|
|
|
|
]);
|
2022-11-01 18:27:03 +08:00
|
|
|
});
|
|
|
|
});
|
|
|
|
it("handles accounts with zero rooms", async () => {
|
|
|
|
const gapMs = 1;
|
|
|
|
const batchSize = 10;
|
|
|
|
mocked(slidingSync.setList).mockResolvedValue("yep");
|
2023-01-19 19:15:08 +08:00
|
|
|
mocked(slidingSync.getListData).mockImplementation((key) => {
|
2022-11-01 18:27:03 +08:00
|
|
|
return {
|
|
|
|
joinedCount: 0,
|
|
|
|
roomIndexToRoomId: {},
|
|
|
|
};
|
|
|
|
});
|
|
|
|
await manager.startSpidering(batchSize, gapMs);
|
2023-03-01 23:23:35 +08:00
|
|
|
expect(slidingSync.getListData).toHaveBeenCalledTimes(1);
|
|
|
|
expect(slidingSync.setList).toHaveBeenCalledTimes(1);
|
|
|
|
expect(slidingSync.setList).toHaveBeenCalledWith(
|
2023-01-19 19:15:08 +08:00
|
|
|
SlidingSyncManager.ListSearch,
|
2022-11-01 18:27:03 +08:00
|
|
|
expect.objectContaining({
|
2022-12-12 19:24:14 +08:00
|
|
|
ranges: [
|
|
|
|
[0, batchSize - 1],
|
|
|
|
[batchSize, batchSize + batchSize - 1],
|
|
|
|
],
|
2022-11-01 18:27:03 +08:00
|
|
|
}),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
it("continues even when setList rejects", async () => {
|
|
|
|
const gapMs = 1;
|
|
|
|
const batchSize = 10;
|
|
|
|
mocked(slidingSync.setList).mockRejectedValue("narp");
|
2023-01-19 19:15:08 +08:00
|
|
|
mocked(slidingSync.getListData).mockImplementation((key) => {
|
2022-11-01 18:27:03 +08:00
|
|
|
return {
|
|
|
|
joinedCount: 0,
|
|
|
|
roomIndexToRoomId: {},
|
|
|
|
};
|
|
|
|
});
|
|
|
|
await manager.startSpidering(batchSize, gapMs);
|
2023-03-01 23:23:35 +08:00
|
|
|
expect(slidingSync.getListData).toHaveBeenCalledTimes(1);
|
|
|
|
expect(slidingSync.setList).toHaveBeenCalledTimes(1);
|
|
|
|
expect(slidingSync.setList).toHaveBeenCalledWith(
|
2023-01-19 19:15:08 +08:00
|
|
|
SlidingSyncManager.ListSearch,
|
2022-11-01 18:27:03 +08:00
|
|
|
expect.objectContaining({
|
2022-12-12 19:24:14 +08:00
|
|
|
ranges: [
|
|
|
|
[0, batchSize - 1],
|
|
|
|
[batchSize, batchSize + batchSize - 1],
|
|
|
|
],
|
2022-11-01 18:27:03 +08:00
|
|
|
}),
|
|
|
|
);
|
|
|
|
});
|
|
|
|
});
|
MSC3575 (Sliding Sync) add well-known proxy support (#12307)
* Initial commit
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove commented code
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Change function to reflect it's proxy not native support
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Re-add check for servers with native support
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add native support check back in
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Re-add endpoint health check function
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Use inbuilt `getWellKnown` function
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Change the error message to the correct function
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Stop storing the proxyurl in the settings for now
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Make the logger messages more useful
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Start moving the checking logic directly into the controller
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add missing import
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Get the client rather than passing it in to the functions
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* remove invalid `function` keyword
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Fix imports
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Our new functions are private
We shouldn't(?) have to use these check in future elsewhere
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Change our proxy check function to return a boolean
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Make `nativeSlidingSyncSupport` also return boolean, add in health check
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Disable the sliding sync option if the server doesn't support
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Only enable the setting if it passes (again)
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Update our comments to better match what's going on
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove unused dialog
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add a well-known check on start-up, if sliding sync has been enabled
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Check against the correct endpoint...
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Extract baseUrl as we'll reuse it
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Make the logs differentiate between the types of proxy
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Grab the client well-known directly for use
Can't use the client object at this point, it hasn't read in the well-known
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add myself to the copyright assignation
I wrote the majority of this file...
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Only return `true` if it's actually there
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Correct the `proxySlidingSyncSupport` function comment to match the code
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Correct the `nativeSlidingSyncSupport`function comment to match the code
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Another comment/functionality paring
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove duplicated types from the doc
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move await to the previous line
Removes brackets, and corrects `wellKnown` from being a `Promise`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* use `waitForClientWellKnown` to avoid a race condition with the request
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move getting the client out of the `if`, use `waitForClientWellKnown`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove `beforeChange` override
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move proxy setup logic into `SlidingSyncManager`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Swap `configure` to private, we call it from `setup` which handles proxy
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Promises are always `true`
TIL.
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* use `timeoutSignal`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Change message when there's no server support
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Refactor `slidingSyncHealthCheck`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Refactor `nativeSlidingSyncSupport` with try/catch
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Change comment to hotlink
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Try and make the toggle disabled when there's no endpoint
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move the if statement outside the refactored fn to avoid an await
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Revert "Swap `configure` to private, we call it from `setup` which handles proxy"
This reverts commit c80a00b50c261becc9ad58e08d2a893d572d8426.
* Remove unused import
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Further refactor `slidingSyncHealthCheck`
`proxySlidingSyncSupport` already checks the client well-known is there
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Make `proxySlidingSyncSupport` log on success
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Clarify log message for proxy being up
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move the logic into SlidingSyncManager
All so we can set a static variable because the disabled check isn't asynchronous :)
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Obviously this isn't a return so don't overwrite with false!
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove outdated comment
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* No need to pass in the client
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Activating SS should probably be info level logs
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* If we've not enabled sliding sync, push the logs down a bit
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Update i18n error message
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove unused i18n strings
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Correct log message
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Prettier
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove many of the log messages
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Short out of `checkSupport` if it's `true`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add the endpoint back into the log when we're enabling it
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Note in the comment that `feature_sliding_sync_proxy_url` is legacy
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Expand the well-known liveness check log
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* No need to stall the client waiting for sliding sync support
* `AutoDiscovery.findClientConfig` throws if the baseUrl is blank
* Fix `getProxyFromWellKnown` (?)
* Add missing semicolon
Sorry, linter!
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Pass our `MatrixClient` through instead of trying to grab it
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add missing return in function comment
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Actually pass through our Client, not the Peg object
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove SonarCube smell complaint
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Neew to make our other two methods public to test
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* First passing test
Hurrah!
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Two more tests, this time on `checkSupport`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Reset our `serverSupportsSlidingSync` between tests
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Check the static member is being set
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move the static assignation down to the relevant tests
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Pull getProxyFromWellKnown mocking up
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Check we /haven't/ shorted out
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move our spy up so we can reuse it
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Check spidering is being called
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Test the proxy is declared
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Test entered manually
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Sorry, linter
* I guess these strings are wrong?
* Replace any with string
Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
---------
Signed-off-by: Ed Geraghty <ed@geraghty.family>
Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
2024-05-01 02:11:11 +08:00
|
|
|
describe("checkSupport", () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
SlidingSyncController.serverSupportsSlidingSync = false;
|
2024-05-14 20:40:10 +08:00
|
|
|
jest.spyOn(manager, "getProxyFromWellKnown").mockResolvedValue("https://proxy/");
|
MSC3575 (Sliding Sync) add well-known proxy support (#12307)
* Initial commit
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove commented code
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Change function to reflect it's proxy not native support
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Re-add check for servers with native support
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add native support check back in
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Re-add endpoint health check function
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Use inbuilt `getWellKnown` function
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Change the error message to the correct function
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Stop storing the proxyurl in the settings for now
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Make the logger messages more useful
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Start moving the checking logic directly into the controller
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add missing import
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Get the client rather than passing it in to the functions
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* remove invalid `function` keyword
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Fix imports
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Our new functions are private
We shouldn't(?) have to use these check in future elsewhere
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Change our proxy check function to return a boolean
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Make `nativeSlidingSyncSupport` also return boolean, add in health check
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Disable the sliding sync option if the server doesn't support
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Only enable the setting if it passes (again)
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Update our comments to better match what's going on
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove unused dialog
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add a well-known check on start-up, if sliding sync has been enabled
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Check against the correct endpoint...
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Extract baseUrl as we'll reuse it
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Make the logs differentiate between the types of proxy
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Grab the client well-known directly for use
Can't use the client object at this point, it hasn't read in the well-known
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add myself to the copyright assignation
I wrote the majority of this file...
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Only return `true` if it's actually there
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Correct the `proxySlidingSyncSupport` function comment to match the code
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Correct the `nativeSlidingSyncSupport`function comment to match the code
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Another comment/functionality paring
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove duplicated types from the doc
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move await to the previous line
Removes brackets, and corrects `wellKnown` from being a `Promise`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* use `waitForClientWellKnown` to avoid a race condition with the request
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move getting the client out of the `if`, use `waitForClientWellKnown`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove `beforeChange` override
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move proxy setup logic into `SlidingSyncManager`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Swap `configure` to private, we call it from `setup` which handles proxy
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Promises are always `true`
TIL.
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* use `timeoutSignal`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Change message when there's no server support
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Refactor `slidingSyncHealthCheck`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Refactor `nativeSlidingSyncSupport` with try/catch
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Change comment to hotlink
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Try and make the toggle disabled when there's no endpoint
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move the if statement outside the refactored fn to avoid an await
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Revert "Swap `configure` to private, we call it from `setup` which handles proxy"
This reverts commit c80a00b50c261becc9ad58e08d2a893d572d8426.
* Remove unused import
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Further refactor `slidingSyncHealthCheck`
`proxySlidingSyncSupport` already checks the client well-known is there
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Make `proxySlidingSyncSupport` log on success
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Clarify log message for proxy being up
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move the logic into SlidingSyncManager
All so we can set a static variable because the disabled check isn't asynchronous :)
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Obviously this isn't a return so don't overwrite with false!
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove outdated comment
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* No need to pass in the client
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Activating SS should probably be info level logs
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* If we've not enabled sliding sync, push the logs down a bit
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Update i18n error message
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove unused i18n strings
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Correct log message
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Prettier
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove many of the log messages
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Short out of `checkSupport` if it's `true`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add the endpoint back into the log when we're enabling it
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Note in the comment that `feature_sliding_sync_proxy_url` is legacy
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Expand the well-known liveness check log
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* No need to stall the client waiting for sliding sync support
* `AutoDiscovery.findClientConfig` throws if the baseUrl is blank
* Fix `getProxyFromWellKnown` (?)
* Add missing semicolon
Sorry, linter!
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Pass our `MatrixClient` through instead of trying to grab it
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add missing return in function comment
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Actually pass through our Client, not the Peg object
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove SonarCube smell complaint
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Neew to make our other two methods public to test
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* First passing test
Hurrah!
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Two more tests, this time on `checkSupport`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Reset our `serverSupportsSlidingSync` between tests
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Check the static member is being set
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move the static assignation down to the relevant tests
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Pull getProxyFromWellKnown mocking up
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Check we /haven't/ shorted out
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move our spy up so we can reuse it
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Check spidering is being called
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Test the proxy is declared
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Test entered manually
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Sorry, linter
* I guess these strings are wrong?
* Replace any with string
Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
---------
Signed-off-by: Ed Geraghty <ed@geraghty.family>
Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
2024-05-01 02:11:11 +08:00
|
|
|
});
|
|
|
|
it("shorts out if the server has 'native' sliding sync support", async () => {
|
|
|
|
jest.spyOn(manager, "nativeSlidingSyncSupport").mockResolvedValue(true);
|
|
|
|
expect(SlidingSyncController.serverSupportsSlidingSync).toBeFalsy();
|
|
|
|
await manager.checkSupport(client);
|
|
|
|
expect(manager.getProxyFromWellKnown).not.toHaveBeenCalled(); // We return earlier
|
|
|
|
expect(SlidingSyncController.serverSupportsSlidingSync).toBeTruthy();
|
|
|
|
});
|
|
|
|
it("tries to find a sliding sync proxy url from the client well-known if there's no 'native' support", async () => {
|
|
|
|
jest.spyOn(manager, "nativeSlidingSyncSupport").mockResolvedValue(false);
|
|
|
|
expect(SlidingSyncController.serverSupportsSlidingSync).toBeFalsy();
|
|
|
|
await manager.checkSupport(client);
|
|
|
|
expect(manager.getProxyFromWellKnown).toHaveBeenCalled();
|
|
|
|
expect(SlidingSyncController.serverSupportsSlidingSync).toBeTruthy();
|
|
|
|
});
|
2024-05-14 20:40:10 +08:00
|
|
|
it("should query well-known on server_name not baseUrl", async () => {
|
|
|
|
fetchMockJest.get("https://matrix.org/.well-known/matrix/client", {
|
|
|
|
"m.homeserver": {
|
|
|
|
base_url: "https://matrix-client.matrix.org",
|
|
|
|
server: "matrix.org",
|
|
|
|
},
|
|
|
|
"org.matrix.msc3575.proxy": {
|
|
|
|
url: "https://proxy/",
|
|
|
|
},
|
|
|
|
});
|
|
|
|
fetchMockJest.get("https://matrix-client.matrix.org/_matrix/client/versions", { versions: ["v1.4"] });
|
|
|
|
|
|
|
|
mocked(manager.getProxyFromWellKnown).mockRestore();
|
|
|
|
jest.spyOn(manager, "nativeSlidingSyncSupport").mockResolvedValue(false);
|
|
|
|
expect(SlidingSyncController.serverSupportsSlidingSync).toBeFalsy();
|
|
|
|
await manager.checkSupport(client);
|
|
|
|
expect(SlidingSyncController.serverSupportsSlidingSync).toBeTruthy();
|
|
|
|
expect(fetchMockJest).not.toHaveFetched("https://matrix-client.matrix.org/.well-known/matrix/client");
|
|
|
|
});
|
MSC3575 (Sliding Sync) add well-known proxy support (#12307)
* Initial commit
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove commented code
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Change function to reflect it's proxy not native support
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Re-add check for servers with native support
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add native support check back in
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Re-add endpoint health check function
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Use inbuilt `getWellKnown` function
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Change the error message to the correct function
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Stop storing the proxyurl in the settings for now
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Make the logger messages more useful
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Start moving the checking logic directly into the controller
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add missing import
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Get the client rather than passing it in to the functions
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* remove invalid `function` keyword
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Fix imports
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Our new functions are private
We shouldn't(?) have to use these check in future elsewhere
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Change our proxy check function to return a boolean
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Make `nativeSlidingSyncSupport` also return boolean, add in health check
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Disable the sliding sync option if the server doesn't support
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Only enable the setting if it passes (again)
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Update our comments to better match what's going on
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove unused dialog
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add a well-known check on start-up, if sliding sync has been enabled
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Check against the correct endpoint...
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Extract baseUrl as we'll reuse it
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Make the logs differentiate between the types of proxy
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Grab the client well-known directly for use
Can't use the client object at this point, it hasn't read in the well-known
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add myself to the copyright assignation
I wrote the majority of this file...
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Only return `true` if it's actually there
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Correct the `proxySlidingSyncSupport` function comment to match the code
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Correct the `nativeSlidingSyncSupport`function comment to match the code
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Another comment/functionality paring
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove duplicated types from the doc
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move await to the previous line
Removes brackets, and corrects `wellKnown` from being a `Promise`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* use `waitForClientWellKnown` to avoid a race condition with the request
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move getting the client out of the `if`, use `waitForClientWellKnown`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove `beforeChange` override
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move proxy setup logic into `SlidingSyncManager`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Swap `configure` to private, we call it from `setup` which handles proxy
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Promises are always `true`
TIL.
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* use `timeoutSignal`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Change message when there's no server support
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Refactor `slidingSyncHealthCheck`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Refactor `nativeSlidingSyncSupport` with try/catch
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Change comment to hotlink
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Try and make the toggle disabled when there's no endpoint
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move the if statement outside the refactored fn to avoid an await
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Revert "Swap `configure` to private, we call it from `setup` which handles proxy"
This reverts commit c80a00b50c261becc9ad58e08d2a893d572d8426.
* Remove unused import
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Further refactor `slidingSyncHealthCheck`
`proxySlidingSyncSupport` already checks the client well-known is there
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Make `proxySlidingSyncSupport` log on success
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Clarify log message for proxy being up
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move the logic into SlidingSyncManager
All so we can set a static variable because the disabled check isn't asynchronous :)
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Obviously this isn't a return so don't overwrite with false!
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove outdated comment
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* No need to pass in the client
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Activating SS should probably be info level logs
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* If we've not enabled sliding sync, push the logs down a bit
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Update i18n error message
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove unused i18n strings
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Correct log message
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Prettier
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove many of the log messages
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Short out of `checkSupport` if it's `true`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add the endpoint back into the log when we're enabling it
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Note in the comment that `feature_sliding_sync_proxy_url` is legacy
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Expand the well-known liveness check log
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* No need to stall the client waiting for sliding sync support
* `AutoDiscovery.findClientConfig` throws if the baseUrl is blank
* Fix `getProxyFromWellKnown` (?)
* Add missing semicolon
Sorry, linter!
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Pass our `MatrixClient` through instead of trying to grab it
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add missing return in function comment
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Actually pass through our Client, not the Peg object
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove SonarCube smell complaint
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Neew to make our other two methods public to test
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* First passing test
Hurrah!
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Two more tests, this time on `checkSupport`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Reset our `serverSupportsSlidingSync` between tests
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Check the static member is being set
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move the static assignation down to the relevant tests
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Pull getProxyFromWellKnown mocking up
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Check we /haven't/ shorted out
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move our spy up so we can reuse it
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Check spidering is being called
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Test the proxy is declared
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Test entered manually
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Sorry, linter
* I guess these strings are wrong?
* Replace any with string
Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
---------
Signed-off-by: Ed Geraghty <ed@geraghty.family>
Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
2024-05-01 02:11:11 +08:00
|
|
|
});
|
2024-05-03 14:31:34 +08:00
|
|
|
describe("nativeSlidingSyncSupport", () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
SlidingSyncController.serverSupportsSlidingSync = false;
|
|
|
|
});
|
|
|
|
it("should make an OPTIONS request to avoid unintended side effects", async () => {
|
|
|
|
// See https://github.com/element-hq/element-web/issues/27426
|
|
|
|
|
2024-05-04 02:45:26 +08:00
|
|
|
const unstableSpy = jest
|
|
|
|
.spyOn(client, "doesServerSupportUnstableFeature")
|
|
|
|
.mockImplementation(async (feature: string) => {
|
|
|
|
expect(feature).toBe("org.matrix.msc3575");
|
|
|
|
return true;
|
|
|
|
});
|
2024-05-14 20:40:10 +08:00
|
|
|
const proxySpy = jest.spyOn(manager, "getProxyFromWellKnown").mockResolvedValue("https://proxy/");
|
2024-05-03 14:31:34 +08:00
|
|
|
|
|
|
|
expect(SlidingSyncController.serverSupportsSlidingSync).toBeFalsy();
|
|
|
|
await manager.checkSupport(client); // first thing it does is call nativeSlidingSyncSupport
|
|
|
|
expect(proxySpy).not.toHaveBeenCalled();
|
2024-05-04 02:45:26 +08:00
|
|
|
expect(unstableSpy).toHaveBeenCalled();
|
2024-05-03 14:31:34 +08:00
|
|
|
expect(SlidingSyncController.serverSupportsSlidingSync).toBeTruthy();
|
|
|
|
});
|
|
|
|
});
|
MSC3575 (Sliding Sync) add well-known proxy support (#12307)
* Initial commit
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove commented code
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Change function to reflect it's proxy not native support
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Re-add check for servers with native support
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add native support check back in
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Re-add endpoint health check function
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Use inbuilt `getWellKnown` function
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Change the error message to the correct function
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Stop storing the proxyurl in the settings for now
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Make the logger messages more useful
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Start moving the checking logic directly into the controller
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add missing import
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Get the client rather than passing it in to the functions
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* remove invalid `function` keyword
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Fix imports
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Our new functions are private
We shouldn't(?) have to use these check in future elsewhere
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Change our proxy check function to return a boolean
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Make `nativeSlidingSyncSupport` also return boolean, add in health check
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Disable the sliding sync option if the server doesn't support
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Only enable the setting if it passes (again)
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Update our comments to better match what's going on
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove unused dialog
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add a well-known check on start-up, if sliding sync has been enabled
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Check against the correct endpoint...
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Extract baseUrl as we'll reuse it
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Make the logs differentiate between the types of proxy
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Grab the client well-known directly for use
Can't use the client object at this point, it hasn't read in the well-known
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add myself to the copyright assignation
I wrote the majority of this file...
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Only return `true` if it's actually there
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Correct the `proxySlidingSyncSupport` function comment to match the code
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Correct the `nativeSlidingSyncSupport`function comment to match the code
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Another comment/functionality paring
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove duplicated types from the doc
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move await to the previous line
Removes brackets, and corrects `wellKnown` from being a `Promise`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* use `waitForClientWellKnown` to avoid a race condition with the request
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move getting the client out of the `if`, use `waitForClientWellKnown`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove `beforeChange` override
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move proxy setup logic into `SlidingSyncManager`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Swap `configure` to private, we call it from `setup` which handles proxy
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Promises are always `true`
TIL.
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* use `timeoutSignal`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Change message when there's no server support
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Refactor `slidingSyncHealthCheck`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Refactor `nativeSlidingSyncSupport` with try/catch
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Change comment to hotlink
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Try and make the toggle disabled when there's no endpoint
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move the if statement outside the refactored fn to avoid an await
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Revert "Swap `configure` to private, we call it from `setup` which handles proxy"
This reverts commit c80a00b50c261becc9ad58e08d2a893d572d8426.
* Remove unused import
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Further refactor `slidingSyncHealthCheck`
`proxySlidingSyncSupport` already checks the client well-known is there
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Make `proxySlidingSyncSupport` log on success
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Clarify log message for proxy being up
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move the logic into SlidingSyncManager
All so we can set a static variable because the disabled check isn't asynchronous :)
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Obviously this isn't a return so don't overwrite with false!
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove outdated comment
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* No need to pass in the client
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Activating SS should probably be info level logs
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* If we've not enabled sliding sync, push the logs down a bit
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Update i18n error message
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove unused i18n strings
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Correct log message
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Prettier
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove many of the log messages
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Short out of `checkSupport` if it's `true`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add the endpoint back into the log when we're enabling it
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Note in the comment that `feature_sliding_sync_proxy_url` is legacy
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Expand the well-known liveness check log
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* No need to stall the client waiting for sliding sync support
* `AutoDiscovery.findClientConfig` throws if the baseUrl is blank
* Fix `getProxyFromWellKnown` (?)
* Add missing semicolon
Sorry, linter!
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Pass our `MatrixClient` through instead of trying to grab it
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add missing return in function comment
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Actually pass through our Client, not the Peg object
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove SonarCube smell complaint
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Neew to make our other two methods public to test
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* First passing test
Hurrah!
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Two more tests, this time on `checkSupport`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Reset our `serverSupportsSlidingSync` between tests
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Check the static member is being set
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move the static assignation down to the relevant tests
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Pull getProxyFromWellKnown mocking up
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Check we /haven't/ shorted out
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move our spy up so we can reuse it
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Check spidering is being called
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Test the proxy is declared
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Test entered manually
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Sorry, linter
* I guess these strings are wrong?
* Replace any with string
Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
---------
Signed-off-by: Ed Geraghty <ed@geraghty.family>
Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
2024-05-01 02:11:11 +08:00
|
|
|
describe("setup", () => {
|
|
|
|
beforeEach(() => {
|
|
|
|
jest.spyOn(manager, "configure");
|
|
|
|
jest.spyOn(manager, "startSpidering");
|
|
|
|
});
|
|
|
|
it("uses the baseUrl as a proxy if no proxy is set in the client well-known and the server has no native support", async () => {
|
|
|
|
await manager.setup(client);
|
|
|
|
expect(manager.configure).toHaveBeenCalled();
|
|
|
|
expect(manager.configure).toHaveBeenCalledWith(client, client.baseUrl);
|
|
|
|
expect(manager.startSpidering).toHaveBeenCalled();
|
|
|
|
});
|
|
|
|
it("uses the proxy declared in the client well-known", async () => {
|
2024-05-14 20:40:10 +08:00
|
|
|
jest.spyOn(manager, "getProxyFromWellKnown").mockResolvedValue("https://proxy/");
|
MSC3575 (Sliding Sync) add well-known proxy support (#12307)
* Initial commit
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove commented code
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Change function to reflect it's proxy not native support
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Re-add check for servers with native support
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add native support check back in
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Re-add endpoint health check function
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Use inbuilt `getWellKnown` function
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Change the error message to the correct function
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Stop storing the proxyurl in the settings for now
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Make the logger messages more useful
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Start moving the checking logic directly into the controller
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add missing import
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Get the client rather than passing it in to the functions
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* remove invalid `function` keyword
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Fix imports
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Our new functions are private
We shouldn't(?) have to use these check in future elsewhere
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Change our proxy check function to return a boolean
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Make `nativeSlidingSyncSupport` also return boolean, add in health check
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Disable the sliding sync option if the server doesn't support
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Only enable the setting if it passes (again)
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Update our comments to better match what's going on
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove unused dialog
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add a well-known check on start-up, if sliding sync has been enabled
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Check against the correct endpoint...
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Extract baseUrl as we'll reuse it
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Make the logs differentiate between the types of proxy
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Grab the client well-known directly for use
Can't use the client object at this point, it hasn't read in the well-known
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add myself to the copyright assignation
I wrote the majority of this file...
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Only return `true` if it's actually there
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Correct the `proxySlidingSyncSupport` function comment to match the code
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Correct the `nativeSlidingSyncSupport`function comment to match the code
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Another comment/functionality paring
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove duplicated types from the doc
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move await to the previous line
Removes brackets, and corrects `wellKnown` from being a `Promise`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* use `waitForClientWellKnown` to avoid a race condition with the request
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move getting the client out of the `if`, use `waitForClientWellKnown`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove `beforeChange` override
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move proxy setup logic into `SlidingSyncManager`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Swap `configure` to private, we call it from `setup` which handles proxy
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Promises are always `true`
TIL.
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* use `timeoutSignal`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Change message when there's no server support
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Refactor `slidingSyncHealthCheck`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Refactor `nativeSlidingSyncSupport` with try/catch
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Change comment to hotlink
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Try and make the toggle disabled when there's no endpoint
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move the if statement outside the refactored fn to avoid an await
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Revert "Swap `configure` to private, we call it from `setup` which handles proxy"
This reverts commit c80a00b50c261becc9ad58e08d2a893d572d8426.
* Remove unused import
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Further refactor `slidingSyncHealthCheck`
`proxySlidingSyncSupport` already checks the client well-known is there
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Make `proxySlidingSyncSupport` log on success
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Clarify log message for proxy being up
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move the logic into SlidingSyncManager
All so we can set a static variable because the disabled check isn't asynchronous :)
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Obviously this isn't a return so don't overwrite with false!
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove outdated comment
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* No need to pass in the client
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Activating SS should probably be info level logs
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* If we've not enabled sliding sync, push the logs down a bit
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Update i18n error message
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove unused i18n strings
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Correct log message
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Prettier
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove many of the log messages
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Short out of `checkSupport` if it's `true`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add the endpoint back into the log when we're enabling it
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Note in the comment that `feature_sliding_sync_proxy_url` is legacy
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Expand the well-known liveness check log
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* No need to stall the client waiting for sliding sync support
* `AutoDiscovery.findClientConfig` throws if the baseUrl is blank
* Fix `getProxyFromWellKnown` (?)
* Add missing semicolon
Sorry, linter!
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Pass our `MatrixClient` through instead of trying to grab it
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add missing return in function comment
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Actually pass through our Client, not the Peg object
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove SonarCube smell complaint
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Neew to make our other two methods public to test
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* First passing test
Hurrah!
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Two more tests, this time on `checkSupport`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Reset our `serverSupportsSlidingSync` between tests
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Check the static member is being set
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move the static assignation down to the relevant tests
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Pull getProxyFromWellKnown mocking up
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Check we /haven't/ shorted out
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move our spy up so we can reuse it
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Check spidering is being called
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Test the proxy is declared
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Test entered manually
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Sorry, linter
* I guess these strings are wrong?
* Replace any with string
Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
---------
Signed-off-by: Ed Geraghty <ed@geraghty.family>
Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
2024-05-01 02:11:11 +08:00
|
|
|
await manager.setup(client);
|
|
|
|
expect(manager.configure).toHaveBeenCalled();
|
2024-05-14 20:40:10 +08:00
|
|
|
expect(manager.configure).toHaveBeenCalledWith(client, "https://proxy/");
|
MSC3575 (Sliding Sync) add well-known proxy support (#12307)
* Initial commit
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove commented code
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Change function to reflect it's proxy not native support
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Re-add check for servers with native support
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add native support check back in
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Re-add endpoint health check function
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Use inbuilt `getWellKnown` function
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Change the error message to the correct function
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Stop storing the proxyurl in the settings for now
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Make the logger messages more useful
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Start moving the checking logic directly into the controller
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add missing import
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Get the client rather than passing it in to the functions
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* remove invalid `function` keyword
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Fix imports
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Our new functions are private
We shouldn't(?) have to use these check in future elsewhere
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Change our proxy check function to return a boolean
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Make `nativeSlidingSyncSupport` also return boolean, add in health check
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Disable the sliding sync option if the server doesn't support
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Only enable the setting if it passes (again)
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Update our comments to better match what's going on
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove unused dialog
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add a well-known check on start-up, if sliding sync has been enabled
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Check against the correct endpoint...
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Extract baseUrl as we'll reuse it
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Make the logs differentiate between the types of proxy
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Grab the client well-known directly for use
Can't use the client object at this point, it hasn't read in the well-known
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add myself to the copyright assignation
I wrote the majority of this file...
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Only return `true` if it's actually there
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Correct the `proxySlidingSyncSupport` function comment to match the code
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Correct the `nativeSlidingSyncSupport`function comment to match the code
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Another comment/functionality paring
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove duplicated types from the doc
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move await to the previous line
Removes brackets, and corrects `wellKnown` from being a `Promise`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* use `waitForClientWellKnown` to avoid a race condition with the request
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move getting the client out of the `if`, use `waitForClientWellKnown`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove `beforeChange` override
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move proxy setup logic into `SlidingSyncManager`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Swap `configure` to private, we call it from `setup` which handles proxy
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Promises are always `true`
TIL.
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* use `timeoutSignal`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Change message when there's no server support
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Refactor `slidingSyncHealthCheck`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Refactor `nativeSlidingSyncSupport` with try/catch
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Change comment to hotlink
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Try and make the toggle disabled when there's no endpoint
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move the if statement outside the refactored fn to avoid an await
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Revert "Swap `configure` to private, we call it from `setup` which handles proxy"
This reverts commit c80a00b50c261becc9ad58e08d2a893d572d8426.
* Remove unused import
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Further refactor `slidingSyncHealthCheck`
`proxySlidingSyncSupport` already checks the client well-known is there
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Make `proxySlidingSyncSupport` log on success
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Clarify log message for proxy being up
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move the logic into SlidingSyncManager
All so we can set a static variable because the disabled check isn't asynchronous :)
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Obviously this isn't a return so don't overwrite with false!
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove outdated comment
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* No need to pass in the client
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Activating SS should probably be info level logs
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* If we've not enabled sliding sync, push the logs down a bit
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Update i18n error message
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove unused i18n strings
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Correct log message
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Prettier
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove many of the log messages
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Short out of `checkSupport` if it's `true`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add the endpoint back into the log when we're enabling it
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Note in the comment that `feature_sliding_sync_proxy_url` is legacy
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Expand the well-known liveness check log
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* No need to stall the client waiting for sliding sync support
* `AutoDiscovery.findClientConfig` throws if the baseUrl is blank
* Fix `getProxyFromWellKnown` (?)
* Add missing semicolon
Sorry, linter!
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Pass our `MatrixClient` through instead of trying to grab it
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add missing return in function comment
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Actually pass through our Client, not the Peg object
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove SonarCube smell complaint
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Neew to make our other two methods public to test
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* First passing test
Hurrah!
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Two more tests, this time on `checkSupport`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Reset our `serverSupportsSlidingSync` between tests
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Check the static member is being set
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move the static assignation down to the relevant tests
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Pull getProxyFromWellKnown mocking up
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Check we /haven't/ shorted out
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move our spy up so we can reuse it
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Check spidering is being called
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Test the proxy is declared
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Test entered manually
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Sorry, linter
* I guess these strings are wrong?
* Replace any with string
Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
---------
Signed-off-by: Ed Geraghty <ed@geraghty.family>
Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
2024-05-01 02:11:11 +08:00
|
|
|
expect(manager.startSpidering).toHaveBeenCalled();
|
|
|
|
});
|
|
|
|
it("uses the legacy `feature_sliding_sync_proxy_url` if it was set", async () => {
|
2024-05-14 20:40:10 +08:00
|
|
|
jest.spyOn(manager, "getProxyFromWellKnown").mockResolvedValue("https://proxy/");
|
MSC3575 (Sliding Sync) add well-known proxy support (#12307)
* Initial commit
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove commented code
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Change function to reflect it's proxy not native support
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Re-add check for servers with native support
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add native support check back in
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Re-add endpoint health check function
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Use inbuilt `getWellKnown` function
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Change the error message to the correct function
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Stop storing the proxyurl in the settings for now
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Make the logger messages more useful
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Start moving the checking logic directly into the controller
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add missing import
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Get the client rather than passing it in to the functions
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* remove invalid `function` keyword
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Fix imports
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Our new functions are private
We shouldn't(?) have to use these check in future elsewhere
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Change our proxy check function to return a boolean
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Make `nativeSlidingSyncSupport` also return boolean, add in health check
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Disable the sliding sync option if the server doesn't support
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Only enable the setting if it passes (again)
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Update our comments to better match what's going on
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove unused dialog
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add a well-known check on start-up, if sliding sync has been enabled
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Check against the correct endpoint...
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Extract baseUrl as we'll reuse it
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Make the logs differentiate between the types of proxy
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Grab the client well-known directly for use
Can't use the client object at this point, it hasn't read in the well-known
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add myself to the copyright assignation
I wrote the majority of this file...
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Only return `true` if it's actually there
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Correct the `proxySlidingSyncSupport` function comment to match the code
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Correct the `nativeSlidingSyncSupport`function comment to match the code
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Another comment/functionality paring
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove duplicated types from the doc
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move await to the previous line
Removes brackets, and corrects `wellKnown` from being a `Promise`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* use `waitForClientWellKnown` to avoid a race condition with the request
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move getting the client out of the `if`, use `waitForClientWellKnown`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove `beforeChange` override
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move proxy setup logic into `SlidingSyncManager`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Swap `configure` to private, we call it from `setup` which handles proxy
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Promises are always `true`
TIL.
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* use `timeoutSignal`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Change message when there's no server support
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Refactor `slidingSyncHealthCheck`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Refactor `nativeSlidingSyncSupport` with try/catch
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Change comment to hotlink
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Try and make the toggle disabled when there's no endpoint
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move the if statement outside the refactored fn to avoid an await
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Revert "Swap `configure` to private, we call it from `setup` which handles proxy"
This reverts commit c80a00b50c261becc9ad58e08d2a893d572d8426.
* Remove unused import
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Further refactor `slidingSyncHealthCheck`
`proxySlidingSyncSupport` already checks the client well-known is there
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Make `proxySlidingSyncSupport` log on success
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Clarify log message for proxy being up
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move the logic into SlidingSyncManager
All so we can set a static variable because the disabled check isn't asynchronous :)
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Obviously this isn't a return so don't overwrite with false!
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove outdated comment
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* No need to pass in the client
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Activating SS should probably be info level logs
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* If we've not enabled sliding sync, push the logs down a bit
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Update i18n error message
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove unused i18n strings
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Correct log message
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Prettier
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove many of the log messages
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Short out of `checkSupport` if it's `true`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add the endpoint back into the log when we're enabling it
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Note in the comment that `feature_sliding_sync_proxy_url` is legacy
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Expand the well-known liveness check log
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* No need to stall the client waiting for sliding sync support
* `AutoDiscovery.findClientConfig` throws if the baseUrl is blank
* Fix `getProxyFromWellKnown` (?)
* Add missing semicolon
Sorry, linter!
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Pass our `MatrixClient` through instead of trying to grab it
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Add missing return in function comment
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Actually pass through our Client, not the Peg object
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Remove SonarCube smell complaint
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Neew to make our other two methods public to test
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* First passing test
Hurrah!
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Two more tests, this time on `checkSupport`
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Reset our `serverSupportsSlidingSync` between tests
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Check the static member is being set
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move the static assignation down to the relevant tests
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Pull getProxyFromWellKnown mocking up
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Check we /haven't/ shorted out
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Move our spy up so we can reuse it
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Check spidering is being called
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Test the proxy is declared
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Test entered manually
Signed-off-by: Ed Geraghty <ed@geraghty.family>
* Sorry, linter
* I guess these strings are wrong?
* Replace any with string
Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
---------
Signed-off-by: Ed Geraghty <ed@geraghty.family>
Co-authored-by: Michael Telatynski <7t3chguy@gmail.com>
2024-05-01 02:11:11 +08:00
|
|
|
jest.spyOn(SettingsStore, "getValue").mockImplementation((name: string) => {
|
|
|
|
if (name === "feature_sliding_sync_proxy_url") return "legacy-proxy";
|
|
|
|
});
|
|
|
|
await manager.setup(client);
|
|
|
|
expect(manager.configure).toHaveBeenCalled();
|
|
|
|
expect(manager.configure).toHaveBeenCalledWith(client, "legacy-proxy");
|
|
|
|
expect(manager.startSpidering).toHaveBeenCalled();
|
|
|
|
});
|
|
|
|
});
|
2022-11-01 18:27:03 +08:00
|
|
|
});
|