Add dendrite support to cypress tests (#9884)

* Minimum hacks required to run cypress tests with dendrite

* Remove wget hack since dendrite containers now have curl

* Add basic dendritedocker plugin & hack into login spec for testing

* Add generic HomeserverInstance interface

* Add env var to configure which homeserver to use

* Remove synapse specific homeserver support api

* Update the rest of the tests to use HomeserverInstance

* Update cypress docs to reference new homeserver abstraction

* Fix formatting issues

* Change dendrite to use main branch container
This commit is contained in:
devonh 2023-01-10 23:29:56 +00:00 committed by GitHub
parent b642df98e9
commit 79033eb034
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
50 changed files with 947 additions and 362 deletions

View file

@ -17,7 +17,7 @@ limitations under the License.
/// <reference types="cypress" />
import Chainable = Cypress.Chainable;
import { SynapseInstance } from "../plugins/synapsedocker";
import { HomeserverInstance } from "../plugins/utils/homeserver";
export interface UserCredentials {
accessToken: string;
@ -41,7 +41,7 @@ declare global {
* useed.
*/
initTestUser(
synapse: SynapseInstance,
homeserver: HomeserverInstance,
displayName: string,
prelaunchFn?: () => void,
userIdPrefix?: string,
@ -52,7 +52,7 @@ declare global {
* @param username login username
* @param password login password
*/
loginUser(synapse: SynapseInstance, username: string, password: string): Chainable<UserCredentials>;
loginUser(synapse: HomeserverInstance, username: string, password: string): Chainable<UserCredentials>;
}
}
}
@ -60,8 +60,8 @@ declare global {
// eslint-disable-next-line max-len
Cypress.Commands.add(
"loginUser",
(synapse: SynapseInstance, username: string, password: string): Chainable<UserCredentials> => {
const url = `${synapse.baseUrl}/_matrix/client/r0/login`;
(homeserver: HomeserverInstance, username: string, password: string): Chainable<UserCredentials> => {
const url = `${homeserver.baseUrl}/_matrix/client/r0/login`;
return cy
.request<{
access_token: string;
@ -95,7 +95,7 @@ Cypress.Commands.add(
Cypress.Commands.add(
"initTestUser",
(
synapse: SynapseInstance,
homeserver: HomeserverInstance,
displayName: string,
prelaunchFn?: () => void,
userIdPrefix = "user_",
@ -112,15 +112,15 @@ Cypress.Commands.add(
const username = Cypress._.uniqueId(userIdPrefix);
const password = Cypress._.uniqueId("password_");
return cy
.registerUser(synapse, username, password, displayName)
.registerUser(homeserver, username, password, displayName)
.then(() => {
return cy.loginUser(synapse, username, password);
return cy.loginUser(homeserver, username, password);
})
.then((response) => {
cy.log(`Registered test user ${username} with displayname ${displayName}`);
cy.window({ log: false }).then((win) => {
// Seed the localStorage with the required credentials
win.localStorage.setItem("mx_hs_url", synapse.baseUrl);
win.localStorage.setItem("mx_hs_url", homeserver.baseUrl);
win.localStorage.setItem("mx_user_id", response.userId);
win.localStorage.setItem("mx_access_token", response.accessToken);
win.localStorage.setItem("mx_device_id", response.deviceId);