Skip to content
This repository has been archived by the owner on Aug 2, 2022. It is now read-only.

Commit

Permalink
Merge pull request #986 from bradlhart/cicd_integration_tests_develop
Browse files Browse the repository at this point in the history
Separates the web tests to separate tests and adds conditionals
  • Loading branch information
Brad Hart authored Jul 8, 2021
2 parents 9c8d70d + 368f4ff commit ca26f30
Show file tree
Hide file tree
Showing 5 changed files with 175 additions and 32 deletions.
156 changes: 144 additions & 12 deletions cypress/integration/index.spec.js
Original file line number Diff line number Diff line change
@@ -1,13 +1,145 @@
import { skipOn } from '@cypress/skip-test';

describe('eosjs web test', () => {
it('loads', () => {
cy.visit(('./src/tests/web.html'));
});
it('runs all tests successfully', () => {
cy.visit(('./src/tests/web.html'))
cy.get('div.tests>div>button').each((test) => { // iterate through all the tests
cy.wrap(test).click(); // click the button to start the test
cy.wrap(test).contains('Success', { timeout: 5000 }); // wait 5 seconds for success or treat as failure
cy.wait(500); // allow time for transaction to confirm (prevents duplicate transactions)
});
});
})
it('loads', () => {
cy.visit(('./src/tests/web.html'));
});

it('test Transact With Config Blocks Behind', () => {
cy.visit(('./src/tests/web.html'));
cy.wait(500);
cy.get('#testTransactWithConfigBlocksBehind').click();
cy.get('#testTransactWithConfigBlocksBehind').contains('Success', { timeout: 5000 });
});

it('test Transact With Config Use Last Irreversible', () => {
cy.visit(('./src/tests/web.html'));
cy.wait(500);
cy.get('#testTransactWithConfigUseLastIrreversible').click();
cy.get('#testTransactWithConfigUseLastIrreversible').contains('Success', { timeout: 5000 });
});

it('test Transact Without Config', () => {
if (Cypress.env('NODEOS_VER')) skipOn(Cypress.env('NODEOS_VER') === 'release/2.0.x');
cy.visit(('./src/tests/web.html'));
cy.wait(500);
cy.get('#testTransactWithoutConfig').click();
cy.get('#testTransactWithoutConfig').contains('Success', { timeout: 5000 });
});

it('test Transact With Compression', () => {
cy.visit(('./src/tests/web.html'));
cy.wait(500);
cy.get('#testTransactWithCompression').click();
cy.get('#testTransactWithCompression').contains('Success', { timeout: 5000 });
});

it('test Transact With Context Free Action', () => {
cy.visit(('./src/tests/web.html'));
cy.wait(500);
cy.get('#testTransactWithContextFreeAction').click();
cy.get('#testTransactWithContextFreeAction').contains('Success', { timeout: 5000 });
});

it('test Transact With Context Free Data', () => {
cy.visit(('./src/tests/web.html'));
cy.wait(500);
cy.get('#testTransactWithContextFreeData').click();
cy.get('#testTransactWithContextFreeData').contains('Success', { timeout: 5000 });
});

it('test Transact Without Broadcast', () => {
cy.visit(('./src/tests/web.html'));
cy.wait(500);
cy.get('#testTransactWithoutBroadcast').click();
cy.get('#testTransactWithoutBroadcast').contains('Success', { timeout: 5000 });
});

it('test Broadcast Result', () => {
cy.visit(('./src/tests/web.html'));
cy.wait(500);
cy.get('#testBroadcastResult').click();
cy.get('#testBroadcastResult').contains('Success', { timeout: 5000 });
});

it('test Shorthand With Api Json', () => {
cy.visit(('./src/tests/web.html'));
cy.wait(500);
cy.get('#testShorthandWithApiJson').click();
cy.get('#testShorthandWithApiJson').contains('Success', { timeout: 5000 });
});

it('test Shorthand With Tx Json', () => {
cy.visit(('./src/tests/web.html'));
cy.wait(500);
cy.get('#testShorthandWithTxJson').click();
cy.get('#testShorthandWithTxJson').contains('Success', { timeout: 5000 });
});

it('test Shorthand With Tx Json Context Free Action', () => {
cy.visit(('./src/tests/web.html'));
cy.wait(500);
cy.get('#testShorthandWithTxJsonContextFreeAction').click();
cy.get('#testShorthandWithTxJsonContextFreeAction').contains('Success', { timeout: 5000 });
});

it('test Shorthand With Tx Json Context Free Data', () => {
cy.visit(('./src/tests/web.html'));
cy.wait(500);
cy.get('#testShorthandWithTxJsonContextFreeData').click();
cy.get('#testShorthandWithTxJsonContextFreeData').contains('Success', { timeout: 5000 });
});

it('test With P256 Elliptic Curve', () => {
cy.visit(('./src/tests/web.html'));
cy.wait(500);
cy.get('#testWithP256EllipticCurve').click();
cy.get('#testWithP256EllipticCurve').contains('Success', { timeout: 5000 });
});

it('test With Return Value Tx', () => {
if (Cypress.env('NODEOS_VER')) skipOn(Cypress.env('NODEOS_VER') === 'release/2.0.x');
cy.visit(('./src/tests/web.html'));
cy.wait(500);
cy.get('#testWithReturnValueTx').click();
cy.get('#testWithReturnValueTx').contains('Success', { timeout: 5000 });
});

it('test With Resource Payer Tx', () => {
if (Cypress.env('NODEOS_VER')) skipOn(Cypress.env('NODEOS_VER') === 'release/2.0.x' || Cypress.env('NODEOS_VER') === 'release/2.1.x');
cy.visit(('./src/tests/web.html'));
cy.wait(500);
cy.get('#testWithResourcePayerTx').click();
cy.get('#testWithResourcePayerTx').contains('Success', { timeout: 5000 });
});

it('test With Read Only Query', () => {
if (Cypress.env('NODEOS_VER')) skipOn(Cypress.env('NODEOS_VER') === 'release/2.0.x' || Cypress.env('NODEOS_VER') === 'release/2.1.x');
cy.visit(('./src/tests/web.html'));
cy.wait(500);
cy.get('#testWithReadOnlyQuery').click();
cy.get('#testWithReadOnlyQuery').contains('Success', { timeout: 5000 });
});

it('test With Read Only Failure Trace', () => {
if (Cypress.env('NODEOS_VER')) skipOn(Cypress.env('NODEOS_VER') === 'release/2.0.x' || Cypress.env('NODEOS_VER') === 'release/2.1.x');
cy.visit(('./src/tests/web.html'));
cy.wait(500);
cy.get('#testWithReadOnlyFailureTrace').click();
cy.get('#testWithReadOnlyFailureTrace').contains('Success', { timeout: 5000 });
});

it('test Transact Should Fail', () => {
cy.visit(('./src/tests/web.html'));
cy.wait(500);
cy.get('#testTransactShouldFail').click();
cy.get('#testTransactShouldFail').contains('Success', { timeout: 5000 });
});

it('test Rpc Should Fail', () => {
cy.visit(('./src/tests/web.html'));
cy.wait(500);
cy.get('#testRpcShouldFail').click();
cy.get('#testRpcShouldFail').contains('Success', { timeout: 5000 });
});
});
1 change: 1 addition & 0 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,7 @@
},
"devDependencies": {
"@blockone/eslint-config-blockone": "^4.0.1",
"@cypress/skip-test": "^2.6.1",
"@types/elliptic": "^6.4.12",
"@types/jest": "^26.0.23",
"@types/node": "^14.17.4",
Expand Down
5 changes: 5 additions & 0 deletions src/tests/node.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ describe('Node JS environment', () => {
});

it('transacts with manually configured TAPOS fields', async () => {
if (process.env.NODEOS_VER && process.env.NODEOS_VER === 'release/2.0.x') return;
transactionResponse = await tests.transactWithoutConfig();
expect(Object.keys(transactionResponse)).toContain('transaction_id');
}, 10000);
Expand Down Expand Up @@ -96,17 +97,20 @@ describe('Node JS environment', () => {
});

it('confirms an action\'s return value can be verified', async () => {
if (process.env.NODEOS_VER && process.env.NODEOS_VER === 'release/2.0.x') return;
const expectedValue = 10;
transactionResponse = await tests.transactWithReturnValue();
expect(transactionResponse.processed.action_traces[0].return_value_data).toEqual(expectedValue);
});

it('transacts with resource payer', async () => {
if (process.env.NODEOS_VER && (process.env.NODEOS_VER === 'release/2.0.x' || process.env.NODEOS_VER === 'release/2.1.x')) return;
transactionResponse = await tests.transactWithResourcePayer();
expect(Object.keys(transactionResponse)).toContain('transaction_id');
});

it('confirms the return value of the read-only query', async () => {
if (process.env.NODEOS_VER && (process.env.NODEOS_VER === 'release/2.0.x' || process.env.NODEOS_VER === 'release/2.1.x')) return;
const expectedValue = [
{'age': 25, 'gender': 1, 'id': 1, 'name': 'Bob Smith'},
{'age': 42, 'gender': 1, 'id': 3, 'name': 'John Smith'},
Expand All @@ -122,6 +126,7 @@ describe('Node JS environment', () => {
});

it('returns failure trace for failed transaction', async () => {
if (process.env.NODEOS_VER && (process.env.NODEOS_VER === 'release/2.0.x' || process.env.NODEOS_VER === 'release/2.1.x')) return;
try {
await tests.readOnlyFailureTrace();
} catch (e) {
Expand Down
40 changes: 20 additions & 20 deletions src/tests/web.html
Original file line number Diff line number Diff line change
Expand Up @@ -608,7 +608,7 @@
let err;
resultsLabel = e.target;
resultsLabel.innerText = EXECUTING;

try {
await readOnlyFailureTrace();
} catch (err) {
Expand Down Expand Up @@ -698,25 +698,25 @@ <h1>Web Build Integration Tests</h1>
</div>
</div>
<div class='tests'>
<div><h2>Transact with blocksBehind Configuration Parameter</h2><button onClick='testTransactWithConfigBlocksBehind(event);'>Test</button></div>
<div><h2>Transact with useLastIrreversible Configuration Parameter</h2><button onClick='testTransactWithConfigUseLastIrreversible(event);'>Test</button></div>
<div><h2>Transact with Manually Configured TAPOS</h2><button onClick='testTransactWithoutConfig(event);'>Test</button></div>
<div><h2>Transact with Compression</h2><button onClick='testTransactWithCompression(event);'>Test</button></div>
<div><h2>Transact with Context Free Action</h2><button onClick='testTransactWithContextFreeAction(event);'>Test</button></div>
<div><h2>Transact with Context Free Data</h2><button onClick='testTransactWithContextFreeData(event);'>Test</button></div>
<div><h2>Transact without Broadcasting</h2><button onClick='testTransactWithoutBroadcast(event);'>Test</button></div>
<div><h2>Broadcast Transaction</h2><button onClick='testBroadcastResult(event);'>Test</button></div>
<div><h2>Transact with .with() Using Api and Json Abi</h2><button onClick='testShorthandWithApiJson(event);'>Test</button></div>
<div><h2>Transact with .with() Using Tx and Json Abi</h2><button onClick='testShorthandWithTxJson(event);'>Test</button></div>
<div><h2>Transact with .with() Using Tx and Json Abi with Context Free Action</h2><button onClick='testShorthandWithTxJsonContextFreeAction(event);'>Test</button></div>
<div><h2>Transact with .with() Using Tx and Json Abi with Context Free Data</h2><button onClick='testShorthandWithTxJsonContextFreeData(event);'>Test</button></div>
<div><h2>Transact elliptic p256/KeyType.r1 Keys and Signatures</h2><button onClick='testWithP256EllipticCurve(event);'>Test</button></div>
<div><h2>Transact Return Values</h2><button onClick='testWithReturnValueTx(event);'>Test</button></div>
<div><h2>Resource Payer</h2><button onClick='testWithResourcePayerTx(event);'>Test</button></div>
<div><h2>Read Only Query</h2><button onClick='testWithReadOnlyQuery(event);'>Test</button></div>
<div><h2>Read Only Failure Trace</h2><button onClick='testWithReadOnlyFailureTrace(event);'>Test</button></div>
<div><h2>Invalid Transaction Throws Error</h2><button onClick='testTransactShouldFail(event);'>Test</button></div>
<div><h2>Invalid Rpc Call Throws Rpc Error</h2><button onClick='testRpcShouldFail(event);'>Test</button></div>
<div><h2>Transact with blocksBehind Configuration Parameter</h2><button id='testTransactWithConfigBlocksBehind' onClick='testTransactWithConfigBlocksBehind(event);'>Test</button></div>
<div><h2>Transact with useLastIrreversible Configuration Parameter</h2><button id='testTransactWithConfigUseLastIrreversible' onClick='testTransactWithConfigUseLastIrreversible(event);'>Test</button></div>
<div><h2>Transact with Manually Configured TAPOS</h2><button id='testTransactWithoutConfig' onClick='testTransactWithoutConfig(event);'>Test</button></div>
<div><h2>Transact with Compression</h2><button id='testTransactWithCompression' onClick='testTransactWithCompression(event);'>Test</button></div>
<div><h2>Transact with Context Free Action</h2><button id='testTransactWithContextFreeAction' onClick='testTransactWithContextFreeAction(event);'>Test</button></div>
<div><h2>Transact with Context Free Data</h2><button id='testTransactWithContextFreeData' onClick='testTransactWithContextFreeData(event);'>Test</button></div>
<div><h2>Transact without Broadcasting</h2><button id='testTransactWithoutBroadcast' onClick='testTransactWithoutBroadcast(event);'>Test</button></div>
<div><h2>Broadcast Transaction</h2><button id='testBroadcastResult' onClick='testBroadcastResult(event);'>Test</button></div>
<div><h2>Transact with .with() Using Api and Json Abi</h2><button id='testShorthandWithApiJson' onClick='testShorthandWithApiJson(event);'>Test</button></div>
<div><h2>Transact with .with() Using Tx and Json Abi</h2><button id='testShorthandWithTxJson' onClick='testShorthandWithTxJson(event);'>Test</button></div>
<div><h2>Transact with .with() Using Tx and Json Abi with Context Free Action</h2><button id='testShorthandWithTxJsonContextFreeAction' onClick='testShorthandWithTxJsonContextFreeAction(event);'>Test</button></div>
<div><h2>Transact with .with() Using Tx and Json Abi with Context Free Data</h2><button id='testShorthandWithTxJsonContextFreeData' onClick='testShorthandWithTxJsonContextFreeData(event);'>Test</button></div>
<div><h2>Transact elliptic p256/KeyType.r1 Keys and Signatures</h2><button id='testWithP256EllipticCurve' onClick='testWithP256EllipticCurve(event);'>Test</button></div>
<div><h2>Transact Return Values</h2><button id='testWithReturnValueTx' onClick='testWithReturnValueTx(event);'>Test</button></div>
<div><h2>Resource Payer</h2><button id='testWithResourcePayerTx' onClick='testWithResourcePayerTx(event);'>Test</button></div>
<div><h2>Read Only Query</h2><button id='testWithReadOnlyQuery' onClick='testWithReadOnlyQuery(event);'>Test</button></div>
<div><h2>Read Only Failure Trace</h2><button id='testWithReadOnlyFailureTrace' onClick='testWithReadOnlyFailureTrace(event);'>Test</button></div>
<div><h2>Invalid Transaction Throws Error</h2><button id='testTransactShouldFail' onClick='testTransactShouldFail(event);'>Test</button></div>
<div><h2>Invalid Rpc Call Throws Rpc Error</h2><button id='testRpcShouldFail' onClick='testRpcShouldFail(event);'>Test</button></div>
</div>
</body>
</html>
5 changes: 5 additions & 0 deletions yarn.lock
Original file line number Diff line number Diff line change
Expand Up @@ -365,6 +365,11 @@
tunnel-agent "^0.6.0"
uuid "^3.3.2"

"@cypress/skip-test@^2.6.1":
version "2.6.1"
resolved "https://registry.yarnpkg.com/@cypress/skip-test/-/skip-test-2.6.1.tgz#44a4bc4c2b2e369a7661177c9b38e50d417a36ea"
integrity sha512-X+ibefBiuOmC5gKG91wRIT0/OqXeETYvu7zXktjZ3yLeO186Y8ia0K7/gQUpAwuUi28DuqMd1+7tBQVtPkzbPA==

"@cypress/xvfb@^1.2.4":
version "1.2.4"
resolved "https://registry.yarnpkg.com/@cypress/xvfb/-/xvfb-1.2.4.tgz#2daf42e8275b39f4aa53c14214e557bd14e7748a"
Expand Down

0 comments on commit ca26f30

Please sign in to comment.