hunk.code_window:             }
           }
           const combinedPosts = makePostListNonNull(this.getAllPosts(id));
           for (const pid in newPosts.posts) {
               if (newPosts.posts.hasOwnProperty(pid)) {
  
hunk.labels: keep keep add keep keep keep keep
hunk.after_edit:         if (checkEarliest) {
               const currentEarliest = this.earliestPostFromPage[id] || {create_at: Number.MAX_SAFE_INTEGER};
               const orderLength = newPosts.order.length;
               if (orderLength >= 1) {
                   const newEarliestPost = newPosts.posts[newPosts.order[orderLength - 1]];
                   if (newEarliestPost.create_at < currentEarliest.create_at) {
                       this.earliestPostFromPage[id] = newEarliestPost;
                   }
               }
           }
  
hunk.file_path: webapp/stores/post_store.jsx
hunk.type: add
file: // Copyright (c) 2016 Mattermost, Inc. All Rights Reserved.
  // See License.txt for license information.
  
  package main
  
  import (
  	"bufio"
  	"fmt"
  	"os"
  	"os/exec"
  
  	"github.com/mattermost/platform/api"
  	"github.com/mattermost/platform/app"
  	"github.com/mattermost/platform/utils"
  	"github.com/spf13/cobra"
  )
  
  var testCmd = &cobra.Command{
  	Use:    "test",
  	Short:  "Testing Commands",
  	Hidden: true,
  }
  
  var runWebClientTestsCmd = &cobra.Command{
  	Use:   "web_client_tests",
  	Short: "Run the web client tests",
  	RunE:  webClientTestsCmdF,
  }
  
  func init() {
  	testCmd.AddCommand(
  		runWebClientTestsCmd,
  	)
  }
  
  func webClientTestsCmdF(cmd *cobra.Command, args []string) error {
  	initDBCommandContextCobra(cmd)
  	utils.InitTranslations(utils.Cfg.LocalizationSettings)
  	api.InitRouter()
  	api.InitApi()
  	setupClientTests()
  	app.StartServer()
  	runWebClientTests()
  	app.StopServer()
  
  	return nil
  }
  
  func setupClientTests() {
  	*utils.Cfg.TeamSettings.EnableOpenServer = true
  	*utils.Cfg.ServiceSettings.EnableCommands = false
  	*utils.Cfg.ServiceSettings.EnableOnlyAdminIntegrations = false
  	*utils.Cfg.ServiceSettings.EnableCustomEmoji = true
  	utils.Cfg.ServiceSettings.EnableIncomingWebhooks = false
  	utils.Cfg.ServiceSettings.EnableOutgoingWebhooks = false
  	utils.SetDefaultRolesBasedOnConfig()
  }
  
  func executeTestCommand(cmd *exec.Cmd) {
  	cmdOutPipe, err := cmd.StdoutPipe()
  	if err != nil {
  		CommandPrintErrorln("Failed to run tests")
  		return
  	}
  
  	cmdOutReader := bufio.NewScanner(cmdOutPipe)
  	go func() {
  		for cmdOutReader.Scan() {
  			fmt.Println(cmdOutReader.Text())
  		}
  	}()
  
  	if err := cmd.Run(); err != nil {
  		CommandPrintErrorln("Client Tests failed")
  		return
  	}
  }
  
  func runWebClientTests() {
  	os.Chdir("webapp")
  	cmd := exec.Command("npm", "test")
  	executeTestCommand(cmd)
  }
  