@ -1,5 +1,5 @@
'use strict'
import { NightwatchBrowser } from 'nightwatch'
import { NightwatchBrowser } from 'nightwatch'
import init from '../helpers/init'
module .exports = {
@ -18,7 +18,9 @@ module.exports = {
. click ( 'select[id="wstemplate"]' )
. click ( 'select[id="wstemplate"] option[value=semaphore]' )
. waitForElementPresent ( '[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok' )
. execute ( function ( ) { ( document . querySelector ( '[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok' ) as HTMLElement ) . click ( ) } )
. execute ( function ( ) {
; ( document . querySelector ( '[data-id="fileSystemModalDialogModalFooter-react"] .modal-ok' ) as HTMLElement ) . click ( )
} )
. pause ( 100 )
. waitForElementVisible ( '*[data-id="treeViewLitreeViewItemcircuits"]' )
. waitForElementVisible ( '*[data-id="treeViewLitreeViewItemcircuits/semaphore.circom"]' )
@ -28,13 +30,7 @@ module.exports = {
. waitForElementVisible ( '*[data-id="treeViewLitreeViewItemtemplates/groth16_verifier.sol.ejs"]' )
} ,
'Should compile a simple circuit using editor play button #group1' : function ( browser : NightwatchBrowser ) {
browser
. click ( '[data-id="treeViewLitreeViewItemcircuits/simple.circom"]' )
. waitForElementPresent ( '[data-path="Semaphore - 1/circuits/simple.circom"]' )
. waitForElementVisible ( '[data-path="Semaphore - 1/circuits/simple.circom"]' )
. click ( '[data-id="play-editor"]' )
. waitForElementPresent ( '[data-id="treeViewLitreeViewItemcircuits/.bin/simple.wasm"]' )
. waitForElementVisible ( '[data-id="treeViewLitreeViewItemcircuits/.bin/simple.wasm"]' )
browser . click ( '[data-id="treeViewLitreeViewItemcircuits/simple.circom"]' ) . waitForElementPresent ( '[data-path="Semaphore - 1/circuits/simple.circom"]' ) . waitForElementVisible ( '[data-path="Semaphore - 1/circuits/simple.circom"]' ) . click ( '[data-id="play-editor"]' ) . waitForElementPresent ( '[data-id="treeViewLitreeViewItemcircuits/.bin/simple.wasm"]' ) . waitForElementVisible ( '[data-id="treeViewLitreeViewItemcircuits/.bin/simple.wasm"]' )
} ,
'Should compute a witness for a simple circuit #group1' : function ( browser : NightwatchBrowser ) {
browser
@ -69,16 +65,7 @@ module.exports = {
. waitForElementVisible ( '[data-id="treeViewLitreeViewItemcircuits/.bin/simple.wasm"]' )
} ,
'Should generate R1CS for a simple circuit #group2' : function ( browser : NightwatchBrowser ) {
browser
. clickLaunchIcon ( 'circuit-compiler' )
. frame ( 0 )
. waitForElementPresent ( 'button[data-id="generate_r1cs_btn"]' )
. waitForElementVisible ( 'button[data-id="generate_r1cs_btn"]' )
. click ( 'button[data-id="generate_r1cs_btn"]' )
. frameParent ( )
. clickLaunchIcon ( 'filePanel' )
. waitForElementPresent ( '[data-id="treeViewLitreeViewItemcircuits/.bin/simple.r1cs"]' )
. waitForElementVisible ( '[data-id="treeViewLitreeViewItemcircuits/.bin/simple.r1cs"]' )
browser . clickLaunchIcon ( 'circuit-compiler' ) . frame ( 0 ) . waitForElementPresent ( 'button[data-id="generate_r1cs_btn"]' ) . waitForElementVisible ( 'button[data-id="generate_r1cs_btn"]' ) . click ( 'button[data-id="generate_r1cs_btn"]' ) . frameParent ( ) . clickLaunchIcon ( 'filePanel' ) . waitForElementPresent ( '[data-id="treeViewLitreeViewItemcircuits/.bin/simple.r1cs"]' ) . waitForElementVisible ( '[data-id="treeViewLitreeViewItemcircuits/.bin/simple.r1cs"]' )
} ,
'Should compile a simple circuit using CTRL + S from the editor #group3' : function ( browser : NightwatchBrowser ) {
browser
@ -95,7 +82,10 @@ module.exports = {
} ,
'Should display warnings for compiled circuit without pragma version #group4' : function ( browser : NightwatchBrowser ) {
browser
. addFile ( 'circuits/warning.circom' , { content : warningCircuit } )
. captureBrowserConsoleLogs ( ( event ) = > {
console . log ( event . type , event . timestamp , event . args [ 0 ] . value )
} )
. addFile ( 'circuits/warning.circom' , { content : warningCircuit } )
. waitForElementPresent ( '[data-path="Semaphore - 1/circuits/warning.circom"]' )
. waitForElementVisible ( '[data-path="Semaphore - 1/circuits/warning.circom"]' )
. click ( '[data-id="treeViewLitreeViewItemcircuits/warning.circom"]' )
@ -104,6 +94,7 @@ module.exports = {
. waitForElementPresent ( 'button[data-id="compile_circuit_btn"]' )
. waitForElementVisible ( 'button[data-id="compile_circuit_btn"]' )
. click ( 'button[data-id="compile_circuit_btn"]' )
. waitForElementContainsText ( '[data-id="circuit_feedback"]' , 'File circuits/warning.circom does not include pragma version. Assuming pragma version (2, 1, 5)' )
. frameParent ( )
. clickLaunchIcon ( 'filePanel' )
. waitForElementPresent ( '[data-id="treeViewLitreeViewItemcircuits/.bin/warning.wasm"]' )
@ -114,20 +105,24 @@ module.exports = {
. waitForElementVisible ( '[data-id="circuit_feedback"]' )
. assert . hasClass ( '[data-id="circuit_feedback"]' , 'alert-warning' )
. waitForElementContainsText ( '[data-id="circuit_feedback"]' , 'File circuits/warning.circom does not include pragma version. Assuming pragma version (2, 1, 5)' )
. execute (
function ( ) {
return ( window as any ) . logs
} ,
[ ] ,
function ( result ) {
console . log ( result )
}
)
} ,
'Should hide/show warnings for compiled circuit #group4' : function ( browser : NightwatchBrowser ) {
browser
. click ( '[data-id="hide_circuit_warnings_checkbox_input"]' )
. waitForElementNotPresent ( '[data-id="circuit_feedback"]' )
. click ( '[data-id="hide_circuit_warnings_checkbox_input"]' )
. waitForElementVisible ( '[data-id="circuit_feedback"]' )
. waitForElementContainsText ( '[data-id="circuit_feedback"]' , 'File circuits/warning.circom does not include pragma version. Assuming pragma version (2, 1, 5)' )
browser . click ( '[data-id="hide_circuit_warnings_checkbox_input"]' ) . waitForElementNotPresent ( '[data-id="circuit_feedback"]' ) . click ( '[data-id="hide_circuit_warnings_checkbox_input"]' ) . waitForElementVisible ( '[data-id="circuit_feedback"]' ) . waitForElementContainsText ( '[data-id="circuit_feedback"]' , 'File circuits/warning.circom does not include pragma version. Assuming pragma version (2, 1, 5)' )
} ,
'Should display error for invalid circuit #group4' : function ( browser : NightwatchBrowser ) {
browser
. frameParent ( )
. clickLaunchIcon ( 'filePanel' )
. addFile ( 'circuits/error.circom' , { content : errorCircuit } )
. addFile ( 'circuits/error.circom' , { content : errorCircuit } )
. waitForElementPresent ( '[data-path="Semaphore - 1/circuits/error.circom"]' )
. waitForElementVisible ( '[data-path="Semaphore - 1/circuits/error.circom"]' )
. click ( '[data-id="treeViewLitreeViewItemcircuits/error.circom"]' )
@ -145,14 +140,9 @@ module.exports = {
. click ( '[data-id="auto_compile_circuit_checkbox_input"]' )
. frameParent ( )
. setEditorValue ( validCircuit , function ( ) {
browser
. frame ( 0 )
. waitForElementNotPresent ( '[data-id="circuit_feedback"]' )
. frameParent ( )
. clickLaunchIcon ( 'filePanel' )
. waitForElementPresent ( '[data-id="treeViewLitreeViewItemcircuits/.bin/error.wasm"]' )
browser . frame ( 0 ) . waitForElementNotPresent ( '[data-id="circuit_feedback"]' ) . frameParent ( ) . clickLaunchIcon ( 'filePanel' ) . waitForElementPresent ( '[data-id="treeViewLitreeViewItemcircuits/.bin/error.wasm"]' )
} )
}
} ,
}
const warningCircuit = `