[15 min fix] Improve reliability of profile dropdown test (#13986)

* wait for profile init

* complete logged out tests first

* add comment
This commit is contained in:
Suzanne Aitchison 2021-06-15 11:46:18 +01:00 committed by GitHub
parent e0798b88e0
commit 2f356dd3a4
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,4 +1,29 @@
describe('Profile User Actions Menu', () => {
// We complete logged out tests first, as unfinished network requests relating to logged-in users can cause unexpected failures
// See: https://github.com/forem/forem/issues/13988
describe('Logged out users', () => {
beforeEach(() => {
cy.testSetup();
});
it('should show a dropdown menu with only the Report Abuse link when the user is not logged in', () => {
cy.visit('/article_editor_v1_user');
// Make sure the dropdown has initialized
cy.get('[data-dropdown-initialized]');
cy.findByRole('button', { name: 'User actions' }).click();
cy.findByRole('link', { name: 'Report Abuse' }).should('have.focus');
cy.findByRole('link', { name: 'Block @article_editor_v1_user' }).should(
'not.exist',
);
cy.findByRole('link', { name: 'Flag @article_editor_v1_user' }).should(
'not.exist',
);
});
});
describe('Logged in users', () => {
beforeEach(() => {
cy.testSetup();
@ -14,6 +39,9 @@ describe('Profile User Actions Menu', () => {
it("should show a dropdown menu when a user views another user's profile", () => {
cy.visit('/article_editor_v1_user');
// Make sure the dropdown has initialized
cy.get('[data-dropdown-initialized]');
cy.findByRole('button', { name: 'User actions' }).as('dropdownButton');
cy.get('@dropdownButton').click();
cy.findByRole('link', { name: 'Block @article_editor_v1_user' }).should(
@ -48,6 +76,10 @@ describe('Profile User Actions Menu', () => {
cy.on('window:confirm', () => true);
cy.visit('/article_editor_v1_user');
// Make sure the dropdown has initialized
cy.get('[data-dropdown-initialized]');
cy.findByRole('button', { name: 'User actions' }).click();
cy.findByRole('link', { name: 'Block @article_editor_v1_user' }).click();
@ -66,6 +98,10 @@ describe('Profile User Actions Menu', () => {
cy.on('window:confirm', () => true);
cy.visit('/article_editor_v1_user');
// Make sure the dropdown has initialized
cy.get('[data-dropdown-initialized]');
cy.findByRole('button', { name: 'User actions' }).click();
cy.findByRole('link', { name: 'Flag @article_editor_v1_user' }).click();
@ -84,6 +120,10 @@ describe('Profile User Actions Menu', () => {
it('should link to report abuse from user', () => {
cy.visit('/article_editor_v1_user');
// Make sure the dropdown has initialized
cy.get('[data-dropdown-initialized]');
cy.findByRole('button', { name: 'User actions' }).click();
cy.findByRole('link', { name: 'Report Abuse' }).click();
@ -91,24 +131,4 @@ describe('Profile User Actions Menu', () => {
cy.url().should('contain', 'article_editor_v1_user');
});
});
describe('Logged out users', () => {
beforeEach(() => {
cy.testSetup();
});
it('should show a dropdown menu with only the Report Abuse link when the user is not logged in', () => {
cy.visit('/article_editor_v1_user');
cy.findByRole('button', { name: 'User actions' }).click();
cy.findByRole('link', { name: 'Report Abuse' }).should('have.focus');
cy.findByRole('link', { name: 'Block @article_editor_v1_user' }).should(
'not.exist',
);
cy.findByRole('link', { name: 'Flag @article_editor_v1_user' }).should(
'not.exist',
);
});
});
});