Open filippsen opened 6 years ago
This reference aims to: a. Demonstrate what a working test example using Web3 would look like; b. Analyze what would be the required dependencies for running it; c. Analyze what would be the inputs necessary to enable testing arbitrary contracts.
This leads to extensive and verbose code (read: explicit and raw). The testing code could be further compressed into a simpler API, focused on providing shortcuts to the most commonly used operations.
The example test reference is based on the HelloWorld.sol
contract from Hello World project template.
Note: some details were suppressed for readability.
describe('User test action: manually check contract data', function (done) {
var contractInstance;
beforeEach(function (done) {
const contractBin = "0x6060...";
const contractABI = instance.abi;
web3.eth.getTransactionCount(account_address, function(error, result) {
[...]
const tx = new Tx[...]
web3.eth.sendRawTransaction("0x"+tx.serialize().toString("hex"),
[...]
getTransactionReceipt(currentContractTransactionHash, function(err, res) {
[...]
var contract = web3.eth.contract(contractABI);
contractInstance = contract.at(res.contractAddress);
done();
});
});
});
});
it('matches message data', function (done) {
var expectedValue = "Hello World!";
contractInstance.message(function(error, result) {
if(error) {
console.error(error);
done(error);
} else {
if(result !== expectedValue) {
done(new Error(result));
} else {
done();
}
}
});
});
it('update message data', function (done) {
[...]
web3.eth.getTransactionCount(account_address, function(error, result) {
if(error) {
done(new Error("Could not get nonce for address " + account_address));
} else {
account_nonce=result;
var data = ABI.ABI.simpleEncode("update(string)", "Super Hello World!");
[...]
const tx = new Tx[...]
web3.eth.sendRawTransaction("0x"+tx.serialize().toString("hex"),
function(error, result) {
if(error) {
console.error(error);
done(error);
} else {
contractInstance.message(function(error, result) {
var expectedValue = "Super Hello World!";
if(error) {
console.error(error);
done(error);
} else {
if(result !== expectedValue) {
done(new Error(result));
} else {
[...]
done();
}
}
});
}
}
);
}
});
});
});
592e5813
("dynamic result data is now rendering")Get a working demonstration against the hardcoded reference contract and tests with all the UI elements in presentable state, according to the original design.
[x] F01. It looks like the "selection" functionality is expected to be a single choice (not multiple choices). The reason for that is because it serves for inspecting the output and repeating a single test, for instance. (Original item: "Ability to select a specific test").
[x] F02. The list of tests begins pre-filled with data. It should be empty at the start. Also, consider a reset mechanism in code. @filippsen
[x] F03. The contract being tested and the list of tests are not being built based on the test results. It should be read from the test output instead i.e. there is no FundRaise in the included example. (Original items: "Scrollable and collapsable list of all available tests files", "Scrollable and collapsable list of all test blocks described in each test file" and "Informs about time taken to complete each test").
[ ] F04. It's likely to be expected that the action buttons are always visible and accessible. Consider detaching the buttons from the list of tests (they already are separated into two "columns", after all). The way it is now they scroll together with the set of items.
More information: the Tests panel is divided into two main elements: left and right. The left side should be further split up into 3 sections: left column with buttons; top Done counter; main list of tests. Example:
<vertical=false split>
<div with TestControls>
<div with vertical=true>
<div with Done counter>
<div with list of tests>
...
[x] F05. When moving the cursor over the "down arrow", for expanding/collapsing the items, the cursor doesn't change (inconsistency across different clickable actions. Please observe the left side menu - Files hierarchy for reference).
[x] F06. Console output reads "NOTE - Console output from this specific test" on success. Consider a clear success message instead (to be defined later). (Original item: "Outputs selected test details") @filippsen
[ ] F07. Listed items text overlap with the time taken information when resizing the test list (to the left, decreasing the width)
More information: It is possible to set the text-overflow
attribute to testResults
in src/components/projecteditor/style.less
. However, the dynamic width must be considered.
[x] F08. Consider setting a minimum width to the list of items. As it is now, it is possible to lose access to the resize action (gets hidden behind another element when resizing all the way to the left). Please observe the Files hierarchy and take it as a reference guideline (for consistency).
[x] F09. Consider a maximum width for the list of items container.
[x] F10. It is possible to scroll down the Tests panel, hiding the black "title" bar. Consider setting the black bar to always be visible for clarity (title makes the context clear) and accessibility (the "X" close button is visible). It is unclear why there is a scroll bar there to begin. Previous feedback from Javier reads: "There is a scrollbar for the entire pane. That should not be the case as the pane itself should not be scrollable but only the container within".
[x] F11. The current test "selection" (choice) should be passed on as argument to the runSingle call. That would repeat the last set of tests only running the current selection. There is an in-code comment hinting for that. @filippsen
[x] F12. The "selection" color depends on the test state i.e. green on success (not red). (Original item: " Informs about success or failure of each test - colored selection rectangle") @filippsen
[x] F13. Test Summary text should be set bold (or a different font, which is hard to tell without seeing the design details. Please refer to the original design material).
[ ] F14. When toggling the Tests panel the editor still flickers. Experiment toggling the Tests panel while other windows are open. There is apparently a "redraw all" action happening.
More information: in panes.js
, the div
with key set topanes2
changes position, depending whether the Tests panel is open or not. There is an in-code comment about that, which helps confirming the issue:
{/*remove this condition and add proper state management for handling closing the pane.*/}
[ ] F15. Reiterating the situation that happens when multiple windows open behind the Tests panel: with the Tests panel open, clicking the Deploy button results in a weird situation (multiple scroll bars. Easy to lose track where things are or went to). This behavior differs from Transactions History, which adapts to everything.
[x] F16. When resizing the browser window, the list of tests container apparently does not redraw correctly (or at all ?). This results in artifacts on the final "image" (dark colored / blurred portion of the screen. Only in Tests panel). Reproducible by opening up the browser console output, moving it to the bottom of the screen and resizing it up and down. Update: unable to reproduce in both Chrome or Firefox.
[x] F17. Reminder: please consider more appropriate naming for data. References to person and persons are still around.
[x] F18. Selecting the text on the list of tests panel and dragging the selection to the right side, scrolls the contents horizontally.
[x] F19. Unstyled panel scrollbar in Firefox More information: it matches other scroll bars. Filed a separate issue: https://github.com/SuperblocksHQ/superblocks-lab/issues/265
[ ] F20. Unaligned milliseconds text when resizing list of tests More information: the test item element does not cover the maximum possible width.
[x] F21. Unimplemented grand total time spent
master-testing
("merge to post-refactoring code base")Unassigning as requested.
Summary
Add support for providing tests to be run against currently selected project.
Motivation
Additional context
Tasks
Test Runner
To enable inspecting all the tests written for the currently open project.
[x] New tests directory
In progress inrefactoring
branch and https://github.com/SuperblocksHQ/superblocks-lab/issues/166master
(version 1.1.0) intofeature/testing-GUI
. New branch created:feature/master-testing
[x] New Tests button
[x] New Tests panel
[x] GUI
[x] A panel, not a window
[x] Contains "X" close button
[x] Contains a "control bar"
[x] Contains the tests list
[x] Contains a "Test Summary" bar
[x] Contains a "Console Output"
[x] Complete interaction with any test file from
/tests/
[x] Solidify low-level test run calls (Security ? Correctness ? Speed ?)
[ ] Fix all that is marked as
TODO
[ ] Resolve all
FIXME
occurrences[x] Properly format the new code added during the early stages (legacy)