docbrown/cypress/integration/profileFlows/followUser.spec.js
Suzanne Aitchison 7a17cdf0f3
[15 min fix] Remove flake in "follow user" spec (#13897)
* always wait until button initialized

* fix flake in follow user spec
2021-06-02 13:32:39 +02:00

31 lines
935 B
JavaScript

describe('Follow user from profile page', () => {
beforeEach(() => {
cy.testSetup();
cy.fixture('users/adminUser.json').as('user');
cy.get('@user').then((user) => {
cy.loginUser(user).then(() => {
cy.visit('/article_editor_v1_user');
});
});
});
it('follows and unfollows a user', () => {
// Wait for the button to be initialised
cy.get('[data-click-initialized="true"]');
cy.findByRole('button', { name: 'Follow' }).click();
cy.findByRole('button', { name: 'Following' });
// Check that the update persists after reload
cy.reload();
cy.get('[data-click-initialized="true"]');
cy.findByRole('button', { name: 'Following' }).click();
cy.findByRole('button', { name: 'Follow' });
// Check that the update persists after reload
cy.reload();
cy.get('[data-click-initialized="true"]');
cy.findByRole('button', { name: 'Follow' });
});
});