interactors
interactors copied to clipboard
Invariant Assertions
By far, Most of the time you want to make sure that an assertion is eventually true over the timeout period. In other words, it can fail any number of time up until the timeout, but the moment it passes, the entire assertion is considered to pass.
convergent assertion profile
|--- timeout ------|
(pass) F -> F -> F -> T
(pass) F-> T
(pass) T
(fail) F -> F -> F -> F -> F
However, we have encountered some cases where you want to assert some invariant is true over the course of time. For example, that a button remains enabled and visible. There is no way to do this currently with interactors.
The feature request is to add assertion methods to ensure that something is true and remains true for a certain period.
invariant assertion profile This is the boolean inverse of the convergent assertion profile.
|--- timeout ------|
(fail) T -> T -> T -> F
(fail) T-> F
(fail) F
(pass) T -> T -> T -> T -> T
Two proposals
new assertion methods Corresponding to each assertion method there is an equivalent "invariant" method which has the invariant assertion profile:
| Flavor | Convergent | Invariant |
|---|---|---|
| identity | is() |
remains() |
| possesion | has() |
retains() |
so to use the button as an example:
await Button("Sign In").remains({ visible: true });
await Button("Sign In").retains({ visibility: true });
assertion modifier
Another possibility is just add a "modifier" to assertions to make them invariant:
await Button("Sign In").is({ visible: true }).continously()
That seems to be simple, and would also be easier to bolt on to things like exists() and absent()
Context
Here is an example of an invariant assertion in the wild that cannot be migrated to interactors https://github.com/folio-org/stripes-core/blob/dc3bd495e00c69737bc145f36c9a2780ed31ba7e/test/bigtest/tests/login-test.js#L80-L82
I like the assertion modifier syntax. Would prefer that if no cons arise.