Skip to content

Commit

Permalink
Completes induction with file uploads
Browse files Browse the repository at this point in the history
  • Loading branch information
sparkplug0025 committed Oct 11, 2021
1 parent ceec234 commit 0f1542c
Show file tree
Hide file tree
Showing 8 changed files with 131 additions and 25 deletions.
1 change: 1 addition & 0 deletions packages/webapp/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,5 @@
.env*.local
cypress/videos
cypress/screenshots
cypress/downloads
cypress.env.json
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
143 changes: 120 additions & 23 deletions packages/webapp/cypress/integration/inductions.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,38 +17,135 @@ describe("Inductions", () => {
inviteButton.should("exist");
});

it("should allow to invite a new member", () => {
cy.login("alice.edev"); // TODO: we should keep sessions
describe("inviting a new member", () => {
const participants = {
inviter: "alice.edev",
invitee: "test235.edev",
witness1: "pip.edev",
witness2: "egeon.edev",
};

const inviteButton = getInviteButton();
inviteButton.click();
it("should allow to invite a new member", () => {
cy.login(participants.inviter);

const inviteButton = getInviteButton();
inviteButton.click();

cy.get("#invitee").type(participants.invitee);
cy.get("#witness1").type(participants.witness1);
cy.get("#witness2").type(participants.witness2);
cy.get('button[type="submit"]').click();
cy.wait("@eosPushTransaction");

const successMessage = cy.get("main h1");
successMessage.should("contain", "Success!");
cy.waitForBlocksPropagation();
});

it("should be able to input induction data", () => {
cy.login(participants.invitee);

cy.contains("Create my profile").click();

cy.get("#name").type("Cypress Smith");
cy.get("#imgFile").attachFile("cypress-avatar.jpg");
cy.get("#attributions").type("Cypress Framework");
cy.get("#bio").type("Thanks to Cypress I'm here!");
cy.get("#eosCommunity").type(participants.invitee + ".ec");
cy.get("#telegram").type(participants.invitee + ".tg");
cy.get("#linkedin").type(participants.invitee + ".li");
cy.get("#twitter").type(participants.invitee + ".tw");
cy.get("#blog").type(
participants.invitee + ".example.com/supercool"
);
cy.get("#facebook").type(participants.invitee + ".fb");

cy.get("button").contains("Preview My Profile").click();

cy.get("#image").click();
cy.get("#statement").click();
cy.get("#links").click();
cy.get("#handles").click();
cy.get("#consent").click();

cy.get("button").contains("Submit Profile").click();
cy.wait("@eosPushTransaction");

const successMessage = cy.get("main h1");
successMessage.should("contain", "Success!");
cy.waitForBlocksPropagation();
});

it("should be able to endorse with witness 1", () => {
cy.login(participants.witness1);

cy.contains("Complete ceremony").click();

cy.get("#videoFile0").attachFile("fake-induction.mp4");
cy.get("button").contains("Upload meeting").click();

cy.contains("Onward!", { timeout: 10000 }).click();

cy.get("#invitee").type("test235.edev");
cy.get("#witness1").type("egeon.edev");
cy.get("#witness2").type("pip.edev");
cy.get('button[type="submit"]').click();
cy.wait("@eosPushTransaction");
endorseInvitee();
});

const successMessage = cy.get("main h1");
successMessage.should("contain", "Success!");
cy.waitForBlocksPropagation();
it("should be able to endorse with witness 2", () => {
cy.login(participants.witness2);

cleanupInvitations();
cy.contains("Review & endorse").click();

endorseInvitee();
});

it("should be able to endorse with inviter", () => {
cy.login(participants.inviter);

cy.contains("Review & endorse").click();

endorseInvitee();
});

it("should be able to complete induction", () => {
cy.login(participants.invitee);

cy.contains("Donate & complete").click();

cy.get("#reviewed").click();

// Todo: Uncomment when put a system to generate random accounts
// for every new induction test
// cy.get("button").contains("Donate").click();
// cy.wait("@eosPushTransaction");
});

const endorseInvitee = () => {
cy.get("#photo").click();
cy.get("#links").click();
cy.get("#video").click();
cy.get("#reviewed").click();
cy.get("button").contains("Endorse").click();
cy.wait("@eosPushTransaction");
};

after(() => {
cleanupInvitations();
});

const cleanupInvitations = () => {
cy.visit(`/induction`);
cy.login(participants.inviter);

const inductionsAvailableForDeleting = cy.get(
`[data-testid="cancel-induction"]`
);
inductionsAvailableForDeleting.click({ multiple: true });
cy.wait("@eosPushTransaction");
};
});
});

const getInviteButton = () => {
return cy.get(`[data-testid="invite-button"]`);
};

const cleanupInvitations = () => {
cy.visit(`/induction`);

const inductionsAvailableForDeleting = cy.get(
`[data-testid="cancel-induction"]`
);
inductionsAvailableForDeleting.click({ multiple: true });
cy.wait("@eosPushTransaction");
};

export {};
4 changes: 3 additions & 1 deletion packages/webapp/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,8 @@
// -- This will overwrite an existing command --
// Cypress.Commands.overwrite('visit', (originalFn, url, options) => { ... })

import "cypress-file-upload";

/**
* Logins with UAL using Eden SoftKey mode
*/
Expand Down Expand Up @@ -51,7 +53,7 @@ Cypress.Commands.add("interceptEosApis", () => {
* Also it makes our tests free of undesirable waits, if we have a new legit
* case for `cy.wait()` we can just add a new command here.
*/
Cypress.Commands.add("waitForBlocksPropagation", (blocks = 3) => {
Cypress.Commands.add("waitForBlocksPropagation", (blocks = 5) => {
cy.wait(blocks * 500);
});

Expand Down
1 change: 1 addition & 0 deletions packages/webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
"@types/uuid": "^8.3.1",
"autoprefixer": "^10.2.5",
"cypress": "^8.4.0",
"cypress-file-upload": "^5.0.8",
"next-transpile-modules": "~3.3.0",
"postcss": "^8.2.9",
"tailwindcss": "^2.0.4",
Expand Down
2 changes: 1 addition & 1 deletion packages/webapp/tsconfig.json
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@
"resolveJsonModule": true,
"isolatedModules": true,
"jsx": "preserve",
"types": ["cypress"]
"types": ["cypress", "cypress-file-upload"]
},
"exclude": ["node_modules", "dist"],
"include": ["next-env.d.ts", "**/*.ts", "**/*.tsx"]
Expand Down
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -4053,6 +4053,11 @@ currently-unhandled@^0.4.1:
dependencies:
array-find-index "^1.0.1"

cypress-file-upload@^5.0.8:
version "5.0.8"
resolved "https://registry.yarnpkg.com/cypress-file-upload/-/cypress-file-upload-5.0.8.tgz#d8824cbeaab798e44be8009769f9a6c9daa1b4a1"
integrity sha512-+8VzNabRk3zG6x8f8BWArF/xA/W0VK4IZNx3MV0jFWrJS/qKn8eHfa5nU73P9fOQAgwHFJx7zjg4lwOnljMO8g==

cypress@^8.1.0:
version "8.2.0"
resolved "https://registry.yarnpkg.com/cypress/-/cypress-8.2.0.tgz#1e4e9f6218324e82a95c1b9cad7f3965ba663d7f"
Expand Down

0 comments on commit 0f1542c

Please sign in to comment.