move execution into function
This commit is contained in:
parent
75a5b71a0a
commit
62a08c9166
@ -62,21 +62,28 @@ const personalDataConfigKeys = [
|
||||
"addr__email", "addr__street", "addr__postcode", "addr__placename"];
|
||||
const bankDetailConfigKeys = ["pymt__iban", "pymt__bic"];
|
||||
|
||||
const genericExecute = (stage, o) => {
|
||||
const success = stage.execute(o);
|
||||
Promise.resolve(success).then(result => {
|
||||
if (result === true) {
|
||||
console.info(currentStage.name, "executed successfully");
|
||||
} else {
|
||||
console.error(currentStage.name, "failed");
|
||||
}
|
||||
nextStage();
|
||||
}, failReason => {
|
||||
console.error(currentStage.name, "failed: ", failReason);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* @param {Node} n
|
||||
*/
|
||||
function processSingleAddedNode(n) {
|
||||
if (currentStage.match(n)) {
|
||||
console.info(currentStage.name, "matched: ", n);
|
||||
const success = currentStage.execute(n);
|
||||
Promise.resolve(success).then((result => {
|
||||
if (result === true) {
|
||||
console.info(currentStage.name, "executed successfully");
|
||||
} else {
|
||||
console.error(currentStage.name, "failed");
|
||||
}
|
||||
nextStage();
|
||||
}));
|
||||
genericExecute(currentStage, n);
|
||||
|
||||
} else {
|
||||
console.debug(currentStage.name, "did not match: ", n);
|
||||
@ -110,13 +117,7 @@ function processMutations(mutationList, observer) {
|
||||
if (currentStage.expects == 'mutation') {
|
||||
if (currentStage.match(mutation)) {
|
||||
console.info(currentStage.name, "matched: ", mutation);
|
||||
let success = currentStage.execute(mutation);
|
||||
if (success){
|
||||
console.info(currentStage.name, "executed successfully");
|
||||
} else {
|
||||
console.error(currentStage.name, "failed");
|
||||
}
|
||||
nextStage();
|
||||
genericExecute(currentStage, mutation);
|
||||
} else {
|
||||
console.debug(currentStage.name, "did not match: ", mutation);
|
||||
}
|
||||
@ -180,7 +181,7 @@ function fillTextInput(parentNode, selector, value) {
|
||||
|
||||
/**
|
||||
*
|
||||
* @param {MutationRecord} mut
|
||||
* @param {MutationRecord} mut
|
||||
* @param {string} testName
|
||||
* @param {"open"|"close"} openOrClose
|
||||
* @returns boolean
|
||||
|
Loading…
Reference in New Issue
Block a user