Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix system tests for when billing is enabled #787

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
55 changes: 10 additions & 45 deletions test/application_system_test_case.rb
Original file line number Diff line number Diff line change
Expand Up @@ -302,40 +302,22 @@ def calculate_resolution(display_details)
end

def complete_pricing_page(card = nil)
assert page.has_content?("Select Your Plan")
assert page.has_content?("The Pricing Page")
sleep 0.5
within(".pricing-plan.highlight") do
start_subscription
end

start_subscription
complete_payment_page(card)
end

def complete_payment_page(card = nil)
# we should be on the credit card page.
if free_trial?
assert page.has_content?("Start Your Free Trial")
assert page.has_content?("30-Day Free Trial".upcase)
else
assert page.has_content?("Upgrade Your Account")
assert page.has_content?("It Will Work For You!".upcase)
end

assert page.has_content?("Subscribe to #{I18n.t("application.name")} Pro")
fill_in_stripe_elements(card)

if free_trial?
click_on "Start Free Trial"
else
click_on "Upgrade Now"
end
click_on "Subscribe"
sleep 3
end

def start_subscription
if free_trial?
click_on "Start Trial"
else
click_on "Sign Up"
end
click_on "Select"
end

def fill_in_stripe_elements(card = nil)
Expand All @@ -349,27 +331,10 @@ def fill_in_stripe_elements(card = nil)
}

using_wait_time(10) do
card_number_frame = find("#card-number iframe")
cvc_frame = find("#card-cvc iframe")
card_exp = find("#card-exp iframe")

within_frame(card_number_frame) do
card[:card_number].chars.each do |digit|
find_field("cardnumber").send_keys(digit)
end
end

within_frame(cvc_frame) do
card[:security_code].chars.each do |digit|
find_field("cvc").send_keys(digit)
end
end

within_frame(card_exp) do
(card[:expiration_month] + card[:expiration_year]).chars.each do |digit|
find_field("exp-date").send_keys(digit)
end
end
fill_in placeholder: "1234 1234 1234 1234", with: card[:card_number]
fill_in placeholder: "MM / YY", with: card[:expiration_month] + card[:expiration_year]
fill_in placeholder: "CVC", with: card[:security_code]
fill_in "Name on card", with: "Hanako"
end
end

Expand Down
12 changes: 6 additions & 6 deletions test/system/account_management_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,12 +15,6 @@ class AccountManagementSystemTest < ApplicationSystemTestCase
fill_in "Confirm Password", with: example_password
click_on "Sign Up"

if billing_enabled?
unless freemium_enabled?
complete_pricing_page
end
end

# we should now be on an onboarding step.
assert page.has_content?("Tell us about you")
fill_in "First Name", with: "Testy"
Expand All @@ -29,6 +23,12 @@ class AccountManagementSystemTest < ApplicationSystemTestCase
page.select "Brisbane", from: "Your Time Zone"
click_on "Next"

if billing_enabled?
unless freemium_enabled?
complete_pricing_page
end
end

assert page.has_content?("The Testing Team’s Dashboard")

user = User.find_by(email: "[email protected]")
Expand Down
11 changes: 8 additions & 3 deletions test/system/account_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,19 @@ class AccountTest < ApplicationSystemTestCase
def setup
super
@jane = create :onboarded_user, first_name: "Jane", last_name: "Smith"
login_as(@jane, scope: :user)
visit root_path
if billing_enabled?
unless freemium_enabled?
complete_pricing_page
sleep 2
end
end
end

@@test_devices.each do |device_name, display_details|
test "user can edit their account on a #{device_name}" do
resize_for(display_details)
login_as(@jane, scope: :user)
visit edit_account_user_path(@jane)
fill_in "First Name", with: "Another"
fill_in "Last Name", with: "Person"
Expand All @@ -23,7 +30,6 @@ def setup

test "user can edit password on a #{device_name} with valid current password" do
resize_for(display_details)
login_as(@jane, scope: :user)
visit edit_account_user_path(@jane)
fill_in "Current Password", with: @jane.password
fill_in "New Password", with: another_example_password
Expand All @@ -42,7 +48,6 @@ def setup

test "user cannot edit password on a #{device_name} with invalid current password" do
resize_for(display_details)
login_as(@jane, scope: :user)
visit edit_account_user_path(@jane)
fill_in "Current Password", with: "invalid"
fill_in "New Password", with: another_example_password
Expand Down
7 changes: 7 additions & 0 deletions test/system/animations_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ def setup
animation_duration = 0.5
resize_for(display_details)
login_as(@jane, scope: :user)
visit root_path
if billing_enabled?
unless freemium_enabled?
complete_pricing_page
sleep 2
end
end

visit account_team_path(@jane.current_team)

Expand Down
12 changes: 6 additions & 6 deletions test/system/application_platform_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ class ApplicationPlatformSystemTest < ApplicationSystemTestCase
fill_in "Confirm Password", with: example_password
click_on "Sign Up"

if billing_enabled?
unless freemium_enabled?
complete_pricing_page
end
end

# we should now be on an onboarding step.
assert page.has_content?("Tell us about you")
fill_in "First Name", with: "Jane"
fill_in "Last Name", with: "Smith"
fill_in "Your Team Name", with: "The Testing Team"
click_on "Next"

if billing_enabled?
unless freemium_enabled?
complete_pricing_page
end
end

# Create a new Platform Application
within_developers_menu_for(display_details) do
click_on "API"
Expand Down
12 changes: 6 additions & 6 deletions test/system/authentication_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,19 @@ class AuthenticationSystemTest < ApplicationSystemTestCase
fill_in "Confirm Password", with: example_password
click_on "Sign Up"

if billing_enabled?
unless freemium_enabled?
complete_pricing_page
end
end

# we should now be on an onboarding step.
assert page.has_content?("Tell us about you")
fill_in "First Name", with: "Testy"
fill_in "Last Name", with: "McTesterson"
fill_in "Your Team Name", with: "The Testing Team"
click_on "Next"

if billing_enabled?
unless freemium_enabled?
complete_pricing_page
end
end

# sign out.
sign_out_for(display_details)

Expand Down
6 changes: 6 additions & 0 deletions test/system/dates_helper_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ class DatesHelperTest < ApplicationSystemTestCase
select "(GMT+00:00) UTC", from: "Your Time Zone"
click_on "Next"

if billing_enabled?
unless freemium_enabled?
complete_pricing_page
end
end

# Create a Tangible Thing
click_on "Creative Concepts"
click_on "Add New Creative Concept"
Expand Down
13 changes: 13 additions & 0 deletions test/system/fields_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,13 @@ class AccountTest < ApplicationSystemTestCase

visit root_path

# TODO: This is an ugly hack to ensure the default test user isn't logged in.
# This is happening when billing is enabled and the entire test suite is run.
if page.text.match?("Jane Smith")
sign_out_for(display_details)
visit root_path
end

invitation_only? ? be_invited_to_sign_up : click_on("Don't have an account?")
assert page.has_content?("Create Your Account")
fill_in "Your Email Address", with: "[email protected]"
Expand All @@ -20,6 +27,12 @@ class AccountTest < ApplicationSystemTestCase
page.select "Brisbane", from: "Your Time Zone"
click_on "Next"

if billing_enabled?
unless freemium_enabled?
complete_pricing_page
end
end

click_on "Add New Creative Concept"
fill_in "Name", with: "My Generic Creative Concept"
fill_in "Description", with: "Dummy description for my creative concept"
Expand Down
13 changes: 9 additions & 4 deletions test/system/invitation_details_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,12 +5,20 @@ def setup
super
@jane = create :onboarded_user, first_name: "Jane", last_name: "Smith"
@john = create :onboarded_user, first_name: "John", last_name: "Smith", email: "[email protected]"

login_as(@jane, scope: :user)
visit root_path
if billing_enabled?
unless freemium_enabled?
complete_pricing_page
sleep 2
end
end
end

@@test_devices.each do |device_name, display_details|
test "admin can create new non admin invitation on a #{device_name}" do
resize_for(display_details)
login_as(@jane, scope: :user)
visit new_account_team_invitation_path(@jane.current_team)
fill_in "Email", with: "[email protected]"
click_on "Create Invitation"
Expand All @@ -21,7 +29,6 @@ def setup

test "admin can create new admin invitation on a #{device_name}" do
resize_for(display_details)
login_as(@jane, scope: :user)
visit new_account_team_invitation_path(@jane.current_team)
fill_in "Email", with: "[email protected]"
check "Invite as Team Administrator"
Expand All @@ -33,7 +40,6 @@ def setup

test "admin can't create invalid invitation on a #{device_name}" do
resize_for(display_details)
login_as(@jane, scope: :user)
visit new_account_team_invitation_path(@jane.current_team)
fill_in "Email", with: ""
click_on "Create Invitation"
Expand All @@ -43,7 +49,6 @@ def setup

test "admin can cancel invitation on a #{device_name}" do
resize_for(display_details)
login_as(@jane, scope: :user)
membership = Membership.new(team: @jane.current_team, user_email: @john.email)
create :invitation, team: @jane.current_team, from_membership: @jane.memberships.first, email: @john.email, membership: membership
visit account_team_invitations_path(@jane.current_team)
Expand Down
18 changes: 12 additions & 6 deletions test/system/invitations_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ class InvitationDetailsTest < ApplicationSystemTestCase
fill_in "Confirm Password", with: example_password
click_on "Sign Up"

if billing_enabled?
unless freemium_enabled?
complete_pricing_page
end
end

# we should now be on an onboarding step.
assert page.has_content?("Tell us about you")
fill_in "First Name", with: "Hanako"
fill_in "Last Name", with: "Tanaka"
fill_in "Your Team Name", with: "The Testing Team"
click_on "Next"

if billing_enabled?
unless freemium_enabled?
complete_pricing_page
end
end

assert page.has_content?("The Testing Team’s Dashboard")
within_team_menu_for(display_details) do
click_on "Team Members"
Expand Down Expand Up @@ -177,6 +177,12 @@ class InvitationDetailsTest < ApplicationSystemTestCase
fill_in "Team Name", with: "Another Team"
click_on "Create Team"

if billing_enabled?
unless freemium_enabled?
complete_pricing_page
end
end

assert page.has_content?("Another Team’s Dashboard")
within_team_menu_for(display_details) do
click_on "Team Members"
Expand Down
12 changes: 6 additions & 6 deletions test/system/membership_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -16,19 +16,19 @@ class MembershipSystemTest < ApplicationSystemTestCase
fill_in "Confirm Password", with: example_password
click_on "Sign Up"

if billing_enabled?
unless freemium_enabled?
complete_pricing_page
end
end

# we should now be on an onboarding step.
assert page.has_content?("Tell us about you")
fill_in "First Name", with: "Jane"
fill_in "Last Name", with: "Smith"
fill_in "Your Team Name", with: "The Testing Team"
click_on "Next"

if billing_enabled?
unless freemium_enabled?
complete_pricing_page
end
end

within_team_menu_for(display_details) do
click_on "Team Members"
end
Expand Down
8 changes: 8 additions & 0 deletions test/system/pagination_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,14 @@ def setup
creative_concept.completely_concrete_tangible_things.create(text_field_value: "Test #{n + 1}")
end

visit root_path
if billing_enabled?
unless freemium_enabled?
complete_pricing_page
sleep 2
end
end

visit account_scaffolding_absolutely_abstract_creative_concept_path(creative_concept)

assert page.has_content?("Test 1")
Expand Down
6 changes: 6 additions & 0 deletions test/system/reactivity_system_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ class ReactivitySystemTest < ApplicationSystemTestCase
page.select "Brisbane", from: "Your Time Zone"
click_on "Next"

if billing_enabled?
unless freemium_enabled?
complete_pricing_page
end
end

# We should be on the account dashboard with no Creative Concepts listed.
assert page.has_content? "My Super Team’s Dashboard"
assert page.has_content? "If you're wondering what this"
Expand Down
6 changes: 6 additions & 0 deletions test/system/tangible_thing_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,12 @@ class TangibleThingTest < ApplicationSystemTestCase
page.select "Brisbane", from: "Your Time Zone"
click_on "Next"

if billing_enabled?
unless freemium_enabled?
complete_pricing_page
end
end

click_on "Add New Creative Concept"
fill_in "Name", with: "My Generic Creative Concept"
fill_in "Description", with: "Dummy description for my creative concept"
Expand Down
Loading