require "test_helper" feature "Landing page" do scenario "has content" do visit '/pages/landing_page' page.must_have_content "Welcome and buy our services" assert_equal true, page.has_no_content?("for half prices") end scenario "force display original" do visit '/pages/landing_page?landing_page_test_ab=0' page.must_have_content "Welcome and buy our services" assert_equal true, page.has_no_content?("for half prices") end scenario "force display variant" do visit '/pages/landing_page?landing_page_test_ab=1' page.must_have_content "Welcome and buy our services for half prices" end scenario "display original - mocked javascript api" do AbExperimentsRails::Settings.any_instance.stubs(:url).returns('/js_mocks/cx_api_mock.js') visit '/pages/landing_page' page.must_have_content "Welcome and buy our services" assert_equal true, page.has_no_content?("for half prices") end scenario "display variant - mocked javascript api" do AbExperimentsRails::Settings.any_instance.stubs(:url).returns('/js_mocks/cx_api_mock_variant.js') visit '/pages/landing_page' page.must_have_content "Welcome and buy our services for half prices" end scenario "disable experiment" do visit '/pages/landing_page?landing_page_test_ab=1' page.must_have_content "Welcome and buy our services for half prices" AbExperimentsRails::Settings.any_instance.stubs(:experiment_enabled).returns(false) visit '/pages/landing_page?landing_page_test_ab=1' sleep 1 assert_equal true, page.has_no_content?("Welcome and buy our services for half prices") end scenario "show spinner and original content when javascript fails" do AbExperimentsRails::Settings.any_instance.stubs(:choosen_variation_variant).returns('undefined') visit '/pages/landing_page?landing_page_test_ab=1' sleep 2 page.must_have_content "Loading" sleep 6 page.must_have_content "Welcome and buy our services" assert_equal true, page.has_no_content?("for half prices") end end