Currently, I have an example of a test within a project that I am actively working on:
AppPage.lastnameInput().clear().then(function () {
AppPage.lastnameInput().sendKeys(lastname).then(function () {
AppPage.firstnameInput().clear().then(function () {
AppPage.firstnameInput().sendKeys(firstname).then(function () {
AppPage.ibanInput().clear().then(function () {
AppPage.ibanInput().sendKeys(IBAN).then(function () {
$('body').click().then(function () {
callback();
});
});
});
});
});
});
});
I believe that this code could be simplified and flattened to something like:
foo(
AppPage.lastnameInput().clear(),
AppPage.lastnameInput().sendKeys(lastname),
AppPage.firstnameInput().clear(),
AppPage.firstnameInput().sendKeys(firstname),
AppPage.ibanInput().clear(),
AppPage.ibanInput().sendKeys(IBAN),
$('body').click(),
).then(() => callback())
I attempted to use forkJoin()
, but it didn't seem to wait for the completion of the first Observable before moving on to the next one.
While I could create my own function for this operation, it seems quite generic. Therefore, I am curious if there is already a more standardized function available for this purpose.