Skip to content
This repository has been archived by the owner on Jul 7, 2022. It is now read-only.

Commit

Permalink
Fixing UI Automation tests (#424)
Browse files Browse the repository at this point in the history
* 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
  • Loading branch information
resh-ie committed May 5, 2021
1 parent c896297 commit 7c66dcf
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 10 deletions.
2 changes: 1 addition & 1 deletion ui-automated-tests/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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`

Expand Down
8 changes: 4 additions & 4 deletions ui-automated-tests/src/flows/brief/atm.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 });
Expand Down Expand Up @@ -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 });
Expand Down Expand Up @@ -130,7 +130,7 @@ const publishBrief = async () => {
};

const create = async (params: IAtmParams): Promise<IAtmResult> => {
console.log("Starting to create atm brief");
console.log("Starting to create atm opportunity");
await createBrief();
await fillWhoCanRespond();
await fillAbout(params.title, params.locations);
Expand Down
4 changes: 2 additions & 2 deletions ui-automated-tests/src/flows/brief/specialist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
2 changes: 2 additions & 0 deletions ui-automated-tests/src/tests/briefResponse/specialist.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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'.
Expand All @@ -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();
Expand Down
1 change: 1 addition & 0 deletions ui-automated-tests/src/tests/briefResponse/training.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
8 changes: 5 additions & 3 deletions ui-automated-tests/src/tests/login/buyer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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]);
});
}
Expand All @@ -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");
});
Expand Down

0 comments on commit 7c66dcf

Please sign in to comment.