You've already forked focalboard
							
							
				mirror of
				https://github.com/mattermost/focalboard.git
				synced 2025-10-31 00:17:42 +02:00 
			
		
		
		
	adding a successful test
This commit is contained in:
		| @@ -185,6 +185,7 @@ func TestPatchBoard(t *testing.T) { | ||||
|  | ||||
| 		// Type not null will retrieve team members | ||||
| 		th.Store.EXPECT().GetUsersByTeam(teamID, "", false, false).Return([]*model.User{}, nil) | ||||
| 		th.Store.EXPECT().GetUserByID(userID).Return(&model.User{ID: userID, Username: "UserName"}, nil) | ||||
|  | ||||
| 		th.Store.EXPECT().PatchBoard(boardID, patch, userID).Return( | ||||
| 			&model.Board{ | ||||
| @@ -425,6 +426,44 @@ func TestPatchBoard(t *testing.T) { | ||||
| 		require.Error(t, err) | ||||
| 	}) | ||||
|  | ||||
| 	t.Run("patch type channel, user with post permissions", func(t *testing.T) { | ||||
| 		const boardID = "board_id_1" | ||||
| 		const userID = "user_id_2" | ||||
| 		const teamID = "team_id_1" | ||||
|  | ||||
| 		channelID := "myChannel" | ||||
| 		patch := &model.BoardPatch{ | ||||
| 			ChannelID: &channelID, | ||||
| 		} | ||||
|  | ||||
| 		// Type not nil, will cause board to be reteived | ||||
| 		// to check isTemplate | ||||
| 		th.Store.EXPECT().GetBoard(boardID).Return(&model.Board{ | ||||
| 			ID:     boardID, | ||||
| 			TeamID: teamID, | ||||
| 		}, nil).Times(2) | ||||
|  | ||||
| 		th.API.EXPECT().HasPermissionToChannel(userID, channelID, model.PermissionCreatePost).Return(true).Times(1) | ||||
|  | ||||
| 		th.Store.EXPECT().PatchBoard(boardID, patch, userID).Return( | ||||
| 			&model.Board{ | ||||
| 				ID:     boardID, | ||||
| 				TeamID: teamID, | ||||
| 			}, | ||||
| 			nil) | ||||
|  | ||||
| 		// Should call GetMembersForBoard 2 times | ||||
| 		// - for WS BroadcastBoardChange | ||||
| 		// - for AddTeamMembers check | ||||
| 		th.Store.EXPECT().GetMembersForBoard(boardID).Return([]*model.BoardMember{}, nil).Times(2) | ||||
|  | ||||
| 		th.Store.EXPECT().PostMessage(utils.Anything, "", "").Times(1) | ||||
|  | ||||
| 		patchedBoard, err := th.App.PatchBoard(patch, boardID, userID) | ||||
| 		require.NoError(t, err) | ||||
| 		require.Equal(t, boardID, patchedBoard.ID) | ||||
| 	}) | ||||
|  | ||||
| 	t.Run("patch type remove channel, user without post permissions", func(t *testing.T) { | ||||
| 		const boardID = "board_id_1" | ||||
| 		const userID = "user_id_2" | ||||
|   | ||||
		Reference in New Issue
	
	Block a user