From 7d449e05562c76bb430efc1c36bd715675a84152 Mon Sep 17 00:00:00 2001 From: George Goldberg Date: Thu, 23 Mar 2017 18:05:36 +0000 Subject: PLT-5755: Infrastructure for Component Testing. (#5814) This migrates the existing webapp tests to using Jest and Enzyme. The infrastructure is put in place for React component testing, and a few simple example component tests are implemented. This also adds snapshot testing of components, coverage checking for the webapp (although that is not yet integrated to Coveralls), and the ability to run npm run test:watch to automatically re-run affected tests when working on the webapp codebase. --- cmd/platform/test.go | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) (limited to 'cmd') diff --git a/cmd/platform/test.go b/cmd/platform/test.go index 65a8528d0..cf67d6702 100644 --- a/cmd/platform/test.go +++ b/cmd/platform/test.go @@ -10,9 +10,12 @@ import ( "os/exec" "github.com/mattermost/platform/api" + "github.com/mattermost/platform/api4" "github.com/mattermost/platform/app" "github.com/mattermost/platform/utils" "github.com/spf13/cobra" + "os/signal" + "syscall" ) var testCmd = &cobra.Command{ @@ -27,9 +30,16 @@ var runWebClientTestsCmd = &cobra.Command{ RunE: webClientTestsCmdF, } +var runServerForWebClientTestsCmd = &cobra.Command{ + Use: "web_client_tests_server", + Short: "Run the server configured for running the web client tests against it", + RunE: serverForWebClientTestsCmdF, +} + func init() { testCmd.AddCommand( runWebClientTestsCmd, + runServerForWebClientTestsCmd, ) } @@ -37,6 +47,7 @@ func webClientTestsCmdF(cmd *cobra.Command, args []string) error { initDBCommandContextCobra(cmd) utils.InitTranslations(utils.Cfg.LocalizationSettings) api.InitRouter() + api4.InitApi(false) api.InitApi() setupClientTests() app.StartServer() @@ -46,6 +57,24 @@ func webClientTestsCmdF(cmd *cobra.Command, args []string) error { return nil } +func serverForWebClientTestsCmdF(cmd *cobra.Command, args []string) error { + initDBCommandContextCobra(cmd) + utils.InitTranslations(utils.Cfg.LocalizationSettings) + api.InitRouter() + api4.InitApi(false) + api.InitApi() + setupClientTests() + app.StartServer() + + c := make(chan os.Signal) + signal.Notify(c, os.Interrupt, syscall.SIGINT, syscall.SIGTERM) + <-c + + app.StopServer() + + return nil +} + func setupClientTests() { *utils.Cfg.TeamSettings.EnableOpenServer = true *utils.Cfg.ServiceSettings.EnableCommands = false -- cgit v1.2.3-1-g7c22