Add a login test against Synapse to Playwright (#11913)

* Install playwright

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Add foundations for writing tests under Playwright

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* .gitignore juggling

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Add tsconfig and fix eslint rules

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Add docker & synapse plugins

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Add login.spec.ts

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Wire up fixture which sets up ElementAppPage & bakes config.json

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Remove launch test, it has served its purpose

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Remove test which has been ported to Playwright

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Fix test not cleaning up after itself

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Move registerUser to the Homeserver interface

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Remove unused fixture param

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Remove redundant launch test

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>

* Add newline

---------

Signed-off-by: Michael Telatynski <7t3chguy@gmail.com>
Co-authored-by: R Midhun Suresh <hi@midhun.dev>
This commit is contained in:
Michael Telatynski 2023-11-22 11:49:51 +00:00 committed by GitHub
parent ecc46aeb8c
commit 52e3e0de1f
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
26 changed files with 1138 additions and 89 deletions

View file

@ -26,65 +26,6 @@ describe("Login", () => {
cy.stopHomeserver(homeserver);
});
describe("m.login.password", () => {
const username = "user1234";
const password = "p4s5W0rD";
beforeEach(() => {
cy.startHomeserver("consent").then((data) => {
homeserver = data;
cy.registerUser(homeserver, username, password);
cy.visit("/#/login");
});
});
it("logs in with an existing account and lands on the home screen", () => {
cy.injectAxe();
// first pick the homeserver, as otherwise the user picker won't be visible
cy.findByRole("button", { name: "Edit" }).click();
cy.findByRole("textbox", { name: "Other homeserver" }).type(homeserver.baseUrl);
cy.findByRole("button", { name: "Continue" }).click();
// wait for the dialog to go away
cy.get(".mx_ServerPickerDialog").should("not.exist");
cy.get(".mx_Spinner").should("not.exist");
cy.get(".mx_ServerPicker_server").should("have.text", homeserver.baseUrl);
cy.findByRole("button", { name: "Edit" }).click();
// select the default server again
cy.get(".mx_StyledRadioButton").first().click();
cy.findByRole("button", { name: "Continue" }).click();
cy.get(".mx_ServerPickerDialog").should("not.exist");
cy.get(".mx_Spinner").should("not.exist");
// name of default server
cy.get(".mx_ServerPicker_server").should("have.text", "server.invalid");
// switch back to the custom homeserver
cy.findByRole("button", { name: "Edit" }).click();
cy.findByRole("textbox", { name: "Other homeserver" }).type(homeserver.baseUrl);
cy.findByRole("button", { name: "Continue" }).click();
// wait for the dialog to go away
cy.get(".mx_ServerPickerDialog").should("not.exist");
cy.get(".mx_Spinner").should("not.exist");
cy.get(".mx_ServerPicker_server").should("have.text", homeserver.baseUrl);
cy.findByRole("textbox", { name: "Username", timeout: 15000 }).should("be.visible");
// Disabled because flaky - see https://github.com/vector-im/element-web/issues/24688
//cy.percySnapshot("Login");
cy.checkA11y();
cy.findByRole("textbox", { name: "Username" }).type(username);
cy.findByPlaceholderText("Password").type(password);
cy.findByRole("button", { name: "Sign in" }).click();
cy.url().should("contain", "/#/home", { timeout: 30000 });
});
});
// tests for old-style SSO login, in which we exchange tokens with Synapse, and Synapse talks to an auth server
describe("SSO login", () => {
beforeEach(() => {

View file

@ -33,6 +33,7 @@ describe("Soft logout", () => {
afterEach(() => {
cy.stopHomeserver(homeserver);
cy.task("stopOAuthServer");
});
describe("with password user", () => {