From 7c66dcff7f4036a89165e3c2ecf19190aaf96465 Mon Sep 17 00:00:00 2001 From: Reshma-M-A <31645577+Reshma-M-A@users.noreply.github.com> Date: Thu, 6 May 2021 09:22:00 +1000 Subject: [PATCH] Fixing UI Automation tests (#424) * fix spelling * change brief to opportunity * changed to reflect the new frontend login screen * changed to smaller dd * change brief to opportunity * change to yyyy * fixed up login tests to reflect the new login screen * add sleep since seller login is too quick --- ui-automated-tests/README.md | 2 +- ui-automated-tests/src/flows/brief/atm.ts | 8 ++++---- ui-automated-tests/src/flows/brief/specialist.ts | 4 ++-- ui-automated-tests/src/tests/briefResponse/specialist.ts | 2 ++ ui-automated-tests/src/tests/briefResponse/training.ts | 1 + ui-automated-tests/src/tests/login/buyer.ts | 8 +++++--- 6 files changed, 15 insertions(+), 10 deletions(-) diff --git a/ui-automated-tests/README.md b/ui-automated-tests/README.md index f8f26865..dbdf46d6 100644 --- a/ui-automated-tests/README.md +++ b/ui-automated-tests/README.md @@ -25,7 +25,7 @@ If there is an issue with an outdated version of node, install the latest versio `nvm install v14.16.0` `nvm use v14.16.0` -Running `npm i puppeter` will not install Chromium and you will need to add the following dependencies manually. +Running `npm i puppeteer` will not install Chromium and you will need to add the following dependencies manually. `sudo apt-get install gconf-service libasound2 libatk1.0-0 libatk-bridge2.0-0 libc6 libcairo2 libcups2 libdbus-1-3 libexpat1 libfontconfig1 libgcc1 libgconf-2-4 libgdk-pixbuf2.0-0 libglib2.0-0 libgtk-3-0 libnspr4 libpango-1.0-0 libpangocairo-1.0-0 libstdc++6 libx11-6 libx11-xcb1 libxcb1 libxcomposite1 libxcursor1 libxdamage1 libxext6 libxfixes3 libxi6 libxrandr2 libxrender1 libxss1 libxtst6 ca-certificates fonts-liberation libappindicator1 libnss3 lsb-release xdg-utils wget` diff --git a/ui-automated-tests/src/flows/brief/atm.ts b/ui-automated-tests/src/flows/brief/atm.ts index 44d26ec4..ab19135c 100644 --- a/ui-automated-tests/src/flows/brief/atm.ts +++ b/ui-automated-tests/src/flows/brief/atm.ts @@ -39,9 +39,9 @@ const fillWhoCanRespond = async () => { const fillAbout = async (title: string, locations: string[]) => { await clickSaveContinue(); - await utils.matchText("li", "Enter the title for your brief"); + await utils.matchText("li", "Enter the title for your opportunity"); await utils.matchText("li", "Enter the name of your organisation"); - await utils.matchText("li", "Enter a summary of your brief"); + await utils.matchText("li", "Enter a summary of your opportunity"); await utils.matchText("li", "You must select at least one location"); await utils.type("title", { value: title }); await utils.type("organisation", { numberOfCharacters: 150 }); @@ -86,7 +86,7 @@ const fillObjectives = async () => { const fillTimeframes = async () => { await clickSaveContinue(); - await utils.matchText("li", "Enter an estimated start date for the brief"); + await utils.matchText("li", "Enter an estimated start date for the opportunity"); await utils.type("start_date", { numberOfCharacters: 100 }); await utils.type("timeframeConstraints", { numberOfWords: 150 }); @@ -130,7 +130,7 @@ const publishBrief = async () => { }; const create = async (params: IAtmParams): Promise => { - console.log("Starting to create atm brief"); + console.log("Starting to create atm opportunity"); await createBrief(); await fillWhoCanRespond(); await fillAbout(params.title, params.locations); diff --git a/ui-automated-tests/src/flows/brief/specialist.ts b/ui-automated-tests/src/flows/brief/specialist.ts index 43ff2dbf..9126d9d1 100644 --- a/ui-automated-tests/src/flows/brief/specialist.ts +++ b/ui-automated-tests/src/flows/brief/specialist.ts @@ -138,9 +138,9 @@ const fillTimeframes = async () => { await utils.matchText("li", "Enter a contract length for the opportunity"); const now = new Date(); const future = new Date(now.setDate(now.getDate() + 14)); - await utils.type("day", { value: `${format(future, "DD")}` }); + await utils.type("day", { value: `${format(future, "dd")}` }); await utils.type("month", { value: `${format(future, "MM")}` }); - await utils.type("year", { value: `${format(future, "YYYY")}` }); + await utils.type("year", { value: `${format(future, "yyyy")}` }); await utils.type("contractLength", { numberOfCharacters: 100 }); await utils.type("contractExtensions", { numberOfCharacters: 100 }); await clickSaveContinue(); diff --git a/ui-automated-tests/src/tests/briefResponse/specialist.ts b/ui-automated-tests/src/tests/briefResponse/specialist.ts index 212787ea..3c2ccf3a 100644 --- a/ui-automated-tests/src/tests/briefResponse/specialist.ts +++ b/ui-automated-tests/src/tests/briefResponse/specialist.ts @@ -8,6 +8,7 @@ import { navigate, selectBrief, } from "../../flows/opportunities/actions"; +import { sleep } from "../../utils"; describe("create and respond to specialist opportunity", () => { // in order to get the right brief we are going for 'today's date'. @@ -28,6 +29,7 @@ describe("create and respond to specialist opportunity", () => { it("should be able to respond to specialist opportunity", async () => { await sellerLogin(); + await sleep(500); for (let i = 0; i < parseInt(brief.numberOfSuppliers, 10); i += 1) { // eslint-disable-next-line no-await-in-loop await navigate(); diff --git a/ui-automated-tests/src/tests/briefResponse/training.ts b/ui-automated-tests/src/tests/briefResponse/training.ts index 75220be2..e6fc5ee3 100644 --- a/ui-automated-tests/src/tests/briefResponse/training.ts +++ b/ui-automated-tests/src/tests/briefResponse/training.ts @@ -21,6 +21,7 @@ describe("create and respond to training brief", () => { it("should be able to respond to a training brief", async () => { await sellerLogin(); + await sleep(500); await navigate(); await selectBrief(title); await applyForTraining(); diff --git a/ui-automated-tests/src/tests/login/buyer.ts b/ui-automated-tests/src/tests/login/buyer.ts index 809b0af5..1b55cd39 100644 --- a/ui-automated-tests/src/tests/login/buyer.ts +++ b/ui-automated-tests/src/tests/login/buyer.ts @@ -3,14 +3,13 @@ import * as util from "../../utils"; describe("should fail sign in", function() { const testCases = [ - { args: ["a", ""], expected: ["a", "You must provide a valid email address"] }, - { args: ["a@b.cm", ""], expected: ["a", "You must provide your password"] }, - { args: ["a@b.cm", "a"], expected: ["p", "Make sure you've entered the right email address and password."] }, + { args: ["a@b.cm", "a"], expected: ["a", "Your password should be at least 10 characters"] } ]; for (const test of testCases) { it(`sign in fails ${test.args.length} args`, async function() { await buyerLogin(test.args[0], test.args[1]); + await util.clickInputButton("Sign in"); await util.matchText(test.expected[0], test.expected[1]); }); } @@ -19,12 +18,15 @@ describe("should fail sign in", function() { describe("should sign in", function() { it("buyer should be able to login", async function() { await buyerLogin(process.env.BUYER_EMAIL, process.env.BUYER_PASSWORD); + await util.clickButton("Menu"); + await util.clickLink("Dashboard"); await util.matchText("h1", "Dashboard"); await signOut("buyer"); }); it("seller should be able to login", async function() { await sellerLogin(process.env.SELLER_EMAIL, process.env.SELLER_PASSWORD); + await util.clickLink("Dashboard"); await util.matchText("h1", "Dashboard"); await signOut("seller"); });