-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
sc-13986 Enabled diabetes option in progress tab with assigned patien…
…ts (#5481) **Story card:** [sc-13986](https://app.shortcut.com/simpledotorg/story/13986/enable-diabetes-option-in-progress-tab) ## Because Enabled the diabetes option with the assigned patients section ## This addresses Enabled the assigned patients section with values as given in the below screenshots. ## Test instructions Enable this flipper flag :diabetes_progress_report_tab to check the functionality. --------- Co-authored-by: Dany Sam <[email protected]>
- Loading branch information
1 parent
f7b647c
commit 75c756a
Showing
10 changed files
with
150 additions
and
19 deletions.
There are no files selected for viewing
17 changes: 17 additions & 0 deletions
17
app/components/progress_tab/diabetes/diagnosis_report_component.html.erb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
<div id="diabetes-report" class="d-none"> | ||
<div class="mb-8px pt-16px pb-16px bgc-white bs-card"> | ||
<a | ||
class="d-inline-flex ai-center h-24px mb-24px pl-16px tt-uppercase" | ||
href="#" | ||
onclick="goToPage(id='diabetes-report', 'home-page'); return false;" | ||
> | ||
<%= inline_file("chevron-left.svg") %> | ||
back | ||
</a> | ||
</div> | ||
<%= render(Reports::ProgressAssignedPatientsComponent.new( | ||
assigned_patients: diabetes_reports_data[:assigned_patients], | ||
region: diabetes_reports_data[:region], | ||
diagnosis: "diabetes" | ||
)) %> | ||
</div> |
12 changes: 12 additions & 0 deletions
12
app/components/progress_tab/diabetes/diagnosis_report_component.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
# frozen_string_literal: true | ||
|
||
class ProgressTab::Diabetes::DiagnosisReportComponent < ApplicationComponent | ||
include AssetsHelper | ||
include ApplicationHelper | ||
|
||
attr_reader :diabetes_reports_data | ||
|
||
def initialize(diabetes_reports_data:) | ||
@diabetes_reports_data = diabetes_reports_data | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
26 changes: 26 additions & 0 deletions
26
spec/components/progress_tab/diabetes/diagnosis_report_component_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe ProgressTab::Diabetes::DiagnosisReportComponent, type: :component do | ||
let(:diabetes_reports_data) do | ||
{ | ||
assigned_patients: 100, | ||
region: double("Region", name: "Region 1"), | ||
diagnosis: "diabetes" | ||
} | ||
end | ||
subject { render_inline(described_class.new(diabetes_reports_data: diabetes_reports_data)) } | ||
|
||
it "renders the diabetes report section" do | ||
expect(subject).to have_css("div#diabetes-report") | ||
end | ||
|
||
it "renders the back link with correct text and onclick behavior" do | ||
expect(subject).to have_css('a[onclick="goToPage(id=\'diabetes-report\', \'home-page\'); return false;"]', text: "back") | ||
end | ||
|
||
it "renders the Reports::ProgressAssignedPatientsComponent with correct data" do | ||
expect(subject.text).to include("Region 1") | ||
expect(subject.text).to include(diabetes_reports_data[:assigned_patients].to_s) | ||
expect(subject.text).to include("diabetes") | ||
end | ||
end |
31 changes: 31 additions & 0 deletions
31
spec/components/reports/progress_assigned_patients_component_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
require "rails_helper" | ||
|
||
RSpec.describe Reports::ProgressAssignedPatientsComponent, type: :component do | ||
let(:region) { double("Region", name: "Region 1") } | ||
let(:assigned_patients) { 100 } | ||
let(:diagnosis) { "hypertension" } | ||
|
||
subject { render_inline(described_class.new(assigned_patients: assigned_patients, region: region, diagnosis: diagnosis)) } | ||
|
||
it "renders the correct title for the assigned patients card" do | ||
expect(subject).to have_css("h2", text: I18n.t("progress_tab.diagnosis_report.assigned_patients_card.title")) | ||
end | ||
|
||
it "displays the assigned patients count" do | ||
expect(subject).to have_css("p", text: assigned_patients.to_s) | ||
end | ||
|
||
it "displays the correct subtitle with region and diagnosis" do | ||
expect(subject).to have_css("p", text: I18n.t("progress_tab.diagnosis_report.assigned_patients_card.subtitle", facility_name: region.name, diagnosis: diagnosis)) | ||
end | ||
|
||
context "when diagnosis is not provided" do | ||
let(:diagnosis) { nil } | ||
|
||
subject { render_inline(described_class.new(assigned_patients: assigned_patients, region: region)) } | ||
|
||
it "uses the default diagnosis value (hypertension)" do | ||
expect(subject).to have_css("p", text: I18n.t("progress_tab.diagnosis_report.assigned_patients_card.subtitle", facility_name: region.name, diagnosis: "hypertension")) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters