Skip to content

Commit

Permalink
Fix complex induction tests
Browse files Browse the repository at this point in the history
  • Loading branch information
sparkplug0025 committed Nov 2, 2021
1 parent 6b8a754 commit d2c71f3
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 30 deletions.
2 changes: 1 addition & 1 deletion packages/webapp/cypress/integration/community.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe("Community", () => {
beforeEach(() => {
cy.interceptSubchain();
cy.interceptBox();
cy.interceptEosApis();
cy.viewport(1000, 1000);
cy.visit(`/members`);
Expand Down
40 changes: 15 additions & 25 deletions packages/webapp/cypress/integration/inductions.spec.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
describe("Inductions", () => {
beforeEach(() => {
cy.interceptSubchain();
cy.interceptBox();
cy.interceptEosApis();
cy.visit(`/induction`);
cy.wait("@boxGetSubchain");
Expand Down Expand Up @@ -71,22 +71,23 @@ describe("Inductions", () => {
cy.get("#consent").click();

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

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

it("should be able to endorse with witness 1", () => {
it("should be able to upload induction video and 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.wait("@boxUploadFile");

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

endorseInvitee();
});
Expand All @@ -104,7 +105,7 @@ describe("Inductions", () => {

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

endorseInvitee();
endorseInvitee(true);
});

it("should be able to complete induction", () => {
Expand All @@ -114,34 +115,23 @@ describe("Inductions", () => {

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");
cy.get("button").contains("Donate").click();
cy.wait("@eosPushTransaction");
});

const endorseInvitee = () => {
const endorseInvitee = (isLastEndorsement = false) => {
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");
cy.contains(
isLastEndorsement
? "This induction is fully endorsed!"
: "Waiting for all witnesses to endorse.",
{ timeout: 10000 }
).click();
};
});
});
Expand Down
5 changes: 3 additions & 2 deletions packages/webapp/cypress/support/commands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,10 +41,11 @@ Cypress.Commands.add("login", (account) => {
});

/**
* Intercept Subchain Calls
* Intercept Box Calls
*/
Cypress.Commands.add("interceptSubchain", () => {
Cypress.Commands.add("interceptBox", () => {
cy.intercept("**/v1/subchain/**").as("boxGetSubchain");
cy.intercept("**/v1/ipfs-upload").as("boxUploadFile");
});

/**
Expand Down
4 changes: 2 additions & 2 deletions packages/webapp/cypress/support/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,9 +25,9 @@ declare namespace Cypress {
login(account: string): Chainable;

/**
* Intercepts and creates default aliases loading up Box Subchain
* Intercepts and creates default aliases loading up Box endpoints calls
*/
interceptSubchain(): Chainable;
interceptBox(): Chainable;

/**
* Intercepts and creates default aliases for main EOS RPC Api Calls
Expand Down

0 comments on commit d2c71f3

Please sign in to comment.