Appservice tests weren't added to tsconfig.json properly.

Some minor fixes now that they have been.
This commit is contained in:
gnuxie 2022-11-28 12:38:35 +00:00
parent 1bc329b5e8
commit 3a6b68356f
6 changed files with 7 additions and 10 deletions

View File

@ -88,12 +88,13 @@ export class MjolnirAppService {
* @param config The parsed configuration file.
* @param registrationFilePath A path to their homeserver registration file.
*/
public static async run(port: number, config: IConfig, registrationFilePath: string) {
public static async run(port: number, config: IConfig, registrationFilePath: string): Promise<MjolnirAppService> {
const dataStore = new PgDataStore(config.db.connectionString);
await dataStore.init();
const service = await MjolnirAppService.makeMjolnirAppService(config, dataStore, registrationFilePath);
// The call to `start` MUST happen last. As it needs the datastore, and the mjolnir manager to be initialized before it can process events from the homeserver.
await service.start(port);
return service;
}
public onUserQuery (queriedUser: MatrixUser) {

View File

@ -16,6 +16,7 @@ describe("Test that the app service can provision a mjolnir on invite of the app
return this.appservice.close();
} else {
console.warn("Missing Appservice in this context, so cannot stop it.")
return Promise.resolve(); // TS7030: Not all code paths return a value.
}
});
it("A moderator that requests a mjolnir via a matrix invitation will be invited to a new policy and management room", async function (this: Context) {

View File

@ -20,6 +20,7 @@ describe("Test that the app service can provision a mjolnir when requested from
return this.appservice.close();
} else {
console.warn("Missing Appservice in this context, so cannot stop it.")
return Promise.resolve(); // TS7030: Not all code paths return a value.
}
});
it("A moderator that requests a mjolnir via a matrix invitation will be invited to a new policy and management room", async function (this: Context) {

View File

@ -2,7 +2,6 @@ import path from "path";
import { MjolnirAppService } from "../../../src/appservice/AppService";
import { ensureAliasedRoomExists } from "../../integration/mjolnirSetupUtils";
import { read as configRead, IConfig } from "../../../src/appservice/config/config";
import { PgDataStore } from "../../../src/appservice/datastore";
import { newTestUser } from "../../integration/clientHelper";
import PolicyList from "../../../src/models/PolicyList";
import { CreateEvent, MatrixClient } from "matrix-bot-sdk";
@ -15,11 +14,7 @@ export async function setupHarness(): Promise<MjolnirAppService> {
const config = readTestConfig();
const utilityUser = await newTestUser(config.homeserver.url, { name: { contains: "utility" }});
await ensureAliasedRoomExists(utilityUser, config.accessControlList);
const dataStore = new PgDataStore(config.db.connectionString);
await dataStore.init();
const appservice = await MjolnirAppService.makeMjolnirAppService(config, dataStore, "mjolnir-registration.yaml");
await appservice.start(9000);
return appservice;
return await MjolnirAppService.run(9000, config, "mjolnir-registration.yaml");
}
export async function isPolicyRoom(user: MatrixClient, roomId: string): Promise<boolean> {

View File

@ -21,7 +21,6 @@ export interface CreateMjolnirResponse {
export class MjolnirWebAPIClient {
private constructor(
private readonly matrixClient: MatrixClient,
private readonly openIDToken: string,
private readonly baseURL: string,
) {
@ -30,7 +29,7 @@ export class MjolnirWebAPIClient {
public static async makeClient(client: MatrixClient, baseUrl: string): Promise<MjolnirWebAPIClient> {
const token = await getOpenIDToken(client);
return new MjolnirWebAPIClient(client, token, baseUrl);
return new MjolnirWebAPIClient(token, baseUrl);
}
public async createMjolnir(roomToProtectId: string): Promise<CreateMjolnirResponse> {

View File

@ -21,7 +21,7 @@
},
"include": [
"./src/**/*",
"./test/appservice/*",
"./test/appservice/**/*",
"./test/integration/manualLaunchScript.ts",
"./test/integration/roomMembersTest.ts",
"./test/integration/banListTest.ts",