{"action":"created","comment":{"url":"https://api.github.com/repos/elastic/kibana/pulls/comments/236452275","pull_request_review_id":178436852,"id":236452275,"node_id":"MDI0OlB1bGxSZXF1ZXN0UmV2aWV3Q29tbWVudDIzNjQ1MjI3NQ==","diff_hunk":"@@ -69,21 +72,39 @@ describe('[CCR API Routes] Auto Follow Pattern', () => {\n       routeHandler = routeHandlers.list;\n     });\n \n-    it('should forward the response from Elasticsearch', async () => {\n-      const mock = { foo: 'bar' };\n-      setHttpRequestResponse(null, mock);\n+    it('should deSerialize the response from Elasticsearch', async () => {\n+      const totalResult = 2;\n+      const deSerializedKeys = Object.keys(deserializeAutofollowPattern('random', getAutoFollowPatternMock()));\n+      setHttpRequestResponse(null, getAutoFollowPatternListMock(totalResult));\n \n       const response = await routeHandler();\n+      const autoFollowPattern = Object.values(response)[0];\n \n-      expect(response).toBe(mock);\n+      expect(Object.keys(response).length).toEqual(totalResult);\n+      expect(Object.keys(autoFollowPattern)).toEqual(deSerializedKeys);\n     });\n+  });\n \n-    it('should prevent a 404 response on the route', async () => {\n-      setHttpRequestResponse({ status: 404 });\n-\n-      const response = await routeHandler();\n+  describe('create()', () => {\n+    beforeEach(() => {\n+      routeHandler = routeHandlers.create;\n+    });\n \n-      expect(response).toEqual({});\n+    it('should serialize the payload before sending it to Elasticsearch', async () => {\n+      callWithRequestFactory.mockReturnValueOnce((_, payload = {}) => {\n+        if (payload.body.remote_cluster !== 'bar') {\n+          return `Error: body (${JSON.stringify(payload)})`;","path":"x-pack/plugins/cross_cluster_replication/server/routes/api/auto_follow_pattern.test.js","position":53,"original_position":53,"commit_id":"bfb0f537e79c6256b12594a8049c9647899b9535","original_commit_id":"bfb0f537e79c6256b12594a8049c9647899b9535","user":{"login":"cjcenizal","id":1238659,"node_id":"MDQ6VXNlcjEyMzg2NTk=","avatar_url":"https://avatars2.githubusercontent.com/u/1238659?v=4","gravatar_id":"","url":"https://api.github.com/users/cjcenizal","html_url":"https://github.com/cjcenizal","followers_url":"https://api.github.com/users/cjcenizal/followers","following_url":"https://api.github.com/users/cjcenizal/following{/other_user}","gists_url":"https://api.github.com/users/cjcenizal/gists{/gist_id}","starred_url":"https://api.github.com/users/cjcenizal/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cjcenizal/subscriptions","organizations_url":"https://api.github.com/users/cjcenizal/orgs","repos_url":"https://api.github.com/users/cjcenizal/repos","events_url":"https://api.github.com/users/cjcenizal/events{/privacy}","received_events_url":"https://api.github.com/users/cjcenizal/received_events","type":"User","site_admin":false},"body":"We can leverage Jest's diffing feature by tweaking this to return the actual request itself and then making assertions against that:\r\n\r\n```js\r\n    it('should serialize the payload before sending it to Elasticsearch', async () => {\r\n      // Return the payload we're sending to ES so we can make assertions against it.\r\n      callWithRequestFactory.mockReturnValueOnce((_, payload = {}) => payload);\r\n\r\n      const request = {\r\n        params: { id: 'foo' },\r\n        payload: {\r\n          remoteCluster: 'bar1',\r\n          leaderIndexPatterns: [ 'bar2' ],\r\n          followIndexPattern: 'bar3',\r\n        },\r\n      };\r\n\r\n      const response = await routeHandler(request);\r\n      expect(response).toEqual({\r\n        id: 'foo',\r\n        body: {\r\n          remote_cluster: 'bar1',\r\n          leader_index_patterns: [ 'bar2' ],\r\n          follow_index_pattern: 'bar3',\r\n        },\r\n      });\r\n    });\r\n```\r\n\r\nThis way I think the failures will be a little easier debug since they'll look something like this:\r\n\r\n![image](https://user-images.githubusercontent.com/1238659/49046031-abccba00-f187-11e8-8de6-f6b03f023323.png)\r\n\r\n","created_at":"2018-11-26T22:26:51Z","updated_at":"2018-11-26T22:42:53Z","html_url":"https://github.com/elastic/kibana/pull/26095#discussion_r236452275","pull_request_url":"https://api.github.com/repos/elastic/kibana/pulls/26095","author_association":"CONTRIBUTOR","_links":{"self":{"href":"https://api.github.com/repos/elastic/kibana/pulls/comments/236452275"},"html":{"href":"https://github.com/elastic/kibana/pull/26095#discussion_r236452275"},"pull_request":{"href":"https://api.github.com/repos/elastic/kibana/pulls/26095"}}},"pull_request":{"url":"https://api.github.com/repos/elastic/kibana/pulls/26095","id":233053720,"node_id":"MDExOlB1bGxSZXF1ZXN0MjMzMDUzNzIw","html_url":"https://github.com/elastic/kibana/pull/26095","diff_url":"https://github.com/elastic/kibana/pull/26095.diff","patch_url":"https://github.com/elastic/kibana/pull/26095.patch","issue_url":"https://api.github.com/repos/elastic/kibana/issues/26095","number":26095,"state":"open","locked":false,"title":"Feature/ccr post auto follow pattern endpoint","user":{"login":"sebelga","id":2854616,"node_id":"MDQ6VXNlcjI4NTQ2MTY=","avatar_url":"https://avatars0.githubusercontent.com/u/2854616?v=4","gravatar_id":"","url":"https://api.github.com/users/sebelga","html_url":"https://github.com/sebelga","followers_url":"https://api.github.com/users/sebelga/followers","following_url":"https://api.github.com/users/sebelga/following{/other_user}","gists_url":"https://api.github.com/users/sebelga/gists{/gist_id}","starred_url":"https://api.github.com/users/sebelga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sebelga/subscriptions","organizations_url":"https://api.github.com/users/sebelga/orgs","repos_url":"https://api.github.com/users/sebelga/repos","events_url":"https://api.github.com/users/sebelga/events{/privacy}","received_events_url":"https://api.github.com/users/sebelga/received_events","type":"User","site_admin":false},"body":"Add API route to create a Cross Cluster Replication auto-follow pattern.  In this PR (de)serialization has been added to both the API `list()` and `create()` routes so we can work with camelCase naming on the client.","created_at":"2018-11-22T18:22:14Z","updated_at":"2018-11-26T22:42:53Z","closed_at":null,"merged_at":null,"merge_commit_sha":"b6553bd0ff7b72a0262466fb264e898a5a9cc3ce","assignee":null,"assignees":[],"requested_reviewers":[{"login":"bmcconaghy","id":2479496,"node_id":"MDQ6VXNlcjI0Nzk0OTY=","avatar_url":"https://avatars1.githubusercontent.com/u/2479496?v=4","gravatar_id":"","url":"https://api.github.com/users/bmcconaghy","html_url":"https://github.com/bmcconaghy","followers_url":"https://api.github.com/users/bmcconaghy/followers","following_url":"https://api.github.com/users/bmcconaghy/following{/other_user}","gists_url":"https://api.github.com/users/bmcconaghy/gists{/gist_id}","starred_url":"https://api.github.com/users/bmcconaghy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/bmcconaghy/subscriptions","organizations_url":"https://api.github.com/users/bmcconaghy/orgs","repos_url":"https://api.github.com/users/bmcconaghy/repos","events_url":"https://api.github.com/users/bmcconaghy/events{/privacy}","received_events_url":"https://api.github.com/users/bmcconaghy/received_events","type":"User","site_admin":false}],"requested_teams":[],"labels":[{"id":1108936463,"node_id":"MDU6TGFiZWwxMTA4OTM2NDYz","url":"https://api.github.com/repos/elastic/kibana/labels/es-management","name":"es-management","color":"26bac1","default":false},{"id":135307740,"node_id":"MDU6TGFiZWwxMzUzMDc3NDA=","url":"https://api.github.com/repos/elastic/kibana/labels/review","name":"review","color":"0052cc","default":false}],"milestone":null,"commits_url":"https://api.github.com/repos/elastic/kibana/pulls/26095/commits","review_comments_url":"https://api.github.com/repos/elastic/kibana/pulls/26095/comments","review_comment_url":"https://api.github.com/repos/elastic/kibana/pulls/comments{/number}","comments_url":"https://api.github.com/repos/elastic/kibana/issues/26095/comments","statuses_url":"https://api.github.com/repos/elastic/kibana/statuses/bfb0f537e79c6256b12594a8049c9647899b9535","head":{"label":"sebelga:feature/ccr_post_auto_follow_pattern_endpoint","ref":"feature/ccr_post_auto_follow_pattern_endpoint","sha":"bfb0f537e79c6256b12594a8049c9647899b9535","user":{"login":"sebelga","id":2854616,"node_id":"MDQ6VXNlcjI4NTQ2MTY=","avatar_url":"https://avatars0.githubusercontent.com/u/2854616?v=4","gravatar_id":"","url":"https://api.github.com/users/sebelga","html_url":"https://github.com/sebelga","followers_url":"https://api.github.com/users/sebelga/followers","following_url":"https://api.github.com/users/sebelga/following{/other_user}","gists_url":"https://api.github.com/users/sebelga/gists{/gist_id}","starred_url":"https://api.github.com/users/sebelga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sebelga/subscriptions","organizations_url":"https://api.github.com/users/sebelga/orgs","repos_url":"https://api.github.com/users/sebelga/repos","events_url":"https://api.github.com/users/sebelga/events{/privacy}","received_events_url":"https://api.github.com/users/sebelga/received_events","type":"User","site_admin":false},"repo":{"id":151076819,"node_id":"MDEwOlJlcG9zaXRvcnkxNTEwNzY4MTk=","name":"kibana","full_name":"sebelga/kibana","private":false,"owner":{"login":"sebelga","id":2854616,"node_id":"MDQ6VXNlcjI4NTQ2MTY=","avatar_url":"https://avatars0.githubusercontent.com/u/2854616?v=4","gravatar_id":"","url":"https://api.github.com/users/sebelga","html_url":"https://github.com/sebelga","followers_url":"https://api.github.com/users/sebelga/followers","following_url":"https://api.github.com/users/sebelga/following{/other_user}","gists_url":"https://api.github.com/users/sebelga/gists{/gist_id}","starred_url":"https://api.github.com/users/sebelga/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/sebelga/subscriptions","organizations_url":"https://api.github.com/users/sebelga/orgs","repos_url":"https://api.github.com/users/sebelga/repos","events_url":"https://api.github.com/users/sebelga/events{/privacy}","received_events_url":"https://api.github.com/users/sebelga/received_events","type":"User","site_admin":false},"html_url":"https://github.com/sebelga/kibana","description":":bar_chart: Kibana analytics and search dashboard for Elasticsearch","fork":true,"url":"https://api.github.com/repos/sebelga/kibana","forks_url":"https://api.github.com/repos/sebelga/kibana/forks","keys_url":"https://api.github.com/repos/sebelga/kibana/keys{/key_id}","collaborators_url":"https://api.github.com/repos/sebelga/kibana/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/sebelga/kibana/teams","hooks_url":"https://api.github.com/repos/sebelga/kibana/hooks","issue_events_url":"https://api.github.com/repos/sebelga/kibana/issues/events{/number}","events_url":"https://api.github.com/repos/sebelga/kibana/events","assignees_url":"https://api.github.com/repos/sebelga/kibana/assignees{/user}","branches_url":"https://api.github.com/repos/sebelga/kibana/branches{/branch}","tags_url":"https://api.github.com/repos/sebelga/kibana/tags","blobs_url":"https://api.github.com/repos/sebelga/kibana/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/sebelga/kibana/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/sebelga/kibana/git/refs{/sha}","trees_url":"https://api.github.com/repos/sebelga/kibana/git/trees{/sha}","statuses_url":"https://api.github.com/repos/sebelga/kibana/statuses/{sha}","languages_url":"https://api.github.com/repos/sebelga/kibana/languages","stargazers_url":"https://api.github.com/repos/sebelga/kibana/stargazers","contributors_url":"https://api.github.com/repos/sebelga/kibana/contributors","subscribers_url":"https://api.github.com/repos/sebelga/kibana/subscribers","subscription_url":"https://api.github.com/repos/sebelga/kibana/subscription","commits_url":"https://api.github.com/repos/sebelga/kibana/commits{/sha}","git_commits_url":"https://api.github.com/repos/sebelga/kibana/git/commits{/sha}","comments_url":"https://api.github.com/repos/sebelga/kibana/comments{/number}","issue_comment_url":"https://api.github.com/repos/sebelga/kibana/issues/comments{/number}","contents_url":"https://api.github.com/repos/sebelga/kibana/contents/{+path}","compare_url":"https://api.github.com/repos/sebelga/kibana/compare/{base}...{head}","merges_url":"https://api.github.com/repos/sebelga/kibana/merges","archive_url":"https://api.github.com/repos/sebelga/kibana/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/sebelga/kibana/downloads","issues_url":"https://api.github.com/repos/sebelga/kibana/issues{/number}","pulls_url":"https://api.github.com/repos/sebelga/kibana/pulls{/number}","milestones_url":"https://api.github.com/repos/sebelga/kibana/milestones{/number}","notifications_url":"https://api.github.com/repos/sebelga/kibana/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/sebelga/kibana/labels{/name}","releases_url":"https://api.github.com/repos/sebelga/kibana/releases{/id}","deployments_url":"https://api.github.com/repos/sebelga/kibana/deployments","created_at":"2018-10-01T11:21:08Z","updated_at":"2018-10-01T11:21:31Z","pushed_at":"2018-11-26T07:45:18Z","git_url":"git://github.com/sebelga/kibana.git","ssh_url":"git@github.com:sebelga/kibana.git","clone_url":"https://github.com/sebelga/kibana.git","svn_url":"https://github.com/sebelga/kibana","homepage":"https://www.elastic.co/products/kibana","size":506282,"stargazers_count":0,"watchers_count":0,"language":"JavaScript","has_issues":false,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":0,"mirror_url":null,"archived":false,"open_issues_count":0,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":0,"open_issues":0,"watchers":0,"default_branch":"master"}},"base":{"label":"elastic:feature/ccr","ref":"feature/ccr","sha":"5c7bb252546246f9f0aa936619edeed4b7e4b333","user":{"login":"elastic","id":6764390,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY3NjQzOTA=","avatar_url":"https://avatars0.githubusercontent.com/u/6764390?v=4","gravatar_id":"","url":"https://api.github.com/users/elastic","html_url":"https://github.com/elastic","followers_url":"https://api.github.com/users/elastic/followers","following_url":"https://api.github.com/users/elastic/following{/other_user}","gists_url":"https://api.github.com/users/elastic/gists{/gist_id}","starred_url":"https://api.github.com/users/elastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elastic/subscriptions","organizations_url":"https://api.github.com/users/elastic/orgs","repos_url":"https://api.github.com/users/elastic/repos","events_url":"https://api.github.com/users/elastic/events{/privacy}","received_events_url":"https://api.github.com/users/elastic/received_events","type":"Organization","site_admin":false},"repo":{"id":7833168,"node_id":"MDEwOlJlcG9zaXRvcnk3ODMzMTY4","name":"kibana","full_name":"elastic/kibana","private":false,"owner":{"login":"elastic","id":6764390,"node_id":"MDEyOk9yZ2FuaXphdGlvbjY3NjQzOTA=","avatar_url":"https://avatars0.githubusercontent.com/u/6764390?v=4","gravatar_id":"","url":"https://api.github.com/users/elastic","html_url":"https://github.com/elastic","followers_url":"https://api.github.com/users/elastic/followers","following_url":"https://api.github.com/users/elastic/following{/other_user}","gists_url":"https://api.github.com/users/elastic/gists{/gist_id}","starred_url":"https://api.github.com/users/elastic/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/elastic/subscriptions","organizations_url":"https://api.github.com/users/elastic/orgs","repos_url":"https://api.github.com/users/elastic/repos","events_url":"https://api.github.com/users/elastic/events{/privacy}","received_events_url":"https://api.github.com/users/elastic/received_events","type":"Organization","site_admin":false},"html_url":"https://github.com/elastic/kibana","description":":bar_chart: Kibana analytics and search dashboard for Elasticsearch","fork":false,"url":"https://api.github.com/repos/elastic/kibana","forks_url":"https://api.github.com/repos/elastic/kibana/forks","keys_url":"https://api.github.com/repos/elastic/kibana/keys{/key_id}","collaborators_url":"https://api.github.com/repos/elastic/kibana/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/elastic/kibana/teams","hooks_url":"https://api.github.com/repos/elastic/kibana/hooks","issue_events_url":"https://api.github.com/repos/elastic/kibana/issues/events{/number}","events_url":"https://api.github.com/repos/elastic/kibana/events","assignees_url":"https://api.github.com/repos/elastic/kibana/assignees{/user}","branches_url":"https://api.github.com/repos/elastic/kibana/branches{/branch}","tags_url":"https://api.github.com/repos/elastic/kibana/tags","blobs_url":"https://api.github.com/repos/elastic/kibana/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/elastic/kibana/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/elastic/kibana/git/refs{/sha}","trees_url":"https://api.github.com/repos/elastic/kibana/git/trees{/sha}","statuses_url":"https://api.github.com/repos/elastic/kibana/statuses/{sha}","languages_url":"https://api.github.com/repos/elastic/kibana/languages","stargazers_url":"https://api.github.com/repos/elastic/kibana/stargazers","contributors_url":"https://api.github.com/repos/elastic/kibana/contributors","subscribers_url":"https://api.github.com/repos/elastic/kibana/subscribers","subscription_url":"https://api.github.com/repos/elastic/kibana/subscription","commits_url":"https://api.github.com/repos/elastic/kibana/commits{/sha}","git_commits_url":"https://api.github.com/repos/elastic/kibana/git/commits{/sha}","comments_url":"https://api.github.com/repos/elastic/kibana/comments{/number}","issue_comment_url":"https://api.github.com/repos/elastic/kibana/issues/comments{/number}","contents_url":"https://api.github.com/repos/elastic/kibana/contents/{+path}","compare_url":"https://api.github.com/repos/elastic/kibana/compare/{base}...{head}","merges_url":"https://api.github.com/repos/elastic/kibana/merges","archive_url":"https://api.github.com/repos/elastic/kibana/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/elastic/kibana/downloads","issues_url":"https://api.github.com/repos/elastic/kibana/issues{/number}","pulls_url":"https://api.github.com/repos/elastic/kibana/pulls{/number}","milestones_url":"https://api.github.com/repos/elastic/kibana/milestones{/number}","notifications_url":"https://api.github.com/repos/elastic/kibana/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/elastic/kibana/labels{/name}","releases_url":"https://api.github.com/repos/elastic/kibana/releases{/id}","deployments_url":"https://api.github.com/repos/elastic/kibana/deployments","created_at":"2013-01-26T04:00:59Z","updated_at":"2018-11-26T22:18:24Z","pushed_at":"2018-11-26T22:42:22Z","git_url":"git://github.com/elastic/kibana.git","ssh_url":"git@github.com:elastic/kibana.git","clone_url":"https://github.com/elastic/kibana.git","svn_url":"https://github.com/elastic/kibana","homepage":"https://www.elastic.co/products/kibana","size":577196,"stargazers_count":10507,"watchers_count":10507,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":true,"has_pages":false,"forks_count":4114,"mirror_url":null,"archived":false,"open_issues_count":3759,"license":{"key":"other","name":"Other","spdx_id":"NOASSERTION","url":null,"node_id":"MDc6TGljZW5zZTA="},"forks":4114,"open_issues":3759,"watchers":10507,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/elastic/kibana/pulls/26095"},"html":{"href":"https://github.com/elastic/kibana/pull/26095"},"issue":{"href":"https://api.github.com/repos/elastic/kibana/issues/26095"},"comments":{"href":"https://api.github.com/repos/elastic/kibana/issues/26095/comments"},"review_comments":{"href":"https://api.github.com/repos/elastic/kibana/pulls/26095/comments"},"review_comment":{"href":"https://api.github.com/repos/elastic/kibana/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/elastic/kibana/pulls/26095/commits"},"statuses":{"href":"https://api.github.com/repos/elastic/kibana/statuses/bfb0f537e79c6256b12594a8049c9647899b9535"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"cjcenizal"}}