Add test case for non channel admin accessing post links (#26131)

This commit is contained in:
yasserfaraazkhan 2024-02-08 15:16:22 +05:30 committed by GitHub
parent b73d642785
commit b2df0086cd
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -228,4 +228,47 @@ describe('Message permalink', () => {
});
});
});
it('MM-T5526 - Non-channel-admin users can use message links in private channels', () => {
let tempUser;
let privateChannel;
let permalink;
let testMessagePostId;
const postMessage = 'This is posted for non-channel-admins';
// # Create a private channel
cy.apiCreateChannel(testTeam.id, 'private', 'Private', 'P').then(({channel}) => {
privateChannel = channel;
cy.visit(`/${testTeam.name}/channels/${privateChannel.name}`);
});
// # Post a message
cy.postMessage(postMessage);
// # Create a permalink for the last post
cy.getLastPostId().then((id) => {
testMessagePostId = id;
permalink = `${Cypress.config('baseUrl')}/${testTeam.name}/pl/${id}`;
cy.postMessage(permalink);
});
// # Create a temporary user
cy.apiCreateUser({prefix: 'temp'}).then(({user: user1}) => {
tempUser = user1;
cy.apiAddUserToTeam(testTeam.id, tempUser.id);
cy.apiAddUserToChannel(privateChannel.id, tempUser.id);
// # Login as the other user
cy.apiLogout();
cy.apiLogin(tempUser);
cy.visit(`/${testTeam.name}/channels/${privateChannel.name}`);
// # Click on the permalink
cy.get('div.attachment--permalink').click();
// * Verify that the permalinked post is highlighted in the center channel
cy.url().should('contain', testMessagePostId);
cy.get(`#post_${testMessagePostId}.post--highlight`).should('be.visible');
});
});
});