{"action":"created","comment":{"url":"https://api.github.com/repos/percy/percy-web/pulls/comments/188786751","pull_request_review_id":120837205,"id":188786751,"diff_hunk":"@@ -0,0 +1,143 @@\n+import {expect} from 'chai';\n+import {describe, it} from 'mocha';\n+import {get} from '@ember/object';\n+import {\n+  computeWidestComparison,\n+  computeComparisonForWidth,\n+  computeComparisonsForBrowser,\n+  computeWidestComparisonWithDiff,\n+  snapshotsWithDiffForBrowser,\n+  countDiffsWithSnapshotsPerBrowser,\n+} from 'percy-web/lib/filtered-comparisons';\n+\n+describe('filtered-comparisons', function() {\n+  const chromeBrowser = {\n+    id: 'chrome-id',\n+  };\n+  const firefoxBrowser = {\n+    id: 'firefox-id',\n+  };\n+\n+  const narrowComparisonNoDiff = {width: 1, isDifferent: false};\n+  const narrowComparisonWithDiff = {width: 1, isDifferent: true};\n+  const wideComparisonNoDiff = {width: 1000, isDifferent: false};\n+  const wideComparisonWithDiff = {width: 1000, isDifferent: true};\n+\n+  describe('#computeWidestComparison', function() {\n+    it('returns widest comparison', function() {\n+      expect(computeWidestComparison([narrowComparisonNoDiff, wideComparisonNoDiff])).to.equal(\n+        wideComparisonNoDiff,\n+      );\n+    });\n+  });\n+\n+  describe('#computeCompraisonForWidth', function() {\n+    it('returns comparison matching inputted width', function() {\n+      expect(\n+        computeComparisonForWidth([narrowComparisonNoDiff, wideComparisonNoDiff], 1000),\n+      ).to.equal(wideComparisonNoDiff);\n+    });\n+\n+    it('returns nothing if there is no matching comparison', function() {\n+      expect(\n+        computeComparisonForWidth([narrowComparisonNoDiff, wideComparisonNoDiff], 293847),\n+      ).to.equal(undefined);\n+    });\n+  });\n+\n+  describe('#computeComparisonsForBrowser', function() {\n+    it('returns comparisons with maching browser', function() {\n+      const chromeComparison = {browser: chromeBrowser};\n+      const firefoxComparison = {browser: firefoxBrowser};\n+\n+      expect(\n+        computeComparisonsForBrowser([firefoxComparison, chromeComparison], chromeBrowser),\n+      ).to.eql([chromeComparison]);\n+    });\n+\n+    it('returns empty array if no matching comparisons', function() {\n+      expect(\n+        computeComparisonsForBrowser([narrowComparisonNoDiff, wideComparisonNoDiff], chromeBrowser),\n+      ).to.eql([]);\n+    });\n+  });\n+\n+  describe('#computeWidestComparisonWithDiff', function() {\n+    it('returns widest comparison with diff', function() {\n+      expect(\n+        computeWidestComparisonWithDiff([\n+          narrowComparisonWithDiff,\n+          wideComparisonWithDiff,\n+          wideComparisonNoDiff,\n+        ]),\n+      ).to.equal(wideComparisonWithDiff);\n+    });\n+\n+    it('returns undefined if no comparisons with diffs', function() {\n+      expect(\n+        computeWidestComparisonWithDiff([narrowComparisonNoDiff, wideComparisonNoDiff]),\n+      ).to.equal(undefined);\n+    });\n+  });\n+\n+  describe('#snapshotsWithDiffForBrowser', function() {\n+    it('returns snapshots which have comparisons with diffs for matching browser', function() {\n+      const chromeComparisonWithDiff = {browser: chromeBrowser, isDifferent: true};\n+      const firefoxComparisonWithDiff = {browser: firefoxBrowser, isDifferent: true};\n+      const chromeComparisonNoDiff = {browser: chromeBrowser, isDifferent: false};\n+\n+      const snapshotWithChrome = {comparisons: [chromeComparisonWithDiff]};\n+      const snapshotWithFirefox = {comparisons: [firefoxComparisonWithDiff]};\n+      const snapshotWithBothBrowsersAndDiffs = {\n+        comparisons: [chromeComparisonWithDiff, firefoxComparisonWithDiff],\n+      };\n+      const snapshotWithBothBrowsersAndMixedDiffs = {\n+        comparisons: [chromeComparisonNoDiff, firefoxComparisonWithDiff],\n+      };\n+\n+      expect(","path":"tests/unit/lib/filtered-comparisons-test.js","position":98,"original_position":98,"commit_id":"be0f721f4048338d316ea9ac363b7126741e4c07","original_commit_id":"be0f721f4048338d316ea9ac363b7126741e4c07","user":{"login":"fotinakis","id":75300,"avatar_url":"https://avatars2.githubusercontent.com/u/75300?v=4","gravatar_id":"","url":"https://api.github.com/users/fotinakis","html_url":"https://github.com/fotinakis","followers_url":"https://api.github.com/users/fotinakis/followers","following_url":"https://api.github.com/users/fotinakis/following{/other_user}","gists_url":"https://api.github.com/users/fotinakis/gists{/gist_id}","starred_url":"https://api.github.com/users/fotinakis/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/fotinakis/subscriptions","organizations_url":"https://api.github.com/users/fotinakis/orgs","repos_url":"https://api.github.com/users/fotinakis/repos","events_url":"https://api.github.com/users/fotinakis/events{/privacy}","received_events_url":"https://api.github.com/users/fotinakis/received_events","type":"User","site_admin":false},"body":"(optional personal style nitpick preference) The heavy nesting makes this hard to read, using a few variables and multiple lines here would flatten this kind of thing up and make it easier to read.\r\n\r\nIe.\r\n\r\n```js\r\nconst allSnapshots = [\r\n  snapshotWithChrome,\r\n  snapshotWithFirefox,\r\n  snapshotWithBothBrowsersAndDiffs,\r\n  snapshotWithBothBrowsersAndMixedDiffs,\r\n];\r\nlet snapshots = snapshotsWithDiffForBrowser(allSnapshots, chromeBrowser)\r\nexpect(snapshots).to.eql([snapshotWithChrome, snapshotWithBothBrowsersAndDiffs]);\r\n```\r\n\r\nvs.\r\n\r\n```js\r\nexpect(\r\n  snapshotsWithDiffForBrowser(\r\n    [\r\n      snapshotWithChrome,\r\n      snapshotWithFirefox,\r\n      snapshotWithBothBrowsersAndDiffs,\r\n      snapshotWithBothBrowsersAndMixedDiffs,\r\n    ],\r\n    chromeBrowser,\r\n  ),\r\n).to.eql([snapshotWithChrome, snapshotWithBothBrowsersAndDiffs]);\r\n```","created_at":"2018-05-16T22:06:10Z","updated_at":"2018-05-16T22:06:11Z","html_url":"https://github.com/percy/percy-web/pull/529#discussion_r188786751","pull_request_url":"https://api.github.com/repos/percy/percy-web/pulls/529","author_association":"MEMBER","_links":{"self":{"href":"https://api.github.com/repos/percy/percy-web/pulls/comments/188786751"},"html":{"href":"https://github.com/percy/percy-web/pull/529#discussion_r188786751"},"pull_request":{"href":"https://api.github.com/repos/percy/percy-web/pulls/529"}}},"pull_request":{"url":"https://api.github.com/repos/percy/percy-web/pulls/529","id":187081723,"html_url":"https://github.com/percy/percy-web/pull/529","diff_url":"https://github.com/percy/percy-web/pull/529.diff","patch_url":"https://github.com/percy/percy-web/pull/529.patch","issue_url":"https://api.github.com/repos/percy/percy-web/issues/529","number":529,"state":"open","locked":false,"title":"[Multiple browser support Part 1] Make builds and comparisons browser-aware (No user-facing changes)","user":{"login":"cadeParade","id":3179218,"avatar_url":"https://avatars3.githubusercontent.com/u/3179218?v=4","gravatar_id":"","url":"https://api.github.com/users/cadeParade","html_url":"https://github.com/cadeParade","followers_url":"https://api.github.com/users/cadeParade/followers","following_url":"https://api.github.com/users/cadeParade/following{/other_user}","gists_url":"https://api.github.com/users/cadeParade/gists{/gist_id}","starred_url":"https://api.github.com/users/cadeParade/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/cadeParade/subscriptions","organizations_url":"https://api.github.com/users/cadeParade/orgs","repos_url":"https://api.github.com/users/cadeParade/repos","events_url":"https://api.github.com/users/cadeParade/events{/privacy}","received_events_url":"https://api.github.com/users/cadeParade/received_events","type":"User","site_admin":false},"body":"This PR updates the existing app to use the idea of `browserComparisons` instead of comparisons. A `browserComparison` is the comparison for a width and a certain browser.  Because we only ever want to see a comparison for a single browser, we always need to filter a snapshot's comparisons by browser.\r\n\r\nThis PR converts the app to invisibly use `browserComparisons` (aka filtered comparisons). It should introduce no user-facing changes. This PR sets up the framework to allow users to switch browsers, since snapshots and comparisons now have knowledge of the active browser.\r\n\r\nThis happens with the addition of the `filtered-comparisons` object. This object takes many of the repeated properties from `snapshot-viewer`, `snapshot-viewer-header`, and `snapshot-viewer-full` and combines them into one object. The object is sort of like an intermediate model for `browserComparisons`. \r\n[Several alternatives approaches to the mixin were explored](https://docs.google.com/document/d/1lRueqe-pJGHN5HM-u9yT8Kp5_eY4BPxwH7HkouvHsBM/edit#heading=h.ncallmtvetbx), but this solution seemed like it was the easiest to maintain and had the fewest and least serious cons.","created_at":"2018-05-10T01:48:25Z","updated_at":"2018-05-16T22:06:11Z","closed_at":null,"merged_at":null,"merge_commit_sha":"1aee44c1c7afb03d868991829ee012bf53331f25","assignee":null,"assignees":[],"requested_reviewers":[],"requested_teams":[],"labels":[],"milestone":null,"commits_url":"https://api.github.com/repos/percy/percy-web/pulls/529/commits","review_comments_url":"https://api.github.com/repos/percy/percy-web/pulls/529/comments","review_comment_url":"https://api.github.com/repos/percy/percy-web/pulls/comments{/number}","comments_url":"https://api.github.com/repos/percy/percy-web/issues/529/comments","statuses_url":"https://api.github.com/repos/percy/percy-web/statuses/be0f721f4048338d316ea9ac363b7126741e4c07","head":{"label":"percy:dry-up-snapshot-viewer-logic","ref":"dry-up-snapshot-viewer-logic","sha":"be0f721f4048338d316ea9ac363b7126741e4c07","user":{"login":"percy","id":12260884,"avatar_url":"https://avatars3.githubusercontent.com/u/12260884?v=4","gravatar_id":"","url":"https://api.github.com/users/percy","html_url":"https://github.com/percy","followers_url":"https://api.github.com/users/percy/followers","following_url":"https://api.github.com/users/percy/following{/other_user}","gists_url":"https://api.github.com/users/percy/gists{/gist_id}","starred_url":"https://api.github.com/users/percy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/percy/subscriptions","organizations_url":"https://api.github.com/users/percy/orgs","repos_url":"https://api.github.com/users/percy/repos","events_url":"https://api.github.com/users/percy/events{/privacy}","received_events_url":"https://api.github.com/users/percy/received_events","type":"Organization","site_admin":false},"repo":{"id":26990470,"name":"percy-web","full_name":"percy/percy-web","owner":{"login":"percy","id":12260884,"avatar_url":"https://avatars3.githubusercontent.com/u/12260884?v=4","gravatar_id":"","url":"https://api.github.com/users/percy","html_url":"https://github.com/percy","followers_url":"https://api.github.com/users/percy/followers","following_url":"https://api.github.com/users/percy/following{/other_user}","gists_url":"https://api.github.com/users/percy/gists{/gist_id}","starred_url":"https://api.github.com/users/percy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/percy/subscriptions","organizations_url":"https://api.github.com/users/percy/orgs","repos_url":"https://api.github.com/users/percy/repos","events_url":"https://api.github.com/users/percy/events{/privacy}","received_events_url":"https://api.github.com/users/percy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/percy/percy-web","description":"Percy's frontend web application, built with Ember.","fork":false,"url":"https://api.github.com/repos/percy/percy-web","forks_url":"https://api.github.com/repos/percy/percy-web/forks","keys_url":"https://api.github.com/repos/percy/percy-web/keys{/key_id}","collaborators_url":"https://api.github.com/repos/percy/percy-web/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/percy/percy-web/teams","hooks_url":"https://api.github.com/repos/percy/percy-web/hooks","issue_events_url":"https://api.github.com/repos/percy/percy-web/issues/events{/number}","events_url":"https://api.github.com/repos/percy/percy-web/events","assignees_url":"https://api.github.com/repos/percy/percy-web/assignees{/user}","branches_url":"https://api.github.com/repos/percy/percy-web/branches{/branch}","tags_url":"https://api.github.com/repos/percy/percy-web/tags","blobs_url":"https://api.github.com/repos/percy/percy-web/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/percy/percy-web/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/percy/percy-web/git/refs{/sha}","trees_url":"https://api.github.com/repos/percy/percy-web/git/trees{/sha}","statuses_url":"https://api.github.com/repos/percy/percy-web/statuses/{sha}","languages_url":"https://api.github.com/repos/percy/percy-web/languages","stargazers_url":"https://api.github.com/repos/percy/percy-web/stargazers","contributors_url":"https://api.github.com/repos/percy/percy-web/contributors","subscribers_url":"https://api.github.com/repos/percy/percy-web/subscribers","subscription_url":"https://api.github.com/repos/percy/percy-web/subscription","commits_url":"https://api.github.com/repos/percy/percy-web/commits{/sha}","git_commits_url":"https://api.github.com/repos/percy/percy-web/git/commits{/sha}","comments_url":"https://api.github.com/repos/percy/percy-web/comments{/number}","issue_comment_url":"https://api.github.com/repos/percy/percy-web/issues/comments{/number}","contents_url":"https://api.github.com/repos/percy/percy-web/contents/{+path}","compare_url":"https://api.github.com/repos/percy/percy-web/compare/{base}...{head}","merges_url":"https://api.github.com/repos/percy/percy-web/merges","archive_url":"https://api.github.com/repos/percy/percy-web/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/percy/percy-web/downloads","issues_url":"https://api.github.com/repos/percy/percy-web/issues{/number}","pulls_url":"https://api.github.com/repos/percy/percy-web/pulls{/number}","milestones_url":"https://api.github.com/repos/percy/percy-web/milestones{/number}","notifications_url":"https://api.github.com/repos/percy/percy-web/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/percy/percy-web/labels{/name}","releases_url":"https://api.github.com/repos/percy/percy-web/releases{/id}","deployments_url":"https://api.github.com/repos/percy/percy-web/deployments","created_at":"2014-11-22T06:04:29Z","updated_at":"2018-05-16T21:25:17Z","pushed_at":"2018-05-16T21:27:08Z","git_url":"git://github.com/percy/percy-web.git","ssh_url":"git@github.com:percy/percy-web.git","clone_url":"https://github.com/percy/percy-web.git","svn_url":"https://github.com/percy/percy-web","homepage":"https://percy.io","size":13748,"stargazers_count":89,"watchers_count":89,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":17,"mirror_url":null,"archived":false,"open_issues_count":11,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":17,"open_issues":11,"watchers":89,"default_branch":"master"}},"base":{"label":"percy:master","ref":"master","sha":"48b3447786dac163ecd23424bcf051cfd89a5928","user":{"login":"percy","id":12260884,"avatar_url":"https://avatars3.githubusercontent.com/u/12260884?v=4","gravatar_id":"","url":"https://api.github.com/users/percy","html_url":"https://github.com/percy","followers_url":"https://api.github.com/users/percy/followers","following_url":"https://api.github.com/users/percy/following{/other_user}","gists_url":"https://api.github.com/users/percy/gists{/gist_id}","starred_url":"https://api.github.com/users/percy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/percy/subscriptions","organizations_url":"https://api.github.com/users/percy/orgs","repos_url":"https://api.github.com/users/percy/repos","events_url":"https://api.github.com/users/percy/events{/privacy}","received_events_url":"https://api.github.com/users/percy/received_events","type":"Organization","site_admin":false},"repo":{"id":26990470,"name":"percy-web","full_name":"percy/percy-web","owner":{"login":"percy","id":12260884,"avatar_url":"https://avatars3.githubusercontent.com/u/12260884?v=4","gravatar_id":"","url":"https://api.github.com/users/percy","html_url":"https://github.com/percy","followers_url":"https://api.github.com/users/percy/followers","following_url":"https://api.github.com/users/percy/following{/other_user}","gists_url":"https://api.github.com/users/percy/gists{/gist_id}","starred_url":"https://api.github.com/users/percy/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/percy/subscriptions","organizations_url":"https://api.github.com/users/percy/orgs","repos_url":"https://api.github.com/users/percy/repos","events_url":"https://api.github.com/users/percy/events{/privacy}","received_events_url":"https://api.github.com/users/percy/received_events","type":"Organization","site_admin":false},"private":false,"html_url":"https://github.com/percy/percy-web","description":"Percy's frontend web application, built with Ember.","fork":false,"url":"https://api.github.com/repos/percy/percy-web","forks_url":"https://api.github.com/repos/percy/percy-web/forks","keys_url":"https://api.github.com/repos/percy/percy-web/keys{/key_id}","collaborators_url":"https://api.github.com/repos/percy/percy-web/collaborators{/collaborator}","teams_url":"https://api.github.com/repos/percy/percy-web/teams","hooks_url":"https://api.github.com/repos/percy/percy-web/hooks","issue_events_url":"https://api.github.com/repos/percy/percy-web/issues/events{/number}","events_url":"https://api.github.com/repos/percy/percy-web/events","assignees_url":"https://api.github.com/repos/percy/percy-web/assignees{/user}","branches_url":"https://api.github.com/repos/percy/percy-web/branches{/branch}","tags_url":"https://api.github.com/repos/percy/percy-web/tags","blobs_url":"https://api.github.com/repos/percy/percy-web/git/blobs{/sha}","git_tags_url":"https://api.github.com/repos/percy/percy-web/git/tags{/sha}","git_refs_url":"https://api.github.com/repos/percy/percy-web/git/refs{/sha}","trees_url":"https://api.github.com/repos/percy/percy-web/git/trees{/sha}","statuses_url":"https://api.github.com/repos/percy/percy-web/statuses/{sha}","languages_url":"https://api.github.com/repos/percy/percy-web/languages","stargazers_url":"https://api.github.com/repos/percy/percy-web/stargazers","contributors_url":"https://api.github.com/repos/percy/percy-web/contributors","subscribers_url":"https://api.github.com/repos/percy/percy-web/subscribers","subscription_url":"https://api.github.com/repos/percy/percy-web/subscription","commits_url":"https://api.github.com/repos/percy/percy-web/commits{/sha}","git_commits_url":"https://api.github.com/repos/percy/percy-web/git/commits{/sha}","comments_url":"https://api.github.com/repos/percy/percy-web/comments{/number}","issue_comment_url":"https://api.github.com/repos/percy/percy-web/issues/comments{/number}","contents_url":"https://api.github.com/repos/percy/percy-web/contents/{+path}","compare_url":"https://api.github.com/repos/percy/percy-web/compare/{base}...{head}","merges_url":"https://api.github.com/repos/percy/percy-web/merges","archive_url":"https://api.github.com/repos/percy/percy-web/{archive_format}{/ref}","downloads_url":"https://api.github.com/repos/percy/percy-web/downloads","issues_url":"https://api.github.com/repos/percy/percy-web/issues{/number}","pulls_url":"https://api.github.com/repos/percy/percy-web/pulls{/number}","milestones_url":"https://api.github.com/repos/percy/percy-web/milestones{/number}","notifications_url":"https://api.github.com/repos/percy/percy-web/notifications{?since,all,participating}","labels_url":"https://api.github.com/repos/percy/percy-web/labels{/name}","releases_url":"https://api.github.com/repos/percy/percy-web/releases{/id}","deployments_url":"https://api.github.com/repos/percy/percy-web/deployments","created_at":"2014-11-22T06:04:29Z","updated_at":"2018-05-16T21:25:17Z","pushed_at":"2018-05-16T21:27:08Z","git_url":"git://github.com/percy/percy-web.git","ssh_url":"git@github.com:percy/percy-web.git","clone_url":"https://github.com/percy/percy-web.git","svn_url":"https://github.com/percy/percy-web","homepage":"https://percy.io","size":13748,"stargazers_count":89,"watchers_count":89,"language":"JavaScript","has_issues":true,"has_projects":true,"has_downloads":true,"has_wiki":false,"has_pages":false,"forks_count":17,"mirror_url":null,"archived":false,"open_issues_count":11,"license":{"key":"mit","name":"MIT License","spdx_id":"MIT","url":"https://api.github.com/licenses/mit"},"forks":17,"open_issues":11,"watchers":89,"default_branch":"master"}},"_links":{"self":{"href":"https://api.github.com/repos/percy/percy-web/pulls/529"},"html":{"href":"https://github.com/percy/percy-web/pull/529"},"issue":{"href":"https://api.github.com/repos/percy/percy-web/issues/529"},"comments":{"href":"https://api.github.com/repos/percy/percy-web/issues/529/comments"},"review_comments":{"href":"https://api.github.com/repos/percy/percy-web/pulls/529/comments"},"review_comment":{"href":"https://api.github.com/repos/percy/percy-web/pulls/comments{/number}"},"commits":{"href":"https://api.github.com/repos/percy/percy-web/pulls/529/commits"},"statuses":{"href":"https://api.github.com/repos/percy/percy-web/statuses/be0f721f4048338d316ea9ac363b7126741e4c07"}},"author_association":"CONTRIBUTOR"}}
{"actor":{"display_login":"fotinakis"}}