|
49 | 49 | allow(region).to receive(:facility_region?).and_return(true) |
50 | 50 | allow(DeviceDetector).to receive(:new).and_return(double(device_type: "desktop")) |
51 | 51 | end |
52 | | - context "and the feature flag is enabled" do |
| 52 | + |
| 53 | + context "and the quick_link_for_metabase feature flag is enabled" do |
53 | 54 | before { Flipper.enable(:quick_link_for_metabase, cvho) } |
54 | | - it "displays the quick links section with the correct URLs" do |
| 55 | + |
| 56 | + it "displays the generic quick links section" do |
55 | 57 | sign_in(cvho.email_authentication) |
56 | 58 | get :show, params: {id: region.slug, report_scope: "facility"} |
57 | 59 | expect(response.body).to include("Quick links") |
58 | | - expect(response.body).to include("Drug stock report") |
59 | 60 | expect(response.body).to include("Metabase: Titration report") |
60 | 61 | expect(response.body).to include("Metabase: BP fudging report") |
61 | | - expect(response.body).to include("https://api.example.com/my_facilities/drug_stocks?facility_group=") |
62 | | - expect(response.body).to include("href=\"https://metabase.example.com/titration?region=#{region.name}\"") |
63 | | - expect(response.body).to include("href=\"https://metabase.example.com/bp_fudging?region=#{region.name}\"") |
64 | 62 | end |
65 | | - end |
66 | | - context "and the feature flag is disabled" do |
67 | | - it "does not display the quick links section" do |
| 63 | + |
| 64 | + it "shows the Metabase: Drug stock report link for Ethiopia" do |
68 | 65 | sign_in(cvho.email_authentication) |
| 66 | + allow(CountryConfig).to receive(:current_country?).and_return(false) |
| 67 | + allow(CountryConfig).to receive(:current_country?).with("Ethiopia").and_return(true) |
69 | 68 | get :show, params: {id: region.slug, report_scope: "facility"} |
70 | | - expect(response.body).to_not include("Quick links") |
71 | | - expect(response.body).to_not include("Drug stock report") |
72 | | - expect(response.body).to_not include("Metabase: Titration report") |
73 | | - expect(response.body).to_not include("Metabase: BP fudging report") |
| 69 | + expect(response.body).to include("Metabase: Drug stock report") |
| 70 | + expect(response.body).to include(ENV.fetch("DRUG_STOCK_REPORT_URL", "")) |
| 71 | + expect(response.body).to include("&name=#{region.name}") |
| 72 | + end |
| 73 | + |
| 74 | + it "does not show any drug stock links for Sri Lanka" do |
| 75 | + sign_in(cvho.email_authentication) |
| 76 | + allow(CountryConfig).to receive(:current_country?).and_return(false) |
| 77 | + allow(CountryConfig).to receive(:current_country?).with("Sri Lanka").and_return(true) |
| 78 | + get :show, params: {id: region.slug, report_scope: "facility"} |
| 79 | + expect(response.body).not_to include("Drug stock report") |
| 80 | + expect(response.body).not_to include("Metabase: Drug stock report") |
74 | 81 | end |
75 | 82 | end |
76 | 83 | end |
|
83 | 90 | allow(region).to receive(:district_region?).and_return(true) |
84 | 91 | allow(DeviceDetector).to receive(:new).and_return(double(device_type: "desktop")) |
85 | 92 | end |
86 | | - context "and the feature flag is enabled" do |
| 93 | + |
| 94 | + context "and the quick_link_for_metabase feature flag is enabled" do |
87 | 95 | before { Flipper.enable(:quick_link_for_metabase, cvho) } |
88 | | - it "displays the quick links section with the correct URLs" do |
| 96 | + |
| 97 | + it "displays the generic quick links section" do |
89 | 98 | sign_in(cvho.email_authentication) |
90 | 99 | get :show, params: {id: facility_group.slug, report_scope: "district"} |
91 | | - expect(response.body).to include("Facility trends") |
92 | | - expect(response.body).to include("Drug stock") |
| 100 | + expect(response.body).to include("Quick links") |
93 | 101 | expect(response.body).to include("Metabase: Titration report") |
94 | 102 | expect(response.body).to include("Metabase: BP fudging report") |
95 | | - expect(response.body).to include("Metabase: Systolic BP reading report") |
96 | | - expect(response.body).to include("https://api.example.com/my_facilities/drug_stocks?facility_group=") |
97 | | - expect(response.body).to include("https://api.example.com/my_facilities/bp_controlled?facility_group=") |
98 | | - expect(response.body).to include("https://metabase.example.com/titration?district_name=") |
99 | | - expect(response.body).to include("https://metabase.example.com/bp_fudging?state_name=") |
100 | | - expect(response.body).to include("https://metabase.example.com/systolic?district_name=") |
101 | 103 | end |
102 | | - end |
103 | | - context "and the feature flag is disabled" do |
104 | | - it "does not display the quick links section" do |
| 104 | + |
| 105 | + it "displays Facility trends link and Metabase: Systolic BP reading report link for Bangladesh" do |
105 | 106 | sign_in(cvho.email_authentication) |
| 107 | + allow(CountryConfig).to receive(:current_country?).and_return(false) |
| 108 | + allow(CountryConfig).to receive(:current_country?).with("Bangladesh").and_return(true) |
106 | 109 | get :show, params: {id: facility_group.slug, report_scope: "district"} |
107 | | - expect(response.body).to_not include("District facility trend report") |
108 | | - expect(response.body).to_not include("District Drug sto_notck report") |
109 | | - expect(response.body).to_not include("Metabase: Titration report") |
110 | | - expect(response.body).to_not include("Metabase: BP fudging report") |
111 | | - expect(response.body).to_not include("Metabase: Systolic BP reading report") |
112 | | - expect(response.body).to_not include("https://api.example.com/my_facilities/drug_stocks?facility_group=") |
113 | | - expect(response.body).to_not include("https://api.example.com/my_facilities/bp_controlled?facility_group=") |
114 | | - expect(response.body).to_not include("https://metabase.example.com/titration?district_name=") |
115 | | - expect(response.body).to_not include("https://metabase.example.com/bp_fudging?state_name=") |
116 | | - expect(response.body).to_not include("https://metabase.example.com/systolic?district_name=") |
| 110 | + expect(response.body).to include("Facility trends") |
| 111 | + expect(response.body).to include(ENV.fetch("DISTRICT_FACILITY_TREND_REPORT_URL", "")) |
| 112 | + expect(response.body).to include("Metabase: Systolic BP reading report") |
| 113 | + expect(response.body).to include(ENV.fetch("DISTRICT_METABASE_SYSTOLIC_BP_URL", "")) |
117 | 114 | end |
118 | | - end |
119 | | - end |
120 | | - |
121 | | - context "drug stock report links by country" do |
122 | | - let(:facility_group) { create(:facility_group, organization: organization) } |
123 | | - let(:facility) { create(:facility, facility_group: facility_group) } |
124 | | - let(:region) { facility.region } |
125 | 115 |
|
126 | | - before do |
127 | | - allow(DeviceDetector).to receive(:new).and_return(double(device_type: "desktop")) |
128 | | - Flipper.enable(:quick_link_for_metabase, cvho) |
129 | | - sign_in(cvho.email_authentication) |
130 | | - end |
131 | | - |
132 | | - context "when country is Ethiopia" do |
133 | | - before do |
| 116 | + it "displays Metabase: Drug stock report link for Ethiopia" do |
| 117 | + sign_in(cvho.email_authentication) |
| 118 | + allow(CountryConfig).to receive(:current_country?).and_return(false) |
134 | 119 | allow(CountryConfig).to receive(:current_country?).with("Ethiopia").and_return(true) |
135 | | - allow(CountryConfig).to receive(:current_country?).with("Sri Lanka").and_return(false) |
136 | | - get :show, params: {id: region.slug, report_scope: "facility"} |
137 | | - end |
138 | | - |
139 | | - it "shows the facility drug stock report link" do |
140 | | - expect(response.body).to include("Metabase: Drug stock report") |
141 | | - expect(response.body).to include(ENV.fetch("DRUG_STOCK_REPORT_URL", "")) |
142 | | - expect(response.body).to include("&name=#{region.name}") |
143 | | - end |
144 | | - |
145 | | - it "shows the district drug stock report link" do |
| 120 | + get :show, params: {id: facility_group.slug, report_scope: "district"} |
146 | 121 | expect(response.body).to include("Metabase: Drug stock report") |
147 | 122 | expect(response.body).to include(ENV.fetch("DISTRICT_DRUG_STOCK_REPORT_URL", "")) |
148 | | - expect(response.body).to include(region.source.slug) |
149 | | - end |
150 | | - end |
151 | | - |
152 | | - context "when country is not Sri Lanka" do |
153 | | - before do |
154 | | - allow(CountryConfig).to receive(:current_country?).with("Ethiopia").and_return(false) |
155 | | - allow(CountryConfig).to receive(:current_country?).with("Sri Lanka").and_return(false) |
156 | | - get :show, params: {id: region.slug, report_scope: "facility"} |
157 | 123 | end |
158 | 124 |
|
159 | | - it "shows the facility drug stock report link" do |
160 | | - expect(response.body).to include("Drug stock report") |
161 | | - expect(response.body).to include(ENV.fetch("DRUG_STOCK_REPORT_URL", "")) |
162 | | - expect(response.body).to include(region.name) |
163 | | - end |
164 | | - |
165 | | - it "shows the district drug stock report link" do |
166 | | - expect(response.body).to include("Drug stock") |
167 | | - expect(response.body).to include(ENV.fetch("DISTRICT_DRUG_STOCK_REPORT_URL", "")) |
168 | | - expect(response.body).to include(region.source.slug) |
169 | | - end |
170 | | - end |
171 | | - |
172 | | - context "when country is Sri Lanka" do |
173 | | - before do |
174 | | - allow(CountryConfig).to receive(:current_country?).with("Ethiopia").and_return(false) |
| 125 | + it "does not show any drug stock links for Sri Lanka" do |
| 126 | + sign_in(cvho.email_authentication) |
| 127 | + allow(CountryConfig).to receive(:current_country?).and_return(false) |
175 | 128 | allow(CountryConfig).to receive(:current_country?).with("Sri Lanka").and_return(true) |
176 | | - get :show, params: {id: region.slug, report_scope: "facility"} |
177 | | - end |
178 | | - |
179 | | - it "does not show any drug stock links" do |
| 129 | + get :show, params: {id: facility_group.slug, report_scope: "district"} |
180 | 130 | expect(response.body).not_to include("Drug stock report") |
181 | 131 | expect(response.body).not_to include("Metabase: Drug stock report") |
182 | 132 | end |
|
0 commit comments