diff --git a/.travis.yml b/.travis.yml index 56a0c3a..eb8da0c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -10,13 +10,14 @@ addons: - libgconf-2-4 env: - # run E2E tests against these values - - REACT_APP_NODE_URI="https://nile.dev-ocean.com" - - REACT_APP_AQUARIUS_URI="https://aquarius.marketplace.dev-ocean.com" - - REACT_APP_BRIZO_URI="https://brizo.marketplace.dev-ocean.com" - - REACT_APP_SECRET_STORE_URI="https://secret-store.marketplace.dev-ocean.com" - - REACT_APP_FAUCET_URI="https://faucet.nile.dev-ocean.com" - - REACT_APP_BRIZO_ADDRESS="0x4aaab179035dc57b35e2ce066919048686f82972" + global: + # run E2E tests against these values + - REACT_APP_NODE_URI="https://nile.dev-ocean.com" + - REACT_APP_AQUARIUS_URI="https://aquarius.marketplace.dev-ocean.com" + - REACT_APP_BRIZO_URI="https://brizo.marketplace.dev-ocean.com" + - REACT_APP_SECRET_STORE_URI="https://secret-store.marketplace.dev-ocean.com" + - REACT_APP_FAUCET_URI="https://faucet.nile.dev-ocean.com" + - REACT_APP_BRIZO_ADDRESS="0x4aaab179035dc57b35e2ce066919048686f82972" before_install: - npm install -g npm diff --git a/README.md b/README.md index 21a6300..02505ac 100644 --- a/README.md +++ b/README.md @@ -22,17 +22,19 @@ If you're a developer and want to contribute to, or want to utilize this marketplace's code in your projects, then keep on reading. -- [🏄 Get Started](#-get-started) - - [🏖 Remote Ocean: Nile](#-remote-ocean-nile) - - [🐳 Use with Barge](#-use-with-barge) - - [⛵️ Environment Variables](#️-environment-variables) -- [👩‍🔬 Testing](#-testing) -- [✨ Code Style](#-code-style) -- [🛳 Production](#-production) -- [⬆️ Releases](#️-releases) -- [📜 Changelog](#-changelog) -- [🎁 Contributing](#-contributing) -- [🏛 License](#-license) +- [🏄 Get Started](#-Get-Started) + - [🏖 Remote Ocean: Nile](#-Remote-Ocean-Nile) + - [🐳 Use with Barge](#-Use-with-Barge) + - [⛵️ Environment Variables](#️-Environment-Variables) +- [👩‍🔬 Testing](#-Testing) + - [Unit Tests](#Unit-Tests) + - [End-to-End Integration Tests](#End-to-End-Integration-Tests) +- [✨ Code Style](#-Code-Style) +- [🛳 Production](#-Production) +- [⬆️ Releases](#️-Releases) +- [📜 Changelog](#-Changelog) +- [🎁 Contributing](#-Contributing) +- [🏛 License](#-License) ## 🏄 Get Started @@ -90,9 +92,11 @@ vi client/.env.local ## 👩‍🔬 Testing -Test suite is setup with [Jest](https://jestjs.io) and [react-testing-library](https://github.com/kentcdodds/react-testing-library). +Test suite is setup with [Jest](https://jestjs.io) and [react-testing-library](https://github.com/kentcdodds/react-testing-library) for unit testing, and [Cypress](https://www.cypress.io) for integration testing. -To run all tests, including all linting tests: +### Unit Tests + +To run all unit tests, including all linting tests: ```bash npm test @@ -114,6 +118,18 @@ cd server/ npm run test:watch ``` +### End-to-End Integration Tests + +To run all integration tests, run: + +```bash +npm run test:e2e +``` + +This will automatically spin up all required resources to run the integrations tests, and then run them. + +The endpoints Cypress runs against are defined by your [Environment Variables](#️-Environment-Variables), and Cypress-specific variables in `cypress.json`. + ## ✨ Code Style For linting and auto-formatting you can use from the root of the project: diff --git a/cypress.json b/cypress.json index 0b2329f..3f7cf82 100644 --- a/cypress.json +++ b/cypress.json @@ -1,7 +1,8 @@ { - "env": { - "NODE_URI": "https://nile.dev-ocean.com", - "SEEDPHRASE": "taxi music thumb unique chat sand crew more leg another off lamp", - "CONSUME_ASSET": "http://localhost:3000/asset/did:op:fb172f4bfeb3454a99ec752fcd20f37665fa3f1879154746b1be1b014fae91d0" - } + "baseUrl": "http://localhost:3000", + "env": { + "NODE_URI": "https://nile.dev-ocean.com", + "SEEDPHRASE": "taxi music thumb unique chat sand crew more leg another off lamp", + "CONSUME_ASSET": "http://localhost:3000/asset/did:op:8014d305dcb44b42a5355791a2f016a654a61184456a4d178dc6e5913deb3a5c" + } } diff --git a/cypress/integration/consume.spec.js b/cypress/integration/consume.spec.js index e546af0..a66a364 100644 --- a/cypress/integration/consume.spec.js +++ b/cypress/integration/consume.spec.js @@ -6,22 +6,14 @@ context('Consume', () => { before(() => { cy.on('window:before:load', win => { const provider = new HDWalletProvider( - Cypress.env('SEEDPHRASE') - ? Cypress.env('SEEDPHRASE') - : 'taxi music thumb unique chat sand crew more leg another off lamp', + Cypress.env('SEEDPHRASE'), Cypress.env('NODE_URI') - ? Cypress.env('NODE_URI') - : 'https://nile.dev-ocean.com' ) win.web3 = new Web3(provider) win.ethereum = win.web3 }) - cy.visit( - Cypress.env('CONSUME_ASSET') - ? Cypress.env('CONSUME_ASSET') - : 'http://localhost:3000/asset/did:op:8014d305dcb44b42a5355791a2f016a654a61184456a4d178dc6e5913deb3a5c' - ) + cy.visit(Cypress.env('CONSUME_ASSET')) // Wait for end of loading cy.get('button', { timeout: 60000 }).should('have.length', 1) diff --git a/cypress/integration/faucet.spec.js b/cypress/integration/faucet.spec.js index 4973215..d089467 100644 --- a/cypress/integration/faucet.spec.js +++ b/cypress/integration/faucet.spec.js @@ -6,18 +6,14 @@ context('Faucet', () => { before(() => { cy.on('window:before:load', win => { const provider = new HDWalletProvider( - Cypress.env('SEEDPHRASE') - ? Cypress.env('SEEDPHRASE') - : 'taxi music thumb unique chat sand crew more leg another off lamp', + Cypress.env('SEEDPHRASE'), Cypress.env('NODE_URI') - ? Cypress.env('NODE_URI') - : 'https://nile.dev-ocean.com' ) win.web3 = new Web3(provider) win.ethereum = win.web3 }) - cy.visit('http://localhost:3000/faucet') + cy.visit('/faucet') // Wait for end of loading cy.get('button', { timeout: 60000 }).should('have.length', 1) }) diff --git a/cypress/integration/publish.spec.js b/cypress/integration/publish.spec.js index bb87dbb..36e20ab 100644 --- a/cypress/integration/publish.spec.js +++ b/cypress/integration/publish.spec.js @@ -6,18 +6,14 @@ context('Publish', () => { before(() => { cy.on('window:before:load', win => { const provider = new HDWalletProvider( - Cypress.env('SEEDPHRASE') - ? Cypress.env('SEEDPHRASE') - : 'taxi music thumb unique chat sand crew more leg another off lamp', + Cypress.env('SEEDPHRASE'), Cypress.env('NODE_URI') - ? Cypress.env('NODE_URI') - : 'https://nile.dev-ocean.com' ) win.web3 = new Web3(provider) win.ethereum = win.web3 }) - cy.visit('http://localhost:3000/publish') + cy.visit('/publish') cy.get('article>div', { timeout: 60000 }).should( 'contain', diff --git a/cypress/integration/search.spec.js b/cypress/integration/search.spec.js index 6f12a19..5f0d9dd 100644 --- a/cypress/integration/search.spec.js +++ b/cypress/integration/search.spec.js @@ -6,18 +6,14 @@ context('Search', () => { before(() => { cy.on('window:before:load', win => { const provider = new HDWalletProvider( - Cypress.env('SEEDPHRASE') - ? Cypress.env('SEEDPHRASE') - : 'taxi music thumb unique chat sand crew more leg another off lamp', + Cypress.env('SEEDPHRASE'), Cypress.env('NODE_URI') - ? Cypress.env('NODE_URI') - : 'https://nile.dev-ocean.com' ) win.web3 = new Web3(provider) win.ethereum = win.web3 }) - cy.visit('http://localhost:3000') + cy.visit('/') // Wait for end of loading cy.get('button', { timeout: 60000 }).should('have.length', 1) }) diff --git a/cypress/integration/viewport.spec.js b/cypress/integration/viewport.spec.js deleted file mode 100644 index 069861c..0000000 --- a/cypress/integration/viewport.spec.js +++ /dev/null @@ -1,14 +0,0 @@ -/// - -context('Viewport', () => { - beforeEach(() => { - cy.visit('http://localhost:3000') - }) - - it('cy.viewport() - set the viewport size and dimension', () => { - cy.get('#root > div > header > div > a > h1').should('be.visible') - cy.viewport(320, 480) - - cy.get('#root > div > header > div > a > h1').should('not.be.visible') - }) -})