mirror of
https://github.com/cryptoadvance/specter-desktop.git
synced 2026-08-13 12:33:29 +02:00
Chore: Add flag to run elements in Cypress test script (#2271)
* cypress script only starts elementsd if stated explicitly * add isElementsRunning to Cypress
This commit is contained in:
parent
16b3fe48d3
commit
c0d657899b
4 changed files with 58 additions and 18 deletions
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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");
|
||||
});
|
||||
|
|
@ -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)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue