-
Notifications
You must be signed in to change notification settings - Fork 20
Expand file tree
/
Copy pathemployer_searches_controller_spec.rb
More file actions
180 lines (154 loc) · 7.02 KB
/
Copy pathemployer_searches_controller_spec.rb
File metadata and controls
180 lines (154 loc) · 7.02 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
require "rails_helper"
RSpec.describe Cbv::EmployerSearchesController do
include PinwheelApiHelper
include ArgyleApiHelper
describe "#show" do
let(:cbv_flow) { create(:cbv_flow, :invited) }
let(:pinwheel_token_id) { "abc-def-ghi" }
let(:user_token) { "foobar" }
before do
session[:flow_id] = cbv_flow.id
end
context "when rendering views" do
render_views
it "renders properly" do
get :show
expect(response).to be_successful
end
it "renders Common questions content" do
get :show
expect(response.body).to include(I18n.t("cbv.employer_searches.show.common_questions_header"))
expect(response.body).to include(I18n.t("cbv.employer_searches.show.lost_job_title"))
expect(response.body).to include(I18n.t("cbv.employer_searches.show.lost_job_body_html"))
expect(response.body).to include(I18n.t("cbv.employer_searches.show.no_income_title"))
expect(response.body).to include(I18n.t("cbv.employer_searches.show.no_income_body", agency_acronym: I18n.t("shared.agency_acronym.sandbox")))
end
it "tracks an event" do
allow(EventTrackingJob).to receive(:perform_later).with("CbvPageView", anything, anything)
expect(EventTrackingJob).to receive(:perform_later).with("ApplicantAccessedSearchPage", anything, hash_including(
time: be_a(Integer),
cbv_applicant_id: cbv_flow.cbv_applicant_id,
cbv_flow_id: cbv_flow.id,
invitation_id: cbv_flow.cbv_flow_invitation_id
))
get :show
end
it "tracks event when clicking popular payroll providers" do
allow(EventTrackingJob).to receive(:perform_later).with("CbvPageView", anything, anything)
expect(EventTrackingJob).to receive(:perform_later).with("ApplicantClickedPopularPayrollProviders", anything, hash_including(
time: be_a(Integer),
cbv_applicant_id: cbv_flow.cbv_applicant_id,
cbv_flow_id: cbv_flow.id,
invitation_id: cbv_flow.cbv_flow_invitation_id
))
allow(EventTrackingJob).to receive(:perform_later).with("ApplicantAccessedSearchPage", anything, anything)
get :show, params: { type: "payroll" }
end
it "tracks a Mixpanel event when clicking popular app employers" do
allow(EventTrackingJob).to receive(:perform_later).with("CbvPageView", anything, anything)
expect(EventTrackingJob).to receive(:perform_later).with("ApplicantClickedPopularAppEmployers", anything, hash_including(
time: be_a(Integer),
cbv_applicant_id: cbv_flow.cbv_applicant_id,
cbv_flow_id: cbv_flow.id,
invitation_id: cbv_flow.cbv_flow_invitation_id
))
allow(EventTrackingJob).to receive(:perform_later).with("ApplicantAccessedSearchPage", anything, anything)
get :show, params: { type: "employer" }
end
end
context "when there are no employer search results" do
before do
pinwheel_stub_request_items_no_items_response
argyle_stub_request_employer_search_response("empty")
end
render_views
context "when the user at least one payroll_account associated with their cbv_flow" do
it "renders the view with a link to the /other_job page" do
create(:payroll_account, flow: cbv_flow)
get :show, params: { query: "no_results" }
expect(response).to be_successful
expect(response.body).to include("If you have no other jobs to add here, continue")
expect(response.body).to include("Continue")
expect(response.body).to include(cbv_flow_other_job_path)
end
end
context "when the user has does not have a payroll_account associated with their cbv_flow" do
it "renders the view with a link to exit income verification" do
get :show, params: { query: "no_results" }
expect(response).to be_successful
expect(response.body).to include("you can exit this site")
expect(response.body).to include("Exit and go to TA")
end
end
end
context "when there are search results" do
before do
pinwheel_stub_request_items_response
argyle_stub_request_employer_search_response("bob")
end
render_views
it "renders successfully" do
get :show, params: { query: "results" }
expect(response).to be_successful
end
it "has aria-labels for each employer button" do
get :show, params: { query: "results" }
expect(response.body).to include('aria-label="Select Walgreens"')
expect(response.body).to include('aria-label="Select Greens Group"')
end
it "tracks a Mixpanel event" do
allow(EventTrackingJob).to receive(:perform_later).with("CbvPageView", anything, anything)
expect(EventTrackingJob).to receive(:perform_later).with(
"ApplicantSearchedForEmployer", anything, hash_including(
cbv_applicant_id: cbv_flow.cbv_applicant_id,
cbv_flow_id: cbv_flow.id,
invitation_id: cbv_flow.cbv_flow_invitation_id,
num_results: 8,
has_payroll_account: false,
pinwheel_result_count: 0,
argyle_result_count: 8
))
get :show, params: { query: "results" }
end
context "when some results should be blocked" do
before do
pinwheel_stub_request_items_response
argyle_stub_request_employer_search_response("empty")
stub_const("ProviderSearchService::BLOCKED_PINWHEEL_EMPLOYERS", [ "fce3eee0-285b-496f-9b36-30e976194736" ])
end
render_views
it "renders successfully without those results" do
get :show, params: { query: "results" }
expect(response).to be_successful
expect(response.body).not_to include("Acme Payroll")
expect(response.body).to include("Lumon")
end
end
end
context "for a CbvFlow" do
render_views
context "when there are search results" do
before do
pinwheel_stub_request_items_response
argyle_stub_request_employer_search_response("bob")
end
it "does not show the add employment manually button" do
get :show, params: { query: "results" }
expect(response.body).not_to include(I18n.t("cbv.employer_searches.show.activity_flow.add_employment_manually"))
expect(response.body).to include(I18n.t("cbv.employer_searches.show.employer_not_listed"))
end
end
context "when there are no search results" do
before do
pinwheel_stub_request_items_no_items_response
argyle_stub_request_employer_search_response("empty")
end
it "does not show the activity flow no results content" do
get :show, params: { query: "no_results" }
expect(response.body).not_to include(I18n.t("cbv.employer_searches.show.activity_flow.no_results_title"))
expect(response.body).to include(I18n.t("cbv.employer_searches.show.no_results_steps_title"))
end
end
end
end
end