Find Item e2e test

This adds a "find item" e2e test that confirms matching items show, and non-matching items don't.

I also implemented the `waitForAnimations` config, but I found the results inconsistent via CLI, so I left those in, after much experimentation.

There are a couple of improvements on reducing the number of `.find()` calls in the Cypress tests, when the elements aren't rendered in the Shadow DOM.
This commit is contained in:
Bruno Bernardino 2022-02-08 14:55:29 +00:00
parent 12f5e04f7f
commit fe8e014ba8
No known key found for this signature in database
GPG Key ID: D1B0A69ADD114ECE
2 changed files with 80 additions and 19 deletions

View File

@ -4,5 +4,6 @@
"video": false,
"chromeWebSecurity": false,
"screenshotOnRunFailure": false,
"videoUploadOnPasses": false
"videoUploadOnPasses": false,
"waitForAnimations": true
}

View File

@ -5,25 +5,24 @@ const testItem = {
url: "https://google.com",
};
const itemSearch = {
existing: "secret",
nonexistent: "apple",
};
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);
cy.get("pl-app").find("pl-items").find("pl-items-list").find("pl-button:eq(2)").click();
// Click create
cy.get("pl-app").find("pl-create-item-dialog").find("footer pl-button.primary").click({ force: true });
cy.get("pl-app").find("pl-create-item-dialog").find("footer pl-button.primary").click();
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")
@ -34,35 +33,96 @@ describe("Items", () => {
cy.get("pl-app")
.find("pl-items")
.find("pl-item-view")
.find("pl-scroller")
.find("pl-list")
.find("pl-field:eq(0)")
.find("pl-scroller pl-list 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-scroller pl-list 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-scroller pl-list 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.get("pl-app").find("pl-items").find("pl-item-view").find("pl-button.primary").click();
cy.url().should("include", "/items/");
cy.url().should("not.include", "/new");
});
it("can find an an item without errors", () => {
cy.unlock();
// 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")
.find("pl-items-list")
.find("pl-input#filterInput")
.find("input")
.type(itemSearch.existing, { force: true });
// 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);
// 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", testItem.name);
// Click clear search sign
cy.get("pl-app")
.find("pl-items")
.find("pl-items-list")
.find("pl-input#filterInput")
.find("pl-button.slim")
.click();
// Click search sign
cy.get("pl-app").find("pl-items").find("pl-items-list").find("pl-button:eq(3)").click();
// Find non-existent Item
cy.get("pl-app")
.find("pl-items")
.find("pl-items-list")
.find("pl-input#filterInput")
.find("input")
.type(itemSearch.nonexistent, { force: true });
// 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);
cy.get("pl-app")
.find("pl-items")
.find("pl-items-list")
.find("main > div.centering")
.should("contain.text", "did not match any items");
});
});