You've already forked matrix-js-sdk
mirror of
https://github.com/matrix-org/matrix-js-sdk.git
synced 2025-08-09 10:22:46 +03:00
* WIP doodles on MembershipManager test cases * . * initial membership manager test setup. * Updates from discussion * revert renaming comments * remove unused import * fix leave delayed event resend test. It was missing a flush. * comment out and remove unused variables * es lint * use jsdom instead of node test environment * remove unused variables * remove unused export * temp * review * fixup tests * more review * remove wait for expect dependency * flatten tests and add comments * add more leave test cases * use defer * remove @jest/environment dependency * Cleanup awaits and Make mock types more correct. Make every mock return a Promise if the real implementation does return a pormise. * remove flush promise dependency * add linting to matrixrtc tests * Add fix async lints and use matrix rtc logger for test environment. * prettier * change to MatrixRTCSession logger * make accessing the full room deprecated * remove deprecated usage of full room * Clean up the deprecation --------- Co-authored-by: Hugh Nimmo-Smith <hughns@matrix.org>
55 lines
2.1 KiB
TypeScript
55 lines
2.1 KiB
TypeScript
/*
|
|
Copyright 2025 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.
|
|
*/
|
|
|
|
/*
|
|
This file adds a custom test environment for the MembershipManager.spec.ts
|
|
It can be used with the comment at the top of the file:
|
|
|
|
@jest-environment ./spec/unit/matrixrtc/memberManagerTestEnvironment.ts
|
|
|
|
It is very specific to the MembershipManager.spec.ts file and introduces the following behaviour:
|
|
- The describe each block in the MembershipManager.spec.ts will go through describe block names `LegacyMembershipManager` and `MembershipManager`
|
|
- It will check all tests that are a child or indirect child of the `LegacyMembershipManager` block and skip the ones which include "!FailsForLegacy"
|
|
in their test name.
|
|
*/
|
|
|
|
import { TestEnvironment } from "jest-environment-jsdom";
|
|
|
|
import { logger as rootLogger } from "../../../src/logger";
|
|
const logger = rootLogger.getChild("MatrixRTCSession");
|
|
|
|
class MemberManagerTestEnvironment extends TestEnvironment {
|
|
handleTestEvent(event: any) {
|
|
if (event.name === "test_start" && event.test.name.includes("!FailsForLegacy")) {
|
|
let parent = event.test.parent;
|
|
let isLegacy = false;
|
|
while (parent) {
|
|
if (parent.name === "LegacyMembershipManager") {
|
|
isLegacy = true;
|
|
break;
|
|
} else {
|
|
parent = parent.parent;
|
|
}
|
|
}
|
|
if (isLegacy) {
|
|
logger.info("skip test: ", event.test.name);
|
|
event.test.mode = "skip";
|
|
}
|
|
}
|
|
}
|
|
}
|
|
module.exports = MemberManagerTestEnvironment;
|