|
37 | 37 | end |
38 | 38 | end |
39 | 39 |
|
| 40 | + context "with dropped achievement" do |
| 41 | + let!(:achievement) { create(:dropped_achievement, user: current_user, activity:) } |
| 42 | + |
| 43 | + before do |
| 44 | + render_inline(described_class.new(activity:, current_user:)) |
| 45 | + end |
| 46 | + |
| 47 | + it "should render the element" do |
| 48 | + expect(page).to have_css(".cpd-course-item") |
| 49 | + end |
| 50 | + |
| 51 | + it "should render title" do |
| 52 | + expect(page).to have_css(".govuk-body", text: activity.title) |
| 53 | + end |
| 54 | + |
| 55 | + it "should render the book now button" do |
| 56 | + expect(page).to have_link("Book now", href: "/courses/#{activity.stem_activity_code}/#{activity.slug}") |
| 57 | + end |
| 58 | + end |
| 59 | + |
40 | 60 | context "when complete" do |
41 | 61 | let!(:achievement) { create(:completed_achievement, user: current_user, activity:) } |
42 | 62 |
|
|
60 | 80 | render_inline(described_class.new(activity:, current_user:)) |
61 | 81 | end |
62 | 82 |
|
63 | | - it "should show completed flag" do |
| 83 | + it "should show in progress flag" do |
64 | 84 | expect(page).to have_css(".status-tag", text: "In progress") |
65 | 85 | end |
66 | 86 |
|
67 | 87 | it "should not show book button" do |
68 | 88 | expect(page).not_to have_link("Book now", href: "/courses/#{activity.stem_activity_code}/#{activity.slug}") |
69 | 89 | end |
70 | 90 | end |
| 91 | + |
| 92 | + context "with dropped achievement and completed" do |
| 93 | + let!(:achievement) { create(:dropped_achievement, user: current_user, activity:) } |
| 94 | + let!(:achievement) { create(:completed_achievement, user: current_user, activity:) } |
| 95 | + |
| 96 | + before do |
| 97 | + render_inline(described_class.new(activity:, current_user:)) |
| 98 | + end |
| 99 | + |
| 100 | + it "should render the element" do |
| 101 | + expect(page).to have_css(".cpd-course-item") |
| 102 | + end |
| 103 | + |
| 104 | + it "should render title" do |
| 105 | + expect(page).to have_css(".govuk-body", text: activity.title) |
| 106 | + end |
| 107 | + |
| 108 | + it "should not show book button" do |
| 109 | + expect(page).not_to have_link("Book now", href: "/courses/#{activity.stem_activity_code}/#{activity.slug}") |
| 110 | + end |
| 111 | + |
| 112 | + it "should show completed flag" do |
| 113 | + expect(page).to have_css(".status-tag", text: "Completed") |
| 114 | + end |
| 115 | + end |
| 116 | + |
| 117 | + context "with dropped achievement and in_progress" do |
| 118 | + let!(:achievement) { create(:dropped_achievement, user: current_user, activity:) } |
| 119 | + let!(:achievement) { create(:achievement, user: current_user, activity:) } |
| 120 | + |
| 121 | + before do |
| 122 | + render_inline(described_class.new(activity:, current_user:)) |
| 123 | + end |
| 124 | + |
| 125 | + it "should render the element" do |
| 126 | + expect(page).to have_css(".cpd-course-item") |
| 127 | + end |
| 128 | + |
| 129 | + it "should render title" do |
| 130 | + expect(page).to have_css(".govuk-body", text: activity.title) |
| 131 | + end |
| 132 | + |
| 133 | + it "should not show book button" do |
| 134 | + expect(page).not_to have_link("Book now", href: "/courses/#{activity.stem_activity_code}/#{activity.slug}") |
| 135 | + end |
| 136 | + |
| 137 | + it "should show in progress flag" do |
| 138 | + expect(page).to have_css(".status-tag", text: "In progress") |
| 139 | + end |
| 140 | + end |
71 | 141 | end |
0 commit comments