-
-
Notifications
You must be signed in to change notification settings - Fork 51
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add test for alternate successfull flow
- Loading branch information
Showing
3 changed files
with
53 additions
and
1 deletion.
There are no files selected for viewing
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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -119,6 +119,38 @@ | |
expect(page).to have_content("You succesfully added a new alert for 24 Bruce Rd, Glenbrook NSW 2773") | ||
end | ||
|
||
it "when via the homepage with a pre-existing user but not logged in in the alternate flow" do | ||
use_ab_test logged_out_alert_flow_order: "create_alert_sign_in" | ||
|
||
create(:geocoded_application, address: "26 Bruce Rd, Glenbrook NSW 2773", lat: -33.772812, lng: 150.624252, lonlat: RGeo::Geographic.spherical_factory(srid: 4326).point(150.624252, -33.772812)) | ||
user = create(:confirmed_user, email: "[email protected]", password: "mypassword") | ||
sign_in user | ||
visit root_path | ||
sign_out user | ||
|
||
visit root_path | ||
fill_in("Street address", with: "24 Bruce Rd, Glenbrook") | ||
within("form") do | ||
click_on("Search") | ||
end | ||
|
||
expect(page).to have_content("Search results") | ||
expect(page).to have_content("Save this search as an email alert") | ||
click_on("Save", match: :first) | ||
|
||
expect(page).to have_content("You'll receive email alerts when new applications match this search") | ||
click_on("Sign in") | ||
|
||
expect(page).to have_content("Sign in to save this search") | ||
expect(page).to have_content("Applications within 2 km of 24 Bruce Rd, Glenbrook") | ||
|
||
fill_in("Your email", with: "[email protected]") | ||
fill_in("Password", with: "mypassword") | ||
click_on("Sign in") | ||
|
||
expect(page).to have_content("You succesfully signed in and added a new alert for 24 Bruce Rd, Glenbrook NSW 2773") | ||
end | ||
|
||
it "when via the homepage but not yet have an account" do | ||
create(:geocoded_application, address: "26 Bruce Rd, Glenbrook NSW 2773", lat: -33.772812, lng: 150.624252, lonlat: RGeo::Geographic.spherical_factory(srid: 4326).point(150.624252, -33.772812)) | ||
|
||
|
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,20 @@ | ||
module SplitHelper | ||
# Force a specific experiment alternative to always be returned: | ||
# use_ab_test(signup_form: "single_page") | ||
# | ||
# Force alternatives for multiple experiments: | ||
# use_ab_test(signup_form: "single_page", pricing: "show_enterprise_prices") | ||
# | ||
def use_ab_test(alternatives_by_experiment) | ||
allow_any_instance_of(Split::Helper).to receive(:ab_test) do |_receiver, experiment, &block| | ||
variant = alternatives_by_experiment.fetch(experiment) { |key| raise "Unknown experiment '#{key}'" } | ||
block.call(variant) unless block.nil? | ||
variant | ||
end | ||
end | ||
end | ||
|
||
# Make the `use_ab_test` method available to all specs: | ||
RSpec.configure do |config| | ||
config.include SplitHelper | ||
end |