Skip to content

Commit

Permalink
Default values for login arguments
Browse files Browse the repository at this point in the history
  • Loading branch information
estellecomment committed Sep 14, 2022
1 parent 85dbdd2 commit ac8216a
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 13 deletions.
5 changes: 1 addition & 4 deletions cypress/e2e/create-room/create-room.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,10 @@ function openCreateDMDialog(): Chainable<JQuery<HTMLElement>> {
}

describe("Create Room", () => {
const homeserverUrl = Cypress.env('E2E_TEST_USER_HOMESERVER_URL');
const email = Cypress.env('E2E_TEST_USER_EMAIL');
const password = Cypress.env('E2E_TEST_USER_PASSWORD');
const homeserverShortname = Cypress.env('E2E_TEST_USER_HOMESERVER_SHORT');

beforeEach(() => {
cy.loginUser(homeserverUrl, email, password);
cy.loginUser();
});

afterEach(() => {
Expand Down
22 changes: 13 additions & 9 deletions cypress/support/loginToRemoteHomeserver.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,25 +32,29 @@ declare global {
interface Chainable {
/**
* Instantiates an Element session with the given user.
* @param homeserverUrl the homeserver to connect to over http
* @param email the email of an existing user in this homeserver
* @param password the password of an existing user in this homeserver
* @param homeserverUrl Optional. The homeserver to connect to over http
* @param email Optional. The email of an existing user in this homeserver
* @param password Optional. The password of an existing user in this homeserver
* @return UserCredentials for the logged in user.
*/
loginUser(
homeserverUrl: string,
email: string,
password: string,
homeserverUrl?: string,
email?: string,
password?: string,
): Chainable<UserCredentials>;
}
}
}

Cypress.Commands.add("loginUser", (
homeserverUrl: string,
email: string,
password: string,
homeserverUrl?: string,
email?: string,
password?: string,
): Chainable<UserCredentials> => {
homeserverUrl = homeserverUrl ?? Cypress.env('E2E_TEST_USER_HOMESERVER_URL');
email = email ?? Cypress.env('E2E_TEST_USER_EMAIL');
password = password ?? Cypress.env('E2E_TEST_USER_PASSWORD');

// XXX: work around Cypress not clearing IDB between tests
// Otherwise Cypress clears all localstorage and cookies between tests.
// https://github.com/cypress-io/cypress/issues/1208
Expand Down

0 comments on commit ac8216a

Please sign in to comment.