Files
raven-test/e2e/tests/regression/service-user/service-user-features.js
2021-11-02 20:55:50 +00:00

84 lines
3.1 KiB
JavaScript

/// <reference types="cypress" />
import dayjs from "../../../support/dayjs.min.js"
describe("When Service user logs in", () => {
it("should correctly run all functionality", () => {
//format for typing input and setting value is always YYYY-MM-DD for date and HH:MM in 24 hour time for time
const dNow = new Date();
const dToday = `${dNow.getFullYear()}-${(dNow.getMonth() + 1)
.toString()
.padStart(2, "0")}-${dNow.getDate().toString().padStart(2, "0")}`;
const tNow = `${dNow.getHours().toString().padStart(2, "0")}:${dNow
.getMinutes()
.toString()
.padStart(2, "0")}`;
const tOneHourFromNow = `${(dNow.getHours() + 1)
.toString()
.padStart(2, "0")}:${dNow.getMinutes().toString().padStart(2, "0")}`;
cy.visit("/login");
cy.get("input[name=username]").clear().type(Cypress.env("serviceuser"));
// {enter} causes the form to submit
cy.get("input[name=password]")
.clear()
.type(`${Cypress.env("servicepassword")}{enter}`);
cy.url().should("include", "/ay-evaluate");
//open nav pane
cy.get("[data-cy=navicon]").click();
cy.contains("- Service"); //part of name displayed at top
//USER OPTIONS
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='nativeDateTimeInput']").check({ force: true });
//WORKORDER
cy.get("[data-cy=navicon]").click();
cy.get("[data-cy=service]").click();
cy.get("[data-cy='nav/svc-workorders']").click();
cy.url().should("include", "/svc-workorders");
cy.get("[data-cy=workordersTable]");
cy.get("[data-cy='workorder-list:new']:first").click();
cy.choosePickList("customerId", "XYZ");
cy.get("[data-cy='woState:open']").click();
cy.chooseVSelect("woState:picker", "Scheduled");
cy.get("[data-cy='woState:btnok']").click();
cy.get("[data-cy='woAddress:open']").click();
cy.get("[data-cy=address]").type(`${Cypress.config("cyid")} E. First St{enter}`);
cy.get("[data-cy=city]").type("Los Angeles");
cy.get("[data-cy=region]").type("California");
cy.get("[data-cy=country]").type("USA");
cy.get("[data-cy=latitude]").type("34.052234");
cy.get("[data-cy=longitude]").type("-118.243685");
cy.get("[data-cy=postAddress]").type(`Box ${Cypress.config("cyid")}`);
cy.get("[data-cy=postCity]").type("Los Angeles");
cy.get("[data-cy=postRegion]").type("CA");
cy.get("[data-cy=postCountry]").type("US");
cy.get("[data-cy=postCode]").type("90012");
cy.get("[data-cy='woAddress:btnok']").click();
cy.get("[data-cy=notes]").type(`Test summary workorder information`);
//complete by now plus 7 days
cy.get("[data-cy='completeByDate:date']").type( dayjs().add(7,'day').format('YYYY-MM-DD'));
cy.get("[data-cy='completeByDate:time']").type( dayjs().add(7,'day').format('HH:mm'));
// //LOGOUT
// cy.get("[data-cy=navicon]").click();
// cy.get("[data-cy=logout]").click();
// cy.url().should("include", "/login");
//END OF TEST
//-----------------------------------------------------
});
});