move execution into function

This commit is contained in:
iw0 2024-06-04 21:36:38 +02:00
parent 75a5b71a0a
commit 62a08c9166

View File

@ -62,21 +62,28 @@ const personalDataConfigKeys = [
"addr__email", "addr__street", "addr__postcode", "addr__placename"]; "addr__email", "addr__street", "addr__postcode", "addr__placename"];
const bankDetailConfigKeys = ["pymt__iban", "pymt__bic"]; 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 * @param {Node} n
*/ */
function processSingleAddedNode(n) { function processSingleAddedNode(n) {
if (currentStage.match(n)) { if (currentStage.match(n)) {
console.info(currentStage.name, "matched: ", n); console.info(currentStage.name, "matched: ", n);
const success = currentStage.execute(n); genericExecute(currentStage, n);
Promise.resolve(success).then((result => {
if (result === true) {
console.info(currentStage.name, "executed successfully");
} else {
console.error(currentStage.name, "failed");
}
nextStage();
}));
} else { } else {
console.debug(currentStage.name, "did not match: ", n); console.debug(currentStage.name, "did not match: ", n);
@ -110,13 +117,7 @@ function processMutations(mutationList, observer) {
if (currentStage.expects == 'mutation') { if (currentStage.expects == 'mutation') {
if (currentStage.match(mutation)) { if (currentStage.match(mutation)) {
console.info(currentStage.name, "matched: ", mutation); console.info(currentStage.name, "matched: ", mutation);
let success = currentStage.execute(mutation); genericExecute(currentStage, mutation);
if (success){
console.info(currentStage.name, "executed successfully");
} else {
console.error(currentStage.name, "failed");
}
nextStage();
} else { } else {
console.debug(currentStage.name, "did not match: ", mutation); 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 {string} testName
* @param {"open"|"close"} openOrClose * @param {"open"|"close"} openOrClose
* @returns boolean * @returns boolean