Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Invariant Assertions #171

Open
cowboyd opened this issue Jan 12, 2022 · 1 comment
Open

Invariant Assertions #171

cowboyd opened this issue Jan 12, 2022 · 1 comment
Labels
enhancement New feature or request question Further information is requested

Comments

@cowboyd
Copy link
Member

cowboyd commented Jan 12, 2022

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

@cowboyd cowboyd changed the title add remains() interaction? Invariant Assertions Jan 12, 2022
@cowboyd cowboyd added enhancement New feature or request question Further information is requested labels Jan 12, 2022
@JohnC-80
Copy link

I like the assertion modifier syntax. Would prefer that if no cons arise.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request question Further information is requested
Projects
None yet
Development

No branches or pull requests

2 participants