Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
3 changes: 2 additions & 1 deletion apps/desktop/hak/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
{
"compilerOptions": {
"moduleResolution": "node",
"moduleResolution": "node16",
"module": "Node16",
"esModuleInterop": true,
"target": "es2022",
"sourceMap": false,
Expand Down
2 changes: 1 addition & 1 deletion apps/desktop/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@
"prettier": "^3.0.0",
"rimraf": "^6.0.0",
"tar": "^7.5.8",
"typescript": "5.9.3"
"typescript": "6.0.3"
},
"hakDependencies": {
"matrix-seshat": "4.2.0"
Expand Down
4 changes: 2 additions & 2 deletions apps/desktop/playwright/element-desktop-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,14 @@ import { PassThrough } from "node:stream";
* A PassThrough stream that captures all data written to it.
*/
class CapturedPassThrough extends PassThrough {
private _chunks = [];
private _chunks: any[] = [];

public constructor() {
super();
super.on("data", this.onData);
}

private onData = (chunk): void => {
private onData = (chunk: any): void => {
this._chunks.push(chunk);
};

Expand Down
7 changes: 4 additions & 3 deletions apps/desktop/playwright/tsconfig.json
Original file line number Diff line number Diff line change
@@ -1,11 +1,12 @@
{
"compilerOptions": {
"resolveJsonModule": true,
"moduleResolution": "node",
"moduleResolution": "bundler",
"esModuleInterop": true,
"target": "es2022",
"module": "es2022",
"lib": ["es2022", "dom"],
"module": "ESNext",
"lib": ["es2024", "dom", "dom.iterable"],
"strictNullChecks": false,
"types": ["node"]
},
"include": ["**/*.ts"]
Expand Down
10 changes: 5 additions & 5 deletions apps/web/playwright/e2e/audio-player/audio-player.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Please see LICENSE files in the repository root for full details.
*/

import type { Locator, Page } from "@playwright/test";
import { test, expect } from "../../element-web-test";
import { test, expect, type ExtendedToMatchScreenshotOptions } from "../../element-web-test";
import { SettingLevel } from "../../../src/settings/SettingLevel";
import { Layout } from "../../../src/settings/enums/Layout";
import { type ElementAppPage } from "../../pages/ElementAppPage";
Expand Down Expand Up @@ -94,7 +94,7 @@ test.describe("Audio player", { tag: ["@no-firefox", "@no-webkit"] }, () => {
// Assert that rendering of the player settled and the play button is visible before taking a snapshot
await checkPlayerVisibility(ircTile);

const screenshotOptions = {
const screenshotOptions: ExtendedToMatchScreenshotOptions = {
css: `
/* The timestamp is of inconsistent width depending on the time the test runs at */
.mx_MessageTimestamp {
Expand All @@ -120,7 +120,7 @@ test.describe("Audio player", { tag: ["@no-firefox", "@no-webkit"] }, () => {
};

// Take a snapshot of mx_EventTile_last on IRC layout
screenshotOptions.clip = await page.locator(".mx_EventTile_last").boundingBox();
screenshotOptions.clip = (await page.locator(".mx_EventTile_last").boundingBox()) ?? undefined;
await scrollToBottomOfTimeline(page);
await expect(page).toMatchScreenshot(`${detail.replaceAll(" ", "-")}-irc-layout.png`, screenshotOptions);

Expand All @@ -129,7 +129,7 @@ test.describe("Audio player", { tag: ["@no-firefox", "@no-webkit"] }, () => {
const groupTile = page.locator(".mx_EventTile_last[data-layout='group']");
await groupTile.locator(".mx_MessageTimestamp").click();
await checkPlayerVisibility(groupTile);
screenshotOptions.clip = await page.locator(".mx_EventTile_last").boundingBox();
screenshotOptions.clip = (await page.locator(".mx_EventTile_last").boundingBox()) ?? undefined;
await scrollToBottomOfTimeline(page);
await expect(page).toMatchScreenshot(`${detail.replaceAll(" ", "-")}-group-layout.png`, screenshotOptions);

Expand All @@ -138,7 +138,7 @@ test.describe("Audio player", { tag: ["@no-firefox", "@no-webkit"] }, () => {
const bubbleTile = page.locator(".mx_EventTile_last[data-layout='bubble']");
await bubbleTile.locator(".mx_MessageTimestamp").click();
await checkPlayerVisibility(bubbleTile);
screenshotOptions.clip = await page.locator(".mx_EventTile_last").boundingBox();
screenshotOptions.clip = (await page.locator(".mx_EventTile_last").boundingBox()) ?? undefined;
await scrollToBottomOfTimeline(page);
await expect(page).toMatchScreenshot(`${detail.replaceAll(" ", "-")}-bubble-layout.png`, screenshotOptions);
};
Expand Down
2 changes: 1 addition & 1 deletion apps/web/playwright/e2e/crypto/crypto.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -44,7 +44,7 @@
const bobRooms = cli.getRooms();
if (!bobRooms.length) {
await new Promise<void>((resolve) => {
const onMembership = (_event) => {
const onMembership = () => {
cli.off(window.matrixcs.RoomMemberEvent.Membership, onMembership);
resolve();
};
Expand Down Expand Up @@ -78,7 +78,7 @@
*/
async function verifyKey(app: ElementAppPage, keyType: "master" | "self_signing" | "user_signing") {
const accountData: { encrypted: Record<string, Record<string, string>> } = await app.client.evaluate(
(cli, keyType) => cli.getAccountDataFromServer(`m.cross_signing.${keyType}`),

Check warning on line 81 in apps/web/playwright/e2e/crypto/crypto.spec.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

'keyType' will use Object's default stringification format ('[object Object]') when stringified.

See more on https://sonarcloud.io/project/issues?id=element-web&issues=AZ20ztJ7Gau9SDmv6Zax&open=AZ20ztJ7Gau9SDmv6Zax&pullRequest=32927
keyType,
);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ 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 { EmittedEvents, Preset } from "matrix-js-sdk/src/matrix";
import type { Preset, RoomMemberEvent, RoomStateEvent } from "matrix-js-sdk/src/matrix";
import { expect, test } from "../../element-web-test";
import {
createRoom,
Expand Down Expand Up @@ -122,7 +122,7 @@ test.describe("Cryptography", function () {
const roomId = await bob.evaluate(
async (client, { alice }) => {
const encryptionStatePromise = new Promise<void>((resolve) => {
client.on("RoomState.events" as EmittedEvents, (event, _state, _lastStateEvent) => {
client.on("RoomState.events" as RoomStateEvent.Events, (event, _state, _lastStateEvent) => {
if (event.getType() === "m.room.encryption") {
resolve();
}
Expand Down Expand Up @@ -253,11 +253,14 @@ test.describe("Cryptography", function () {

// invite Alice
const inviteAlicePromise = new Promise<void>((resolve) => {
client.on("RoomMember.membership" as EmittedEvents, (_event, member, _oldMembership?) => {
if (member.userId === alice.userId && member.membership === "invite") {
resolve();
}
});
client.on(
"RoomMember.membership" as RoomMemberEvent.Membership,
(_event, member, _oldMembership?) => {
if (member.userId === alice.userId && member.membership === "invite") {
resolve();
}
},
);
});
await client.invite(roomId, alice.userId);
// wait for the invite to come back so that we encrypt to Alice
Expand All @@ -271,11 +274,14 @@ test.describe("Cryptography", function () {

// kick Alice
const kickAlicePromise = new Promise<void>((resolve) => {
client.on("RoomMember.membership" as EmittedEvents, (_event, member, _oldMembership?) => {
if (member.userId === alice.userId && member.membership === "leave") {
resolve();
}
});
client.on(
"RoomMember.membership" as RoomMemberEvent.Membership,
(_event, member, _oldMembership?) => {
if (member.userId === alice.userId && member.membership === "leave") {
resolve();
}
},
);
});
await client.kick(roomId, alice.userId);
await kickAlicePromise;
Expand Down
10 changes: 3 additions & 7 deletions apps/web/playwright/e2e/crypto/dehydration.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -166,13 +166,9 @@ async function getDehydratedDeviceIds(client: Client): Promise<string[]> {
return await client.evaluate(async (client) => {
const userId = client.getUserId();
const devices = await client.getCrypto().getUserDeviceInfo([userId]);
return Array.from(
devices
.get(userId)
.values()
.filter((d) => d.dehydrated)
.map((d) => d.deviceId),
);
return Array.from(devices.get(userId).values())
.filter((d) => d.dehydrated)
.map((d) => d.deviceId);
});
}

Expand Down
4 changes: 2 additions & 2 deletions apps/web/playwright/e2e/crypto/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -579,8 +579,8 @@ export async function deleteCachedSecrets(page: Page) {
await page.evaluate(async () => {
const removeCachedSecrets = new Promise((resolve) => {
const request = window.indexedDB.open("matrix-js-sdk::matrix-sdk-crypto");
request.onsuccess = (event: Event & { target: { result: IDBDatabase } }) => {
const db = event.target.result;
request.onsuccess = function (this: IDBRequest) {
const db = this.result as IDBDatabase;
const request = db.transaction("core", "readwrite").objectStore("core").delete("private_identity");
request.onsuccess = () => {
db.close();
Expand Down
4 changes: 2 additions & 2 deletions apps/web/playwright/e2e/read-receipts/read-receipts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Please see LICENSE files in the repository root for full details.
*/

import type { JSHandle } from "@playwright/test";
import type { MatrixEvent, ISendEventResponse, ReceiptType } from "matrix-js-sdk/src/matrix";
import type { MatrixEvent, ISendEventResponse, ReceiptType, RelationType } from "matrix-js-sdk/src/matrix";
import { expect } from "../../element-web-test";
import { type ElementAppPage } from "../../pages/ElementAppPage";
import { type Bot } from "../../pages/bot";
Expand Down Expand Up @@ -47,7 +47,7 @@ test.describe("Read receipts", { tag: "@mergequeue" }, () => {
getId: () => eventResponse.event_id,
threadRootId,
getTs: () => 1,
isRelation: (relType) => {
isRelation: (relType: RelationType) => {
return !relType || relType === "m.thread";
},
} as any as MatrixEvent;
Expand Down
6 changes: 2 additions & 4 deletions apps/web/playwright/e2e/timeline/timeline.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Please see LICENSE files in the repository root for full details.
*/

import type { Locator, Page } from "@playwright/test";
import type { ISendEventResponse, EventType, MsgType } from "matrix-js-sdk/src/matrix";
import type { ISendEventResponse, EventType, MsgType, IContent } from "matrix-js-sdk/src/matrix";
import { test, expect } from "../../element-web-test";
import { SettingLevel } from "../../../src/settings/SettingLevel";
import { Layout } from "../../../src/settings/enums/Layout";
Expand Down Expand Up @@ -50,11 +50,9 @@ const expectAvatar = async (cli: Client, e: Locator, avatarUrl: string): Promise
};

const sendEvent = async (client: Client, roomId: string, html = false): Promise<ISendEventResponse> => {
const content = {
const content: IContent = {
msgtype: "m.text" as MsgType,
body: "Message",
format: undefined,
formatted_body: undefined,
};
if (html) {
content.format = "org.matrix.custom.html";
Expand Down
4 changes: 2 additions & 2 deletions apps/web/playwright/e2e/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -42,15 +42,15 @@
return new Promise<Room>((resolve) => {
const room = matrixClient.getRoom(roomId);

if (window[predicateId](room)) {
if ((<any>window)[predicateId](room)) {

Check warning on line 45 in apps/web/playwright/e2e/utils.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer `globalThis` over `window`.

See more on https://sonarcloud.io/project/issues?id=element-web&issues=AZ20ztRXGau9SDmv6Zay&open=AZ20ztRXGau9SDmv6Zay&pullRequest=32927
resolve(room);
return;
}

function onEvent(ev: MatrixEvent) {
if (ev.getRoomId() !== roomId) return;

if (window[predicateId](room)) {
if ((<any>window)[predicateId](room)) {

Check warning on line 53 in apps/web/playwright/e2e/utils.ts

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Prefer `globalThis` over `window`.

See more on https://sonarcloud.io/project/issues?id=element-web&issues=AZ20ztRXGau9SDmv6Zaz&open=AZ20ztRXGau9SDmv6Zaz&pullRequest=32927
matrixClient.removeListener("event" as ClientEvent, onEvent);
resolve(room);
}
Expand Down
2 changes: 1 addition & 1 deletion apps/web/playwright/element-web-test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,7 +107,7 @@ export const test = base.extend<TestFixtures>({
},
});

interface ExtendedToMatchScreenshotOptions extends ToMatchScreenshotOptions {
export interface ExtendedToMatchScreenshotOptions extends ToMatchScreenshotOptions {
includeDialogBackground?: boolean;
showTooltips?: boolean;
timeout?: number;
Expand Down
30 changes: 29 additions & 1 deletion apps/web/playwright/pages/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ Please see LICENSE files in the repository root for full details.
*/

import { type JSHandle, type Page } from "@playwright/test";
import { type PageFunctionOn } from "playwright-core/types/structs";
import { type ElementHandle } from "playwright-core";

import { Network } from "./network";
import type {
Expand All @@ -30,6 +30,34 @@ import type {
import type { RoomMessageEventContent } from "matrix-js-sdk/src/types";
import { type CredentialsOptionalAccessToken } from "./bot";

/** Types cribbed from playwright-core/types/structs as they are not importable */
export type NoHandles<Arg> = Arg extends JSHandle
? never
: Arg extends object
? { [Key in keyof Arg]: NoHandles<Arg[Key]> }
: Arg;
export type Unboxed<Arg> =
Arg extends ElementHandle<infer T>
? T
: Arg extends JSHandle<infer T>
? T
: Arg extends NoHandles<Arg>
? Arg
: Arg extends [infer A0]
? [Unboxed<A0>]
: Arg extends [infer A0, infer A1]
? [Unboxed<A0>, Unboxed<A1>]
: Arg extends [infer A0, infer A1, infer A2]
? [Unboxed<A0>, Unboxed<A1>, Unboxed<A2>]
: Arg extends [infer A0, infer A1, infer A2, infer A3]
? [Unboxed<A0>, Unboxed<A1>, Unboxed<A2>, Unboxed<A3>]
: Arg extends Array<infer T>
? Array<Unboxed<T>>
: Arg extends object
? { [Key in keyof Arg]: Unboxed<Arg[Key]> }
: Arg;
export type PageFunctionOn<On, Arg2, R> = string | ((on: On, arg2: Unboxed<Arg2>) => R | Promise<R>);

export class Client {
public network: Network;
protected client: JSHandle<MatrixClient>;
Expand Down
26 changes: 13 additions & 13 deletions apps/web/playwright/testcontainers/dendrite.ts
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ const DEFAULT_CONFIG = {
global: {
server_name: "localhost",
private_key: "matrix_key.pem",
old_private_keys: null,
old_private_keys: null as any,
key_validity_period: "168h0m0s",
cache: {
max_size_estimated: "1gb",
Expand All @@ -47,7 +47,7 @@ const DEFAULT_CONFIG = {
room_name: "Server Alerts",
},
jetstream: {
addresses: null,
addresses: null as any,
disable_tls_validation: false,
storage_path: "./",
topic_prefix: "Dendrite",
Expand All @@ -67,7 +67,7 @@ const DEFAULT_CONFIG = {
},
app_service_api: {
disable_tls_validation: false,
config_files: null,
config_files: null as any,
},
client_api: {
registration_disabled: false,
Expand All @@ -79,14 +79,14 @@ const DEFAULT_CONFIG = {
recaptcha_bypass_secret: "",
turn: {
turn_user_lifetime: "5m",
turn_uris: null,
turn_uris: null as any,
turn_shared_secret: "",
},
rate_limiting: {
enabled: true,
threshold: 20,
cooloff_ms: 500,
exempt_user_ids: null,
exempt_user_ids: null as any,
},
},
federation_api: {
Expand Down Expand Up @@ -140,7 +140,7 @@ const DEFAULT_CONFIG = {
},
},
mscs: {
mscs: null,
mscs: null as any,
database: {
connection_string: "file:dendrite-msc.db",
},
Expand All @@ -157,7 +157,7 @@ const DEFAULT_CONFIG = {
},
user_api: {
bcrypt_cost: 10,
auto_join_rooms: null,
auto_join_rooms: null as any,
account_database: {
connection_string: "file:dendrite-userapi.db",
},
Expand All @@ -183,12 +183,12 @@ const DEFAULT_CONFIG = {
serviceName: "",
disabled: false,
rpc_metrics: false,
tags: [],
sampler: null,
reporter: null,
headers: null,
baggage_restrictions: null,
throttler: null,
tags: [] as any[],
sampler: null as any,
reporter: null as any,
headers: null as any,
baggage_restrictions: null as any,
throttler: null as any,
},
},
logging: [
Expand Down
Loading
Loading