diff --git a/playwright/testcontainers/synapse.ts b/playwright/testcontainers/synapse.ts index ff1b000232..8c5fafdbd5 100644 --- a/playwright/testcontainers/synapse.ts +++ b/playwright/testcontainers/synapse.ts @@ -243,7 +243,7 @@ export class StartedSynapseContainer extends AbstractStartedContainer implements ) { super(container); this.csApi = new ClientServerApi(this.baseUrl); - this.adminApi = new Api(`${this.baseUrl}/_synapse/admin/`); + this.adminApi = new Api(`${this.baseUrl}/_synapse/admin`); } public setRequest(request: APIRequestContext): void { @@ -266,10 +266,10 @@ export class StartedSynapseContainer extends AbstractStartedContainer implements // We hide the rooms from the room directory to save time between tests and for portability between homeservers const { chunk: rooms } = await this.csApi.request<{ chunk: { room_id: string }[]; - }>("GET", "v3/publicRooms", token, {}); + }>("GET", "/v3/publicRooms", token, {}); await Promise.all( rooms.map((room) => - this.csApi.request("PUT", `v3/directory/list/room/${room.room_id}`, token, { visibility: "private" }), + this.csApi.request("PUT", `/v3/directory/list/room/${room.room_id}`, token, { visibility: "private" }), ), ); } @@ -280,7 +280,7 @@ export class StartedSynapseContainer extends AbstractStartedContainer implements displayName?: string, admin = false, ): Promise { - const path = `v1/register`; + const path = "/v1/register"; const { nonce } = await this.adminApi.request<{ nonce: string }>("GET", path, undefined, {}); const mac = crypto .createHmac("sha1", this.registrationSharedSecret) @@ -292,14 +292,12 @@ export class StartedSynapseContainer extends AbstractStartedContainer implements user_id: string; device_id: string; }>("POST", path, undefined, { - data: { - nonce, - username, - password, - mac, - admin, - displayname: displayName, - }, + nonce, + username, + password, + mac, + admin, + displayname: displayName, }); return { @@ -351,7 +349,7 @@ export class StartedSynapseContainer extends AbstractStartedContainer implements if (this._mas) { return this._mas.setThreepid(userId, medium, address); } - await this.adminRequest("PUT", `v2/users/${userId}`, { + await this.adminRequest("PUT", `/v2/users/${userId}`, { threepids: [ { medium, diff --git a/playwright/testcontainers/utils.ts b/playwright/testcontainers/utils.ts index 487562f8af..c48c655c2e 100644 --- a/playwright/testcontainers/utils.ts +++ b/playwright/testcontainers/utils.ts @@ -58,7 +58,7 @@ export class Api { public async request(verb: "GET", path: string, token?: string, data?: never): Promise; public async request(verb: Verb, path: string, token?: string, data?: object): Promise; public async request(verb: Verb, path: string, token?: string, data?: object): Promise { - const url = `${this.baseUrl}/_matrix/client/${path}`; + const url = `${this.baseUrl}${path}`; const res = await this._request.fetch(url, { data, method: verb, @@ -79,7 +79,7 @@ export class Api { export class ClientServerApi extends Api { constructor(baseUrl: string) { - super(`${baseUrl}/_matrix/client/`); + super(`${baseUrl}/_matrix/client`); } public async loginUser(userId: string, password: string): Promise { @@ -88,7 +88,7 @@ export class ClientServerApi extends Api { user_id: string; device_id: string; home_server: string; - }>("POST", "v3/login", undefined, { + }>("POST", "/v3/login", undefined, { type: "m.login.password", identifier: { type: "m.id.user",