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

IPFS publish & consume integration tests

This commit is contained in:
Matthias Kretschmann 2019-09-18 15:54:50 +02:00
parent c6f5f8561c
commit 752498d6b3
Signed by: m
GPG Key ID: 606EEEF3C479A91F
5 changed files with 110 additions and 10 deletions

1
.gitignore vendored
View File

@ -26,4 +26,5 @@ yarn-error.log*
cypress/screenshots cypress/screenshots
cypress/videos cypress/videos
cypress/fixtures/did.txt cypress/fixtures/did.txt
cypress/fixtures/did-ipfs.txt
artifacts artifacts

View File

@ -1,6 +1,6 @@
/// <reference types="Cypress" /> /// <reference types="Cypress" />
context('Publish', () => { describe('Publish', () => {
before(() => { beforeEach(() => {
cy.visit('/publish') cy.visit('/publish')
cy.get('article>div', { timeout: 60000 }).should( cy.get('article>div', { timeout: 60000 }).should(
@ -9,7 +9,7 @@ context('Publish', () => {
) )
}) })
it('Publish flow', () => { it('should publish https:// file', () => {
// Fill title // Fill title
cy.get('input#name').type('Commons Integration Test') cy.get('input#name').type('Commons Integration Test')
// Open Add a file form // Open Add a file form
@ -76,4 +76,72 @@ context('Publish', () => {
) )
}) })
}) })
it('should publish ipfs:// file', () => {
// Fill title
cy.get('input#name').type('Commons Integration IPFS Test')
// Open Add a file form
cy.get('button')
.contains('+ From URL')
.click()
// Fill url of file
cy.get('input#url').type(
'ipfs://QmX5LRpEVocfks9FNDnRoK2imf2fy9mPpP4wfgaDVXWfYD/video.mp4'
)
// 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: 12000
}).should('be.visible')
// Store DID
cy.get('a')
.contains('See published asset')
.invoke('attr', 'href')
.then(href => {
cy.writeFile(
'cypress/fixtures/did-ipfs.txt',
href.replace('/asset/', '')
)
})
})
}) })

View File

@ -1,12 +1,12 @@
/// <reference types="Cypress" /> /// <reference types="Cypress" />
context('Search', () => { describe('Search', () => {
before(() => { before(() => {
cy.visit('/') cy.visit('/')
// Wait for end of loading // Wait for end of loading
cy.get('button', { timeout: 60000 }).should('have.length', 1) cy.get('button', { timeout: 60000 }).should('have.length', 1)
}) })
it('Search for assets from homepage', () => { it('should search for assets from homepage', () => {
// Fill search phrase // Fill search phrase
cy.get('input#search').type('Title test') cy.get('input#search').type('Title test')
// Start search // Start search

View File

@ -1,6 +1,6 @@
/// <reference types="Cypress" /> /// <reference types="Cypress" />
context('Consume', () => { describe('Consume', () => {
before(() => { beforeEach(() => {
cy.fixture('did').then(did => { cy.fixture('did').then(did => {
cy.visit(`/asset/${did}`) cy.visit(`/asset/${did}`)
}) })
@ -15,7 +15,38 @@ context('Consume', () => {
cy.get('button[name="Download"]').should('not.be.disabled') cy.get('button[name="Download"]').should('not.be.disabled')
}) })
it('Consume asset and check if there is no error', () => { it('should consume https:// file', () => {
// eslint-disable-next-line
cy.wait(10000)
// Wait for faucet
// Click consume button
cy.get('button[name="Download"]').click()
// Wait consume process to end
cy.get('button[name="Download"]', { timeout: 600000 }).should(
'contain',
'Get file'
)
// check if there is no error
cy.get('article>div').should(
'not.contain',
'. Sorry about that, can you try again?'
)
// eslint-disable-next-line
cy.wait(10000)
// wait for file to download before closing browser
// to prevent alert poping up
})
it('should consume ipfs:// file', () => {
cy.fixture('did-ipfs').then(did => {
cy.visit(`/asset/${did}`)
})
// Alias button selector & wait for end of loading
cy.get('button[name="Download"]', { timeout: 60000 })
.first()
.should('have.length', 1)
// eslint-disable-next-line // eslint-disable-next-line
cy.wait(10000) cy.wait(10000)
// Wait for faucet // Wait for faucet

View File

@ -1,5 +1,5 @@
/// <reference types="Cypress" /> /// <reference types="Cypress" />
context('Faucet', () => { describe('Faucet', () => {
before(() => { before(() => {
cy.visit('/faucet') cy.visit('/faucet')
// Wait for end of loading // Wait for end of loading
@ -21,7 +21,7 @@ context('Faucet', () => {
.should('not.be.disabled') .should('not.be.disabled')
}) })
it('Execute faucet call', () => { it('should execute faucet call', () => {
// Execute call // Execute call
cy.get('@button') cy.get('@button')
.contains('Request ETH') .contains('Request ETH')