docbrown/spec/system/authentication/conditional_registration_spec.rb
Julianna Tetreault 8d00e27b69
Remove Creator Onboarding Feature Flags from Codebase (#15982)
* Removes FeatureFlag.enabled?(:creator_onboarding) from codebase

* Removes FeatureFlag.enabled?(:creator_onboarding) from specs

* Further cleanup, removal, and spec fixes

* Fixes the user_request_confirmation_spec.rb

* Reverts change to confirmation email button

* Revert revert after looking at designs again :(

* Removes redundant logo_png field from config + fixes test

* Rewords an expectation in user_uses_the_editor_spec.rb

* Revert removal of logo_png from Config images

* Removes CSS class from user_uses_the_editor_spec.rb

* Removes test from user_uses_the_editor_sepc.rb

* Removes unnecessary else from _logo.html.erb

* Adds back removed system spec

* Removes SVG-related code from _logo.html.erb

* Removes AsyncInfoController#use_creator_onboarding

* Fixes spec failues due to removed code

* Removes svg-related code (that I thought I removed already :/ )

* Re-removes FeatureFlag and logo_svg from _images.html.erb

* Remove newest instances of FeatureFlag(:creator_onboarding)

* remove instances where we use the creator_onboarding field from the base_data

* fix: redirect to the correct path in the reguistrations controller based on whether the user is a creator or not

Co-authored-by: Ridhwana <ridhwana.khan16@gmail.com>
2022-01-31 11:30:43 -07:00

131 lines
6.3 KiB
Ruby

require "rails_helper"
# This test file can be removed once we have a longterm solution for
# ForemWebView contexts when Apple Auth isn't enabled
RSpec.describe "Conditional registration (ForemWebView)", type: :system do
let(:all_providers) { Authentication::Providers.available }
let(:all_providers_except_apple) { Authentication::Providers.available - %i[apple] }
let(:all_providers_minus_apple_forem) { Authentication::Providers.available - %i[apple forem] }
let(:mobile_browser_ua) { "Mozilla/5.0 (iPhone) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148" }
let(:foremwebview_ua) do
"Mozilla/5.0 (iPhone) AppleWebKit/605.1.15 (KHTML, like Gecko) Mobile/15E148 ForemWebView/1.0"
end
let(:flow_b_fallback_text) do
"Unfortunately, we do not support creating new accounts right now on our "\
"mobile app. If you want create a new account to join "\
"#{Settings::Community.community_name}, please do that on the web at"
end
before do
allow(Settings::Authentication).to receive(:allow_email_password_registration).and_return(true)
end
context "when browsing using mobile browser" do
before { Capybara.current_session.driver.header("User-Agent", mobile_browser_ua) }
it "renders the social providers when all providers are enabled" do
# All auth options enabled for registration
allow(Settings::Authentication).to receive(:providers).and_return(all_providers)
visit sign_up_path(state: "new-user")
expect(page).to have_text("Sign up with Apple")
expect(page).to have_text("Sign up with GitHub")
expect(page).to have_text("Sign up with Email")
# All auth options enabled for login
visit sign_up_path
expect(page).to have_text("Continue with Apple")
expect(page).to have_text("Continue with GitHub")
expect(page).to have_text("Have a password? Continue with your email address")
end
it "renders the social providers when all providers except Apple are enabled" do
# All auth options except apple for registration
allow(Settings::Authentication).to receive(:providers).and_return(all_providers_except_apple)
visit sign_up_path(state: "new-user")
expect(page).not_to have_text("Sign up with Apple")
expect(page).to have_text("Sign up with GitHub")
expect(page).to have_text("Sign up with Email")
# All auth options except apple for login
visit sign_up_path
expect(page).not_to have_text("Continue with Apple")
expect(page).to have_text("Continue with GitHub")
expect(page).to have_text("Have a password? Continue with your email address")
end
end
context "when browsing using ForemWebView" do
before { Capybara.current_session.driver.header("User-Agent", foremwebview_ua) }
it "renders the social providers if Apple Auth is enabled" do
# Renders the social provider options because Apple Auth is available for registration
allow(Settings::Authentication).to receive(:providers).and_return(all_providers)
visit sign_up_path(state: "new-user")
expect(page).to have_text("Sign up with Apple")
expect(page).to have_text("Sign up with GitHub")
expect(page).to have_text("Sign up with Email")
# Renders the social provider options because Apple Auth is available for login
visit sign_up_path
expect(page).to have_text("Continue with Apple")
expect(page).to have_text("Continue with GitHub")
expect(page).to have_text("Have a password? Continue with your email address")
end
it "doesn't render social providers if Apple Auth isn't enabled" do
# Only renders email option because Apple Auth isn't available for registration
allow(Settings::Authentication).to receive(:providers).and_return(all_providers_except_apple)
visit sign_up_path(state: "new-user")
expect(page).not_to have_text("Sign up with Apple")
expect(page).not_to have_text("Sign up with GitHub")
expect(page).to have_text("Sign up with Email")
# Only renders email option because Apple Auth isn't available for login
visit sign_up_path
expect(page).not_to have_text("Continue with Apple")
expect(page).not_to have_text("Continue with GitHub")
expect(page).to have_text("Have a password? Continue with your email address")
end
context "when Apple Auth and email registration aren't enabled" do
before do
allow(Settings::Authentication).to receive(:allow_email_password_registration).and_return(false)
end
it "renders the fallback message if Forem Auth is also disabled" do
# Only renders email option because Apple Auth isn't available for registration
allow(Settings::Authentication).to receive(:providers).and_return(all_providers_minus_apple_forem)
visit sign_up_path(state: "new-user")
expect(page).not_to have_text("Sign up with Apple")
expect(page).not_to have_text("Sign up with GitHub")
expect(page).not_to have_text("Sign up with Forem")
expect(page).to have_text("Sorry to be a bummer...")
expect(page).to have_text(flow_b_fallback_text)
# Only renders email option because Apple Auth isn't available for login
visit sign_up_path
expect(page).not_to have_text("Continue with Apple")
expect(page).not_to have_text("Continue with GitHub")
expect(page).to have_text("Have a password? Continue with your email address")
end
it "doesn't render the fallback because Forem Auth is enabled" do
# Only renders email option because Apple Auth isn't available for registration
allow(Settings::Authentication).to receive(:providers).and_return(all_providers_except_apple)
visit sign_up_path(state: "new-user")
expect(page).not_to have_text("Sign up with GitHub")
expect(page).to have_text("Sign up with Forem")
expect(page).not_to have_text("Sorry to be a bummer...")
expect(page).not_to have_text(flow_b_fallback_text)
# Only renders email option because Apple Auth isn't available for login
visit sign_up_path
expect(page).not_to have_text("Continue with Apple")
expect(page).not_to have_text("Continue with GitHub")
expect(page).to have_text("Continue with Forem")
expect(page).to have_text("Have a password? Continue with your email address")
end
end
end
end