From bd7d43f46267bff7ead3b53438d2e2e554ad18d3 Mon Sep 17 00:00:00 2001 From: John Cardinal Date: Wed, 1 Apr 2020 17:19:41 +0000 Subject: [PATCH] --- ayanova/devdocs/todo.txt | 1 + ayanova/tests/e2e/specs/widget-crud.js | 45 ++++++++------------------ 2 files changed, 14 insertions(+), 32 deletions(-) diff --git a/ayanova/devdocs/todo.txt b/ayanova/devdocs/todo.txt index f1fff8b0..a18fb0d7 100644 --- a/ayanova/devdocs/todo.txt +++ b/ayanova/devdocs/todo.txt @@ -51,6 +51,7 @@ CURRENT TODOs +todo: save new widget delete button missing after save, but refresh and it appears todo: Client automated testing - Need several as basis for all future, make sure it's right. diff --git a/ayanova/tests/e2e/specs/widget-crud.js b/ayanova/tests/e2e/specs/widget-crud.js index 8ed18f0b..1c78b820 100644 --- a/ayanova/tests/e2e/specs/widget-crud.js +++ b/ayanova/tests/e2e/specs/widget-crud.js @@ -1,10 +1,9 @@ // https://docs.cypress.io/api/introduction/api.html - -describe("WIDGET", () => { - it("Performs all crud ops on widget", () => { +//https://docs.cypress.io/guides/references/assertions.html#BDD-Assertions +describe("WIDGET FORM", () => { + it("Performs all crud ops on widget successfully", () => { let unique = new Date().getTime(); cy.visit("/login"); - cy.get("input[name=username]") .clear() .type(Cypress.env("adminusername")); @@ -17,6 +16,7 @@ describe("WIDGET", () => { cy.url().should("include", "/home-dashboard"); cy.visit("/widgets/0"); cy.url().should("include", "/widgets/0"); + //save the start url for later let startUrl = null; //funcs are async so need to get result via then @@ -30,7 +30,8 @@ describe("WIDGET", () => { cy.contains("Name is a required field"); cy.contains("Price is a required field"); //enter name - cy.get("[data-cy=name]").type("E2E CRUD " + unique); + let name = "E2E CRUD " + unique; + cy.get("[data-cy=name]").type(name); //confirm error went away cy.contains("Name is a required field").should("not.exist"); @@ -40,8 +41,7 @@ describe("WIDGET", () => { //start date cy.get("[data-cy='dtfpick:startDate']").click(); - //second row first day (the first row first day is variable so not suitable) - //cy.get(':nth-child(2) > :nth-child(1) > .v-btn') + //second row first day (the first row first day is variable (not always Monday) so not suitable) cy.get( '[data-cy="dpick:startDate"] > .v-picker__body > :nth-child(1) > .v-date-picker-table > table > tbody > :nth-child(2) > :nth-child(1)' ).click(); @@ -74,7 +74,6 @@ describe("WIDGET", () => { //If need exact selector in future use Firefox, pick element and select Copy->CSS Selector to get accurate thing to select cy.get("[data-cy='ttfpick:endDate']").click(); //click on 4 - //.v-dialog--active > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > span:nth-child(6) > span:nth-child(1) cy.get( ".v-dialog--active > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > span:nth-child(6) > span:nth-child(1)" ).click(); @@ -82,7 +81,6 @@ describe("WIDGET", () => { cy.get( ".v-dialog--active > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > div:nth-child(2) > div:nth-child(2)" ).click(); - // cy.get(" div.v-picker__title__btn:nth-child(2) > :nth-child(1)").click(); //click on 20 cy.get( ".v-dialog--active > div:nth-child(1) > div:nth-child(2) > div:nth-child(1) > div:nth-child(1) > div:nth-child(1) > span:nth-child(6) > span:nth-child(1)" @@ -99,38 +97,21 @@ describe("WIDGET", () => { ".v-autocomplete__content > .v-select-list > div:nth-child(2)" ).click(); - //select customer user cy.get("[data-cy=usertype]").type("cu{enter}", { force: true }); - cy.get("[data-cy=notes]").type("Testing 1..2..3{enter}EOT"); - - cy.get("[data-cy=tags] input[type=text] ").type("zone1{enter}{esc}"); - - // cy.get("[data-cy=WidgetCustom2]").click(); //to close the tags above + cy.get("[data-cy=tags] input[type=text] ").type("zone1{enter}{esc}"); //esc necessary to close tags control cy.get("[data-cy=WidgetCustom2]").type( "Custom text field testing a...b...c...{enter}EOT" ); - //SAve the record + //SAve the record and ensure it's different cy.get('[data-cy="widget-edit:save"]').click(); - cy.url().should("not.eql", startUrl); - //cy.get("[data-cy=WidgetCustom4]").check({ force: true }); //have to force, for some reason it thinks it's covered + //confirm it's the same one + cy.get("[data-cy=name]").should("have.value", name); - //cy.get("[data-cy=tags]").type("zone1{enter}", { force: true }); - - // // we should be redirected to /dashboard - // cy.url().should("include", "/home-dashboard"); - - // //navigate and confirm - // //open nav and home menu - // cy.get("[data-cy=navicon]").click(); - // cy.get("[data-cy=home]").click(); - // cy.get("[data-cy='nav/home-user-settings']").click(); - // cy.url().should("include", "/home-user-settings"); - // cy.get("[data-cy=contextmenu]").click(); - // cy.get("[data-cy='app:logout']").click(); - // cy.url().should("include", "/login"); + //delete the record + cy.get('[data-cy="widget-edit:delete"]').click(); }); });