From 7cdbe095a1963dfc7fe9aef2a0143bc57cb06721 Mon Sep 17 00:00:00 2001 From: Elias Nahum Date: Fri, 6 Aug 2021 10:51:52 -0400 Subject: [PATCH] MM-37577 Do not set post id when posting a message (#5602) * MM-37577 Do not set post id when posting a message * Add unit test to verify that creating a post always send an empty string as the id --- app/mm-redux/actions/posts.test.js | 2 ++ app/mm-redux/actions/posts.ts | 1 + 2 files changed, 3 insertions(+) diff --git a/app/mm-redux/actions/posts.test.js b/app/mm-redux/actions/posts.test.js index 27d03005a..ad30eba51 100644 --- a/app/mm-redux/actions/posts.test.js +++ b/app/mm-redux/actions/posts.test.js @@ -38,12 +38,14 @@ describe('Actions.Posts', () => { it('createPost', async () => { const channelId = TestHelper.basicChannel.id; const post = TestHelper.fakePost(channelId); + const createPost = jest.spyOn(Client4, 'createPost'); nock(Client4.getBaseRoute()). post('/posts'). reply(201, {...post, id: TestHelper.generateId()}); await Actions.createPost(post)(store.dispatch, store.getState); + expect(createPost).toHaveBeenCalledWith(expect.objectContaining({id: ''})); const state = store.getState(); const createRequest = state.requests.posts.createPost; diff --git a/app/mm-redux/actions/posts.ts b/app/mm-redux/actions/posts.ts index 1430a1717..ceb1b93ed 100644 --- a/app/mm-redux/actions/posts.ts +++ b/app/mm-redux/actions/posts.ts @@ -182,6 +182,7 @@ export function createPost(post: Post, files: any[] = []) { let newPost = { ...post, + id: '', pending_post_id: pendingPostId, create_at: timestamp, update_at: timestamp,