Skip to content

Commit 298b65c

Browse files
committed
Add specs
1 parent 7de7e04 commit 298b65c

6 files changed

Lines changed: 87 additions & 3 deletions

File tree

spec/components/csr_table/score_summary_component_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,26 @@
1515
it { is_expected.to have_text "An Energy Supplier Inc scores for October to December 2023" }
1616
it { is_expected.to have_css ".stars", count: 4 }
1717

18+
context "when FF_NEW_CSR_DATA is enabled" do
19+
around do |example|
20+
ClimateControl.modify(FF_NEW_CSR_DATA: "true") do
21+
example.run
22+
end
23+
end
24+
25+
it { is_expected.to have_text "Billing and metering" }
26+
end
27+
28+
context "when FF_NEW_CSR_DATA is not enabled" do
29+
around do |example|
30+
ClimateControl.modify(FF_NEW_CSR_DATA: "false") do
31+
example.run
32+
end
33+
end
34+
35+
it { is_expected.to have_no_text "Billing and metering" }
36+
end
37+
1838
context "when there is no supplier" do
1939
let(:supplier) { nil }
2040

spec/components/csr_table/supplier_table_component_spec.rb

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,24 @@
1919
it { is_expected.to have_selector :columnheader, "Contact waiting time" }
2020
it { is_expected.to have_selector :columnheader, "Customer commitments" }
2121
it { is_expected.to have_selector :columnheader, "Overall rating" }
22+
23+
context "when FF_NEW_CSR_DATA is enabled" do
24+
around do |example|
25+
ClimateControl.modify(FF_NEW_CSR_DATA: "true") do
26+
example.run
27+
end
28+
end
29+
30+
it { is_expected.to have_selector :columnheader, "Billing and metering" }
31+
end
32+
33+
context "when FF_NEW_CSR_DATA is not enabled" do
34+
around do |example|
35+
ClimateControl.modify(FF_NEW_CSR_DATA: "false") do
36+
example.run
37+
end
38+
end
39+
40+
it { is_expected.to have_no_selector :columnheader, "Billing and metering" }
41+
end
2242
end

spec/components/csr_table/supplier_table_row_component_spec.rb

Lines changed: 20 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,9 +11,28 @@
1111
render_inline described_class.new(supplier)
1212
end
1313

14+
context "when FF_NEW_CSR_DATA is enabled" do
15+
around do |example|
16+
ClimateControl.modify(FF_NEW_CSR_DATA: "true") do
17+
example.run
18+
end
19+
end
20+
21+
it { is_expected.to have_css ".stars", count: 5 }
22+
end
23+
24+
context "when FF_NEW_CSR_DATA is not enabled" do
25+
around do |example|
26+
ClimateControl.modify(FF_NEW_CSR_DATA: "false") do
27+
example.run
28+
end
29+
end
30+
31+
it { is_expected.to have_css ".stars", count: 4 }
32+
end
33+
1434
it { is_expected.to have_text "1" }
1535
it { is_expected.to have_text "An Energy Supplier Inc" }
16-
it { is_expected.to have_css ".stars", count: 4 }
1736
it { is_expected.to have_css ".stars--highlight", count: 1 }
1837
it { is_expected.to have_link "More details", href: "#{CSR_APP_PATH}an-energy-supplier-inc/details" }
1938

spec/components/csr_table/unranked_suppliers/stars_summary_component_spec.rb

Lines changed: 24 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,30 @@
1717
end
1818

1919
it { is_expected.to have_text "You can compare the contact waiting time and customer commitments ratings with other suppliers." }
20-
it { is_expected.to have_css ".stars", count: 3 }
20+
21+
context "when FF_NEW_CSR_DATA is enabled" do
22+
around do |example|
23+
ClimateControl.modify(FF_NEW_CSR_DATA: "true") do
24+
example.run
25+
end
26+
end
27+
28+
before do
29+
render_inline described_class.new(build(:supplier))
30+
end
31+
32+
it { is_expected.to have_css ".stars", count: 4 }
33+
it { is_expected.to have_text "Billing and metering" }
34+
end
35+
36+
context "when FF_NEW_CSR_DATA is not enabled" do
37+
before do
38+
render_inline described_class.new(build(:supplier))
39+
end
40+
41+
it { is_expected.to have_css ".stars", count: 3 }
42+
it { is_expected.to have_no_text "Billing and metering" }
43+
end
2144

2245
context "when there is no supplier" do
2346
before do

spec/factories/supplier.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
contact_rating { 2.3 }
1212
guarantee_rating { 3 }
1313
overall_rating { 4.8 }
14+
bill_accuracy_and_metering_rating { 4.8 }
1415
contact_info { { json: JSON.parse(File.read("spec/fixtures/contact_info.json")) } }
1516
billing_info { { json: JSON.parse(File.read("spec/fixtures/billing_info.json")) } }
1617
opening_hours { { json: JSON.parse(File.read("spec/fixtures/opening_hours.json")) } }

spec/models/supplier_spec.rb

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,7 +85,7 @@
8585
its(:complaints_rating) { is_expected.to eq 4.3 }
8686
end
8787

88-
context "when FF_CSR_NEW_DATA is disabled" do
88+
context "when FF_CSR_NEW_DATA is not enabled" do
8989
around do |example|
9090
ClimateControl.modify(FF_NEW_CSR_DATA: "false") do
9191
example.run
@@ -106,6 +106,7 @@
106106
its(:guarantee_rating) { is_expected.to eq 3 }
107107
its(:overall_rating) { is_expected.to eq 4.8 }
108108
its(:id) { is_expected.to eq "an-energy-supplier-inc" }
109+
its(:bill_accuracy_and_metering_rating) { is_expected.to eq 4.8 }
109110

110111
it { is_expected.to be_top_three }
111112
it { is_expected.to be_persisted }

0 commit comments

Comments
 (0)