Skip to content

Commit 9a164ab

Browse files
committed
Add contact waiting time scores component specs
1 parent 6b7173b commit 9a164ab

2 files changed

Lines changed: 122 additions & 0 deletions

File tree

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
# frozen_string_literal: true
2+
3+
require "rails_helper"
4+
5+
RSpec.describe CsrTable::ContactWaitingTimeScoresComponent, type: :component do
6+
subject { page }
7+
8+
let(:supplier) { build(:supplier, :ranked) }
9+
10+
before do
11+
render_inline described_class.new(supplier)
12+
end
13+
14+
it { is_expected.to have_text "Contact waiting time" }
15+
it { is_expected.to have_text "How long can you expect to wait when contacting this supplier?" }
16+
17+
it { is_expected.to have_text "Emails responded to within 2 days" }
18+
it { is_expected.to have_text "89%" }
19+
it { is_expected.to have_text "Average call centre wait time" }
20+
it { is_expected.to have_text "3 minutes 27 seconds" }
21+
22+
context "when the supplier has synchronous customer contact channels" do
23+
let(:supplier) { build(:supplier, :sync_contact) }
24+
25+
it { is_expected.to have_text "Average Webchat response time" }
26+
it { is_expected.to have_text "3 minutes" }
27+
it { is_expected.to have_text "Average Whatsapp response time" }
28+
it { is_expected.to have_text "1 hour 23 minutes 10 seconds" }
29+
it { is_expected.to have_text "Average SMS response time" }
30+
it { is_expected.to have_text "4 hours 47 minutes" }
31+
it { is_expected.to have_text "Average response time using the supplier's app" }
32+
it { is_expected.to have_text "39 minutes 16 seconds" }
33+
it { is_expected.to have_text "Average response time using a customer account portal" }
34+
it { is_expected.to have_text "1 hour 1 minute 1 second" }
35+
end
36+
37+
context "when the supplier has asynchronous customer contact channels" do
38+
let(:supplier) { build(:supplier, :async_contact) }
39+
40+
it { is_expected.to have_text "Webchat messages responded to within 2 days" }
41+
it { is_expected.to have_text "45.7%" }
42+
it { is_expected.to have_text "Whatsapp messages responded to within 2 days" }
43+
it { is_expected.to have_text "89.3%" }
44+
it { is_expected.to have_text "SMS messages responded to within 2 days" }
45+
it { is_expected.to have_text "99.9%" }
46+
it { is_expected.to have_text "Messages responded to within 2 days using the supplier's app" }
47+
it { is_expected.to have_text "74.2%" }
48+
it { is_expected.to have_text "Messages responded to within 2 days using a customer account portal" }
49+
it { is_expected.to have_text "82.9%" }
50+
end
51+
52+
context "when the supplier has no asynchronous or synchronous customer contact channels" do
53+
let(:supplier) { build(:supplier, :no_sync_or_async_contact) }
54+
55+
it { is_expected.to have_text "Emails responded to within 2 days" }
56+
it { is_expected.to have_text "Average call centre wait time" }
57+
58+
it { is_expected.to have_no_text "Average Webchat response time" }
59+
it { is_expected.to have_no_text "Average Whatsapp response time" }
60+
it { is_expected.to have_no_text "Average SMS response time" }
61+
it { is_expected.to have_no_text "Average response time using the supplier's app" }
62+
it { is_expected.to have_no_text "Average response time using a customer account portal" }
63+
it { is_expected.to have_no_text "Webchat messages responded to within 2 days" }
64+
it { is_expected.to have_no_text "Whatsapp messages responded to within 2 days" }
65+
it { is_expected.to have_no_text "SMS messages responded to within 2 days" }
66+
it { is_expected.to have_no_text "Messages responded to within 2 days using the supplier's app" }
67+
it { is_expected.to have_no_text "Messages responded to within 2 days using a customer account portal" }
68+
end
69+
70+
context "when there is no supplier" do
71+
let(:supplier) { nil }
72+
73+
it { is_expected.to have_no_css "body" }
74+
end
75+
end

spec/factories/supplier.rb

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,6 +32,41 @@
3232
contact_social_media { "01:15:00" }
3333
end
3434

35+
trait :sync_contact do
36+
contact_time { "00:03:27" }
37+
contact_email { 89 }
38+
contact_webchat_sync { "00:03:00" }
39+
contact_whatsapp_sync { "01:23:10" }
40+
contact_sms_sync { "04:47:00" }
41+
contact_in_app_sync { "00:39:16" }
42+
contact_portal_sync { "01:01:01" }
43+
end
44+
45+
trait :async_contact do
46+
contact_time { "00:03:27" }
47+
contact_email { 89 }
48+
contact_webchat_async { 45.7 }
49+
contact_whatsapp_async { 89.3 }
50+
contact_sms_async { 99.9 }
51+
contact_in_app_async { 74.2 }
52+
contact_portal_async { 82.9 }
53+
end
54+
55+
trait :no_sync_or_async_contact do
56+
contact_time { "00:03:27" }
57+
contact_email { 89 }
58+
contact_webchat_sync { nil }
59+
contact_whatsapp_sync { nil }
60+
contact_sms_sync { nil }
61+
contact_in_app_sync { nil }
62+
contact_portal_sync { nil }
63+
contact_webchat_async { nil }
64+
contact_whatsapp_async { nil }
65+
contact_sms_async { nil }
66+
contact_in_app_async { nil }
67+
contact_portal_async { nil }
68+
end
69+
3570
trait :missing_fuel_mix do
3671
fuel_mix { nil }
3772
end
@@ -56,6 +91,18 @@
5691
data factory: %i[supplier_data ranked]
5792
end
5893

94+
trait(:sync_contact) do
95+
data factory: %i[supplier_data sync_contact]
96+
end
97+
98+
trait(:async_contact) do
99+
data factory: %i[supplier_data async_contact]
100+
end
101+
102+
trait(:no_sync_or_async_contact) do
103+
data factory: %i[supplier_data no_sync_or_async_contact]
104+
end
105+
59106
trait(:whitelabelled) do
60107
data factory: %i[supplier_data whitelabelled]
61108
end

0 commit comments

Comments
 (0)