Move /e2e -> /e2e-tests
Этот коммит содержится в:
155
e2e-tests/cypress/tests/support/ui/global_header.js
Обычный файл
155
e2e-tests/cypress/tests/support/ui/global_header.js
Обычный файл
@@ -0,0 +1,155 @@
|
||||
// Copyright (c) 2015-present Mattermost, Inc. All Rights Reserved.
|
||||
// See LICENSE.txt for license information.
|
||||
|
||||
Cypress.Commands.add('uiGetProductMenuButton', () => {
|
||||
return cy.findByRole('button', {name: 'Product switch menu'}).should('be.visible');
|
||||
});
|
||||
|
||||
Cypress.Commands.add('uiGetProductMenu', () => {
|
||||
return cy.get('.product-switcher-menu').should('be.visible');
|
||||
});
|
||||
|
||||
Cypress.Commands.add('uiOpenProductMenu', (item = '') => {
|
||||
// # Click on product switch button
|
||||
cy.uiGetProductMenuButton().click();
|
||||
|
||||
if (!item) {
|
||||
// # Return the menu if no item is passed
|
||||
return cy.uiGetProductMenu();
|
||||
}
|
||||
|
||||
// # Click on a particular item
|
||||
return cy.uiGetProductMenu().
|
||||
findByText(item).
|
||||
scrollIntoView().
|
||||
should('be.visible').
|
||||
click();
|
||||
});
|
||||
|
||||
Cypress.Commands.add('uiGetSetStatusButton', () => {
|
||||
return cy.findByRole('button', {name: /Select to open profile and status menu\./i}).should('be.visible');
|
||||
});
|
||||
|
||||
Cypress.Commands.add('uiGetProfileHeader', () => {
|
||||
return cy.uiGetSetStatusButton().parent();
|
||||
});
|
||||
|
||||
Cypress.Commands.add('uiGetStatusMenuContainer', (options = {exist: true}) => {
|
||||
if (options.exist) {
|
||||
return cy.findByRole('menu').should('exist');
|
||||
}
|
||||
|
||||
return cy.findByRole('menu').should('not.exist');
|
||||
});
|
||||
|
||||
Cypress.Commands.add('uiGetStatusMenu', (options = {visible: true}) => {
|
||||
if (options.visible) {
|
||||
return cy.uiGetStatusMenuContainer().
|
||||
find('ul').
|
||||
should('be.visible');
|
||||
}
|
||||
|
||||
return cy.uiGetStatusMenuContainer().
|
||||
find('ul').
|
||||
should('not.be.visible');
|
||||
});
|
||||
|
||||
Cypress.Commands.add('uiOpenHelpMenu', (item = '') => {
|
||||
// # Click on help status button
|
||||
cy.uiGetHelpButton().click();
|
||||
|
||||
if (!item) {
|
||||
// # Return the menu if no item is passed
|
||||
return cy.uiGetHelpMenu();
|
||||
}
|
||||
|
||||
// # Click on a particular item
|
||||
return cy.uiGetHelpMenu().
|
||||
findByText(item).
|
||||
scrollIntoView().
|
||||
should('be.visible').
|
||||
click();
|
||||
});
|
||||
|
||||
Cypress.Commands.add('uiGetHelpButton', () => {
|
||||
return cy.findByRole('button', {name: 'Help'}).should('be.visible');
|
||||
});
|
||||
|
||||
Cypress.Commands.add('uiGetHelpMenu', (options = {visible: true}) => {
|
||||
const dropdown = () => cy.get('#helpMenuPortal').find('.dropdown-menu');
|
||||
|
||||
if (options.visible) {
|
||||
return dropdown().should('be.visible');
|
||||
}
|
||||
|
||||
return dropdown().should('not.be.visible');
|
||||
});
|
||||
|
||||
Cypress.Commands.add('uiOpenUserMenu', (item = '') => {
|
||||
// # Click on user status button
|
||||
cy.uiGetSetStatusButton().click();
|
||||
|
||||
if (!item) {
|
||||
// # Return the menu if no item is passed
|
||||
return cy.uiGetStatusMenu();
|
||||
}
|
||||
|
||||
// # Click on a particular item
|
||||
return cy.uiGetStatusMenu().
|
||||
findByText(item).
|
||||
scrollIntoView().
|
||||
should('be.visible').
|
||||
click();
|
||||
});
|
||||
|
||||
Cypress.Commands.add('uiGetSearchContainer', () => {
|
||||
return cy.get('#searchFormContainer').should('be.visible');
|
||||
});
|
||||
|
||||
Cypress.Commands.add('uiGetSearchBox', () => {
|
||||
return cy.get('#searchBox').should('be.visible');
|
||||
});
|
||||
|
||||
Cypress.Commands.add('uiGetRecentMentionButton', () => {
|
||||
return cy.findByRole('button', {name: 'Recent mentions'}).should('be.visible');
|
||||
});
|
||||
|
||||
Cypress.Commands.add('uiGetSavedPostButton', () => {
|
||||
return cy.findByRole('button', {name: 'Saved posts'}).should('be.visible');
|
||||
});
|
||||
|
||||
Cypress.Commands.add('uiGetSettingsButton', () => {
|
||||
return cy.findByRole('button', {name: 'Settings'}).should('be.visible');
|
||||
});
|
||||
|
||||
Cypress.Commands.add('uiGetChannelInfoButton', () => {
|
||||
return cy.findByRole('button', {name: 'View Info'}).should('be.visible');
|
||||
});
|
||||
|
||||
Cypress.Commands.add('uiGetSettingsModal', () => {
|
||||
// # Get settings modal
|
||||
return cy.findByRole('dialog', {name: 'Settings'});
|
||||
});
|
||||
|
||||
Cypress.Commands.add('uiOpenSettingsModal', (section = '') => {
|
||||
// # Open settings modal
|
||||
cy.uiGetSettingsButton().click();
|
||||
|
||||
if (!section) {
|
||||
return cy.uiGetSettingsModal();
|
||||
}
|
||||
|
||||
// # Click on a particular section
|
||||
cy.findByRoleExtended('tab', {name: section}).should('be.visible').click();
|
||||
|
||||
return cy.uiGetSettingsModal();
|
||||
});
|
||||
|
||||
Cypress.Commands.add('uiLogout', () => {
|
||||
// # Click logout via user menu
|
||||
cy.uiOpenUserMenu('Log Out');
|
||||
|
||||
cy.url().should('include', '/login');
|
||||
cy.get('.login-body-message').should('be.visible');
|
||||
cy.get('.login-body-card').should('be.visible');
|
||||
});
|
||||
Ссылка в новой задаче
Block a user