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

Fix/cypress tests #37

Closed
wants to merge 19 commits into from
Closed
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
23 changes: 23 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,29 @@ on:
- v*.*.*

jobs:
cypress-run:
runs-on: ubuntu-22.04
steps:
- name: Check out Git repository
uses: actions/checkout@v3

- name: Install Node.js
uses: actions/setup-node@v3
with:
node-version: 18

- name: Install Dependencies
working-directory: "./clients/mercury-web"
run: npm install

- name: Cypress run
working-directory: "./clients/mercury-web"
run: |
npm run build
npm start &
npm install cypress
npx cypress run --browser chrome

release:
permissions: write-all
runs-on: ${{ matrix.os }}
Expand Down
21 changes: 21 additions & 0 deletions clients/mercury-web/.eslintrc.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
module.exports = {
root: true,
env: { browser: true, es2020: true },
extends: [
'eslint:recommended',
'plugin:react/recommended',
'plugin:react/jsx-runtime',
'plugin:react-hooks/recommended',
],
ignorePatterns: ['dist', '.eslintrc.cjs'],
parserOptions: { ecmaVersion: 'latest', sourceType: 'module' },
settings: { react: { version: '18.2' } },
plugins: ['react-refresh'],
rules: {
'react/jsx-no-target-blank': 'off',
'react-refresh/only-export-components': [
'warn',
{ allowConstantExport: true },
],
},
}
24 changes: 24 additions & 0 deletions clients/mercury-web/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,24 @@
# Logs
logs
*.log
npm-debug.log*
yarn-debug.log*
yarn-error.log*
pnpm-debug.log*
lerna-debug.log*

node_modules
dist
dist-ssr
*.local

# Editor directories and files
.vscode/*
!.vscode/extensions.json
.idea
.DS_Store
*.suo
*.ntvs*
*.njsproj
*.sln
*.sw?
Empty file added clients/mercury-web/README.md
Empty file.
10 changes: 10 additions & 0 deletions clients/mercury-web/cypress.config.cjs
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
const { defineConfig } = require("cypress");

module.exports = defineConfig({
e2e: {
baseUrl: "http://localhost:5173/",
setupNodeEvents(on, config) {
// implement node event listeners here
},
},
});
12 changes: 12 additions & 0 deletions clients/mercury-web/cypress/e2e/deposit.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Cypress.on("uncaught:exception", (err, runnable) => {
// returning false here prevents Cypress from
// failing the test
return false;
});

describe("Deposit", () => {
// Should deposit funds from the bank account to the wallet
it("Should deposit funds to the wallet", () => {
return true;
});
});
12 changes: 12 additions & 0 deletions clients/mercury-web/cypress/e2e/load_wallet.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
Cypress.on("uncaught:exception", (err, runnable) => {
// returning false here prevents Cypress from
// failing the test
return false;
});

describe("LoadWallet", () => {
// Should load an existing wallet from the database supplied
it("Should load an existing wallet from the database supplied", () => {
return true;
});
});
203 changes: 203 additions & 0 deletions clients/mercury-web/cypress/e2e/new_wallet.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,203 @@
Cypress.on("uncaught:exception", (err, runnable) => {
// returning false here prevents Cypress from
// failing the test
return false;
});

describe("WelcomePage", () => {
beforeEach(() => {
cy.visit("/"); // This will run before each test
});

it("displays welcome message", () => {
cy.get("[data-cy=welcome-message]").should("exist");
cy.get("[data-cy=welcome-title]").should("contain", "Welcome to Mercury");
cy.get("[data-cy=welcome-description]").should(
"contain",
"If you’re using Mercury Layer for the first time"
);
});

it("has buttons for new wallet, load wallet, and recover wallet", () => {
cy.get("[data-cy=new-wallet-button]").should("exist");
cy.get("[data-cy=load-wallet-button]").should("exist");
cy.get("[data-cy=recover-wallet-button]").should("exist");
});

it("clicking new wallet button navigates to new wallet page", () => {
cy.get("[data-cy=new-wallet-button]").click();
cy.url().should("include", "/new-wallet-0");
});
});

describe("WalletWizardPage", () => {
beforeEach(() => {
cy.visit("/");
cy.get("[data-cy=new-wallet-button]").click();
cy.url().should("include", "/new-wallet-0");
});

it("displays wallet wizard steps", () => {
cy.get("[data-cy=wallet-wizard-step]").should("exist");
cy.get("[data-cy=wallet-info-step]").should("exist");
cy.get("[data-cy=wallet-seed-step]").should("exist");
cy.get("[data-cy=confirm-seed-step]").should("exist");
});

it("allows selection of network type", () => {
cy.get("[data-cy=network-type-select]").select("Testnet"); // Assuming this is the correct select element
cy.get("[data-cy=network-type-select]").should("have.value", "Testnet");
});

it("displays confirmation checkbox", () => {
cy.get("[data-cy=confirmation-checkbox]").should("exist");
});

it("clicking GO BACK button navigates to previous page", () => {
cy.get("[data-cy=go-back-button]").click();
// Add assertion for navigation if needed
});
// Add more tests as needed
it("click confirmation checkbox", () => {
cy.get("[data-cy=confirmation-checkbox]").click();
cy.get("[data-cy=next-button]").should("not.be.disabled");
});

it("click confirmation checkbox and press next ", () => {
cy.get("[data-cy=confirmation-checkbox]").click();
cy.get("[data-cy=next-button]").should("not.be.disabled");
cy.get("[data-cy=next-button]").click();
cy.url().should("include", "/new-wallet-1");
});
});

describe("WalletWizardPage1", () => {
beforeEach(() => {
cy.visit("/"); // Visit the initial page
cy.get("[data-cy=new-wallet-button]").click(); // Click on the new wallet button to navigate to the wizard page
cy.url().should("include", "/new-wallet-0"); // Check if the URL includes the expected path
cy.get("[data-cy=confirmation-checkbox]").click();
cy.get("[data-cy=next-button]").should("not.be.disabled");
cy.get("[data-cy=next-button]").click();
cy.url().should("include", "/new-wallet-1");
});

it("should enter a wallet name", () => {
cy.get("[data-cy=wallet-name-input").type("Hello");
});

it("should display an error message when entering a password that does not match confirmation", () => {
cy.get("[data-cy=password-input]").type("password123");
cy.get("[data-cy=confirm-password-input]").type("password321");
cy.get("[data-cy=terms-checkbox]").check();
cy.get("[data-cy=next-button]").click();
cy.get(".fixed").should("be.visible").contains("Passwords do not match.");
});

/*
it('should display an error message when wallet name already exists', () => {
cy.get('[data-cy=wallet-name-input]').type('ExistingWallet')
cy.get('[data-cy=password-input]').type('password123')
cy.get('[data-cy=confirm-password-input]').type('password123')
cy.get('[data-cy=terms-checkbox]').check()
cy.get('[data-cy=next-button]').click()
cy.get('.fixed')
.should('be.visible')
.contains('A wallet with the same name already exists. Please choose a different name.')
})*/

it("should navigate to the next step when all fields are filled correctly", () => {
cy.get("[data-cy=wallet-name-input]").type("NewWallet");
cy.get("[data-cy=password-input]").type("password123");
cy.get("[data-cy=confirm-password-input]").type("password123");
cy.get("[data-cy=terms-checkbox]").check();
cy.get("[data-cy=next-button]").should("not.be.disabled").click();
cy.url().should("include", "/new-wallet-2");
});
});

describe("WalletWizardPage2", () => {
beforeEach(() => {
cy.visit("/"); // Visit the initial page
cy.get("[data-cy=new-wallet-button]").click(); // Click on the new wallet button to navigate to the wizard page
cy.url().should("include", "/new-wallet-0"); // Check if the URL includes the expected path
cy.get("[data-cy=confirmation-checkbox]").click();
cy.get("[data-cy=next-button]").should("not.be.disabled");
cy.get("[data-cy=next-button]").click();
cy.url().should("include", "/new-wallet-1");
cy.get("[data-cy=wallet-name-input]").type("NewWallet");
cy.get("[data-cy=password-input]").type("password123");
cy.get("[data-cy=confirm-password-input]").type("password123");
cy.get("[data-cy=terms-checkbox]").check();
cy.get("[data-cy=next-button]").should("not.be.disabled").click();
cy.url().should("include", "/new-wallet-2");
});

it("should display the seed phrase panel", () => {
cy.get("[data-cy=seed-phrase-panel]").should("be.visible");
});

it("should display correct warning messages about storing seed phrase safely", () => {
cy.contains(
"Carefully write down and store your seed somewhere safe, as it provides access to your wallet."
).should("exist");
cy.contains(
"For best practice, never store it online or on the same computer as the wallet."
).should("exist");
});

it('should navigate back to the previous step when "GO BACK" button is clicked', () => {
cy.get("[data-cy=go-back-button]").click();
cy.url().should("include", "/new-wallet-1");
});

it('should navigate to the next step when "NEXT" button is clicked', () => {
cy.get("[data-cy=next-button]").click();
cy.url().should("include", "/new-wallet-3");
});
});

describe("WalletWizardPage3", () => {
beforeEach(() => {
cy.visit("/"); // Visit the initial page
cy.get("[data-cy=new-wallet-button]").click(); // Click on the new wallet button to navigate to the wizard page
cy.url().should("include", "/new-wallet-0"); // Check if the URL includes the expected path
cy.get("[data-cy=confirmation-checkbox]").click();
cy.get("[data-cy=next-button]").should("not.be.disabled");
cy.get("[data-cy=next-button]").click();
cy.url().should("include", "/new-wallet-1");
cy.get("[data-cy=wallet-name-input]").type("NewWallet");
cy.get("[data-cy=password-input]").type("password123");
cy.get("[data-cy=confirm-password-input]").type("password123");
cy.get("[data-cy=terms-checkbox]").check();
cy.get("[data-cy=next-button]").should("not.be.disabled").click();
cy.url().should("include", "/new-wallet-2");
cy.get("[data-cy=next-button]").click();
cy.url().should("include", "/new-wallet-3");
});

it("should display the Wallet Wizard Page 3", () => {
// Check if the page contains the relevant elements
cy.get("[data-cy=step-1-info]").should("contain", "Wallet Info");
cy.get("[data-cy=step-2-info]").should("contain", "Wallet seed");
cy.get("[data-cy=step-3-info]").should("contain", "Confirm seed");
cy.get("[data-cy=confirm-seed-instruction]").should(
"contain",
"Click to confirm your seed key."
);
cy.get("[data-cy=confirm-seed-panel]").should("exist");
cy.get("[data-cy=go-back-button]").should("exist");
cy.get("[data-cy=confirm-button]").should("exist");
});

it("should navigate back to Wallet Wizard Page 2 when Go Back button is clicked", () => {
cy.get("[data-cy=go-back-button]").click();
cy.url().should("include", "/new-wallet-2");
});

/* TODO - issue with ipcRenderer commands for some reason in cypress
it('should navigate to the next step when Confirm button is clicked', () => {
cy.get('[data-cy=confirm-button]').click()
cy.url().should('include', '/mainpage')
})*/
});
11 changes: 11 additions & 0 deletions clients/mercury-web/cypress/e2e/settings.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Cypress.on("uncaught:exception", (err, runnable) => {
// returning false here prevents Cypress from
// failing the test
return false;
});

describe("Settings", () => {
it("Should load the settings page", () => {
return true;
});
});
11 changes: 11 additions & 0 deletions clients/mercury-web/cypress/e2e/transfer.cy.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
Cypress.on("uncaught:exception", (err, runnable) => {
// returning false here prevents Cypress from
// failing the test
return false;
});

describe("Transfer", () => {
it("Should transfer funds from one account to another", () => {
return true;
});
});
3 changes: 3 additions & 0 deletions clients/mercury-web/cypress/fixtures/depositGetToken.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"ok": "ok"
}
3 changes: 3 additions & 0 deletions clients/mercury-web/cypress/fixtures/depositInitPod.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"ok": "ok"
}
3 changes: 3 additions & 0 deletions clients/mercury-web/cypress/fixtures/infoConfig.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"ok": "ok"
}
6 changes: 6 additions & 0 deletions clients/mercury-web/cypress/fixtures/infoStatecoin1.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"enclave_public_key": "",
"num_sigs": "",
"statechain_info": "",
"x1_pub": ""
}
6 changes: 6 additions & 0 deletions clients/mercury-web/cypress/fixtures/signFirst.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
{
"statechain_id": "string",
"r2_commitment": "string",
"blind_commitment": "string",
"signed_statechain_id": "string"
}
3 changes: 3 additions & 0 deletions clients/mercury-web/cypress/fixtures/signSecond.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"ok": ""
}
8 changes: 8 additions & 0 deletions clients/mercury-web/cypress/fixtures/statechainInfo.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
{
"statechain_id": "string",
"r2_commitment": "string",
"blind_commitment": "string",
"server_pubnonce": "string",
"challenge": "string",
"tx_n": 0
}
3 changes: 3 additions & 0 deletions clients/mercury-web/cypress/fixtures/tokenConfirmDebug.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"data": "todo"
}
7 changes: 7 additions & 0 deletions clients/mercury-web/cypress/fixtures/tokenInit.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
{
"btc_payment_address": "bc1qvfeh43dxutf9cpduqjsnvcssqag426kyttkf90",
"fee": "0.001",
"lightning_invoice": "lnbc1m1pjlrer9pp5h2etv8rapuvpxqjuxnmzsup6ewwtp5q74d5x5h9rtjcxppm2tphsdp6v5uxydpnvcer2tfjvd3xztf5xccxgtfcxs6rgtt98yckye33893kywf4xucqzzsxqrrsssp5e4u0k3q2532ckc59g522zpr0mp5kfkcm6qxy7dlg04jpaqtm7ksq9qyyssqyujgpekwwrntlczq2lxrcl43f5yuy33ugg8edfgg6thnlhrdu5j8hgerhxg07qe2djnp3s36da4rj2c5kkrsywdddxsq4ddqy42gtfqpz5dcuc",
"processor_id": "bab2b61c7d0f1813025c34f628703acb9cb0d01eab686a5ca35cb060876a586f",
"token_id": "e8b43f25-2cba-460d-8444-e91bf19cb957"
}
3 changes: 3 additions & 0 deletions clients/mercury-web/cypress/fixtures/tokenVerify.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
{
"data": "todo"
}
Loading
Loading