mirror of
https://github.com/mattermost/mattermost.git
synced 2025-02-25 18:55:24 -06:00
MM-52487: fix more playbooks tests (#23475)
* fix playbooks/channels/rhs/template_spec.js * fix playbooks/channels/update_request_post_spec.js * fix playbooks/runs/rdp_rhs_runinfo_spec.js * fix playbooks/runs/rdp_rhs_statusupdates_spec.js * remove enableexperimentalfeatures flag in e2e tests * rdp_main_header_spec: simplify channel loaded assertion * playbooks rhs participants: fix infinite fetch loop * improved onboarding skipping * simplify participants fetching
This commit is contained in:
parent
36027ac1c4
commit
803d0c6e60
@ -34,10 +34,6 @@ describe('channels > rhs > template', {testIsolation: true}, () => {
|
||||
// # Switch to playbooks DM channel
|
||||
cy.visit(`/${team1.name}/messages/@playbooks`);
|
||||
|
||||
// * Checking the bot badge as an indicator of page
|
||||
// * stability / rendering finished
|
||||
cy.findByText('BOT').should('be.visible');
|
||||
|
||||
// # Open playbooks RHS.
|
||||
cy.getPlaybooksAppBarIcon().should('be.visible').click();
|
||||
|
||||
@ -58,10 +54,6 @@ describe('channels > rhs > template', {testIsolation: true}, () => {
|
||||
// # Switch to playbooks DM channel
|
||||
cy.visit(`/${team1.name}/messages/@playbooks`);
|
||||
|
||||
// * Checking the bot badge as an indicator of page
|
||||
// * stability / rendering finished
|
||||
cy.findByText('BOT').should('be.visible');
|
||||
|
||||
// # Open playbooks RHS.
|
||||
cy.getPlaybooksAppBarIcon().should('be.visible').click();
|
||||
|
||||
|
@ -19,6 +19,13 @@ describe('channels > update request post', {testIsolation: true}, () => {
|
||||
let testPlaybookRun2;
|
||||
|
||||
before(() => {
|
||||
cy.apiUpdateConfig({
|
||||
ServiceSettings: {
|
||||
ThreadAutoFollow: true,
|
||||
CollapsedThreads: 'default_on',
|
||||
},
|
||||
});
|
||||
|
||||
cy.apiInitSetup().then(({team, user}) => {
|
||||
testTeam = team;
|
||||
testParticipant = user;
|
||||
|
@ -40,34 +40,7 @@ describe('playbooks > feedback', {testIsolation: true}, () => {
|
||||
});
|
||||
});
|
||||
|
||||
it('playbooks shows prompt in global header, with experimental feature flag', () => {
|
||||
// # Enable experimental feature flag
|
||||
cy.apiAdminLogin().then(() => {
|
||||
cy.apiEnsureFeatureFlag('enableexperimentalfeatures', true);
|
||||
|
||||
// # Login as testUser
|
||||
cy.apiLogin(testUser);
|
||||
});
|
||||
|
||||
// # Visit the playbooks product
|
||||
cy.visit('/playbooks');
|
||||
|
||||
// # Verify Give Feedback link is configured to open in a new tab.
|
||||
cy.findByText('Give feedback').invoke('attr', 'target').should('eq', '_blank');
|
||||
|
||||
// # Verify Give Feedback link href
|
||||
cy.findByText('Give feedback').invoke('attr', 'href').should('match', /playbooks-feedback/);
|
||||
});
|
||||
|
||||
it('playbooks shows prompt in global header, without experimental feature flag', () => {
|
||||
// # Disable experimental feature flag
|
||||
cy.apiAdminLogin().then(() => {
|
||||
cy.apiEnsureFeatureFlag('enableexperimentalfeatures', false);
|
||||
|
||||
// # Login as testUser
|
||||
cy.apiLogin(testUser);
|
||||
});
|
||||
|
||||
it('playbooks shows prompt in global header', () => {
|
||||
// # Visit the playbooks product
|
||||
cy.visit('/playbooks');
|
||||
|
||||
|
@ -618,13 +618,8 @@ describe('runs > run details page > header', {testIsolation: true}, () => {
|
||||
// # Navigate to the playbook run channel
|
||||
cy.visit(`/${testTeam.name}/channels/${playbookRunChannelName}`);
|
||||
|
||||
// * Verify the user was added to the channel
|
||||
cy.getFirstPostId().then((id) => {
|
||||
cy.get(`#postMessageText_${id}`).within(() => {
|
||||
cy.contains('You and');
|
||||
cy.contains('joined the channel');
|
||||
});
|
||||
});
|
||||
// # Verify channel loads
|
||||
cy.get('#channelHeaderTitle').should('be.visible').should('contain', playbookRunName);
|
||||
|
||||
// * assert telemetry data
|
||||
cy.expectTelemetryToContain([
|
||||
@ -681,13 +676,8 @@ describe('runs > run details page > header', {testIsolation: true}, () => {
|
||||
// # Navigate to the playbook run channel
|
||||
cy.visit(`/${testTeam.name}/channels/${playbookRunChannelName}`);
|
||||
|
||||
// * Verify that the user was added to the channel
|
||||
cy.getFirstPostId().then((id) => {
|
||||
cy.get(`#postMessageText_${id}`).within(() => {
|
||||
cy.contains('You and');
|
||||
cy.contains('joined the channel');
|
||||
});
|
||||
});
|
||||
// # Verify channel loads
|
||||
cy.get('#channelHeaderTitle').should('be.visible').should('contain', playbookRunName);
|
||||
});
|
||||
});
|
||||
});
|
||||
@ -812,13 +802,8 @@ describe('runs > run details page > header', {testIsolation: true}, () => {
|
||||
// # Navigate to the playbook run channel
|
||||
cy.visit(`/${testTeam.name}/channels/${playbookRunChannelName}`);
|
||||
|
||||
// * Verify that the user was added to the channel
|
||||
cy.getFirstPostId().then((id) => {
|
||||
cy.get(`#postMessageText_${id}`).within(() => {
|
||||
cy.contains('You and');
|
||||
cy.contains('joined the channel');
|
||||
});
|
||||
});
|
||||
// # Verify channel loads
|
||||
cy.get('#channelHeaderTitle').should('be.visible').should('contain', playbookRunName);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -164,7 +164,7 @@ describe('runs > run details page > run info', {testIsolation: true}, () => {
|
||||
from: 'run_details',
|
||||
playbookrun_id: testRun.id,
|
||||
},
|
||||
], {waitForCalls: 3});
|
||||
], {waitForCalls: 2});
|
||||
});
|
||||
|
||||
it('click channel link navigates to run\'s channel', () => {
|
||||
|
@ -100,13 +100,13 @@ describe('runs > run details page > status update', {testIsolation: true}, () =>
|
||||
});
|
||||
|
||||
describe('as viewer', () => {
|
||||
beforeEach(() => {
|
||||
cy.apiLogin(testViewerUser).then(() => {
|
||||
cy.visit(`/playbooks/runs/${testRun.id}`);
|
||||
});
|
||||
});
|
||||
|
||||
it('rhs can not be open when there is no updates', () => {
|
||||
// * Log in as viewer user
|
||||
cy.apiLogin(testViewerUser);
|
||||
|
||||
// * Browse to test run
|
||||
cy.visit(`/playbooks/runs/${testRun.id}`);
|
||||
|
||||
// * Assert that the link is not present
|
||||
cy.findByTestId('run-statusupdate-section').findByText('View all updates').should('not.exist');
|
||||
});
|
||||
@ -125,22 +125,26 @@ describe('runs > run details page > status update', {testIsolation: true}, () =>
|
||||
});
|
||||
});
|
||||
|
||||
cy.apiLogin(testViewerUser).then(() => {
|
||||
// # Click View all updates link
|
||||
cy.findByTestId('run-statusupdate-section').findByText('View all updates').click();
|
||||
// * Log in as viewer user
|
||||
cy.apiLogin(testViewerUser);
|
||||
|
||||
// * Assert RHS is open and have the correct title/subtitle
|
||||
getRHS().should('be.visible');
|
||||
getRHS().findByTestId('rhs-title').contains('Status updates');
|
||||
getRHS().findByTestId('rhs-subtitle').contains(testRun.name);
|
||||
// * Browse to test run
|
||||
cy.visit(`/playbooks/runs/${testRun.id}`);
|
||||
|
||||
// * Assert that we have both updates in reverse order
|
||||
getStatusUpdates().should('have.length', 2);
|
||||
getStatusUpdates().eq(0).contains('message 2');
|
||||
getStatusUpdates().eq(0).contains(testUser.username);
|
||||
getStatusUpdates().eq(1).contains('message 1');
|
||||
getStatusUpdates().eq(1).contains(testUser.username);
|
||||
});
|
||||
// # Click View all updates link
|
||||
cy.findByTestId('run-statusupdate-section').findByText('View all updates').click();
|
||||
|
||||
// * Assert RHS is open and have the correct title/subtitle
|
||||
getRHS().should('be.visible');
|
||||
getRHS().findByTestId('rhs-title').contains('Status updates');
|
||||
getRHS().findByTestId('rhs-subtitle').contains(testRun.name);
|
||||
|
||||
// * Assert that we have both updates in reverse order
|
||||
getStatusUpdates().should('have.length', 2);
|
||||
getStatusUpdates().eq(0).contains('message 2');
|
||||
getStatusUpdates().eq(0).contains(testUser.username);
|
||||
getStatusUpdates().eq(1).contains('message 1');
|
||||
getStatusUpdates().eq(1).contains(testUser.username);
|
||||
});
|
||||
});
|
||||
});
|
||||
|
@ -80,31 +80,7 @@ describe('Task Inbox >', {testIsolation: true}, () => {
|
||||
|
||||
const getRHS = () => cy.get('#playbooks-backstage-sidebar-right');
|
||||
|
||||
it('icon in global header, with experimental feature flag', () => {
|
||||
// # Enable experimental feature flag
|
||||
cy.apiAdminLogin().then(() => {
|
||||
cy.apiEnsureFeatureFlag('enableexperimentalfeatures', true);
|
||||
|
||||
// # Login as testUser
|
||||
cy.apiLogin(testUser);
|
||||
});
|
||||
|
||||
// # Visit the playbooks product
|
||||
cy.visit('/playbooks');
|
||||
|
||||
// # Verify icon present in global header icon to open
|
||||
cy.findByTestId('header-task-inbox-icon').click();
|
||||
});
|
||||
|
||||
it('icon in global header, without experimental feature flag', () => {
|
||||
// # Disable experimental feature flag
|
||||
cy.apiAdminLogin().then(() => {
|
||||
cy.apiEnsureFeatureFlag('enableexperimentalfeatures', false);
|
||||
|
||||
// # Login as testUser
|
||||
cy.apiLogin(testUser);
|
||||
});
|
||||
|
||||
it('icon in global header', () => {
|
||||
// # Visit the playbooks product
|
||||
cy.visit('/playbooks');
|
||||
|
||||
|
@ -260,7 +260,7 @@ Cypress.Commands.add('apiCreateUser', ({
|
||||
cy.apiSaveDraftsTourTipPreference(createdUser.id, true);
|
||||
|
||||
if (bypassTutorial) {
|
||||
cy.apiSaveTutorialStep(createdUser.id, '999');
|
||||
cy.apiDisableTutorials(createdUser.id);
|
||||
}
|
||||
|
||||
if (hideActionsMenu) {
|
||||
|
@ -6,10 +6,11 @@ import {useIntl} from 'react-intl';
|
||||
import styled from 'styled-components';
|
||||
import {AccountPlusOutlineIcon} from '@mattermost/compass-icons/components';
|
||||
import {useDispatch, useSelector} from 'react-redux';
|
||||
import {getProfilesByIds} from 'mattermost-redux/actions/users';
|
||||
import {getMissingProfilesByIds} from 'mattermost-redux/actions/users';
|
||||
import {UserProfile} from '@mattermost/types/users';
|
||||
import {sortByUsername} from 'mattermost-redux/utils/user_utils';
|
||||
import {getCurrentUser} from 'mattermost-redux/selectors/entities/users';
|
||||
import {getUser} from 'mattermost-redux/selectors/entities/users';
|
||||
import {GlobalState} from '@mattermost/types/store';
|
||||
|
||||
import Profile from 'src/components/profile/profile';
|
||||
import Tooltip from 'src/components/widgets/tooltip';
|
||||
@ -44,8 +45,6 @@ export const Participants = ({playbookRun, role, teamName}: Props) => {
|
||||
const {formatMessage} = useIntl();
|
||||
const [manageMode, setManageMode] = useState(false);
|
||||
const [searchTerm, setSearchTerm] = useState('');
|
||||
const myUser = useSelector(getCurrentUser);
|
||||
const [participantsProfiles, setParticipantsProfiles] = useState<UserProfile[]>([]);
|
||||
const [showAddParticipantsModal, setShowAddParticipantsModal] = useState(false);
|
||||
|
||||
const {removeFromRun, changeRunOwner} = useManageRunMembership(playbookRun.id);
|
||||
@ -55,19 +54,14 @@ export const Participants = ({playbookRun, role, teamName}: Props) => {
|
||||
return removeFromRun(userIDs);
|
||||
};
|
||||
|
||||
useEffect(() => {
|
||||
const profiles = dispatch(getProfilesByIds(playbookRun.participant_ids));
|
||||
const participantsProfiles = useSelector((state: GlobalState) => {
|
||||
const profiles = playbookRun.participant_ids.map((id) => getUser(state, id));
|
||||
return profiles.sort(sortByUsername);
|
||||
});
|
||||
|
||||
//@ts-ignore
|
||||
profiles.then(({data}: { data: UserProfile[] }) => {
|
||||
// getProfilesByIds doesn't return current user profile, so add it when a user is participant
|
||||
if (role === Role.Participant) {
|
||||
data.push(myUser);
|
||||
}
|
||||
data.sort(sortByUsername);
|
||||
setParticipantsProfiles(data || []);
|
||||
});
|
||||
}, [dispatch, myUser, playbookRun.participant_ids, role]);
|
||||
useEffect(() => {
|
||||
dispatch(getMissingProfilesByIds(playbookRun.participant_ids));
|
||||
}, [dispatch, playbookRun.participant_ids]);
|
||||
|
||||
const includesTerm = (user: UserProfile) => {
|
||||
const userInfo = user.first_name + ';' + user.last_name + ';' + user.nickname + ';' + user.username;
|
||||
|
Loading…
Reference in New Issue
Block a user