diff --git a/.eslintrc b/.eslintrc index ad742b6..6087027 100644 --- a/.eslintrc +++ b/.eslintrc @@ -10,9 +10,10 @@ "prettier/standard", "plugin:prettier/recommended", "plugin:@typescript-eslint/recommended", - "prettier/@typescript-eslint" + "prettier/@typescript-eslint", + "plugin:cypress/recommended" ], - "plugins": ["@typescript-eslint", "prettier"], + "plugins": ["@typescript-eslint", "prettier", "cypress"], "rules": { "@typescript-eslint/explicit-function-return-type": 0, "@typescript-eslint/member-delimiter-style": [ @@ -23,6 +24,7 @@ "env": { "es6": true, "browser": true, - "jest": true + "jest": true, + "cypress/globals": true } } diff --git a/cypress/fixtures/asset.duero.json b/cypress/fixtures/asset.duero.json new file mode 100644 index 0000000..dca543d --- /dev/null +++ b/cypress/fixtures/asset.duero.json @@ -0,0 +1,190 @@ +{ + "@context": "https://w3id.org/did/v1", + "id": "did:op:52f2ed716f97463e97beeb414195a075b606675874204e3da39b0c237377dbd3", + "publicKey": [ + { + "id": "did:op:52f2ed716f97463e97beeb414195a075b606675874204e3da39b0c237377dbd3", + "type": "EthereumECDSAKey", + "owner": "0x5e3264A651303b93A3a3BC5eaB5c8676f5C3D7b1" + } + ], + "authentication": [ + { + "type": "RsaSignatureAuthentication2018", + "publicKey": "did:op:52f2ed716f97463e97beeb414195a075b606675874204e3da39b0c237377dbd3" + } + ], + "service": [ + { + "type": "Access", + "creator": "", + "purchaseEndpoint": "https://brizo.duero.dev-ocean.com:443/api/v1/brizo/services/access/initialize", + "serviceEndpoint": "https://brizo.duero.dev-ocean.com:443/api/v1/brizo/services/consume", + "name": "dataAssetAccessServiceAgreement", + "templateId": "0xfA16d26e9F4fffC6e40963B281a0bB08C31ed40C", + "serviceAgreementTemplate": { + "contractName": "EscrowAccessSecretStoreTemplate", + "events": [ + { + "name": "AgreementCreated", + "actorType": "consumer", + "handler": { + "moduleName": "escrowAccessSecretStoreTemplate", + "functionName": "fulfillLockRewardCondition", + "version": "0.1" + } + } + ], + "fulfillmentOrder": [ + "lockReward.fulfill", + "accessSecretStore.fulfill", + "escrowReward.fulfill" + ], + "conditionDependency": { + "lockReward": [], + "accessSecretStore": [], + "escrowReward": ["lockReward", "accessSecretStore"] + }, + "conditions": [ + { + "name": "lockReward", + "timelock": 0, + "timeout": 0, + "contractName": "LockRewardCondition", + "functionName": "fulfill", + "parameters": [ + { + "name": "_rewardAddress", + "type": "address", + "value": "0x5e3264A651303b93A3a3BC5eaB5c8676f5C3D7b1" + }, + { "name": "_amount", "type": "uint256", "value": 0 } + ], + "events": [ + { + "name": "Fulfilled", + "actorType": "publisher", + "handler": { + "moduleName": "lockRewardCondition", + "functionName": "fulfillAccessSecretStoreCondition", + "version": "0.1" + } + } + ] + }, + { + "name": "accessSecretStore", + "timelock": 0, + "timeout": 0, + "contractName": "AccessSecretStoreCondition", + "functionName": "fulfill", + "parameters": [ + { + "name": "_documentId", + "type": "bytes32", + "value": "52f2ed716f97463e97beeb414195a075b606675874204e3da39b0c237377dbd3" + }, + { "name": "_grantee", "type": "address", "value": "" } + ], + "events": [ + { + "name": "Fulfilled", + "actorType": "publisher", + "handler": { + "moduleName": "accessSecretStore", + "functionName": "fulfillEscrowRewardCondition", + "version": "0.1" + } + }, + { + "name": "TimedOut", + "actorType": "consumer", + "handler": { + "moduleName": "accessSecretStore", + "functionName": "fulfillEscrowRewardCondition", + "version": "0.1" + } + } + ] + }, + { + "name": "escrowReward", + "timelock": 0, + "timeout": 0, + "contractName": "EscrowReward", + "functionName": "fulfill", + "parameters": [ + { "name": "_amount", "type": "uint256", "value": 0 }, + { "name": "_receiver", "type": "address", "value": "" }, + { "name": "_sender", "type": "address", "value": "" }, + { "name": "_lockCondition", "type": "bytes32", "value": "" }, + { "name": "_releaseCondition", "type": "bytes32", "value": "" } + ], + "events": [ + { + "name": "Fulfilled", + "actorType": "publisher", + "handler": { + "moduleName": "escrowRewardCondition", + "functionName": "verifyRewardTokens", + "version": "0.1" + } + } + ] + } + ] + }, + "serviceDefinitionId": "0" + }, + { + "type": "Authorization", + "service": "SecretStore", + "serviceEndpoint": "https://secret-store.duero.dev-ocean.com:443", + "serviceDefinitionId": "1" + }, + { + "type": "Metadata", + "serviceEndpoint": "https://aquarius.duero.dev-ocean.com:443/api/v1/aquarius/assets/ddo/did:op:52f2ed716f97463e97beeb414195a075b606675874204e3da39b0c237377dbd3", + "metadata": { + "curation": { "rating": 0.0, "numVotes": 0, "isListed": true }, + "base": { + "name": "Technical Whitepaper", + "description": "This paper presents Ocean Protocol. Ocean is a decentralized protocol and network of artificial intelligence (AI) data/services. \n\nOcean does decentralized orchestration: at its core are decentralized service agreements and decentralized access control, which execute on decentralized virtual machines. This allows connection to, monetization of, and curation of arbitrary data services. On that, Ocean adds network rewards to incentivize data sharing, including privacy-preserving data commons.", + "dateCreated": "2019-05-10T11:55:58.492Z", + "author": "Ocean Protocol", + "type": "dataset", + "license": "Public Domain", + "copyrightHolder": "Ocean Protocol Foundation Ltd.", + "files": [ + { + "found": true, + "contentLength": "2989228", + "contentType": "application/pdf", + "compression": "none", + "index": 0 + } + ], + "categories": ["Engineering"], + "links": [], + "tags": "", + "price": 0, + "encryptedFiles": "0x95116a697eadb4b5058682749f587321cb918ec6239a193a7e1e3587d7de28e761e8819e2241e9375b035eacc3dcec4799e0da4cd52552ab583082366ff4e0fb1f72a63ae071206859cfc53abdea2135c660cfba1e81361efce10bfcec323d63b0dcf009dd2c48dfcde09c95dcf69d6c6a318e869ac26b7dc0fcb085e1421b394aaf4d4fac05e992c13a225c5c1e138a7fb27185ba5e1709760ecd43e89eafef435ad97ffb", + "checksum": "9b624a8f9cd7f9d1127c818f32453f43dc6c633472a682bb880d69093b4b9615", + "datePublished": "2019-05-10T14:40:01Z" + }, + "additionalInformation": { + "updateFrequency": null, + "structuredMarkup": [] + } + }, + "serviceDefinitionId": "2" + } + ], + "created": "2019-05-10T14:39:53Z", + "proof": { + "created": "2019-05-10T14:39:55Z", + "creator": "0x5e3264A651303b93A3a3BC5eaB5c8676f5C3D7b1", + "type": "DDOIntegritySignature", + "signatureValue": "0x94c3042facdb0601cb5c90264b1e8d1ae6902043af4303c57869d2881748621b03d943f4bb2ccd5d18429964f4ebc425d77baffc576884cfd78ae0987082c5931b" + } +} diff --git a/cypress/fixtures/example.json b/cypress/fixtures/example.json deleted file mode 100644 index da18d93..0000000 --- a/cypress/fixtures/example.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "name": "Using fixtures to represent data", - "email": "hello@cypress.io", - "body": "Fixtures are a great way to mock data for responses to routes" -} \ No newline at end of file diff --git a/cypress/fixtures/profile.json b/cypress/fixtures/profile.json deleted file mode 100644 index b6c355c..0000000 --- a/cypress/fixtures/profile.json +++ /dev/null @@ -1,5 +0,0 @@ -{ - "id": 8739, - "name": "Jane", - "email": "jane@example.com" -} \ No newline at end of file diff --git a/cypress/fixtures/users.json b/cypress/fixtures/users.json deleted file mode 100644 index 79b699a..0000000 --- a/cypress/fixtures/users.json +++ /dev/null @@ -1,232 +0,0 @@ -[ - { - "id": 1, - "name": "Leanne Graham", - "username": "Bret", - "email": "Sincere@april.biz", - "address": { - "street": "Kulas Light", - "suite": "Apt. 556", - "city": "Gwenborough", - "zipcode": "92998-3874", - "geo": { - "lat": "-37.3159", - "lng": "81.1496" - } - }, - "phone": "1-770-736-8031 x56442", - "website": "hildegard.org", - "company": { - "name": "Romaguera-Crona", - "catchPhrase": "Multi-layered client-server neural-net", - "bs": "harness real-time e-markets" - } - }, - { - "id": 2, - "name": "Ervin Howell", - "username": "Antonette", - "email": "Shanna@melissa.tv", - "address": { - "street": "Victor Plains", - "suite": "Suite 879", - "city": "Wisokyburgh", - "zipcode": "90566-7771", - "geo": { - "lat": "-43.9509", - "lng": "-34.4618" - } - }, - "phone": "010-692-6593 x09125", - "website": "anastasia.net", - "company": { - "name": "Deckow-Crist", - "catchPhrase": "Proactive didactic contingency", - "bs": "synergize scalable supply-chains" - } - }, - { - "id": 3, - "name": "Clementine Bauch", - "username": "Samantha", - "email": "Nathan@yesenia.net", - "address": { - "street": "Douglas Extension", - "suite": "Suite 847", - "city": "McKenziehaven", - "zipcode": "59590-4157", - "geo": { - "lat": "-68.6102", - "lng": "-47.0653" - } - }, - "phone": "1-463-123-4447", - "website": "ramiro.info", - "company": { - "name": "Romaguera-Jacobson", - "catchPhrase": "Face to face bifurcated interface", - "bs": "e-enable strategic applications" - } - }, - { - "id": 4, - "name": "Patricia Lebsack", - "username": "Karianne", - "email": "Julianne.OConner@kory.org", - "address": { - "street": "Hoeger Mall", - "suite": "Apt. 692", - "city": "South Elvis", - "zipcode": "53919-4257", - "geo": { - "lat": "29.4572", - "lng": "-164.2990" - } - }, - "phone": "493-170-9623 x156", - "website": "kale.biz", - "company": { - "name": "Robel-Corkery", - "catchPhrase": "Multi-tiered zero tolerance productivity", - "bs": "transition cutting-edge web services" - } - }, - { - "id": 5, - "name": "Chelsey Dietrich", - "username": "Kamren", - "email": "Lucio_Hettinger@annie.ca", - "address": { - "street": "Skiles Walks", - "suite": "Suite 351", - "city": "Roscoeview", - "zipcode": "33263", - "geo": { - "lat": "-31.8129", - "lng": "62.5342" - } - }, - "phone": "(254)954-1289", - "website": "demarco.info", - "company": { - "name": "Keebler LLC", - "catchPhrase": "User-centric fault-tolerant solution", - "bs": "revolutionize end-to-end systems" - } - }, - { - "id": 6, - "name": "Mrs. Dennis Schulist", - "username": "Leopoldo_Corkery", - "email": "Karley_Dach@jasper.info", - "address": { - "street": "Norberto Crossing", - "suite": "Apt. 950", - "city": "South Christy", - "zipcode": "23505-1337", - "geo": { - "lat": "-71.4197", - "lng": "71.7478" - } - }, - "phone": "1-477-935-8478 x6430", - "website": "ola.org", - "company": { - "name": "Considine-Lockman", - "catchPhrase": "Synchronised bottom-line interface", - "bs": "e-enable innovative applications" - } - }, - { - "id": 7, - "name": "Kurtis Weissnat", - "username": "Elwyn.Skiles", - "email": "Telly.Hoeger@billy.biz", - "address": { - "street": "Rex Trail", - "suite": "Suite 280", - "city": "Howemouth", - "zipcode": "58804-1099", - "geo": { - "lat": "24.8918", - "lng": "21.8984" - } - }, - "phone": "210.067.6132", - "website": "elvis.io", - "company": { - "name": "Johns Group", - "catchPhrase": "Configurable multimedia task-force", - "bs": "generate enterprise e-tailers" - } - }, - { - "id": 8, - "name": "Nicholas Runolfsdottir V", - "username": "Maxime_Nienow", - "email": "Sherwood@rosamond.me", - "address": { - "street": "Ellsworth Summit", - "suite": "Suite 729", - "city": "Aliyaview", - "zipcode": "45169", - "geo": { - "lat": "-14.3990", - "lng": "-120.7677" - } - }, - "phone": "586.493.6943 x140", - "website": "jacynthe.com", - "company": { - "name": "Abernathy Group", - "catchPhrase": "Implemented secondary concept", - "bs": "e-enable extensible e-tailers" - } - }, - { - "id": 9, - "name": "Glenna Reichert", - "username": "Delphine", - "email": "Chaim_McDermott@dana.io", - "address": { - "street": "Dayna Park", - "suite": "Suite 449", - "city": "Bartholomebury", - "zipcode": "76495-3109", - "geo": { - "lat": "24.6463", - "lng": "-168.8889" - } - }, - "phone": "(775)976-6794 x41206", - "website": "conrad.com", - "company": { - "name": "Yost and Sons", - "catchPhrase": "Switchable contextually-based project", - "bs": "aggregate real-time technologies" - } - }, - { - "id": 10, - "name": "Clementina DuBuque", - "username": "Moriah.Stanton", - "email": "Rey.Padberg@karina.biz", - "address": { - "street": "Kattie Turnpike", - "suite": "Suite 198", - "city": "Lebsackbury", - "zipcode": "31428-2261", - "geo": { - "lat": "-38.2386", - "lng": "57.2232" - } - }, - "phone": "024-648-3804", - "website": "ambrose.net", - "company": { - "name": "Hoeger LLC", - "catchPhrase": "Centralized empowering task-force", - "bs": "target end-to-end models" - } - } -] \ No newline at end of file diff --git a/cypress/integration/.gitkeep b/cypress/integration/.gitkeep new file mode 100644 index 0000000..e69de29 diff --git a/cypress/integration/examples/actions.spec.js b/cypress/integration/examples/actions.spec.js deleted file mode 100644 index ea2a857..0000000 --- a/cypress/integration/examples/actions.spec.js +++ /dev/null @@ -1,302 +0,0 @@ -/// - -context('Actions', () => { - beforeEach(() => { - cy.visit('https://example.cypress.io/commands/actions') - }) - - // https://on.cypress.io/interacting-with-elements - - it('.type() - type into a DOM element', () => { - // https://on.cypress.io/type - cy.get('.action-email') - .type('fake@email.com') - .should('have.value', 'fake@email.com') - - // .type() with special character sequences - .type('{leftarrow}{rightarrow}{uparrow}{downarrow}') - .type('{del}{selectall}{backspace}') - - // .type() with key modifiers - .type('{alt}{option}') //these are equivalent - .type('{ctrl}{control}') //these are equivalent - .type('{meta}{command}{cmd}') //these are equivalent - .type('{shift}') - - // Delay each keypress by 0.1 sec - .type('slow.typing@email.com', { delay: 100 }) - .should('have.value', 'slow.typing@email.com') - - cy.get('.action-disabled') - // Ignore error checking prior to type - // like whether the input is visible or disabled - .type('disabled error checking', { force: true }) - .should('have.value', 'disabled error checking') - }) - - it('.focus() - focus on a DOM element', () => { - // https://on.cypress.io/focus - cy.get('.action-focus') - .focus() - .should('have.class', 'focus') - .prev() - .should('have.attr', 'style', 'color: orange;') - }) - - it('.blur() - blur off a DOM element', () => { - // https://on.cypress.io/blur - cy.get('.action-blur') - .type('About to blur') - .blur() - .should('have.class', 'error') - .prev() - .should('have.attr', 'style', 'color: red;') - }) - - it('.clear() - clears an input or textarea element', () => { - // https://on.cypress.io/clear - cy.get('.action-clear') - .type('Clear this text') - .should('have.value', 'Clear this text') - .clear() - .should('have.value', '') - }) - - it('.submit() - submit a form', () => { - // https://on.cypress.io/submit - cy.get('.action-form') - .find('[type="text"]') - .type('HALFOFF') - cy.get('.action-form') - .submit() - .next() - .should('contain', 'Your form has been submitted!') - }) - - it('.click() - click on a DOM element', () => { - // https://on.cypress.io/click - cy.get('.action-btn').click() - - // You can click on 9 specific positions of an element: - // ----------------------------------- - // | topLeft top topRight | - // | | - // | | - // | | - // | left center right | - // | | - // | | - // | | - // | bottomLeft bottom bottomRight | - // ----------------------------------- - - // clicking in the center of the element is the default - cy.get('#action-canvas').click() - - cy.get('#action-canvas').click('topLeft') - cy.get('#action-canvas').click('top') - cy.get('#action-canvas').click('topRight') - cy.get('#action-canvas').click('left') - cy.get('#action-canvas').click('right') - cy.get('#action-canvas').click('bottomLeft') - cy.get('#action-canvas').click('bottom') - cy.get('#action-canvas').click('bottomRight') - - // .click() accepts an x and y coordinate - // that controls where the click occurs :) - - cy.get('#action-canvas') - .click(80, 75) // click 80px on x coord and 75px on y coord - .click(170, 75) - .click(80, 165) - .click(100, 185) - .click(125, 190) - .click(150, 185) - .click(170, 165) - - // click multiple elements by passing multiple: true - cy.get('.action-labels>.label').click({ multiple: true }) - - // Ignore error checking prior to clicking - cy.get('.action-opacity>.btn').click({ force: true }) - }) - - it('.dblclick() - double click on a DOM element', () => { - // https://on.cypress.io/dblclick - - // Our app has a listener on 'dblclick' event in our 'scripts.js' - // that hides the div and shows an input on double click - cy.get('.action-div') - .dblclick() - .should('not.be.visible') - cy.get('.action-input-hidden').should('be.visible') - }) - - it('.check() - check a checkbox or radio element', () => { - // https://on.cypress.io/check - - // By default, .check() will check all - // matching checkbox or radio elements in succession, one after another - cy.get('.action-checkboxes [type="checkbox"]') - .not('[disabled]') - .check() - .should('be.checked') - - cy.get('.action-radios [type="radio"]') - .not('[disabled]') - .check() - .should('be.checked') - - // .check() accepts a value argument - cy.get('.action-radios [type="radio"]') - .check('radio1') - .should('be.checked') - - // .check() accepts an array of values - cy.get('.action-multiple-checkboxes [type="checkbox"]') - .check(['checkbox1', 'checkbox2']) - .should('be.checked') - - // Ignore error checking prior to checking - cy.get('.action-checkboxes [disabled]') - .check({ force: true }) - .should('be.checked') - - cy.get('.action-radios [type="radio"]') - .check('radio3', { force: true }) - .should('be.checked') - }) - - it('.uncheck() - uncheck a checkbox element', () => { - // https://on.cypress.io/uncheck - - // By default, .uncheck() will uncheck all matching - // checkbox elements in succession, one after another - cy.get('.action-check [type="checkbox"]') - .not('[disabled]') - .uncheck() - .should('not.be.checked') - - // .uncheck() accepts a value argument - cy.get('.action-check [type="checkbox"]') - .check('checkbox1') - .uncheck('checkbox1') - .should('not.be.checked') - - // .uncheck() accepts an array of values - cy.get('.action-check [type="checkbox"]') - .check(['checkbox1', 'checkbox3']) - .uncheck(['checkbox1', 'checkbox3']) - .should('not.be.checked') - - // Ignore error checking prior to unchecking - cy.get('.action-check [disabled]') - .uncheck({ force: true }) - .should('not.be.checked') - }) - - it('.select() - select an option in a