forked from mattermost/mattermost-webapp
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
MM-20904 Add E2E tests for custom categories (mattermost#5981)
* MM-20904 Add E2E tests for custom categories * Tests for create, delete and rename categories * MM-20904 fix types * Update e2e/cypress/integration/channel_sidebar/custom_categories_spec.js Co-authored-by: Guillermo Vayá <[email protected]> * Update e2e/cypress/integration/channel_sidebar/custom_categories_spec.js Co-authored-by: Harrison Healey <[email protected]> * Update e2e/cypress/integration/channel_sidebar/custom_categories_spec.js Co-authored-by: Guillermo Vayá <[email protected]> * Update PR * Update e2e/cypress/integration/channel_sidebar/custom_categories_spec.js Co-authored-by: Jelena Gilliam <[email protected]> * Update e2e/cypress/integration/channel_sidebar/custom_categories_spec.js Co-authored-by: Jelena Gilliam <[email protected]> * Update e2e/cypress/integration/channel_sidebar/custom_categories_spec.js Co-authored-by: Jelena Gilliam <[email protected]> * Update e2e/cypress/integration/channel_sidebar/custom_categories_spec.js Co-authored-by: Jelena Gilliam <[email protected]> * Update e2e/cypress/integration/channel_sidebar/custom_categories_spec.js Co-authored-by: Jelena Gilliam <[email protected]> * update snapshots Co-authored-by: Guillermo Vayá <[email protected]> Co-authored-by: Harrison Healey <[email protected]> Co-authored-by: Jelena Gilliam <[email protected]>
- Loading branch information
1 parent
d5dc814
commit cb13baa
Showing
5 changed files
with
151 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
141 changes: 141 additions & 0 deletions
141
e2e/cypress/integration/channel_sidebar/custom_categories_spec.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved. | ||
// See LICENSE.txt for license information. | ||
|
||
// *************************************************************** | ||
// - [#] indicates a test step (e.g. # Go to a page) | ||
// - [*] indicates an assertion (e.g. * Check the title) | ||
// - Use element ID when selecting an element. Create one if none. | ||
// *************************************************************** | ||
|
||
// Stage: @prod | ||
// Group: @channel_sidebar | ||
|
||
import {getRandomId} from '../../utils'; | ||
|
||
describe('Channel sidebar', () => { | ||
before(() => { | ||
// # Enable channel sidebar organization | ||
cy.apiUpdateConfig({ | ||
ServiceSettings: { | ||
ExperimentalChannelSidebarOrganization: 'default_on', | ||
}, | ||
}); | ||
|
||
// # Login as test user and visit town-square | ||
cy.apiInitSetup({loginAfter: true}).then(({team}) => { | ||
cy.visit(`/${team.name}/channels/town-square`); | ||
}); | ||
|
||
// # Close "What's new" modal | ||
cy.uiCloseWhatsNewModal(); | ||
}); | ||
|
||
it('MM-T3161_1 should create a new category from sidebar menu', () => { | ||
const categoryName = createCategoryFromSidebarMenu(); | ||
|
||
// * check if the category exists | ||
cy.get(`button[aria-label='${categoryName}']`).should('contain', categoryName); | ||
}); | ||
|
||
it('MM-T3161_2 should create a new category from category menu', () => { | ||
const categoryName = createCategoryFromSidebarMenu(); | ||
|
||
// # create a category from category menu | ||
cy.get(`button[aria-label='${categoryName}']`).parents('.SidebarChannelGroup').within(() => { | ||
cy.get('.SidebarMenu').invoke('show').get('.SidebarMenu_menuButton').click(); | ||
cy.get('.icon-folder-plus-outline').parents('button').click(); | ||
}); | ||
|
||
const newCategoryName = `category-${getRandomId()}`; | ||
cy.get('#editCategoryModal input').type(newCategoryName).type('{enter}'); | ||
|
||
// * check if the newly created category exists | ||
cy.get(`button[aria-label='${newCategoryName}']`).should('contain', newCategoryName); | ||
}); | ||
|
||
it('MM-T3161_3 move an existing channel to a new category', () => { | ||
const newCategoryName = `category-${getRandomId()}`; | ||
|
||
// # move to a new category | ||
cy.get('#sidebarItem_off-topic').parent().then((element) => { | ||
// # get id of the channel | ||
const id = element[0].getAttribute('data-rbd-draggable-id'); | ||
cy.get('#sidebarItem_off-topic').parent('li').within(() => { | ||
// # open dropown next to channel name | ||
cy.get('.SidebarMenu').invoke('show').get('.SidebarMenu_menuButton').click(); | ||
|
||
// # open sub menu | ||
cy.get(`#moveTo-${id}`).parent('.SubMenuItem').trigger('mouseover'); | ||
|
||
// # click on move to new category | ||
cy.get(`#moveToNewCategory-${id}`).parent('.SubMenuItem').click(); | ||
}); | ||
}); | ||
cy.get('#editCategoryModal input').type(newCategoryName).type('{enter}'); | ||
|
||
// * check if the newly created category exists | ||
cy.get(`button[aria-label='${newCategoryName}']`).should('contain', newCategoryName); | ||
}); | ||
|
||
it('MM-T3163 Rename a category', () => { | ||
const categoryName = createCategoryFromSidebarMenu(); | ||
cy.get(`button[aria-label='${categoryName}']`).should('contain', categoryName); | ||
cy.get(`button[aria-label='${categoryName}']`).parents('.SidebarChannelGroup').then((element) => { | ||
// # get id of the category | ||
const id = element[0].getAttribute('data-rbd-draggable-id'); | ||
cy.get(`button[aria-label='${categoryName}']`).parents('.SidebarChannelGroup').within(() => { | ||
cy.get('.SidebarMenu').invoke('show').get('.SidebarMenu_menuButton').click(); | ||
|
||
// # click on rename menu item | ||
cy.get(`#rename-${id}`).click(); | ||
}); | ||
|
||
const renameCategory = `category-${getRandomId()}`; | ||
|
||
// # rename category | ||
cy.get('#editCategoryModal input').clear().type(renameCategory).type('{enter}'); | ||
|
||
// * check if the previous category exist | ||
cy.get(`button[aria-label='${categoryName}']`).should('not.exist'); | ||
|
||
// * check if the renamed category exists | ||
cy.get(`button[aria-label='${renameCategory}']`).should('contain', renameCategory); | ||
}); | ||
}); | ||
|
||
it('MM-T3165 Delete a category', () => { | ||
const categoryName = createCategoryFromSidebarMenu(); | ||
cy.get(`button[aria-label='${categoryName}']`).should('contain', categoryName); | ||
cy.get(`button[aria-label='${categoryName}']`).parents('.SidebarChannelGroup').then((element) => { | ||
// # get id of the category | ||
const id = element[0].getAttribute('data-rbd-draggable-id'); | ||
cy.get(`button[aria-label='${categoryName}']`).parents('.SidebarChannelGroup').within(() => { | ||
cy.get('.SidebarMenu').invoke('show').get('.SidebarMenu_menuButton').click(); | ||
|
||
// # click on delete menu item | ||
cy.get(`#delete-${id}`).click(); | ||
}); | ||
|
||
// # click on delete button | ||
cy.get('.GenericModal__button.delete').click(); | ||
|
||
// * check if the deleted category exists | ||
cy.get(`button[aria-label='${categoryName}']`).should('not.exist'); | ||
}); | ||
}); | ||
}); | ||
|
||
function createCategoryFromSidebarMenu() { | ||
// # Start with a new category | ||
const categoryName = `category-${getRandomId()}`; | ||
|
||
// # Click on the siebar menu dropdown | ||
cy.get('.AddChannelDropdown_dropdownButton').click(); | ||
|
||
// # Click on create category link | ||
cy.get('#createCategory').click(); | ||
|
||
// # Enter category name and hit enter | ||
cy.get('#editCategoryModal input').type(categoryName).type('{enter}'); | ||
return categoryName; | ||
} |