MM-50746 : Edits to messages persist after cancelling (#22676)
Этот коммит содержится в:
@@ -145,4 +145,42 @@ describe('Edit Message', () => {
|
|||||||
cy.get(postText).should('have.text', `${secondMessage} Another new message Edited`);
|
cy.get(postText).should('have.text', `${secondMessage} Another new message Edited`);
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
it('MM-T5416 should discard any changes made after cancelling the edit and opening the edit textbox again should display the original message', () => {
|
||||||
|
const message = 'World!';
|
||||||
|
cy.postMessage(message);
|
||||||
|
|
||||||
|
// * Verify message is sent and not pending
|
||||||
|
cy.getLastPostId().then((postId) => {
|
||||||
|
const postText = `#postMessageText_${postId}`;
|
||||||
|
cy.get(postText).should('have.text', message);
|
||||||
|
|
||||||
|
// # Open edit textbox
|
||||||
|
cy.uiGetPostTextBox().type('{uparrow}');
|
||||||
|
|
||||||
|
// * Edit Post Input should appear, and edit the post
|
||||||
|
cy.get('#edit_textbox').should('be.visible');
|
||||||
|
|
||||||
|
// * Press the escape key to cancel
|
||||||
|
cy.get('#edit_textbox').should('have.text', message).type(' Another new message{esc}');
|
||||||
|
cy.get('#edit_textbox').should('not.exist');
|
||||||
|
|
||||||
|
// * Check that the message wasn't edited
|
||||||
|
cy.get(postText).should('have.text', message);
|
||||||
|
});
|
||||||
|
|
||||||
|
cy.getLastPostId().then((postId) => {
|
||||||
|
const postText = `#postMessageText_${postId}`;
|
||||||
|
cy.get(postText).should('have.text', message);
|
||||||
|
|
||||||
|
// # Open edit textbox again
|
||||||
|
cy.uiGetPostTextBox().type('{uparrow}');
|
||||||
|
|
||||||
|
// * Edit Post Input should appear, and edit the post
|
||||||
|
cy.get('#edit_textbox').should('be.visible');
|
||||||
|
|
||||||
|
// * Opening the edit textbox again after previously cancelling the edit should contain the original message.
|
||||||
|
cy.get('#edit_textbox').should('have.text', message);
|
||||||
|
});
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -220,7 +220,13 @@ const EditPost = ({editingPost, actions, canEditPost, config, channelId, draft,
|
|||||||
actions.unsetEditingPost();
|
actions.unsetEditingPost();
|
||||||
};
|
};
|
||||||
|
|
||||||
const handleAutomatedRefocusAndExit = () => handleRefocusAndExit(editingPost.refocusId || null);
|
const handleAutomatedRefocusAndExit = () => {
|
||||||
|
draftRef.current = {
|
||||||
|
...draftRef.current,
|
||||||
|
message: '',
|
||||||
|
};
|
||||||
|
handleRefocusAndExit(editingPost.refocusId || null);
|
||||||
|
};
|
||||||
|
|
||||||
const handleEdit = async () => {
|
const handleEdit = async () => {
|
||||||
if (!editingPost.post || isSaveDisabled()) {
|
if (!editingPost.post || isSaveDisabled()) {
|
||||||
|
|||||||
Ссылка в новой задаче
Block a user