From 621b6493f7193136d3a27ad34d732494e6f3817d Mon Sep 17 00:00:00 2001 From: Maja Komel Date: Wed, 12 Jun 2019 11:26:24 +0200 Subject: [PATCH] DEV: test badge titles presence on badge page follow-up on 2863e7c --- .../javascripts/acceptance/badges-test.js.es6 | 13 +++++++++- .../fixtures/badges_fixture.js.es6 | 24 +++++++++++++++++++ test/javascripts/fixtures/user-badges.js.es6 | 13 ++++++++++ 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/test/javascripts/acceptance/badges-test.js.es6 b/test/javascripts/acceptance/badges-test.js.es6 index 9de24ae3f9c..a9cb69a43c3 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 0bde34c6778..eff532d4964 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 59cd0dfa5d6..97f8217ded6 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 } ] }