Files
element-web/test/end-to-end-tests/src/usecases/rightpanel.ts
Matthew Hodgson b8b5dd82aa Triple the speed of E2E tests and stop them exploding if a circular datastructure is logged (#8095)
* stop e2e tests exploding if a circular datastructure is logged

it's valid for the webapp to log datastructures to the console which happen to be circular
but the e2e test running explodes badly with a runtime exception and bombs out before
logging anything or providing a sensible stacktrace. you can trap the exception though and
get a sensible error however.

* don't barf on circular refs in return vals either

and log timestamps

* log timestamps

* speed up roomDir & E2EE tests by 3x

use timeouts correctly, so the first set
of scenarios take 42s to run rather than 2m21s

* speed up space test by 20s
2022-03-21 10:26:26 +00:00

53 lines
2.1 KiB
TypeScript

/*
Copyright 2020 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.
*/
import { ElementSession } from "../session";
export async function openRoomRightPanel(session: ElementSession): Promise<void> {
// block until we have a roomSummaryButton
const roomSummaryButton = await session.query('.mx_RoomHeader .mx_AccessibleButton[aria-label="Room Info"]');
// check if it's highlighted
const highlightedRoomSummaryButton = await session.queryWithoutWaiting(
'.mx_RoomHeader .mx_RightPanel_headerButton_highlight[aria-label="Room Info"]',
);
if (!highlightedRoomSummaryButton) {
// If the room summary is not yet open, open it
await roomSummaryButton.click();
}
}
export async function goBackToRoomSummaryCard(session: ElementSession): Promise<void> {
for (let i = 0; i < 5; i++) {
try {
const backButton = await session.query(".mx_BaseCard_back", 500);
// Right panel is open to the wrong thing - go back up to the Room Summary Card
// Sometimes our tests have this opened to MemberInfo
await backButton.click();
} catch (e) {
// explicitly check for TimeoutError as this sometimes returned
// `Error: Node is detached from document` due to a re-render race or similar
if (e.name === "TimeoutError") {
break; // stop trying to go further back
}
}
}
}
export async function openRoomSummaryCard(session: ElementSession) {
await openRoomRightPanel(session);
await goBackToRoomSummaryCard(session);
}