Document incompatibility between playwright fixtures and MAS (#34101)
* Document incompatibility between playwright fixtures and MAS * another comment
This commit is contained in:
@@ -15,7 +15,11 @@ import { sample, uniqueId } from "lodash-es";
|
|||||||
import { test as base } from "./panel.js";
|
import { test as base } from "./panel.js";
|
||||||
import { type Credentials } from "../utils/api.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) {
|
export async function populateLocalStorageWithCredentials(page: Page, credentials: Credentials) {
|
||||||
await page.addInitScript(
|
await page.addInitScript(
|
||||||
({ credentials }) => {
|
({ 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_pickle_key", "false");
|
||||||
window.localStorage.setItem("mx_has_access_token", "true");
|
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(
|
window.localStorage.setItem(
|
||||||
"mx_local_settings",
|
"mx_local_settings",
|
||||||
JSON.stringify({
|
JSON.stringify({
|
||||||
@@ -61,6 +73,9 @@ export interface TestFixtures {
|
|||||||
* but adds an initScript which will populate localStorage with the user's details from
|
* but adds an initScript which will populate localStorage with the user's details from
|
||||||
* {@link #credentials} and {@link #homeserver}.
|
* {@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.
|
* Similar to {@link #user}, but doesn't load the app.
|
||||||
*/
|
*/
|
||||||
pageWithCredentials: Page;
|
pageWithCredentials: Page;
|
||||||
@@ -69,6 +84,9 @@ export interface TestFixtures {
|
|||||||
* A (rather poorly-named) test fixture which registers a user per {@link #credentials}, stores
|
* 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
|
* the credentials into localStorage per {@link #pageWithCredentials}, and then loads the front page of the
|
||||||
* app.
|
* app.
|
||||||
|
*
|
||||||
|
* Warning: the user credentials are an incomplete implementation, particularly in MAS environments: for example, a logout operation
|
||||||
|
* will not work correctly.
|
||||||
*/
|
*/
|
||||||
user: Credentials;
|
user: Credentials;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -14,6 +14,8 @@ import { routeConfigJson } from "./config_json.js";
|
|||||||
import { populateLocalStorageWithCredentials } from "../fixtures/user.js";
|
import { populateLocalStorageWithCredentials } from "../fixtures/user.js";
|
||||||
|
|
||||||
/** Create a new instance of the application, in a separate browser context, using the given credentials.
|
/** 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 browser - the browser to use
|
||||||
* @param credentials - the credentials to use for the new instance
|
* @param credentials - the credentials to use for the new instance
|
||||||
|
|||||||
Reference in New Issue
Block a user