magic_test
magic_test copied to clipboard
Potentially create abstraction for testingOutput sender arguments
https://github.com/bullet-train-co/magic_test/blob/b086d2f9bdfcbbe1b3d5283fa10fd5877f73256b/app/views/magic_test/_javascript_helpers.html#L12-L14
I'm seeing these three values grouped together often like this:
testingOutput.push({action: action, target: target, options: options });
Curious if we should make an abstraction of this object and give it a name.
Maybe we could do something like this.
function buildCapybaraAction(action, data = nil) {
switch(action) {
case 'fill_in':
// ...
case 'click_on':
// ...
}
return {action: action, target: target, options: options}
}
Here data
represents whatever information is necessary to build the arguments and options for the action we want to build.
I still haven't sifted through the code enough to know if this is a viable option, but I think it will make the intention of the code clearer to first-time readers, and we can perhaps simplify the current code.