Files
upstream-mattermost/e2e-tests/cypress/tests/integration/channels/scroll/channel_scroll_spec.js
upstream-mirror 240db4e2a7
Some checks failed
Server CI / Postgres (shard 0) (push) Has been skipped
Server CI / Postgres (shard 3) (push) Has been skipped
BuildEnv Docker Image / build-image (push) Failing after 4s
BuildEnv Docker Image / build-image-fips (push) Failing after 4s
Migration Review & Release Notes / Generate migration review & release notes (push) Failing after 3s
Server CI / Build Environment (push) Failing after 3s
Server CI / Postgres (shard 1) (push) Has been skipped
Tools CI / check-style (mattermost-govet) (push) Failing after 4s
Server CI / Postgres (shard 2) (push) Has been skipped
Tools CI / check-style (mmgotool) (push) Failing after 3s
Server CI / Elasticsearch v8 Compatibility (push) Has been skipped
Server CI / OpenSearch v2 Compatibility (push) Has been skipped
Server CI / Postgres FIPS (shard 0) (push) Has been skipped
Tools CI / Test (mattermost-govet) (push) Failing after 3s
Server CI / Postgres FIPS (shard 1) (push) Has been skipped
Server CI / Postgres FIPS (shard 2) (push) Has been skipped
Tools CI / Test (mmgotool) (push) Failing after 3s
Server CI / Postgres FIPS (shard 3) (push) Has been skipped
Server CI / Run mmctl tests (push) Has been skipped
Server CI / Run mmctl tests (FIPS) (push) Has been skipped
Server CI / Merge Postgres Test Results (push) Has been skipped
Server CI / Merge Postgres FIPS Test Results (push) Has been skipped
Server CI / Check backport migrations (push) Has been skipped
Server CI / Check generated files (push) Has been skipped
Server CI / check-style (push) Has been skipped
Server CI / Vet API (push) Has been skipped
Server CI / Build mattermost server app (push) Has been skipped
Server CI / Server CI Complete (push) Failing after 2s
Server CI / Server CI Artifacts (push) Has been skipped
Server CI / Sentry Upload (push) Has been skipped
Server CI / Server CI Report (push) Failing after 5m1s
Server CI Nightly Race / Race Detector (push) Has been skipped
CodeQL / Analyze (go) (push) Has been cancelled
CodeQL / Analyze (javascript) (push) Has been cancelled
Webapp CI Cache Warm / Warm Webapp node_modules Cache (push) Has been cancelled
E2E CI Cache Warm / Warm E2E npm Registry Cache (push) Has been cancelled
API / build (push) Has been cancelled
Web App CI / check-types (push) Has been cancelled
Web App CI / check-lint (push) Has been cancelled
Web App CI / check-i18n (push) Has been cancelled
Web App CI / check-external-links (push) Has been cancelled
Web App CI / test (platform) (push) Has been cancelled
Web App CI / test (mattermost-redux) (push) Has been cancelled
Web App CI / test (channels shard 1/4) (push) Has been cancelled
Web App CI / test (channels shard 2/4) (push) Has been cancelled
Web App CI / test (channels shard 3/4) (push) Has been cancelled
Web App CI / test (channels shard 4/4) (push) Has been cancelled
Web App CI / upload-coverage (push) Has been cancelled
Web App CI / build (push) Has been cancelled
YAML Lint / yamllint (push) Has been cancelled
Push mirrored docker images / cd/Push mirrored docker images (push) Has been cancelled
docs-cd / Build and deploy docs (push) Has been cancelled
Docs CI / build (push) Has been cancelled
E2E Cache Warm: Cypress deps / Warm Cypress deps cache (push) Has been cancelled
Scorecards supply-chain security / Scorecard analysis (push) Has been cancelled
Server CI Weekly / Postgres FIPS (push) Has been skipped
Server CI Weekly / Run mmctl tests (FIPS) (push) Has been skipped
Server CI Weekly / Postgres with binary parameters (push) Has been skipped
Server CI Weekly / Build Environment (push) Failing after 1s
Server CI Cache Warm / Warm Go Module and Build Cache (push) Failing after 2s
Server CI Nightly Race / Build Environment (push) Failing after 1s
snapshot of https://github.com/mattermost/mattermost.git (master, 2026-09-16; blobs > 131072B omitted)
2026-09-16 00:29:55 +05:00

189 lines
7.3 KiB
JavaScript

// 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 @scroll
import * as MESSAGES from '@/fixtures/messages';
import * as TIMEOUTS from '@/fixtures/timeouts';
describe('Scroll', () => {
let testTeam;
let testChannel;
let otherUser;
beforeEach(() => {
// # Create new team and new user and visit Town Square channel
cy.apiInitSetup().then(({team, channel}) => {
testTeam = team;
testChannel = channel;
cy.apiCreateUser().then(({user: user2}) => {
otherUser = user2;
cy.apiAddUserToTeam(testTeam.id, otherUser.id).then(() => {
cy.apiAddUserToChannel(testChannel.id, otherUser.id);
});
});
cy.visit(`/${testTeam.name}/channels/${channel.name}`);
});
});
it('MM-T2378 Channel with only a few posts opens at the bottom', () => {
// # Post a starting message with user 1
cy.postMessage('This is the first post');
// # Post as few as messages so that scroll bar appears as channel name scroll hidden
Cypress._.times(20, (postIndex) => {
cy.postMessage(`p-${postIndex + 1}`);
});
// # Post the last message
cy.postMessage('This is the last post');
// # Reload the browser
cy.reload();
// * Verify that the top of the channel is scrolled past hidden
cy.findByText(`Beginning of ${testChannel.display_name}`).should('exist').and('not.be.visible');
// * Verify that the last message is visible implying that channel scrolled to bottom on reload
cy.findByText('This is the last post').should('exist').and('be.visible');
});
it('MM-T2382 Center channel scroll', () => {
// # Post a starting message with user 1
cy.postMessage('This is the first post');
// # Make enough posts so that first post is scrolled past hidden
Cypress._.times(30, (postIndex) => {
cy.postMessage(`p-${postIndex + 1}`);
});
// * Verify that we are the bottom of the channel
cy.findByText('This is the first post').should('exist').and('not.be.visible');
// * Make post from another user and verify that channel is scrolled down as post appear
Cypress._.times(3, (postIndex) => {
postMessageAndcheckIfTopMessagesAreScrolled(postIndex + 1, otherUser, testChannel.id);
});
});
it('MM-T2367 Compact view', () => {
const message = 'This is the first post';
// # Set display mode to standard
cy.apiSaveMessageDisplayPreference('clean');
// # Post a starting message with user 1
Cypress._.times(2, () => {
cy.postMessage(message);
});
// * Verify that messages do no have user's name in post
cy.getLastPostId().then((parentMessageId) => {
cy.get(`#${parentMessageId}_message`).invoke('text').then((text) => {
expect(text).to.equal(message);
expect(text).to.not.have.string('sysadmin');
});
});
// # Set display mode to compact
cy.apiSaveMessageDisplayPreference('compact');
cy.visit(`/${testTeam.name}/channels/${testChannel.name}`);
// * Verify that messages have user's name in post
cy.getLastPostId().then((parentMessageId) => {
cy.get(`#${parentMessageId}_message`).parent().invoke('text').then((text) => {
expect(text).to.contain('sysadmin');
expect(text).to.contain(message);
});
});
});
// https://automation-test-cases.vercel.app/test/MM-T2374
it('MM-T2374 System Messages', () => {
const firstPost = '<< This is the first post><';
const lastPost = '<< This is the last post><';
// # Make an opening first post
cy.postMessage(firstPost);
// # Make enough post so the channel can scroll sufficiently
Cypress._.times(6, () => {
cy.uiPostMessageQuickly(MESSAGES.LARGE);
cy.uiPostMessageQuickly(MESSAGES.MEDIUM);
});
// # Make a final post
cy.postMessage(lastPost);
// # Scroll to top
cy.get('div.post-list__dynamic').should('be.visible').scrollTo('top', {duration: TIMEOUTS.ONE_SEC}).wait(TIMEOUTS.ONE_SEC);
// * Verify we are on the top of the channel
cy.findByText(firstPost).should('exist').and('be.visible');
cy.findByText(lastPost).should('exist').and('not.be.visible');
// # Add few users to the same channel
cy.apiCreateUser().then(({user: userAddRemove1}) => {
cy.apiAddUserToTeam(testTeam.id, userAddRemove1.id).then(() => {
cy.apiAddUserToChannel(testChannel.id, userAddRemove1.id);
cy.wait(TIMEOUTS.THREE_SEC);
cy.apiCreateUser().then(({user: userAddRemove2}) => {
cy.apiAddUserToTeam(testTeam.id, userAddRemove2.id).then(() => {
cy.apiAddUserToChannel(testChannel.id, userAddRemove2.id);
cy.wait(TIMEOUTS.THREE_SEC);
cy.apiCreateUser().then(({user: userAddRemove3}) => {
cy.apiAddUserToTeam(testTeam.id, userAddRemove3.id).then(() => {
cy.apiAddUserToChannel(testChannel.id, userAddRemove3.id);
// # Wait a little before we can start removing
cy.wait(TIMEOUTS.FIVE_SEC);
// # Remove few users from the same channel
cy.removeUserFromChannel(testChannel.id, userAddRemove1.id);
cy.wait(TIMEOUTS.THREE_SEC);
cy.removeUserFromChannel(testChannel.id, userAddRemove2.id);
// # Wait a little after we removed the users
cy.wait(TIMEOUTS.FIVE_SEC);
});
});
});
});
});
});
// * Verify we are still on the top of the channel and no scrolling occured
cy.findByText(firstPost).should('exist').and('be.visible');
cy.findByText(lastPost).should('exist').and('not.be.visible');
});
});
function postMessageAndcheckIfTopMessagesAreScrolled(postIndex, sender, channelId) {
// # Make posts from other user
cy.postMessageAs({sender, message: `Other users p-${postIndex}`, channelId});
cy.get('#post-list').should('exist').within(() => {
// * Verify that top post are hidden behind scroll
cy.findByText(`p-${postIndex}`).should('exist').and('not.be.visible');
cy.findByText(`p-${postIndex + 1}`).should('exist').and('not.be.visible');
// * Also verify that latest messages from the other user are visible
cy.findByText(`Other users p-${postIndex}`).should('exist').and('be.visible');
});
}