Skip to content
Merged
Show file tree
Hide file tree
Changes from 37 commits
Commits
Show all changes
48 commits
Select commit Hold shift + click to select a range
df7bb61
Experimental SSS
dbkr Sep 12, 2024
7fbac10
Adjust tests to use new behaviour
kegsay Sep 13, 2024
194362a
Remove well-known proxy URL lookup; always use native
kegsay Sep 13, 2024
48eec70
Linting
kegsay Sep 13, 2024
797ef2d
Merge branch 'develop' into dbkr/sss
kegsay Sep 16, 2024
8325c59
Debug logging
kegsay Sep 16, 2024
ee85f73
Control the race condition when swapping between rooms
kegsay Sep 16, 2024
be76852
Dont' filter by space as synapse doesn't support it
kegsay Sep 16, 2024
0b142b4
Remove SS code related to registering lists and managing ranges
kegsay Sep 17, 2024
7621fe2
User bumpStamp if it is present
kegsay Sep 17, 2024
7662b99
Drop initial room load from 20 per list to 10
kegsay Sep 18, 2024
52c2436
Half the batch size to trickle more quickly
kegsay Sep 18, 2024
f90178a
Merge remote-tracking branch 'react-sdk/dbkr/sss' into dbkr/sss
dbkr Nov 21, 2024
bb2f6d3
Merge branch 'develop' into dbkr/sss
dbkr Nov 21, 2024
628d2bd
Prettier
dbkr Nov 21, 2024
473d861
prettier on tests too
dbkr Nov 21, 2024
60cee83
Merge remote-tracking branch 'origin/develop' into dbkr/sss
dbkr Dec 13, 2024
fd97548
Merge branch 'develop' into dbkr/sss
dbkr Feb 12, 2025
fb1b7e2
Remove proxy URL & unused import
dbkr Feb 12, 2025
56906bb
Hopefully fix tests to assert what the behaviour is supposed to be
dbkr Feb 12, 2025
ef990e2
Move the singleton to the manager tyo fix import loop
dbkr Feb 13, 2025
e60b331
Very well, code, I will remove you
dbkr Feb 13, 2025
ce6a080
Strip out more unused stuff
dbkr Feb 13, 2025
7af6053
Fix playwright test
dbkr Feb 13, 2025
5ce0d09
Fix test to do maybe what it was supposed to do... possibly?
dbkr Feb 13, 2025
560dc15
Remove test for old pre-simplified sliding sync behaviour
dbkr Feb 13, 2025
0608f82
Unused import
dbkr Feb 13, 2025
527c636
Remove sliding sync proxy & test
dbkr Feb 17, 2025
31efca4
Merge branch 'develop' into dbkr/sss
dbkr Feb 17, 2025
9fa612a
Remove now pointless credentials
dbkr Feb 17, 2025
9475972
Remove subscription removal as SSS doesn't do that
dbkr Feb 19, 2025
943a452
Update tests
dbkr Feb 19, 2025
efd78e1
add test
dbkr Feb 19, 2025
81507f3
Switch to new labs flag & break if old labs flag is enabled
dbkr Feb 19, 2025
0bbd2d3
Remove unused import & fix test
dbkr Feb 19, 2025
084fe59
Fix other test
dbkr Feb 19, 2025
8a52c49
Remove name & description from old labs flag
dbkr Feb 19, 2025
3d6afc7
Remove old sliding sync option
dbkr Mar 6, 2025
3777116
Add back unread nindicator test but inverted
dbkr Mar 10, 2025
fc41b54
Reinstate test for room_subscriptions
dbkr Mar 10, 2025
378b8c9
Use UserFriendlyError
dbkr Mar 10, 2025
5943e41
Remove empty constructor
dbkr Mar 10, 2025
4b0c52c
Remove unrelated changes
dbkr Mar 10, 2025
da7e4ba
Merge remote-tracking branch 'origin/develop' into dbkr/sss
dbkr Mar 10, 2025
e2e9a46
Unused import
dbkr Mar 10, 2025
862174a
Fix import
dbkr Mar 10, 2025
5f8719f
Avoid moving import
dbkr Mar 10, 2025
04554ef
Merge remote-tracking branch 'origin/develop' into dbkr/sss
dbkr Mar 18, 2025
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 1 addition & 105 deletions playwright/e2e/sliding-sync/sliding-sync.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,48 +6,16 @@ SPDX-License-Identifier: AGPL-3.0-only OR GPL-3.0-only OR LicenseRef-Element-Com
Please see LICENSE files in the repository root for full details.
*/

import { type Page, type Request } from "@playwright/test";
import { GenericContainer, type StartedTestContainer, Wait } from "testcontainers";
import { type Page } from "@playwright/test";

import { test as base, expect } from "../../element-web-test";
import type { ElementAppPage } from "../../pages/ElementAppPage";
import type { Bot } from "../../pages/bot";

const test = base.extend<{
slidingSyncProxy: StartedTestContainer;
testRoom: { roomId: string; name: string };
joinedBot: Bot;
}>({
slidingSyncProxy: async ({ logger, network, postgres, page, homeserver }, use, testInfo) => {
const container = await new GenericContainer("ghcr.io/matrix-org/sliding-sync:v0.99.3")
.withNetwork(network)
.withExposedPorts(8008)
.withLogConsumer(logger.getConsumer("sliding-sync-proxy"))
.withWaitStrategy(Wait.forHttp("/client/server.json", 8008))
.withEnvironment({
SYNCV3_SECRET: "bwahahaha",
SYNCV3_DB: `user=${postgres.getUsername()} dbname=postgres password=${postgres.getPassword()} host=postgres sslmode=disable`,
SYNCV3_SERVER: `http://homeserver:8008`,
})
.start();

const proxyAddress = `http://${container.getHost()}:${container.getMappedPort(8008)}`;
await page.addInitScript((proxyAddress) => {
window.localStorage.setItem(
"mx_local_settings",
JSON.stringify({
feature_sliding_sync_proxy_url: proxyAddress,
}),
);
window.localStorage.setItem("mx_labs_feature_feature_sliding_sync", "true");
}, proxyAddress);
await use(container);
await container.stop();
},
// Ensure slidingSyncProxy is set up before the user fixture as it relies on an init script
credentials: async ({ slidingSyncProxy, credentials }, use) => {
await use(credentials);
},
testRoom: async ({ user, app }, use) => {
const name = "Test Room";
const roomId = await app.client.createRoom({ name });
Expand Down Expand Up @@ -188,30 +156,6 @@ test.describe("Sliding Sync", () => {
).not.toBeAttached();
});

test("should not show unread indicators", async ({ page, app, joinedBot: bot, testRoom }) => {
// TODO: for now. Later we should.

// disable notifs in this room (TODO: CS API call?)
const locator = page.getByRole("treeitem", { name: "Test Room" });
await locator.hover();
await locator.getByRole("button", { name: "Notification options" }).click();
await page.getByRole("menuitemradio", { name: "Mute room" }).click();

// create a new room so we know when the message has been received as it'll re-shuffle the room list
await app.client.createRoom({ name: "Dummy" });

await checkOrder(["Dummy", "Test Room"], page);

await bot.sendMessage(testRoom.roomId, "Do you read me?");

// wait for this message to arrive, tell by the room list resorting
await checkOrder(["Test Room", "Dummy"], page);

await expect(
page.getByRole("treeitem", { name: "Test Room" }).locator(".mx_NotificationBadge"),
).not.toBeAttached();
});

test("should update user settings promptly", async ({ page, app }) => {
await app.settings.openUserSettings("Preferences");
const locator = page.locator(".mx_SettingsFlag").filter({ hasText: "Show timestamps in 12 hour format" });
Expand Down Expand Up @@ -361,52 +305,4 @@ test.describe("Sliding Sync", () => {
// ensure the reply-to does not disappear
await expect(page.locator(".mx_ReplyPreview")).toBeVisible();
});

test("should send unsubscribe_rooms for every room switch", async ({ page, app }) => {
// create rooms and check room names are correct
const roomIds: string[] = [];
for (const fruit of ["Apple", "Pineapple", "Orange"]) {
const id = await app.client.createRoom({ name: fruit });
roomIds.push(id);
await expect(page.getByRole("treeitem", { name: fruit })).toBeVisible();
}
const [roomAId, roomPId, roomOId] = roomIds;

const matchRoomSubRequest = (subRoomId: string) => (request: Request) => {
if (!request.url().includes("/sync")) return false;
const body = request.postDataJSON();
return body.txn_id && body.room_subscriptions?.[subRoomId];
};
const matchRoomUnsubRequest = (unsubRoomId: string) => (request: Request) => {
if (!request.url().includes("/sync")) return false;
const body = request.postDataJSON();
return (
body.txn_id && body.unsubscribe_rooms?.includes(unsubRoomId) && !body.room_subscriptions?.[unsubRoomId]
);
};

// Select the Test Room and wait for playwright to get the request
const [request] = await Promise.all([
page.waitForRequest(matchRoomSubRequest(roomAId)),
page.getByRole("treeitem", { name: "Apple", exact: true }).click(),
]);
const roomSubscriptions = request.postDataJSON().room_subscriptions;
expect(roomSubscriptions, "room_subscriptions is object").toBeDefined();

// Switch to another room and wait for playwright to get the request
await Promise.all([
page.waitForRequest(matchRoomSubRequest(roomPId)),
page.waitForRequest(matchRoomUnsubRequest(roomAId)),
page.getByRole("treeitem", { name: "Pineapple", exact: true }).click(),
]);

// And switch to even another room and wait for playwright to get the request
await Promise.all([
page.waitForRequest(matchRoomSubRequest(roomOId)),
page.waitForRequest(matchRoomUnsubRequest(roomPId)),
page.getByRole("treeitem", { name: "Orange", exact: true }).click(),
]);

// TODO: Add tests for encrypted rooms
});
});
8 changes: 8 additions & 0 deletions src/MatrixClientPeg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -299,6 +299,14 @@ class MatrixClientPegClass implements IMatrixClientPeg {
opts.threadSupport = true;

if (SettingsStore.getValue("feature_sliding_sync")) {
throw new Error(
"Legacy sliding sync is no longer supported: please log out and back in to enable the new sliding sync flag",
);
}

// If the user has enabled the labs feature for sliding sync, set it up
// otherwise check if the feature is supported
if (SettingsStore.getValue("feature_simplified_sliding_sync")) {
opts.slidingSync = await SlidingSyncManager.instance.setup(this.matrixClient);
} else {
SlidingSyncManager.instance.checkSupport(this.matrixClient);
Expand Down
Loading
Loading