diff --git a/cypress/integration/spec_connections.js b/cypress/integration/spec_connections.js index 710f26ef2..95f5ab404 100644 --- a/cypress/integration/spec_connections.js +++ b/cypress/integration/spec_connections.js @@ -28,22 +28,29 @@ describe('Connecting nodes', () => { }) it('Connect with Liquid node', () => { - cy.get('#node-switch-icon').click() - cy.get('[data-cy="new-connection-btn"]').click() - cy.get('#name').clear() - cy.get('#name').type("Liquid") - cy.get('#username').clear() - cy.get('#username').type('liquid') - cy.get('#password').clear() - cy.get('#password').type('secret') - cy.get('#host').clear() - cy.get('#host').type('http://localhost') - cy.get('#port').clear() - cy.get('#port').type(8040) - cy.get('[data-cy="connect-btn"]').click() + cy.isElementsRunning().then((isRunning) => { + if (isRunning) { + cy.get('#node-switch-icon').click() + cy.get('[data-cy="new-connection-btn"]').click() + cy.get('#name').clear() + cy.get('#name').type("Liquid") + cy.get('#username').clear() + cy.get('#username').type('liquid') + cy.get('#password').clear() + cy.get('#password').type('secret') + cy.get('#host').clear() + cy.get('#host').type('http://localhost') + cy.get('#port').clear() + cy.get('#port').type(8040) + cy.get('[data-cy="connect-btn"]').click() + } + else { + cy.log('Test was skipped: Elementsd was not started by the test script.') + Cypress.runner.stop() + } + }) }) - // TODO: For testing the deletion we could delete the Liquid connection here if we don't run the Liquid tests it('Select Bitcoin Core connection', () => { cy.get('#node-switch-icon').click() cy.contains('Bitcoin Core').click() diff --git a/cypress/plugins/index.js b/cypress/plugins/index.js index e49f3e311..9b44b86e6 100644 --- a/cypress/plugins/index.js +++ b/cypress/plugins/index.js @@ -21,8 +21,17 @@ module.exports = (on, config) => { // `config` is the resolved Cypress config const btc_conn_file = fs.readFileSync('btcd-conn.json'); const btc_conn = JSON.parse(btc_conn_file); - const elm_conn_file = fs.readFileSync('elmd-conn.json'); - const elm_conn = JSON.parse(elm_conn_file); + const elm_conn_file_path = 'elmd-conn.json'; + // Elementsd is not always started + let elm_conn + if (fs.existsSync(elm_conn_file_path)) { + const elm_conn_file = fs.readFileSync(elm_conn_file_path); + elm_conn = JSON.parse(elm_conn_file); + } + else { + elm_conn = '' + } + on('task', { 'clear:specter-home': () => { console.log('Removing and recreating Specter-data-folder %s', btc_conn["specter_data_folder"]) @@ -79,6 +88,16 @@ module.exports = (on, config) => { } }) - + on("task", { + isElementsRunning: () => { + const elm_conn_file_path = "elmd-conn.json"; + if (fs.existsSync(elm_conn_file_path)) { + return true; + } + else { + return false; + } + }, + }); } diff --git a/cypress/support/commands.js b/cypress/support/commands.js index 898633705..56f3c08bc 100644 --- a/cypress/support/commands.js +++ b/cypress/support/commands.js @@ -271,3 +271,7 @@ Cypress.Commands.add("connect", () => { cy.get('#port').type(15443) cy.get('[data-cy="connect-btn"]').click() }) + +Cypress.Commands.add("isElementsRunning", () => { + return cy.task("isElementsRunning"); +}); \ No newline at end of file diff --git a/utils/test-cypress.sh b/utils/test-cypress.sh index 1887e3d9c..f9dac8b72 100755 --- a/utils/test-cypress.sh +++ b/utils/test-cypress.sh @@ -63,6 +63,7 @@ Subcommands: generic-options: --debug Run as much stuff in debug as we can + --with-elements In addition to bitcoind, also start elementsd EOF } @@ -176,7 +177,9 @@ function start_bitcoind { } function start_elementsd { - start_node --elements $* + if [ $USE_ELEMENTSD = true ]; then + start_node --elements $* + fi } function stop_bitcoind { @@ -396,6 +399,9 @@ function parse_and_execute() { exit 0 fi + # Don't start elementsd unless --with-elements is set + # Usage: ./utils/test-cypress.sh --with-elements run + USE_ELEMENTSD=false while [[ $# -gt 0 ]] do arg="$1" @@ -413,6 +419,10 @@ function parse_and_execute() { ELMLOGSTDOUT=true shift ;; + --with-elements) + USE_ELEMENTSD=true + shift + ;; *) shift START=$(date +%s)