Этот коммит содержится в:
Mario Vitale
2023-03-27 16:28:42 +02:00
родитель da7a6825ce
Коммит ba6b97fb62
1142 изменённых файлов: 44 добавлений и 44 удалений

Просмотреть файл

@@ -0,0 +1,49 @@
// 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.
// ***************************************************************
import * as TIMEOUTS from '../../../fixtures/timeouts';
import {getRandomId} from '../../../utils';
export function visitTownSquareAndWaitForPageToLoad() {
// # Click town-square at LHS and wait for post list to load
cy.get('#sidebarItem_town-square').should('be.visible').click();
cy.get('#channelHeaderTitle').should('be.visible').and('have.text', 'Town Square');
cy.findAllByTestId('postView').should('be.visible');
}
export function scrollUpAndPostAMessage(sender, channelId, nTimes = 1) {
scrollUp();
// # Post number of messages
const randomId = getRandomId();
Cypress._.times(nTimes, (num) => {
cy.postMessageAs({sender, message: `${num} ${randomId}`, channelId});
});
}
export function scrollDown() {
// # Scroll down
cy.get('div.post-list__dynamic').should('be.visible').
scrollTo('bottom', {duration: TIMEOUTS.ONE_SEC}).
wait(TIMEOUTS.ONE_SEC);
}
export function scrollUp() {
// # Scroll up so bottom is not visible
cy.get('div.post-list__dynamic').should('be.visible').
scrollTo(0, '70%', {duration: TIMEOUTS.ONE_SEC}).
wait(TIMEOUTS.ONE_SEC);
}
export function scrollToTop() {
// # Scroll up so bottom is not visible
cy.get('div.post-list__dynamic').should('be.visible').
scrollTo(0, 0, {duration: TIMEOUTS.ONE_SEC}).
wait(TIMEOUTS.ONE_SEC);
}

Просмотреть файл

@@ -0,0 +1,193 @@
// 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: @channels @toast
import {getRandomId} from '../../../utils';
import * as TIMEOUTS from '../../../fixtures/timeouts';
import {
scrollDown,
scrollUp,
scrollUpAndPostAMessage,
} from './helpers';
describe('Toast', () => {
let otherUser;
let testTeam;
let testChannelId;
let testChannelName;
before(() => {
// # Create other user
cy.apiCreateUser().then(({user}) => {
otherUser = user;
});
// # Build data to test and login as testUser
cy.apiInitSetup().then(({team, channel, user, channelUrl}) => {
testTeam = team;
testChannelId = channel.id;
testChannelName = channel.name;
cy.apiAddUserToTeam(testTeam.id, otherUser.id).then(() => {
cy.apiAddUserToChannel(testChannelId, otherUser.id).then(() => {
cy.apiLogin(user);
cy.visit(channelUrl);
});
});
});
});
beforeEach(() => {
// # Click on test channel then off-topic channel in LHS
cy.uiClickSidebarItem(testChannelName);
cy.postMessage('This is Testing');
cy.uiClickSidebarItem('off-topic');
});
it('MM-T1784_1 should see a toast with Jump to recent messages button', () => {
// # Have a channel with more than a page of unread messages (have another user post around 30 messages)
const randomId = getRandomId();
const numberOfPost = 30;
Cypress._.times(numberOfPost, (num) => {
cy.postMessageAs({sender: otherUser, message: `${num} ${randomId}`, channelId: testChannelId});
});
cy.wait(TIMEOUTS.ONE_SEC);
// # Switch to the channel
cy.uiClickSidebarItem(testChannelName);
// * Toast should be visible with jump to recent messages button
cy.get('div.toast').should('be.visible');
cy.get('div.toast__jump').should('be.visible');
// * Check that the message is correct
cy.get('div.toast__message>span').should('be.visible').first().contains(`${numberOfPost} new messages`);
scrollDown();
// * Should hide the scroll to new message button as it is at the bottom
cy.get('div.toast__jump').should('not.exist');
// * As time elapsed the toast should be hidden
cy.get('div.toast').should('not.exist');
});
it('MM-T1784_2 should see a toast with number of unread messages in the toast if the bottom is not in view', () => {
// # Switch to the test channel
cy.uiClickSidebarItem(testChannelName);
// # Scroll up and have another user post couple of messages
const numberOfPost = 2;
scrollUpAndPostAMessage(otherUser, testChannelId, numberOfPost);
// * Toast should be visible with correct message
cy.get('div.toast').should('be.visible');
cy.get('div.toast__message>span').should('be.visible').first().contains(`${numberOfPost} new messages`);
});
it('MM-T1784_3 should show the mobile view version of the toast', () => {
cy.uiClickSidebarItem(testChannelName);
const numberOfPost = 2;
scrollUpAndPostAMessage(otherUser, testChannelId, numberOfPost);
// * Verify toast on desktop view
cy.get('div.toast').should('be.visible');
cy.get('.toast__visible').should('be.visible').within(() => {
cy.get('.toast__jump').findAllByLabelText('Down Arrow Icon').should('be.visible');
cy.findByText('Jump to new messages').should('be.visible');
cy.get('.toast__message>span').should('be.visible').first().contains(`${numberOfPost} new messages today`).find('time').should('be.visible');
cy.get('#dismissToast').should('be.visible');
});
// * Verify toast on mobile view
cy.viewport('iphone-6');
cy.get('.toast__visible').should('be.visible').within(() => {
cy.get('.toast__jump').findAllByLabelText('Down Arrow Icon').should('be.visible');
cy.findByText('Jump to new messages').should('not.exist');
cy.get('.toast__message>span').should('be.visible').first().contains(`${numberOfPost} new messages`).find('time').should('not.exist');
cy.get('#dismissToast').should('be.visible');
});
});
it('MM-T1784_4 marking a channel as unread should reappear new message toast', () => {
cy.uiClickSidebarItem(testChannelName);
cy.get('div.toast').should('not.exist');
// # Scroll up so bottom is not visible
scrollUp();
const oldPostNumber = 28;
cy.getNthPostId(-oldPostNumber).then((postId) => {
// # Mark post as unread
cy.uiClickPostDropdownMenu(postId, 'Mark as Unread');
// # Visit another channel and come back to the same channel again
cy.uiClickSidebarItem('off-topic');
cy.get('div.post-list__dynamic').should('be.visible');
cy.uiClickSidebarItem(testChannelName);
// # Scroll up so bottom is not visible
scrollUp();
// # New message toast is present with expected number of messages
cy.get('div.toast').should('be.visible');
cy.get('div.toast__message>span').should('be.visible').first().contains(`${oldPostNumber} new messages today`);
const randomId = getRandomId();
Cypress._.times(2, (num) => {
cy.postMessageAs({sender: otherUser, message: `${num} ${randomId}`, channelId: testChannelId});
// * Count increments as new messages are posted
cy.get('div.toast__message>span').should('be.visible').first().contains(`${oldPostNumber + num + 1} new messages today`);
});
});
});
it('MM-T1786 Dismissing the toast using Jump to', () => {
// # Have a channel with more than a page of unread messages (have another user post around 30 messages)
const randomId = getRandomId();
const numberOfPost = 30;
Cypress._.times(numberOfPost, (num) => {
cy.postMessageAs({sender: otherUser, message: `${num} ${randomId}`, channelId: testChannelId});
});
// # Switch to the channel
cy.uiClickSidebarItem(testChannelName);
// * Verify toast is visible with jump to recent messages button
cy.get('div.toast').should('be.visible');
cy.get('div.toast').findByText('Jump to recents').should('be.visible').click();
// * Verify toast is not visible
cy.get('div.toast__jump').should('not.exist');
// # Scroll up on the channel
scrollUp();
Cypress._.times(2, (num) => {
// # Post messages as otherUser
cy.postMessageAs({sender: otherUser, message: `${num} ${randomId}`, channelId: testChannelId});
});
// * Toast should be visible with jump to new messages button
cy.get('div.toast').should('be.visible');
cy.get('div.toast').findByText('Jump to new messages').should('be.visible');
// # Scroll down to the bottom to read all messages
scrollDown();
// * Verify toast is not visible
cy.get('div.toast').should('not.exist');
});
});

Просмотреть файл

@@ -0,0 +1,49 @@
// 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: @channels @toast
describe('Toast', () => {
let testChannelDisplayName;
let testChannelUrl;
before(() => {
// # Create new team and new user
cy.apiInitSetup({loginAfter: true}).then(({channel, channelUrl}) => {
testChannelDisplayName = channel.display_name;
testChannelUrl = channelUrl;
cy.visit(testChannelUrl);
});
});
it('MM-T1791 Permalink \'Jump to\' in Search', () => {
// # Search for a term e.g.test
const searchTerm = 'test';
cy.postMessage(searchTerm);
cy.uiGetSearchBox().type(searchTerm).type('{enter}');
// # Click on Jump to link in search results
cy.get('.search-item__jump').first().click();
cy.getLastPostId().then((postId) => {
// # Jump to link opens on main channel view
cy.url().should('include', `${testChannelUrl}/${postId}`);
cy.get('#channelHeaderInfo').should('be.visible').and('contain', testChannelDisplayName);
// # Post is highlighted then fades out.
cy.get(`#post_${postId}`).should('have.class', 'post--highlight');
cy.get(`#post_${postId}`).should('not.have.class', 'post--highlight');
// # URL changes to channel url
cy.url().should('include', testChannelUrl).and('not.include', postId);
});
});
});

Просмотреть файл

@@ -0,0 +1,57 @@
// 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: @channels @toast
describe('Toast', () => {
let testTeam;
before(() => {
cy.apiInitSetup({loginAfer: true}).then(({team, offTopicUrl}) => {
testTeam = team;
cy.visit(offTopicUrl);
});
});
it('MM-T1792 Permalink post', () => {
// # Add a message to the channel
cy.postMessage('test');
cy.getLastPostId().then((id) => {
const permalink = `${Cypress.config('baseUrl')}/${testTeam.name}/pl/${id}`;
// # Check if ... button is visible in last post right side
cy.get(`#CENTER_button_${id}`).should('not.be.visible');
// # Click on ... button of last post
cy.clickPostDotMenu(id);
// * Click on "Copy Link" and verify the permalink in clipboard is same as we formed
cy.uiClickCopyLink(permalink, id);
// # post the permalink in the channel
cy.postMessage(permalink);
// # Click on permalink
cy.getLastPost().get('.post-message__text a').last().scrollIntoView().click();
// * check the URL should be changed to permalink post
cy.url().should('include', `/${testTeam.name}/channels/off-topic/${id}`);
// * Post is highlighted then fades out
cy.get(`#post_${id}`).should('have.class', 'post--highlight');
cy.get(`#post_${id}`).should('not.have.class', 'post--highlight');
// * URL changes to channel url
cy.url().should('include', `/${testTeam.name}/channels/off-topic`).and('not.include', id);
});
});
});

Просмотреть файл

@@ -0,0 +1,94 @@
// 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: @channels @toast
import {getRandomId} from '../../../utils';
describe('Toast', () => {
let testTeam;
let otherUser;
let testChannelId;
let testChannelUrl;
let postIdToJumpTo;
const numberOfPosts = 30;
before(() => {
cy.apiCreateUser().then(({user}) => {
otherUser = user;
});
cy.apiInitSetup().then(({team, channel, user, channelUrl}) => {
testTeam = team;
testChannelId = channel.id;
testChannelUrl = channelUrl;
cy.apiAddUserToTeam(testTeam.id, otherUser.id).then(() => {
cy.apiAddUserToChannel(testChannelId, otherUser.id);
cy.apiLogin(user);
cy.visit(testChannelUrl);
});
});
});
it('MM-T1794 Permalink post view combined with New Message toast', () => {
// # Post 30 random messages from the 'otherUser' account in test channel
Cypress._.times(numberOfPosts, (num) => {
if (num === 2) {
cy.getLastPostId().then((postId) => {
postIdToJumpTo = postId;
});
}
cy.postMessageAs({sender: otherUser, message: `${num} ${getRandomId()}`, channelId: testChannelId});
});
cy.getLastPostId().then((id) => {
const permalink = `${Cypress.config('baseUrl')}/${testTeam.name}/pl/${id}`;
// * Check that the ... button is not visible in last post right side
cy.get(`#CENTER_button_${id}`).should('not.be.visible');
// # Click on ... button of last post
cy.clickPostDotMenu(id);
// * Click on "Copy Link" and verify the permalink in clipboard is same as we formed
cy.uiClickCopyLink(permalink, id);
// # Post the permalink in the channel
cy.postMessage(permalink);
// # Click on permalink
cy.getLastPost().get('.post-message__text a').last().scrollIntoView().click();
// * check the URL should be changed to permalink post
cy.url().should('include', `${testChannelUrl}/${id}`);
// # Scroll to the second post in the channel so that the 'Jump to New Messages' button would be visible
cy.get(`#postMessageText_${postIdToJumpTo}`).scrollIntoView();
// # Post two new messages as 'otherUser'
cy.postMessageAs({sender: otherUser, message: 'Random Message', channelId: testChannelId});
cy.postMessageAs({sender: otherUser, message: 'Last Message', channelId: testChannelId});
// * Verify that the last message is currently not visible
cy.findByText('Last Message').should('not.be.visible');
// # Click on the 'Jump to New Messages' button
cy.get('.toast__visible').should('be.visible').click();
// * Verify that the last message is now visible
cy.findByText('Last Message').should('be.visible');
// * Verify that the URL changes to the channel url
cy.url().should('include', testChannelUrl).and('not.include', id);
});
});
});

Просмотреть файл

@@ -0,0 +1,397 @@
// 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.
// ***************************************************************
// Group: @channels @toast
import * as TIMEOUTS from '../../../fixtures/timeouts';
import {
scrollDown,
scrollUp,
scrollUpAndPostAMessage,
} from './helpers';
describe('toasts', () => {
let otherUser;
let testTeam;
let testChannelId;
let testChannelName;
let otherChannel;
before(() => {
// # Create other user
cy.apiCreateUser().then(({user}) => {
otherUser = user;
});
// # Build data to test and login as testUser
cy.apiInitSetup().then(({team, channel, user, channelUrl}) => {
testTeam = team;
otherChannel = channel;
testChannelName = channel.name;
testChannelId = channel.id;
cy.apiAddUserToTeam(testTeam.id, otherUser.id).then(() => {
cy.apiAddUserToChannel(testChannelId, otherUser.id).then(() => {
cy.apiLogin(user);
cy.visit(channelUrl);
});
});
});
});
beforeEach(() => {
// # Click on test channel then off-topic channel in LHS
cy.uiClickSidebarItem(testChannelName);
cy.uiClickSidebarItem('off-topic');
});
it('Unread messages toast is shown when visiting a channel with unreads and should disappear if scrolled to bottom', () => {
// # Add enough messages
for (let index = 0; index < 30; index++) {
cy.postMessageAs({sender: otherUser, message: `This is an old message [${index}]`, channelId: testChannelId});
}
cy.uiClickSidebarItem(testChannelName);
// * Verify the toast is visible with correct message
cy.get('div.toast').should('be.visible').contains('30 new messages');
// # Scroll to the bottom
scrollDown();
// * Verify toast jump is not visible
cy.get('div.toast__jump').should('not.exist');
// * Verify toast is not visible
cy.get('div.toast').should('not.exist');
});
it('Should show new message indicator when posts arrive and user is not at bottom', () => {
cy.uiClickSidebarItem(testChannelName);
scrollUpAndPostAMessage(otherUser, testChannelId);
// * Verify the toast is visible with correct message
cy.get('div.toast').should('be.visible').contains('1 new message');
});
it('New message toast should not have action button when at bottom and hide toast in a sec', () => {
cy.uiClickSidebarItem(testChannelName);
scrollUpAndPostAMessage(otherUser, testChannelId);
// * Verify the toast is visible
cy.get('div.toast').should('be.visible');
// # Scroll to the bottom
scrollDown();
// * Verify toast jump is not visible
cy.get('div.toast__jump').should('not.exist');
// * Verify toast is not visible
cy.get('div.toast').should('not.exist');
});
it('New message toast should take to new messages line when clicked', () => {
cy.uiClickSidebarItem(testChannelName);
// # Scroll up so bottom is not visible
scrollUp();
// # Post few new message
for (let index = 0; index < 4; index++) {
cy.postMessageAs({sender: otherUser, message: `This is a new message [${index}]`, channelId: testChannelId});
}
// * Verify the new messages line is not visible
cy.get('.NotificationSeparator').should('not.exist');
// # Click on toast pointer
cy.get('div.toast__visible div.toast__pointer').should('be.visible').click();
// * Verify the new messages line is visible
cy.get('.NotificationSeparator').should('be.visible');
});
it('Unread messages toast should take to bottom when clicked', () => {
cy.uiClickSidebarItem(testChannelName);
// # Scroll up so bottom is not visible
scrollUp();
// # Add enough messages
for (let index = 0; index < 10; index++) {
cy.postMessageAs({sender: otherUser, message: `This is a message for checking action on toast [${index}]`, channelId: testChannelId});
}
// * Verify the toast is visible
cy.get('div.toast').should('be.visible');
// # Click on toast pointer
cy.get('div.toast__visible div.toast__pointer').should('be.visible').click();
// * Verify last posted message is in view
cy.getLastPostId().then((postId) => {
cy.get(`#postMessageText_${postId} > p`).should('be.visible').contains('This is a message for checking action on toast [9]');
});
});
it('New message toast should be removed on clicking remove button', () => {
cy.uiClickSidebarItem(testChannelName);
scrollUpAndPostAMessage(otherUser, testChannelId);
// * Verify the toast is visible
cy.get('div.toast').should('be.visible');
// # Click on toast dismiss button to close the toast
cy.findByTestId('dismissToast').should('be.visible').click();
// * Verify the toast is not visible
cy.get('div.toast').should('not.exist');
});
it('Recurring visit to a channel with unreads should have unread toast', () => {
cy.uiClickSidebarItem(testChannelName);
// # Scroll up so bottom is not visible
scrollUp();
// # Click on sidebar off-topic link
cy.get('#sidebarItem_off-topic').should('be.visible').scrollIntoView().click();
// # Add enough messages
for (let index = 0; index < 40; index++) {
cy.postMessageAs({sender: otherUser, message: `This is a new message [${index}]`, channelId: testChannelId});
}
// # Go back
cy.go('back');
// # Scroll up so bottom is not visible
scrollUp();
// * Verify the toast is visible
cy.get('div.toast').should('be.visible');
// # Click on toast dismiss button to close the toast
cy.findByTestId('dismissToast').should('be.visible').click();
// * Verify the toast is not visible
cy.get('div.toast').should('not.exist');
});
it('New message count should increase with incoming messages', () => {
cy.uiClickSidebarItem(testChannelName);
scrollUpAndPostAMessage(otherUser, testChannelId);
// * Verify the toasts are visible with correct messages
cy.get('div.toast').should('be.visible').contains('1 new message');
cy.postMessageAs({sender: otherUser, message: 'This is another new message', channelId: testChannelId}).then(() => {
cy.get('div.toast').should('be.visible').contains('2 new message');
});
});
it('New message count should reset when dismissed', () => {
cy.uiClickSidebarItem(testChannelName);
scrollUpAndPostAMessage(otherUser, testChannelId);
// * Verify the toast is visible with correct message
cy.get('div.toast').should('be.visible').contains('1 new message');
// # Click on toast dismiss button to close the toast
cy.findByTestId('dismissToast').should('be.visible').click();
// * Verify the toast is not visible
cy.get('div.toast').should('not.exist');
// # Post a new message
cy.postMessageAs({sender: otherUser, message: 'This is another new message', channelId: testChannelId}).then(() => {
// * Verify the toast is visible with correct message
cy.get('div.toast').should('be.visible').contains('1 new message');
});
});
it('Marking channel as unread should make unread toast appear', () => {
cy.uiClickSidebarItem(testChannelName);
// # Scroll up so bottom is not visible
scrollUp();
cy.getNthPostId(40).then((postId) => {
// # Mark post as unread
cy.uiClickPostDropdownMenu(postId, 'Mark as Unread');
// # Visit another channel and come back to the same channel again
cy.uiClickSidebarItem('off-topic');
cy.get('div.post-list__dynamic').should('be.visible');
cy.uiClickSidebarItem(testChannelName);
// # Scroll up so bottom is not visible
scrollUp();
// * Verify toast is visible with correct message
cy.get('div.toast').should('be.visible').contains('new messages today');
});
});
it('New message line should move if user is scrolled up and new messages arrive', () => {
cy.uiClickSidebarItem(testChannelName);
// # Scroll to the bottom
scrollDown();
// # Post a new message
cy.postMessageAs({sender: otherUser, message: 'post1', channelId: testChannelId}).then(() => {
// * Verify the new messages line should appear above the last post
cy.get('.NotificationSeparator').should('exist').parent().parent().parent().next().should('contain', 'post1');
// # Scroll up so bottom is not visible
scrollUp();
// * Verify the new messages line should have moved to the last post
cy.postMessageAs({sender: otherUser, message: 'post2', channelId: testChannelId}).then(() => {
cy.get('.NotificationSeparator').parent().parent().parent().next().should('contain', 'post2');
});
});
});
it('Archive toast is not shown when visiting a permalink at the bottom', () => {
// # Add one message
cy.postMessageAs({sender: otherUser, message: 'This is a message for permalink', channelId: testChannelId}).then(({id}) => {
cy.uiClickSidebarItem(testChannelName);
// # Visit permalink
cy.visit(`/${testTeam.name}/pl/${id}`);
cy.findAllByTestId('postView').should('be.visible');
// * Verify toast is not visible
cy.get('div.toast').should('not.exist');
});
});
it('Archive toast should be shown when visiting a post which is not at bottom', () => {
// # Create new channel and add other user to channel
cy.apiCreateChannel(testTeam.id, 'channel-test', 'Channel').then(({channel}) => {
const otherChannelId = channel.id;
cy.apiAddUserToChannel(otherChannelId, otherUser.id);
// # Add one message
cy.postMessageAs({sender: otherUser, message: 'This is a message for permalink', channelId: otherChannelId}).then(({id}) => {
cy.uiClickSidebarItem(testChannelName);
// # Add 25 posts to create enough space from bottom for showing archive toast
for (let index = 0; index < 25; index++) {
cy.postMessageAs({sender: otherUser, message: `# This is an old message [${index}]`, channelId: otherChannelId});
}
// # Visit permalink
cy.visit(`/${testTeam.name}/pl/${id}`);
cy.findAllByTestId('postView').should('be.visible');
// * Verify toast is visible with correct message
cy.get('div.toast').should('be.visible').contains('Viewing message history');
});
});
});
it('MM-T1787 Toast does not appear when all new messages are visible without scrolling down', () => {
// # Go to other channel
cy.get(`#sidebarItem_${otherChannel.name}`).should('be.visible').click();
// # Add enough messages to test channel
for (let index = 0; index < 30; index++) {
cy.postMessageAs({sender: otherUser, message: `This is an old message [${index}]`, channelId: testChannelId});
}
// # Visit test channel and read all messages
cy.uiClickSidebarItem(testChannelName);
cy.get('div.post-list__dynamic').should('be.visible').scrollTo('bottom', {duration: TIMEOUTS.ONE_SEC});
// # Visit other channel
cy.uiClickSidebarItem(otherChannel.name);
// # Add less number of messages to town square channel
cy.postMessageAs({sender: otherUser, message: 'This is an new message 1', channelId: testChannelId});
cy.postMessageAs({sender: otherUser, message: 'This is an new message 2', channelId: testChannelId});
// # Visit town square channel
cy.uiClickSidebarItem(testChannelName);
// * Assert toast should not be present as the messages are visible without scrolling down
cy.get('div.toast').should('not.exist');
// # Move to the top of the channel
Cypress._.times(3, () => {
cy.get('div.post-list__dynamic').should('be.visible').scrollTo('top', {duration: TIMEOUTS.ONE_SEC}).wait(TIMEOUTS.ONE_SEC);
});
// * Verify that test channel is loaded
cy.get('#channelIntro').contains('Beginning of');
// * Assert toast should not be present as the messages are already read
cy.get('div.toast').should('not.exist');
});
it('MM-T1785 Toast - When marking post as unread', () => {
cy.uiClickSidebarItem(testChannelName);
// # Add 30 posts to create enough space from bottom for making channel scrollable
for (let index = 0; index < 30; index++) {
cy.postMessageAs({sender: otherUser, message: `This is an old message [${index}]`, channelId: testChannelId});
}
cy.getNthPostId(2).then((postId) => {
// # Mark post as unread
cy.uiClickPostDropdownMenu(postId, 'Mark as Unread');
});
// * Verify toast is visible with correct message
cy.get('div.toast').should('be.visible').contains('new messages');
// # Move to the channel bottom
cy.get('div.post-list__dynamic').should('be.visible').scrollTo('bottom', {duration: TIMEOUTS.ONE_SEC});
// # Move to the second last message in the channel and mark as unread
cy.getNthPostId(-2).then((postId) => {
// # Mark post as unread
cy.uiClickPostDropdownMenu(postId, 'Mark as Unread');
});
// * Verify toast is not visible
cy.get('div.toast').should('not.exist');
// # Reload to remove new messages line
cy.reload();
});
it('MM-T1788 Toast count', () => {
// # Visit other channel
cy.uiClickSidebarItem(otherChannel.name);
// # Add 25 posts to create enough space from bottom for showing archive toast
for (let index = 0; index < 25; index++) {
cy.postMessageAs({sender: otherUser, message: `This is an old message [${index}]`, channelId: testChannelId});
}
cy.uiClickSidebarItem(testChannelName);
// * Verify toast is visible with correct message
cy.get('div.toast').should('be.visible').contains('25 new messages');
const initialCount = 25;
// # Add 10 messages to channel and check the toast count increases
Cypress._.times(10, (num) => {
cy.postMessageAs({sender: otherUser, message: `This is an old message [${initialCount + num}]`, channelId: testChannelId});
// * Verify toast is visible with correct message
cy.get('div.toast').should('be.visible').contains(`${initialCount + num + 1} new messages`);
});
});
});

Просмотреть файл

@@ -0,0 +1,145 @@
// 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: @channels @toast
import * as TIMEOUTS from '../../../fixtures/timeouts';
import {scrollToTop} from './helpers';
describe('unread_with_bottom_start_toast', () => {
let otherUser;
let testTeam;
before(() => {
// # Create other user
cy.apiCreateUser().then(({user}) => {
otherUser = user;
});
// # Build data to test and login as testUser
cy.apiInitSetup().then(({team, user}) => {
testTeam = team;
cy.apiAddUserToTeam(testTeam.id, otherUser.id);
cy.apiLogin(user);
cy.apiSaveUnreadScrollPositionPreference(user.id, 'start_from_newest');
});
});
it('MM-T4873_1 Unread with bottom start toast is shown when visiting a channel with unreads and should disappear if scrolled to new messages indicator', () => {
cy.apiCreateChannel(testTeam.id, 'channel-a', 'ChannelA').then(({channel}) => {
cy.apiAddUserToChannel(channel.id, otherUser.id).then(() => {
cy.visit(`/${testTeam.name}/channels/${channel.name}`);
cy.uiClickSidebarItem('off-topic');
cy.postMessage('hi');
// # Add enough messages
for (let index = 0; index < 30; index++) {
cy.postMessageAs({sender: otherUser, message: `test message ${index}`, channelId: channel.id});
}
cy.postMessage('hello');
// # Switch to test channel
cy.uiClickSidebarItem(channel.name).wait(TIMEOUTS.HALF_SEC);
// * Verify the newest message is visible
cy.get('div.post__content').contains('test message 29').should('be.visible');
// * Verify the toast is visible with correct message
cy.get('div.toast').should('be.visible').contains('30 new messages');
// # Scroll to the new messages indicator
cy.get('.NotificationSeparator').should('exist').scrollIntoView({offset: {top: -150}});
// * Verify toast jump is not visible
cy.get('div.toast__jump').should('not.exist');
// * Verify toast is not visible
cy.get('div.toast').should('not.exist');
});
});
});
it('MM-T4873_2 Unread with bottom start toast should take to the new messages indicator when clicked', () => {
cy.apiCreateChannel(testTeam.id, 'channel-b', 'ChannelB').then(({channel}) => {
cy.apiAddUserToChannel(channel.id, otherUser.id).then(() => {
cy.visit(`/${testTeam.name}/channels/${channel.name}`);
cy.uiClickSidebarItem('off-topic');
cy.postMessage('hi');
// # Add enough messages
for (let index = 0; index < 30; index++) {
cy.postMessageAs({sender: otherUser, message: `test message ${index}`, channelId: channel.id});
}
cy.postMessage('hello');
// # Visit test channel
cy.uiClickSidebarItem(channel.name).wait(TIMEOUTS.HALF_SEC);
// * Verify the toast is visible with correct message
cy.get('div.toast').should('be.visible').contains('30 new messages');
// # Click on toast pointer
cy.get('div.toast__visible div.toast__pointer').should('be.visible').click();
// * Verify toast jump is not visible
cy.get('div.toast__jump').should('not.exist');
// * Verify toast is not visible
cy.get('div.toast').should('not.exist');
// * Verify new messages indicator is visible
cy.get('.NotificationSeparator').should('be.visible');
});
});
});
it('MM-T4873_3 Unread with bottom start toast is shown when post is marked as unread', () => {
cy.apiCreateChannel(testTeam.id, 'channel-c', 'ChannelC').then(({channel}) => {
cy.apiAddUserToChannel(channel.id, otherUser.id).then(() => {
cy.visit(`/${testTeam.name}/channels/${channel.name}`);
// # Add enough messages
for (let index = 0; index < 30; index++) {
cy.postMessageAs({sender: otherUser, message: `test message ${index}`, channelId: channel.id});
}
cy.wait(TIMEOUTS.ONE_SEC);
// # Scroll to the top to find the oldest message
scrollToTop();
cy.getNthPostId(1).then((postId) => {
// # Mark post as unread
cy.uiClickPostDropdownMenu(postId, 'Mark as Unread');
});
// # Visit off-topic channel and switch back to test channel
cy.uiClickSidebarItem('off-topic');
cy.uiClickSidebarItem(channel.name);
// * Verify toast is visible
cy.get('div.toast').should('be.visible').contains('30 new messages');
// # Click on toast pointer
cy.get('div.toast__visible div.toast__pointer').should('be.visible').click();
// * Verify unread marked post is visible
cy.get('div.post__content').contains('test message 0').should('be.visible');
// * Verify new messages indicator is visible
cy.get('.NotificationSeparator').should('be.visible');
});
});
});
});