DEV: test badge titles presence on badge page

approved
#1

DEV: test badge titles presence on badge page

follow-up on 2863e7c

diff --git a/test/javascripts/acceptance/badges-test.js.es6 b/test/javascripts/acceptance/badges-test.js.es6
index 9de24ae..a9cb69a 100644
--- a/test/javascripts/acceptance/badges-test.js.es6
+++ b/test/javascripts/acceptance/badges-test.js.es6
@@ -1,4 +1,5 @@
-import { acceptance } from "helpers/qunit-helpers";
+import selectKit from "helpers/select-kit-helper";
+import { acceptance, logIn } from "helpers/qunit-helpers";
 
 acceptance("Badges");
 
@@ -14,3 +15,13 @@ QUnit.test("Visit Badge Pages", async assert => {
   assert.ok(exists(".user-info"), "has the list of users with that badge");
   assert.ok(!exists(".badge-card:eq(0) script"));
 });
+
+QUnit.test("shows correct badge titles to choose from", async assert => {
+  logIn();
+  Discourse.reset();
+  const availableBadgeTitles = selectKit(".select-kit");
+
+  await visit("/badges/50/custombadge");
+  await availableBadgeTitles.expand();
+  assert.ok(availableBadgeTitles.rowByIndex(1).name() === "CustomBadge");
+});
diff --git a/test/javascripts/fixtures/badges_fixture.js.es6 b/test/javascripts/fixtures/badges_fixture.js.es6
index 0bde34c..eff532d 100644
--- a/test/javascripts/fixtures/badges_fixture.js.es6
+++ b/test/javascripts/fixtures/badges_fixture.js.es6
@@ -404,6 +404,30 @@ export default {
       badge_type_id: 3
     }
   },
+  "/badges/50": {
+    badge_types: [
+      {
+        id: 3,
+        name: "Bronze"
+      }
+    ],
+    badge: {
+      id: 50,
+      name: "CustomBadge",
+      description: null,
+      long_description: "",
+      grant_count: 10,
+      allow_title: true,
+      multiple_grant: true,
+      icon: "fa-certificate",
+      listable: true,
+      enabled: true,
+      badge_grouping_id: 1,
+      system: false,
+      badge_type_id: 3,
+      has_badge: true
+    }
+  },
   "/user_badges.json": {
     badges: [
       {
diff --git a/test/javascripts/fixtures/user-badges.js.es6 b/test/javascripts/fixtures/user-badges.js.es6
index 59cd0df..97f8217 100644
--- a/test/javascripts/fixtures/user-badges.js.es6
+++ b/test/javascripts/fixtures/user-badges.js.es6
@@ -36,6 +36,13 @@ export default {
         name: "Badge 8",
         description: null,
         badge_type_id: 13
+      },
+      {
+        id: 50,
+        name: "CustomBadge",
+        description: null,
+        allow_title: true,
+        badge_type_id: 3
       }
     ],
     badge_types: [
@@ -51,6 +58,12 @@ export default {
         granted_at: "2014-03-09T20:30:01.420-04:00",
         badge_id: 880,
         granted_by_id: null
+      },
+      {
+        id: 669,
+        granted_at: "2014-03-09T20:30:01.420-04:00",
+        badge_id: 50,
+        granted_by_id: null
       }
     ]
   }

GitHub sha: 621b6493

2 Likes
Approved #2