Document incompatibility between playwright fixtures and MAS (#34101)

* Document incompatibility between playwright fixtures and MAS

* another comment
This commit is contained in:
Richard van der Hoff
2026-07-02 14:48:16 +00:00
committed by GitHub
parent 1a9691e7e7
commit 28c9eed57a
2 changed files with 21 additions and 1 deletions
@@ -15,7 +15,11 @@ import { sample, uniqueId } from "lodash-es";
import { test as base } from "./panel.js";
import { type Credentials } from "../utils/api.js";
/** Adds an initScript to the given page which will populate localStorage appropriately so that Element will use the given credentials. */
/**
* Adds an initScript to the given page which will populate localStorage appropriately so that Element will use the given credentials.
*
* Warning: this is an incomplete implementation, particularly in MAS environments: for example, a logout operation will not work correctly.
*/
export async function populateLocalStorageWithCredentials(page: Page, credentials: Credentials) {
await page.addInitScript(
({ credentials }) => {
@@ -27,6 +31,14 @@ export async function populateLocalStorageWithCredentials(page: Page, credential
window.localStorage.setItem("mx_has_pickle_key", "false");
window.localStorage.setItem("mx_has_access_token", "true");
// XXX: If the homeserver is using MAS, then Element uses additional localstorage settings to store more
// data. The fact that we don't populate them means that, for example, when you hit "Remove this device" in
// the app, it attempts to hit the legacy `/logout` endpoint, which returns a 40x error, which is silently
// ignored.
//
// If you fix this, (1) yay! (2) please remember to update the warning on the doc-comments of this method
// and its callers.
window.localStorage.setItem(
"mx_local_settings",
JSON.stringify({
@@ -61,6 +73,9 @@ export interface TestFixtures {
* but adds an initScript which will populate localStorage with the user's details from
* {@link #credentials} and {@link #homeserver}.
*
* Warning: this is an incomplete implementation, particularly in MAS environments: for example, a logout operation
* will not work correctly.
*
* Similar to {@link #user}, but doesn't load the app.
*/
pageWithCredentials: Page;
@@ -69,6 +84,9 @@ export interface TestFixtures {
* A (rather poorly-named) test fixture which registers a user per {@link #credentials}, stores
* the credentials into localStorage per {@link #pageWithCredentials}, and then loads the front page of the
* app.
*
* Warning: the user credentials are an incomplete implementation, particularly in MAS environments: for example, a logout operation
* will not work correctly.
*/
user: Credentials;
}
@@ -14,6 +14,8 @@ import { routeConfigJson } from "./config_json.js";
import { populateLocalStorageWithCredentials } from "../fixtures/user.js";
/** Create a new instance of the application, in a separate browser context, using the given credentials.
*
* Warning: `populateLocalStorageWithCredentials` is an incomplete implementation, particularly in MAS environments: for example, a logout operation will not work correctly.
*
* @param browser - the browser to use
* @param credentials - the credentials to use for the new instance