Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Completes induction with file uploads #569

Merged
merged 6 commits into from
Nov 5, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
60 changes: 5 additions & 55 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -253,57 +253,6 @@ jobs:
path: |
build/eden-micro-chain.wasm

box-e2e:
needs: build-micro-chain
name: Eden Box E2E Tests
runs-on: ubuntu-latest

steps:
- name: ✅ Checkout code
uses: actions/checkout@v2

- uses: dorny/paths-filter@v2
id: filter
with:
filters: |
src:
- ".github/workflows/build.yml"

- ".eslintignore"
- ".eslintrc.js"
- ".prettierrc.json"
- "lerna.json"
- "package.json"
- "packages/common/**"
- "tsconfig.build.json"
- "tsconfig.json"
- "yarn.lock"

- "docker/eden-box.Dockerfile"
- "packages/box/**"

- name: Download Eden Microchain
if: steps.filter.outputs.src == 'true'
uses: actions/download-artifact@v2
with:
name: Eden Microchain
path: build

- name: 🛠 Build and Start Box
if: steps.filter.outputs.src == 'true'
run: |
export DFUSE_PREVENT_CONNECT=1
yarn
yarn build --stream
cd packages/box
yarn start &

- name: 🧪 Run E2E
if: steps.filter.outputs.src == 'true'
# TODO: add real E2E tests... for now it's just a shameless curl ping
run: |
curl localhost:3032

box-build:
needs: build-micro-chain
name: Build Eden Box
Expand Down Expand Up @@ -378,9 +327,9 @@ jobs:
tags: ${{ steps.prep.outputs.tags }}
context: .

webapp-e2e:
e2e:
needs: [build-cpp, build-micro-chain]
name: WebApp E2E Tests
name: E2E Tests
environment: e2e_tests
runs-on: ubuntu-latest

Expand Down Expand Up @@ -430,6 +379,7 @@ jobs:
path: build

- name: Start Genesis Ephemeral Chain
if: steps.filter.outputs.src == 'true'
run: |
cp ./scripts/eden_chain_runner.sh ./build
cd build
Expand All @@ -446,13 +396,13 @@ jobs:
yarn
yarn build --stream --ignore @edenos/example-history-app
yarn start-test --stream --ignore @edenos/example-history-app &
env:
IPFS_PINATA_JWT: ${{ secrets.IPFS_PINATA_JWT }}

- name: 🧪 Run E2E
if: steps.filter.outputs.src == 'true'
run: |
yarn test --stream
env:
cypress_test_users_pk: ${{ secrets.CYPRESS_TEST_USERS_PK }}

- name: 🎥 Upload Cypress Results
if: always() && steps.filter.outputs.src == 'true'
Expand Down
5 changes: 4 additions & 1 deletion packages/box/src/config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,10 @@ export const ipfsConfig = {
"https://api.pinata.cloud/pinning/pinFileToIPFS",
pinataJwt: process.env.IPFS_PINATA_JWT || "<pinata-jwt-here>",
};
console.info({ ...ipfsConfig, pinataJwt: "<secret>" });
console.info({
...ipfsConfig,
pinataJwt: `${ipfsConfig.pinataJwt.substr(0,8)}..${ipfsConfig.pinataJwt.substr(-8)}`
});

export const validUploadActions: ValidUploadActions = {
[edenContractAccount]: {
Expand Down
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.
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
135 changes: 111 additions & 24 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 All @@ -19,38 +19,125 @@ describe("Inductions", () => {
inviteButton.should("exist");
});

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

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("@boxUploadFile");

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

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.get("#invitee").type("bertie");
cy.get("#witness1").type("egeon");
cy.get("#witness2").type("pip");
cy.get('button[type="submit"]').click();
cy.wait("@eosPushTransaction");
cy.get("button").contains("Onward!", { timeout: 10000 }).click();

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

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

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

endorseInvitee();
});

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

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

endorseInvitee(true);
});

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

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

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

cy.get("button").contains("Donate").click();
cy.wait("@eosPushTransaction");
});

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");
cy.contains(
isLastEndorsement
? "This induction is fully endorsed!"
: "Waiting for all witnesses to endorse.",
{ timeout: 10000 }
).click();
};
});
});

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 {};
9 changes: 6 additions & 3 deletions 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 All @@ -39,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 All @@ -60,7 +63,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
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
1 change: 1 addition & 0 deletions packages/webapp/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,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 @@ -4070,6 +4070,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