Skip to content

Commit

Permalink
Merge pull request #18 from CirclesUBI/feature/app-460-fix-cypress-te…
Browse files Browse the repository at this point in the history
…sts-in-app2

Feature/app 460 fix cypress tests in app2
  • Loading branch information
codeho authored Aug 22, 2023
2 parents bdd18c7 + 39fe86c commit 59864ea
Show file tree
Hide file tree
Showing 29 changed files with 1,423 additions and 172 deletions.
3 changes: 2 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
node_modules
videos
screenshots
*.y4m
*.y4m
.history
17 changes: 17 additions & 0 deletions cypress/e2e/components/googleMapSearch.cy.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
import value from "../../fixtures/testData";

const enterLocationInput = "[data-cy=enterLocationInput]";

const googleMapSearch = {
enterLocationInput,
testGoogleMapSearch: () => {
cy.get(enterLocationInput).type(value.location);
cy.get(".pac-item", { timeout: 10000 }).should("be.visible");
cy.get(enterLocationInput).type("{downarrow}");
cy.get(enterLocationInput).type("{enter}");

cy.get("button[type='submit']").should("exist").click();
},
};

export default googleMapSearch;
20 changes: 11 additions & 9 deletions cypress/e2e/modules/loginPreSeeded.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,21 +2,23 @@ import { openPassport } from "./o-dashboard/openPassport";
import { survey } from "./survey";

export const loginFirstPreSeededAccount = () => {


// cy.visit("/#/passport/actions/logout");

// cy.wait(5000);

cy.visit("/#/passport/actions/login/2");

cy.get("button[class='relative btn btn-block btn-primary']").should("exist").click();
cy.get("button[class='relative btn btn-block btn-primary']")
.should("exist")
.click();

cy.get("input").each(($input) => {
cy.wrap($input).type("1");
});

cy.get("button[class='relative btn btn-block btn-primary']").should("exist").click();
cy.get("button[class='relative btn btn-block btn-primary']")
.should("exist")
.click();

cy.wait(1000);

Expand Down Expand Up @@ -46,18 +48,18 @@ export const loginFirstPreSeededAccount = () => {
cy.get("button[type=submit]").should("exist").click();
}
});
}
};

export const loginSecondPreSeededAccount = () => {

// cy.visit("/#/passport/actions/logout");

// cy.wait(5000);

cy.visit("/#/passport/actions/login/3");

cy.get("button[class='relative btn btn-block btn-primary']").should("exist").click();

cy.get("button[class='relative btn btn-block btn-primary']")
.should("exist")
.click();

cy.get("input").each(($input) => {
cy.wrap($input).type("1");
Expand Down Expand Up @@ -93,4 +95,4 @@ export const loginSecondPreSeededAccount = () => {
cy.get("button[type=submit]").should("exist").click();
}
});
}
};
8 changes: 2 additions & 6 deletions cypress/e2e/modules/notifications.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
export const testNotification = () => {


describe("check notifications", () => {
it("should open the notifications", () => {
cy.wait(2000);
Expand All @@ -9,17 +7,15 @@ export const testNotification = () => {
});

// it("should open side-menu", () => {
// cy.getByClass("flex items-center justify-center w-12 h-12 ml-4 bg-notifications rounded-full cursor-pointer svelte-v0kil9 text-white").should("exist").click();
// cy.getByClass("flex items-center justify-center w-12 h-12 ml-4 bg-notifications rounded-full cursor-pointer text-white").should("exist").click();
// });

// it("should filter for Trust-events", () => {
// cy.contains("Trust events").should("exist").click();
// });


it("should not show 'Loading...' message", () => {

cy.contains("Loading...").should("not.exist");
});
});
}
};
4 changes: 2 additions & 2 deletions cypress/e2e/modules/o-dashboard/openPassport.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
export const openPassport = () => {
it("opens passport dapp", () => {
it("opens passport dapp", { retries: 2 }, () => {
cy.getByI18nKey("dapps.o-dashboard.pages.home.passport")
.should("exist")
.click();
});
}
};
30 changes: 17 additions & 13 deletions cypress/e2e/modules/o-passport/createNewShop.ts
Original file line number Diff line number Diff line change
@@ -1,5 +1,11 @@
import { getRandomCompanyName } from "../../../src/utils/randomNames";

import googleMapSearch from "../../components/googleMapSearch.cy";

const categorySelect = "[data-cy=categorySelect]";

let randNum = Math.floor(Math.random() * 9) + 1;

export const createNewShop = () => {
const companyName = getRandomCompanyName();

Expand Down Expand Up @@ -29,22 +35,19 @@ export const createNewShop = () => {
cy.get("button[type='submit']").should("exist").click();
});

it("sets a location for the shop", { retries: 3 }, () => {
cy.wait(1000);

cy.getById("pacInput").type("Angkah selemadeg barat");

cy.get(".pac-item").should("exist").first().click();

cy.get("button[type='submit']").should("exist").click();
it("sets a location for the shop", () => {
googleMapSearch.testGoogleMapSearch();
});

it("sets a logo for the shop", () => {
cy.get("input[type=file]").selectFile("./cypress/static/Person.png", {
force: true,
});
cy.get("input[type=file]").selectFile(
"./cypress/static/" + randNum + ".jpg",
{
force: true,
}
);

cy.get("button[class='btn transition-all overflow-hidden transform relative btn-primary svelte-12kbnbk px-8']").should("exist").click();
cy.get(".btn").contains("Simpan").click();
});

it("sets a phonenumber for the shop", () => {
Expand All @@ -56,7 +59,8 @@ export const createNewShop = () => {
});

it("sets the vendor type", () => {
cy.get("select").eq(1).select("Sembako");
cy.get(categorySelect).should("exist");
cy.get(categorySelect).select("1");
});

it("sets the opening hours", () => {
Expand Down
62 changes: 27 additions & 35 deletions cypress/e2e/modules/o-passport/profileSettings.ts
Original file line number Diff line number Diff line change
@@ -1,73 +1,65 @@
import { openPassport } from "../o-dashboard/openPassport";
import { openSideMenu } from "../openSideMenu";
import googleMapSearch from "../../components/googleMapSearch.cy";
import { getRandomPersonName } from "../../../src/utils/randomNames";

export const profileSettings = () => {
describe("profile settings", () => {
const editPhoto = "[data-cy=editPhoto]";
const randomName = getRandomPersonName();

let randNum = Math.floor(Math.random() * 9) + 1;

export const profileSettings = () => {
describe("profile settings", () => {
openPassport();



it("sets new first- and last-name", () => {

cy.getByClass("text-2xl cursor-pointer sm:text-4xl font-heading")
.should("exist")
.click();

cy.get("input").clear().type("firstnametest");
cy.get("input").clear().type(randomName.firstName);

cy.get("button[type=submit]").should("exist").click();
// cy.contains("Save").should("exist").click();

cy.get("input").clear().type("lastnametest");
cy.get("input").clear().type(randomName.lastName);

cy.get("button[type=submit]").should("exist").click();
// cy.contains("Save").should("exist").click();
});

it("sets new location", { retries: 4 }, () => {

cy.getByClass("mt-1 text-sm text-center cursor-pointer")
.should("exist")
.click();

cy.wait(1000);

cy.get("input[id='pacInput']").clear().wait(1000).type("Bandar");

cy.get(".pac-item-query").should("exist").first().click();

cy.get("button[type=submit]").should("exist").click();
googleMapSearch.testGoogleMapSearch();
});

// it("sets new profile picture", () => {


// cy.getByClass("relative w-28 h-28 m-auto bg-white rounded-full")
// .should("exist")
// .click();

// cy.getByClass("input[type=file]").should("exist").click();
// cy.wait(1000);

// if (checkIfElementExists("relative inline-flex")) {
// cy.getByClass("table-cell w-10 h-10 align-middle bg-black rounded-full text-primary bg-opacity-60")
// .should("exist")
// .click();
// } else {
// cy.get("input[type=file]").selectFile("./cypress/static/image.png", {
// force: true,
// });
// }
it("opens photo editor", () => {
cy.getByClass("relative w-28 h-28 m-auto bg-white rounded-full")
.should("exist")
.click();
});

it("sets new profile picture", () => {
cy.get(editPhoto).should("exist").click();
cy.get("input[type=file]").should("exist");

cy.get("input[type=file]").selectFile(
"./cypress/static/" + randNum + ".jpg",
{
force: true,
}
);

// cy.contains("Submit").click();
// });
cy.get(".btn").should("exist").contains("Simpan").click();
});

it("opens accounts from side-menu checks if circles-address is expandable", () => {
openSideMenu("bg-passport");
});
});
};
};
6 changes: 4 additions & 2 deletions cypress/e2e/modules/openSideMenu.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,9 @@
export const openSideMenu = (context: string) => {
it("should open side-menu", () => {
cy.getByClass(
`flex items-center justify-center w-12 h-12 ml-4 ${context} rounded-full cursor-pointer svelte-v0kil9 text-white`).should("exist")
.click();;
`flex items-center justify-center w-12 h-12 ml-4 ${context} rounded-full cursor-pointer text-white`
)
.should("exist")
.click();
});
};
41 changes: 19 additions & 22 deletions cypress/e2e/modules/signUp.ts
Original file line number Diff line number Diff line change
@@ -1,51 +1,48 @@
import { getRandomPersonName } from "../../src/utils/randomNames";
import { survey } from "./survey";

import googleMapSearch from "../components/googleMapSearch.cy";

const randomName = getRandomPersonName();

export const signUp = () => {
cy.getByI18nKey("shared.molecules.nextNav.components.loginPill.signInNow")
.should("exist")
.click();

cy.get("button[class='relative btn btn-block btn-primary']").should("exist").click();

//cy.contains("Login with Apple").should("exist").click();
cy.get("button[class='relative btn btn-block btn-primary']")
.should("exist")
.click();

cy.get("input").each(($input) => {
cy.wrap($input).type("1");
});
cy.get("input")
.should("exist")
.each(($input) => {
cy.wrap($input).type("1");
});

cy.get("button[type=submit]").should("exist").click();

survey();

cy.getByI18nKey("shared.molecules.nextNav.components.loginPill.signInNow").should("exist").click();

// Get all 'button' elements and filter them by their text valuz
cy.getByI18nKey("shared.molecules.nextNav.components.loginPill.signInNow")
.should("exist")
.click();

cy.get("button").eq(0).click();

//const name = getRandomPersonName();
cy.getById("firstName").type("John");
cy.getById("firstName").type(randomName.firstName);

cy.get("button[type='submit']").click();

cy.getById("lastName").type("Doe");
cy.getById("lastName").type(randomName.lastName);

cy.get("button[type='submit']").click();

cy.get("input[type=file]").selectFile("./cypress/static/Person.png", {
force: true,
});

cy.get("button[class='btn transition-all overflow-hidden transform relative btn-primary svelte-12kbnbk px-8']").click();

it("sets the location", { retries: 3 }, () => {
cy.getById("pacInput").type("Angkah selemadeg barat");
cy.get(".pac-item", { timeout: 10000 })
.should("be.visible")
.first()
.click();
});
cy.get(".btn").contains("Simpan").click();

cy.get("button[type='submit']").click({ force: true });
googleMapSearch.testGoogleMapSearch();
};
14 changes: 5 additions & 9 deletions cypress/e2e/modules/signupJourney.ts
Original file line number Diff line number Diff line change
@@ -1,15 +1,11 @@
import { survey } from "./survey";

export const signupJourney = () => {
cy.visit("/");

// cy.visit("/#/passport/actions/logout");

// cy.wait(5000);

cy.visit("/#/passport/actions/login/3");

cy.get("button[class='relative btn btn-block btn-primary']").should("exist").click();

cy.get("button[class='relative btn btn-block btn-primary']")
.should("exist")
.click();

cy.get("input").each(($input) => {
cy.wrap($input).type("1");
Expand All @@ -20,4 +16,4 @@ export const signupJourney = () => {
cy.wait(1000);

survey();
}
};
Loading

0 comments on commit 59864ea

Please sign in to comment.