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
This commit is contained in:
Elias Nahum 2021-08-06 10:51:52 -04:00 committed by GitHub
parent 4837ff5d70
commit 7cdbe095a1
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 0 deletions

View file

@ -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;

View file

@ -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,