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

Retry capabilities for blocks of actions/tasks/questions #39

Open
kbrueckner opened this issue Mar 3, 2023 · 2 comments
Open

Retry capabilities for blocks of actions/tasks/questions #39

kbrueckner opened this issue Mar 3, 2023 · 2 comments

Comments

@kbrueckner
Copy link
Contributor

Imagine the following scenario:
A user triggers some interaction in a UI. In the background some data is put on a data stream is processed by a backend service and ends up updating an existing entry in a database. For that scenario a test could look like follow:

John.attemptsTo(
	Type.in(INPUT_FIELD, ‘some change’),
	Click.on(SUBMIT_BUTTON),
);

Const entity = await DBAdmin.attemptsTo(
	Query.dataset(123),
);
DBAdmin.asks(
	Entity.hasAttribute(entity, { attr: ‘some change’ });
);

The challenge could be, that the whole flow takes some time so that the changes are not immediately found in the DB but require some time. A Retry routine would help to overcome that. An idea how that could look like is:

John.attemptsTo(
	Type.in(INPUT_FIELD, ‘some change’),
	Click.on(SUBMIT_BUTTON),
);

DBAdmin.retries(
	DBAdmin.attemptsTo(
		Query.dataset(123),
	),
	DBAdmin.asks(
		Entity.hasAttribute(entity, { attr: ‘some change’ });
	),
).withInterval(30000).withMaxRetries(5);

In case the actions inside a retry are split among different users

DBAdmin.and.DBAdmin2.retry(
	DBAdmin.attemptsTo(
		Query.dataset(123),
	),
	DBAdmin2.asks(
		Entity.hasAttribute(entity, { attr: ‘some change’ });
	),
).withInterval(30000).withMaxRetries(5);
@JEnglandOhalo
Copy link
Contributor

https://github.com/awaitility/awaitility/wiki/Usage is a quite nice library in Java for synchronizing operations in tests. I quite like its fluent API

I wonder if it could be combined with Questions?

DBAdmin
   .waits()
   .atMost(5, SECONDS)
  .until(Entity.hasAttribute(entity, { attr: ‘some change’ }))

@kbrueckner kbrueckner removed this from the 1.5.0 milestone Feb 7, 2024
@kbrueckner
Copy link
Contributor Author

This actually should be implemented in the screenplay core package

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants