Merge pull request #396 from padloc/feature/create-item-e2e-test

Create Item end-to-end test
This commit is contained in:
Bruno Bernardino 2022-02-02 17:44:25 +00:00 committed by GitHub
commit 12f5e04f7f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 71 additions and 3 deletions

View File

@ -0,0 +1,68 @@
const testItem = {
name: "Google",
username: "example@google.com",
password: "somethingsecret",
url: "https://google.com",
};
describe("Items", () => {
it("can create an item without errors", () => {
cy.login();
// Click plus sign
cy.get("pl-app").find("pl-items").find("pl-items-list").find("pl-button:eq(2)").click({ force: true });
// Give the app some time to render the animations
cy.wait(100);
// Click create
cy.get("pl-app").find("pl-create-item-dialog").find("footer pl-button.primary").click({ force: true });
cy.url().should("include", "/items/");
cy.url().should("include", "/new");
// Give the app some (more) time to render the animations
cy.wait(100);
// Fill in form
cy.get("pl-app")
.find("pl-items")
.find("pl-item-view")
.find("pl-input#nameInput")
.find("input")
.type(testItem.name, { force: true });
cy.get("pl-app")
.find("pl-items")
.find("pl-item-view")
.find("pl-scroller")
.find("pl-list")
.find("pl-field:eq(0)")
.find("pl-input.value-input")
.find("input.input-element")
.type(testItem.username, { force: true });
cy.get("pl-app")
.find("pl-items")
.find("pl-item-view")
.find("pl-scroller")
.find("pl-list")
.find("pl-field:eq(1)")
.find("pl-input.value-input")
.find("input.input-element")
.type(testItem.password, { force: true });
cy.get("pl-app")
.find("pl-items")
.find("pl-item-view")
.find("pl-scroller")
.find("pl-list")
.find("pl-field:eq(2)")
.find("pl-input.value-input")
.find("input.input-element")
.type(testItem.url, { force: true });
// Click save
cy.get("pl-app").find("pl-items").find("pl-item-view").find("pl-button.primary").click({ force: true });
cy.url().should("include", "/items/");
cy.url().should("not.include", "/new");
});
});

View File

@ -547,7 +547,7 @@ export class App extends ServiceWorker(StateMixin(AutoSync(ErrorHandling(AutoLoc
target.classList.add("dragging");
target.addEventListener("dragend", () => target.classList.remove("dragging"), { once: true });
const totp: TOTPElement | null = (target.querySelector("pl-totp") ||
(target.shadowRoot && target.shadowRoot.querySelector("pl-totp"))) as TOTPElement | null;
target.shadowRoot?.querySelector("pl-totp")) as TOTPElement | null;
event.dataTransfer!.setData("text/plain", field.type === "totp" && totp ? totp.token : field.value);
}
}

View File

@ -152,7 +152,7 @@ export class FieldElement extends LitElement {
private _collapseSuggestions() {
window.setTimeout(() => {
const drawer = this._valueInput.querySelector("pl-drawer") as Drawer;
const drawer = this._valueInput?.querySelector("pl-drawer") as Drawer;
drawer && (drawer.collapsed = true);
}, 50);
}

View File

@ -477,7 +477,7 @@ export class App {
* Locks the app and wipes all sensitive information from memory.
*/
async lock() {
[this.account!, ...this.state.orgs, ...this.state.vaults].forEach((each) => each && each.lock());
[this.account!, ...this.state.orgs, ...this.state.vaults].forEach((each) => each?.lock());
this.publish();
}