Merge pull request #401 from padloc/feature/v3-compatibility-e2e-login-test

v3 client compatibility end-to-end tests
This commit is contained in:
Bruno Bernardino 2022-02-15 11:21:26 +00:00 committed by GitHub
commit 858fc3a324
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 176 additions and 175 deletions

View File

@ -15,136 +15,125 @@ describe("v3 compatibility", () => {
cy.v3_signup();
});
// it("can login without errors", () => {
// cy.v3_login();
// });
it("can login without errors", () => {
cy.v3_login();
});
// it("can lock/unlock without errors", () => {
// cy.v3_login();
it("can lock/unlock without errors", () => {
cy.v3_login();
// cy.v3_lock();
cy.v3_lock();
// cy.v3_unlock();
// });
cy.v3_unlock();
});
// it("can create an item without errors", () => {
// cy.v3_login();
it("can create an item without errors", () => {
cy.v3_login();
// // Click plus sign
// cy.get("pl-app").find("pl-items").find("pl-items-list").find("pl-button:eq(2)").click();
// Click plus sign
cy.get("pl-app").find("pl-items-list").find("pl-icon[icon='add']").click();
// // Click create
// cy.get("pl-app").find("pl-create-item-dialog").find("footer pl-button.primary").click();
// Click create
cy.get("pl-app").find("pl-create-item-dialog").find(".footer button.primary").click();
// cy.url().should("include", "/items/");
// cy.url().should("include", "/new");
cy.url().should("match", /\/items\/[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}/);
// // Give the app some time to finish animations
// cy.wait(300);
// Give the app some time to finish animations
cy.wait(300);
// // Fill in form
// cy.get("pl-app")
// .find("pl-items")
// .find("pl-item-view")
// .find("pl-input#nameInput")
// .find("input")
// .type(v3_testItem.name, { force: true });
// cy.get("pl-app")
// .find("pl-items")
// .find("pl-item-view")
// .find("pl-scroller pl-list pl-field:eq(0)")
// .find("pl-input.value-input")
// .find("input.input-element")
// .type(v3_testItem.username, { force: true });
// cy.get("pl-app")
// .find("pl-items")
// .find("pl-item-view")
// .find("pl-scroller pl-list pl-field:eq(1)")
// .find("pl-input.value-input")
// .find("input.input-element")
// .type(v3_testItem.password, { force: true });
// cy.get("pl-app")
// .find("pl-items")
// .find("pl-item-view")
// .find("pl-scroller pl-list pl-field:eq(2)")
// .find("pl-input.value-input")
// .find("input.input-element")
// .type(v3_testItem.url, { force: true });
// Fill in form
cy.get("pl-app")
.find("pl-item-dialog")
.find("pl-input#nameInput")
.find("input")
.type(v3_testItem.name, { force: true });
// // Click save
// cy.get("pl-app").find("pl-items").find("pl-item-view").find("pl-button.primary").click();
cy.get("pl-app")
.find("pl-item-dialog")
.find("pl-field.item:eq(0)")
.find("pl-input.value-input")
.find("input.input-element")
.type(v3_testItem.username, { force: true });
// cy.url().should("include", "/items/");
// cy.url().should("not.include", "/new");
// });
cy.get("pl-app")
.find("pl-item-dialog")
.find("pl-field.item:eq(1)")
.find("pl-input.value-input")
.find("input.input-element")
.type(v3_testItem.password, { force: true });
// it("can find an an item without errors", () => {
// cy.v3_unlock();
cy.get("pl-app")
.find("pl-item-dialog")
.find("pl-field.item:eq(2)")
.find("pl-input.value-input")
.find("input.input-element")
.type(v3_testItem.url, { force: true });
// // Click search sign
// cy.get("pl-app").find("pl-items").find("pl-items-list").find("pl-button:eq(3)").click();
// Click save
cy.get("pl-app").find("pl-item-dialog").find("button.primary.save-button").click();
// // Give the app some time to finish animations
// cy.wait(100);
// Close dialog
cy.get("pl-app").find("pl-item-dialog").find("pl-icon[icon='close']").click();
// // Find Item
// cy.get("pl-app")
// .find("pl-items")
// .find("pl-items-list")
// .find("pl-input#filterInput")
// .find("input")
// .type(v3_itemSearch.existing, { force: true });
cy.url().should("include", "/items");
cy.url().should(
"not.match",
/\/items\/[0-9a-f]{8}-[0-9a-f]{4}-[0-5][0-9a-f]{3}-[089ab][0-9a-f]{3}-[0-9a-f]{12}/
);
});
// // Confirm we only find one
// cy.get("pl-app")
// .find("pl-items")
// .find("pl-items-list")
// .find("main pl-virtual-list pl-scroller")
// .find("div.content")
// .children("div")
// .should("have.length", 1);
it("can find an an item without errors", () => {
cy.v3_unlock();
// // Confirm we find the right one
// cy.get("pl-app")
// .find("pl-items")
// .find("pl-items-list")
// .find("main pl-virtual-list pl-scroller")
// .find("div.content pl-vault-item-list-item")
// .find("div > div > div.semibold")
// .should("include.text", v3_testItem.name);
// Click search sign
cy.get("pl-app").find("pl-items-list").find("header pl-icon[icon='search']").click();
// // Click clear search sign
// cy.get("pl-app")
// .find("pl-items")
// .find("pl-items-list")
// .find("pl-input#filterInput")
// .find("pl-button.slim")
// .click();
// Give the app some time to finish animations
cy.wait(100);
// // Click search sign
// cy.get("pl-app").find("pl-items").find("pl-items-list").find("pl-button:eq(3)").click();
// Find Item
cy.get("pl-app")
.find("pl-items-list")
.find("pl-input#filterInput")
.find("input")
.type(v3_itemSearch.existing, { force: true });
// // Find non-existent Item
// cy.get("pl-app")
// .find("pl-items")
// .find("pl-items-list")
// .find("pl-input#filterInput")
// .find("input")
// .type(v3_itemSearch.nonexistent, { force: true });
// Confirm we only find one
cy.get("pl-app")
.find("pl-items-list")
.find("#main pl-virtual-list div.content")
.children(".cell")
.should("have.length", 1);
// // Confirm we find none
// cy.get("pl-app")
// .find("pl-items")
// .find("pl-items-list")
// .find("main pl-virtual-list pl-scroller")
// .find("div.content")
// .children("div")
// .should("have.length", 0);
// Confirm we find the right one
cy.get("pl-app")
.find("pl-items-list")
.find("#main pl-virtual-list div.content .cell .item-header .item-name")
.should("include.text", v3_testItem.name);
// cy.get("pl-app")
// .find("pl-items")
// .find("pl-items-list")
// .find("main > div.centering")
// .should("contain.text", "did not match any items");
// });
// Click clear search sign
cy.get("pl-app").find("pl-items-list").find("header pl-icon[icon='cancel']").click();
// Click search sign
cy.get("pl-app").find("pl-items-list").find("header pl-icon[icon='search']").click();
// Find non-existent Item
cy.get("pl-app")
.find("pl-items-list")
.find("pl-input#filterInput")
.find("input")
.type(v3_itemSearch.nonexistent, { force: true });
// Confirm we find none
cy.get("pl-app")
.find("pl-items-list")
.find("#main pl-virtual-list div.content")
.children(".cell")
.should("have.length", 0);
cy.get("pl-app")
.find("pl-items-list")
.find(".empty-placeholder")
.should("contain.text", "did not match any items");
});
});

View File

@ -353,75 +353,87 @@ Cypress.Commands.add("v3_signup", () => {
});
Cypress.Commands.add("v3_login", () => {
// cy.clearCookies();
// cy.clearLocalStorage();
// cy.clearIndexedDb();
// cy.visit("/");
// const { email, emailToken, password } = Cypress.env();
// cy.get("pl-app").find("pl-start").find("pl-login-signup").find("pl-input#emailInput").find("input").type(email);
// cy.get("pl-app")
// .find("pl-start")
// .find("pl-login-signup")
// .find("pl-button#submitEmailButton")
// .click({ force: true });
// // Give the app some time to render the animations
// cy.wait(100);
// cy.get("pl-app")
// .find("pl-prompt-dialog")
// .find("pl-input")
// .find("input[placeholder='Enter Verification Code']")
// .type(emailToken, { force: true });
// cy.get("pl-app").find("pl-prompt-dialog").find("pl-button#confirmButton").click({ force: true });
// // Give the app some time to render the animations
// cy.wait(100);
// cy.get("pl-app")
// .find("pl-start")
// .find("pl-login-signup")
// .find("pl-drawer:eq(3)")
// .find("pl-password-input#loginPasswordInput")
// .find("input[type='password']")
// .type(password, { force: true });
// cy.get("pl-app")
// .find("pl-start")
// .find("pl-login-signup")
// .find("pl-drawer:eq(3)")
// .find("pl-button#loginButton")
// .click({ force: true });
// // Give the app some time to render the animations
// cy.wait(100);
// // Add trusted device
// cy.get("pl-app").find("pl-alert-dialog").find("pl-button:eq(0)").click({ force: true });
// cy.url().should("include", "/items");
cy.clearCookies();
cy.clearLocalStorage();
cy.clearIndexedDb();
const { v3_email, emailToken, password, v3_url } = Cypress.env();
// This is required because the email validation requirement on login throws an error in the console, and without it, Cypress will halt
cy.on("uncaught:exception", (error) => {
// @ts-ignore this exists
if (error.code === "email_verification_required") {
return false;
}
});
cy.visit(`${v3_url}/`);
cy.get("pl-app").find("pl-start").find("pl-login").find("pl-input#emailInput").find("input").type(v3_email);
cy.get("pl-app")
.find("pl-start")
.find("pl-login")
.find("pl-password-input#passwordInput")
.find("input[type='password']")
.type(password, { force: true });
cy.get("pl-app").find("pl-start").find("pl-login").find("pl-loading-button#loginButton").click({ force: true });
// Give the app some time to render the animations
cy.wait(100);
cy.get("pl-app")
.find("pl-prompt-dialog")
.find("pl-input.tap")
.find("input[placeholder='Enter Verification Code']")
.type(emailToken, { force: true });
cy.get("pl-app").find("pl-prompt-dialog").find("pl-loading-button#confirmButton").click({ force: true });
// Give the app some time to render the animations
cy.wait(100);
cy.url().should("include", "/items");
});
Cypress.Commands.add("v3_lock", () => {
// cy.visit("/");
// // Open menu
// cy.get("pl-app").find("pl-items").find("pl-items-list").find("pl-button.menu-button:eq(0)").click({ force: true });
// // Click lock
// cy.get("pl-app").find("pl-menu").find("pl-button.menu-footer-button:eq(0)").click({ force: true });
// cy.url().should("include", "/unlock");
const { v3_url } = Cypress.env();
cy.visit(`${v3_url}/`);
// Click lock
cy.get("pl-app").find("pl-menu").find("pl-icon[icon='lock'].tap").click({ force: true });
cy.url().should("include", "/unlock");
});
Cypress.Commands.add("v3_unlock", () => {
// cy.visit("/");
// const { email, password } = Cypress.env();
// // Give the app some time to render the animations
// cy.wait(100);
// cy.get("pl-app")
// .find("pl-start")
// .find("pl-unlock")
// .find("pl-input[label='Logged In As']")
// .find("input")
// .should("have.value", email);
// // Give the app some time to render the animations
// cy.wait(100);
// cy.get("pl-app")
// .find("pl-start")
// .find("pl-unlock")
// .find("pl-password-input#passwordInput")
// .find("input[type='password']")
// .type(password, { force: true });
// cy.get("pl-app").find("pl-start").find("pl-unlock").find("pl-button#unlockButton").click({ force: true });
// cy.url().should("include", "/items");
const { v3_url, v3_email, password } = Cypress.env();
cy.visit(`${v3_url}/`);
// Give the app some time to render the animations
cy.wait(100);
cy.get("pl-app")
.find("pl-start")
.find("pl-unlock")
.find("pl-input[readonly]")
.find("input")
.should("have.value", v3_email);
// Give the app some time to render the animations
cy.wait(100);
cy.get("pl-app")
.find("pl-start")
.find("pl-unlock")
.find("pl-password-input#passwordInput")
.find("input[type='password']")
.type(password, { force: true });
cy.get("pl-app").find("pl-start").find("pl-unlock").find("pl-loading-button#unlockButton").click({ force: true });
cy.url().should("include", "/items");
});