'Cypress test data concurrency

I need to test in Cypress the concurrence of several users to the data, that is, I have a list of tasks that can be modified by several users, when a user enters the index page all the tasks are shown, I need to simulate in Cypress that another user has modified some task so that when the update button is clicked, the list will be updated and show the modified data.

When I do the manual test of this function I go to the index page with one user, then in another browser I go with another user, I modify a task and then I go back to the initial user and click the update button.

I don't know how to simulate this in Cypress.



Solution 1:[1]

The way to do it depends on the way information is transferred between apps. If it's via http then cy.intercept() will catch calls from the app (if for example polling occurs) and you can stub the expected response to simulate a change made by another user.

If via web sockets, there's articles here

Solution 2:[2]

I'm working with similar behavior, but i need to do operation with admin user in the backoffice, while the client is testing thing on a completely different page. The way my approach has been so far and i have had little to no issues is by creating custom commands that utilize the API, like command for example "cy.approveRegistration()" Read more here: official cypress docs, but there is a ton of tutorials on youtube

Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source
Solution 1 Fody
Solution 2 Bogdan Pehlivanov