1
0
mirror of https://github.com/oceanprotocol/commons.git synced 2023-03-15 18:03:00 +01:00

add tests

This commit is contained in:
Jernej Pregelj 2019-06-19 15:28:31 +02:00
parent 667c46303c
commit e5960d3fd6
7 changed files with 2066 additions and 2587 deletions

View File

@ -1296,9 +1296,9 @@
"integrity": "sha512-nOpbSE/BG+tQBfLXZ/EqSOvUPzOuot84vHxjAfEU8K3v4eOnqFJVo+oyB7KlcF87wBJXDmi/Ir9qHY4c0Saipg==" "integrity": "sha512-nOpbSE/BG+tQBfLXZ/EqSOvUPzOuot84vHxjAfEU8K3v4eOnqFJVo+oyB7KlcF87wBJXDmi/Ir9qHY4c0Saipg=="
}, },
"@oceanprotocol/squid": { "@oceanprotocol/squid": {
"version": "0.5.14", "version": "0.5.15",
"resolved": "https://registry.npmjs.org/@oceanprotocol/squid/-/squid-0.5.14.tgz", "resolved": "https://registry.npmjs.org/@oceanprotocol/squid/-/squid-0.5.15.tgz",
"integrity": "sha512-LyJ9Dv3kJD/th7bqk5iTqDNlQfidy4j5bTcLbzCIFvzFqPztTCWRON01G52z1A1jCYXBhtncX2jzwaOZDdmxsg==", "integrity": "sha512-M2dTC2Vhl0BWa7DADTvcSdzW3Z8veLm4EhyfbN/qKS6xNRET/5h8CB9t+sk/vCm/ZR82GKKv1EMn/UCp5V5h+g==",
"requires": { "requires": {
"@oceanprotocol/keeper-contracts": "^0.9.7", "@oceanprotocol/keeper-contracts": "^0.9.7",
"bignumber.js": "^8.1.1", "bignumber.js": "^8.1.1",

View File

@ -3,7 +3,7 @@ import Web3 from 'web3'
import HDWalletProvider from 'truffle-hdwallet-provider' import HDWalletProvider from 'truffle-hdwallet-provider'
context('Consume', () => { context('Consume', () => {
beforeEach(() => { before(() => {
cy.on('window:before:load', win => { cy.on('window:before:load', win => {
const provider = new HDWalletProvider( const provider = new HDWalletProvider(
'taxi music thumb unique chat sand crew more leg another off lamp', 'taxi music thumb unique chat sand crew more leg another off lamp',
@ -16,11 +16,23 @@ context('Consume', () => {
cy.visit( cy.visit(
'http://localhost:3000/asset/did:op:48870c70dac448949634c41817c8017dc558ce59ad774002996e9811b97a36d5' 'http://localhost:3000/asset/did:op:48870c70dac448949634c41817c8017dc558ce59ad774002996e9811b97a36d5'
) )
// wait for the asset details to have loaded // Wait for end of loading
cy.get('button', { timeout: 10000 }).should('have.length', 1) cy.get('button', { timeout: 20000 }).should('have.length', 1)
}) })
it('Download button is clickable when user is connected.', () => { it('Download button is clickable when user is connected.', () => {
cy.get('button').should('not.be.disabled') cy.get('button').should('not.be.disabled')
}) })
it('Consume asset and check if there is no error', () => {
// Click consume button
cy.get('button').click()
// Wait consume process to end
cy.get('button', { timeout: 60000 }).should('contain', 'Get file')
// check if there is no error
cy.get('article>div').should(
'not.contain',
'. Sorry about that, can you try again?'
)
})
}) })

View File

@ -0,0 +1,31 @@
/// <reference types="Cypress" />
import Web3 from 'web3'
import HDWalletProvider from 'truffle-hdwallet-provider'
context('Faucet', () => {
before(() => {
cy.on('window:before:load', win => {
const provider = new HDWalletProvider(
'taxi music thumb unique chat sand crew more leg another off lamp',
'http://localhost:8545'
)
win.web3 = new Web3(provider)
win.ethereum = win.web3
})
cy.visit('http://localhost:3000/faucet')
// Wait for end of loading
cy.get('button', { timeout: 20000 }).should('have.length', 1)
})
it('Execute faucet call', () => {
// Execute call
cy.get('button')
.contains('Request Ether')
.click()
// Verify that we got response from server
cy.contains(/(Successfully added|Already requested)/, {
timeout: 60000
}).should('be.visible')
})
})

View File

@ -0,0 +1,80 @@
/// <reference types="Cypress" />
import Web3 from 'web3'
import HDWalletProvider from 'truffle-hdwallet-provider'
context('Publish', () => {
before(() => {
cy.on('window:before:load', win => {
const provider = new HDWalletProvider(
'taxi music thumb unique chat sand crew more leg another off lamp',
'http://localhost:8545'
)
win.web3 = new Web3(provider)
win.ethereum = win.web3
})
cy.visit('http://localhost:3000/publish')
cy.get('article>div', { timeout: 20000 }).should(
'contain',
'Essentials'
)
})
it('Publish flow', () => {
// Fill title
cy.get('input#name').type('Title test')
// Open Add a file form
cy.get('button')
.contains('+ Add a file')
.click()
// Fill url of file
cy.get('input#url').type(
'https://oceanprotocol.com/tech-whitepaper.pdf'
)
// Add file to main form
cy.get('button')
.contains('Add File')
.click()
// Verify and nove to next step
cy.get('button')
.contains('Next →')
.should('not.be.disabled')
.click()
// Verify we are on next step
cy.get('article>div').should('contain', 'Information')
// Fill description
cy.get('textarea#description').type('This is test description')
// Pick category
cy.get('select#categories').select('Biology')
// Verify and move to next step
cy.get('button')
.contains('Next →')
.should('not.be.disabled')
.click()
// Verify we are on next step
cy.get('article>div').should('contain', 'Authorship')
// Fill author
cy.get('input#author').type('Super Author')
// Fill copyright holder
cy.get('input#copyrightHolder').type('Super Copyright Holder')
// Pick author
cy.get('select#license').select('Public Domain')
// Verify and move to next step
cy.get('button')
.contains('Next →')
.should('not.be.disabled')
.click()
// Verify we are on next step
cy.get('article>div').should('contain', 'Register')
// Start publish process
cy.get('button')
.contains('Register asset')
.should('not.be.disabled')
.click()
// Wait for finish
cy.contains('Your asset is published!', {
timeout: 60000
}).should('be.visible')
})
})

View File

@ -0,0 +1,34 @@
/// <reference types="Cypress" />
import Web3 from 'web3'
import HDWalletProvider from 'truffle-hdwallet-provider'
context('Search', () => {
before(() => {
cy.on('window:before:load', win => {
const provider = new HDWalletProvider(
'taxi music thumb unique chat sand crew more leg another off lamp',
'http://localhost:8545'
)
win.web3 = new Web3(provider)
win.ethereum = win.web3
})
cy.visit('http://localhost:3000')
// Wait for end of loading
cy.get('button', { timeout: 20000 }).should('have.length', 1)
})
it('Search for assets from homepage', () => {
// Fill search phrase
cy.get('input#search').type('Title test')
// Start search
cy.get('button')
.contains('Search')
.click()
// Verify there are results
cy.get('article > a', { timeout: 10000 }).should(
'have.length.greaterThan',
0
)
})
})

4412
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@ -384,9 +384,9 @@
} }
}, },
"@types/babel__traverse": { "@types/babel__traverse": {
"version": "7.0.6", "version": "7.0.7",
"resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.0.6.tgz", "resolved": "https://registry.npmjs.org/@types/babel__traverse/-/babel__traverse-7.0.7.tgz",
"integrity": "sha512-XYVgHF2sQ0YblLRMLNPB3CkFMewzFmlDsH/TneZFHUXDlABQgh88uOxuez7ZcXxayLFrqLwtDH1t+FmlFwNZxw==", "integrity": "sha512-CeBpmX1J8kWLcDEnI3Cl2Eo6RfbGvzUctA+CjZUhOKDFbLfcr7fc4usEqLNWetrlJd7RhAkyYe2czXop4fICpw==",
"dev": true, "dev": true,
"requires": { "requires": {
"@babel/types": "^7.3.0" "@babel/types": "^7.3.0"
@ -439,9 +439,9 @@
"dev": true "dev": true
}, },
"@types/express": { "@types/express": {
"version": "4.16.1", "version": "4.17.0",
"resolved": "https://registry.npmjs.org/@types/express/-/express-4.16.1.tgz", "resolved": "https://registry.npmjs.org/@types/express/-/express-4.17.0.tgz",
"integrity": "sha512-V0clmJow23WeyblmACoxbHBu2JKlE5TiIme6Lem14FnPW9gsttyHtk6wq7njcdIWH1njAaFgR8gW09lgY98gQg==", "integrity": "sha512-CjaMu57cjgjuZbh9DpkloeGxV45CnMGlVd+XpG7Gm9QgVrd7KFq+X4HY0vM+2v0bczS48Wg7bvnMY5TN+Xmcfw==",
"dev": true, "dev": true,
"requires": { "requires": {
"@types/body-parser": "*", "@types/body-parser": "*",
@ -450,9 +450,9 @@
} }
}, },
"@types/express-serve-static-core": { "@types/express-serve-static-core": {
"version": "4.16.6", "version": "4.16.7",
"resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.16.6.tgz", "resolved": "https://registry.npmjs.org/@types/express-serve-static-core/-/express-serve-static-core-4.16.7.tgz",
"integrity": "sha512-8wr3CA/EMybyb6/V8qvTRKiNkPmgUA26uA9XWD6hlA0yFDuqi4r2L0C2B0U2HAYltJamoYJszlkaWM31vrKsHg==", "integrity": "sha512-847KvL8Q1y3TtFLRTXcVakErLJQgdpFSaq+k043xefz9raEf0C7HalpSY7OW5PyjCnY8P7bPW5t/Co9qqp+USg==",
"dev": true, "dev": true,
"requires": { "requires": {
"@types/node": "*", "@types/node": "*",
@ -494,9 +494,9 @@
} }
}, },
"@types/jest": { "@types/jest": {
"version": "24.0.13", "version": "24.0.15",
"resolved": "https://registry.npmjs.org/@types/jest/-/jest-24.0.13.tgz", "resolved": "https://registry.npmjs.org/@types/jest/-/jest-24.0.15.tgz",
"integrity": "sha512-3m6RPnO35r7Dg+uMLj1+xfZaOgIHHHut61djNjzwExXN4/Pm9has9C6I1KMYSfz7mahDhWUOVg4HW/nZdv5Pww==", "integrity": "sha512-MU1HIvWUme74stAoc3mgAi+aMlgKOudgEvQDIm1v4RkrDudBh1T+NFp5sftpBAdXdx1J0PbdpJ+M2EsSOi1djA==",
"dev": true, "dev": true,
"requires": { "requires": {
"@types/jest-diff": "*" "@types/jest-diff": "*"
@ -524,9 +524,9 @@
} }
}, },
"@types/node": { "@types/node": {
"version": "11.13.13", "version": "11.13.14",
"resolved": "https://registry.npmjs.org/@types/node/-/node-11.13.13.tgz", "resolved": "https://registry.npmjs.org/@types/node/-/node-11.13.14.tgz",
"integrity": "sha512-GFWH7e4Q/OGLAO545bupVju+nE1YtLSwYAdLfSzAXnTPqoqKoXCOEtB7Cluvg9B/h2nGLhyzCDyCInYvrOE2nw==", "integrity": "sha512-9NjFOB6UUGjJLNANmyIouuaN8YPsPgC4DCOd5lU+DL7HSX/RCfzz0JOtHlspEJq1Ll/JUu/8Cm4wzxpZ8w5sjQ==",
"dev": true "dev": true
}, },
"@types/range-parser": { "@types/range-parser": {
@ -1474,9 +1474,9 @@
}, },
"dependencies": { "dependencies": {
"ms": { "ms": {
"version": "2.1.1", "version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==" "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w=="
} }
} }
}, },
@ -3435,9 +3435,9 @@
"dev": true "dev": true
}, },
"jest-haste-map": { "jest-haste-map": {
"version": "24.8.0", "version": "24.8.1",
"resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-24.8.0.tgz", "resolved": "https://registry.npmjs.org/jest-haste-map/-/jest-haste-map-24.8.1.tgz",
"integrity": "sha512-ZBPRGHdPt1rHajWelXdqygIDpJx8u3xOoLyUBWRW28r3tagrgoepPrzAozW7kW9HrQfhvmiv1tncsxqHJO1onQ==", "integrity": "sha512-SwaxMGVdAZk3ernAx2Uv2sorA7jm3Kx+lR0grp6rMmnY06Kn/urtKx1LPN2mGTea4fCT38impYT28FfcLUhX0g==",
"dev": true, "dev": true,
"requires": { "requires": {
"@jest/types": "^24.8.0", "@jest/types": "^24.8.0",
@ -4235,9 +4235,9 @@
} }
}, },
"ms": { "ms": {
"version": "2.1.1", "version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
"dev": true "dev": true
} }
} }
@ -4958,9 +4958,9 @@
} }
}, },
"rsvp": { "rsvp": {
"version": "4.8.4", "version": "4.8.5",
"resolved": "https://registry.npmjs.org/rsvp/-/rsvp-4.8.4.tgz", "resolved": "https://registry.npmjs.org/rsvp/-/rsvp-4.8.5.tgz",
"integrity": "sha512-6FomvYPfs+Jy9TfXmBpBuMWNH94SgCsZmJKcanySzgNNP6LjWxBvyLTa9KaMfDDM5oxRfrKDB0r/qeRsLwnBfA==", "integrity": "sha512-nfMOlASu9OnRJo1mbEk2cz0D56a1MBNrJ7orjRZQG10XDyuvwksKbuXNp6qa+kbn839HwjwhBzhFmdsaEAfauA==",
"dev": true "dev": true
}, },
"safe-buffer": { "safe-buffer": {
@ -5516,9 +5516,9 @@
} }
}, },
"ms": { "ms": {
"version": "2.1.1", "version": "2.1.2",
"resolved": "https://registry.npmjs.org/ms/-/ms-2.1.1.tgz", "resolved": "https://registry.npmjs.org/ms/-/ms-2.1.2.tgz",
"integrity": "sha512-tgp+dl5cGk28utYktBsrFqA7HKgrhgPsg6Z/EfhWI4gl1Hwq8B/GmY/0oXZ6nF8hDVesS/FpnYaD/kOWhYQvyg==", "integrity": "sha512-sGkPx+VjMtmA6MX27oA4FBFELFCZZ4S4XqeGOXCv68tT+jb3vk/RyaKWP0PTKyWtmLSM0b+adUTEvbs1PEaH2w==",
"dev": true "dev": true
} }
} }
@ -5543,9 +5543,9 @@
} }
}, },
"symbol-tree": { "symbol-tree": {
"version": "3.2.2", "version": "3.2.4",
"resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.2.tgz", "resolved": "https://registry.npmjs.org/symbol-tree/-/symbol-tree-3.2.4.tgz",
"integrity": "sha1-rifbOPZgp64uHDt9G8KQgZuFGeY=", "integrity": "sha512-9QNk5KwDF+Bvz+PyObkmSYjI5ksVUYtjW7AU22r2NKcfLJcXp96hkDWU3+XndOsUb+AQ9QhfzfCT2O+CNWT5Tw==",
"dev": true "dev": true
}, },
"term-size": { "term-size": {
@ -5749,9 +5749,9 @@
} }
}, },
"ts-node": { "ts-node": {
"version": "8.2.0", "version": "8.3.0",
"resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.2.0.tgz", "resolved": "https://registry.npmjs.org/ts-node/-/ts-node-8.3.0.tgz",
"integrity": "sha512-m8XQwUurkbYqXrKqr3WHCW310utRNvV5OnRVeISeea7LoCWVcdfeB/Ntl8JYWFh+WRoUAdBgESrzKochQt7sMw==", "integrity": "sha512-dyNS/RqyVTDcmNM4NIBAeDMpsAdaQ+ojdf0GOLqE6nwJOgzEkdRNzJywhDfwnuvB10oa6NLVG1rUJQCpRN7qoQ==",
"dev": true, "dev": true,
"requires": { "requires": {
"arg": "^4.1.0", "arg": "^4.1.0",