Commit 7a09a974 authored by Joseph Baylon's avatar Joseph Baylon Committed by Saturnino Abril
Browse files

Cypress/E2E: Fix channel sidebar specs (#5984)

* Fix channel sidebar specs

* Fix lint issues
parent 48a1a692
......@@ -37,6 +37,9 @@ describe('Channel sidebar', () => {
});
it('should display collapsed state when collapsed', () => {
// # Close "What's new" modal
cy.uiCloseWhatsNewModal();
// # Check that the CHANNELS group header is visible
cy.get('.SidebarChannelGroupHeader:contains(CHANNELS)').should('be.visible').as('channelsGroup');
......
......@@ -28,6 +28,9 @@ describe('Channel sidebar', () => {
cy.apiInitSetup({loginAfter: true}).then(({team}) => {
cy.visit(`/${team.name}/channels/town-square`);
});
// # Close "What's new" modal
cy.uiCloseWhatsNewModal();
});
it('should switch channels when clicking on a channel in the sidebar', () => {
......
......@@ -36,13 +36,16 @@ describe('Channel sidebar', () => {
channelName = response.body.display_name;
});
cy.visit(`/${team.name}/channels/town-square`);
// * Verify that we've switched to the new team
cy.get('#headerTeamName', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').should('contain', teamName);
});
});
it('should move channel to correct place when dragging channel within category', () => {
// # Close "What's new" modal
cy.uiCloseWhatsNewModal();
// * Verify that we've switched to the new team
cy.get('#headerTeamName', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').should('contain', teamName);
// * Verify the order is correct to begin with
cy.get('.SidebarChannel > .SidebarLink').should('be.visible').as('fromChannelSidebarLink');
cy.get('@fromChannelSidebarLink').eq(0).should('contain', channelName);
......@@ -63,6 +66,9 @@ describe('Channel sidebar', () => {
});
it('should move category to correct place', () => {
// * Verify that we've switched to the new team
cy.get('#headerTeamName', {timeout: TIMEOUTS.ONE_MIN}).should('be.visible').should('contain', teamName);
// # Get channel group button and wait for Channels to be visible since for some reason it shows up later...
cy.get('.SidebarChannelGroupHeader_groupButton > div[data-rbd-drag-handle-draggable-id]').should('be.visible').as('fromChannelGroup');
cy.get('@fromChannelGroup').should('contain', 'CHANNELS');
......
......@@ -26,6 +26,9 @@ describe('Channel sidebar', () => {
cy.apiInitSetup({loginAfter: true}).then(({team}) => {
cy.visit(`/${team.name}/channels/town-square`);
});
// # Close "What's new" modal
cy.uiCloseWhatsNewModal();
});
it('should not show history arrows on the regular webapp', () => {
......
......@@ -26,6 +26,9 @@ describe('Channel sidebar', () => {
cy.apiInitSetup({loginAfter: true}).then(({team}) => {
cy.visit(`/${team.name}/channels/town-square`);
});
// # Close "What's new" modal
cy.uiCloseWhatsNewModal();
});
it('should create a new channel when using the new channel dropdown', () => {
......
......@@ -33,6 +33,9 @@ describe('Handle removed user - new sidebar', () => {
cy.apiInitSetup({loginAfter: true}).then(({team, channel}) => {
cy.visit(`/${team.name}/channels/${channel.name}`);
});
// # Close "What's new" modal
cy.uiCloseWhatsNewModal();
});
it('should be redirected to last channel when a user is removed from their current channel', () => {
......
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
import './modal';
import './post_dropdown_menu';
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
/// <reference types="cypress" />
// ***************************************************************
// Each command should be properly documented using JSDoc.
// See https://jsdoc.app/index.html for reference.
// Basic requirements for documentation are the following:
// - Meaningful description
// - Each parameter with `@params`
// - Return value with `@returns`
// - Example usage with `@example`
// Custom command should follow naming convention of having `ui` prefix, e.g. `uiCloseModal`.
// ***************************************************************
declare namespace Cypress {
interface Chainable<Subject = any> {
/**
* Close modal with header label
* @param {string} headerLabel - the header label
*
* @example
* const headerLabel = 'What\'s New';
* cy.uiCloseModal(headerLabel);
*/
uiCloseModal(headerLabel: string): Chainable;
/**
* Close "What's new" modal
*
* @example
* cy.uiCloseWhatsNewModal();
*/
uiCloseWhatsNewModal(): Chainable;
}
}
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
// See LICENSE.txt for license information.
Cypress.Commands.add('uiCloseModal', (headerLabel) => {
// # Close modal with modal label
cy.get('#genericModalLabel').should('have.text', headerLabel).parents().find('.modal-dialog').findByLabelText('Close').click();
});
Cypress.Commands.add('uiCloseWhatsNewModal', () => {
// # Close "What's new" modal
cy.uiCloseModal('What\'s new');
});
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment