From 8fe9620f2a11d46ca21ff47e2ffa54364f4b33e5 Mon Sep 17 00:00:00 2001 From: gazayas Date: Sat, 19 Aug 2023 21:40:03 +0900 Subject: [PATCH 01/18] Prepare database for invitation lists --- ...9_create_account_onboarding_invitation_lists.rb | 10 ++++++++++ ...819123854_add_invitation_list_to_invitations.rb | 5 +++++ db/schema.rb | 14 +++++++++++++- 3 files changed, 28 insertions(+), 1 deletion(-) create mode 100644 db/migrate/20230819123719_create_account_onboarding_invitation_lists.rb create mode 100644 db/migrate/20230819123854_add_invitation_list_to_invitations.rb diff --git a/db/migrate/20230819123719_create_account_onboarding_invitation_lists.rb b/db/migrate/20230819123719_create_account_onboarding_invitation_lists.rb new file mode 100644 index 000000000..fedb8cd04 --- /dev/null +++ b/db/migrate/20230819123719_create_account_onboarding_invitation_lists.rb @@ -0,0 +1,10 @@ +class CreateAccountOnboardingInvitationLists < ActiveRecord::Migration[7.0] + def change + create_table :account_onboarding_invitation_lists do |t| + t.references :team, null: false, foreign_key: true + t.jsonb :invitations + + t.timestamps + end + end +end diff --git a/db/migrate/20230819123854_add_invitation_list_to_invitations.rb b/db/migrate/20230819123854_add_invitation_list_to_invitations.rb new file mode 100644 index 000000000..807472529 --- /dev/null +++ b/db/migrate/20230819123854_add_invitation_list_to_invitations.rb @@ -0,0 +1,5 @@ +class AddInvitationListToInvitations < ActiveRecord::Migration[7.0] + def change + add_reference :invitations, :invitation_list, null: true, foreign_key: {to_table: :account_onboarding_invitation_lists} + end +end diff --git a/db/schema.rb b/db/schema.rb index f52d0bb36..2e36795bf 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,10 +10,18 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2022_12_31_003438) do +ActiveRecord::Schema[7.0].define(version: 2023_08_19_123854) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" + create_table "account_onboarding_invitation_lists", force: :cascade do |t| + t.bigint "team_id", null: false + t.jsonb "invitations" + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + t.index ["team_id"], name: "index_account_onboarding_invitation_lists_on_team_id" + end + create_table "action_mailbox_inbound_emails", force: :cascade do |t| t.integer "status", default: 0, null: false t.string "message_id", null: false @@ -78,6 +86,8 @@ t.datetime "created_at", precision: nil, null: false t.datetime "updated_at", precision: nil, null: false t.integer "team_id" + t.bigint "invitation_list_id" + t.index ["invitation_list_id"], name: "index_invitations_on_invitation_list_id" t.index ["team_id"], name: "index_invitations_on_team_id" end @@ -338,10 +348,12 @@ t.index ["team_id"], name: "index_webhooks_outgoing_events_on_team_id" end + add_foreign_key "account_onboarding_invitation_lists", "teams" add_foreign_key "active_storage_attachments", "active_storage_blobs", column: "blob_id" add_foreign_key "active_storage_variant_records", "active_storage_blobs", column: "blob_id" add_foreign_key "integrations_stripe_installations", "oauth_stripe_accounts" add_foreign_key "integrations_stripe_installations", "teams" + add_foreign_key "invitations", "account_onboarding_invitation_lists", column: "invitation_list_id" add_foreign_key "invitations", "teams" add_foreign_key "memberships", "invitations" add_foreign_key "memberships", "memberships", column: "added_by_id" From 747b2fcc7597c0282a42164f3a74c98cdc71ec33 Mon Sep 17 00:00:00 2001 From: gazayas Date: Sat, 19 Aug 2023 22:03:15 +0900 Subject: [PATCH 02/18] Skip bulk invitation step in most system tests --- test/system/account_management_test.rb | 1 + test/system/application_platform_test.rb | 1 + test/system/authentication_test.rb | 1 + test/system/dates_helper_test.rb | 1 + test/system/fields_test.rb | 1 + test/system/invitations_test.rb | 1 + test/system/membership_test.rb | 1 + test/system/reactivity_system_test.rb | 1 + test/system/tangible_thing_test.rb | 1 + 9 files changed, 9 insertions(+) diff --git a/test/system/account_management_test.rb b/test/system/account_management_test.rb index 20f31a61b..f7b3a1eba 100644 --- a/test/system/account_management_test.rb +++ b/test/system/account_management_test.rb @@ -22,6 +22,7 @@ class AccountManagementSystemTest < ApplicationSystemTestCase fill_in "Your Team Name", with: "The Testing Team" page.select "Brisbane", from: "Your Time Zone" click_on "Next" + click_on "Skip" if billing_enabled? unless freemium_enabled? diff --git a/test/system/application_platform_test.rb b/test/system/application_platform_test.rb index c19e60195..7c52a916d 100644 --- a/test/system/application_platform_test.rb +++ b/test/system/application_platform_test.rb @@ -22,6 +22,7 @@ class ApplicationPlatformSystemTest < ApplicationSystemTestCase fill_in "Last Name", with: "Smith" fill_in "Your Team Name", with: "The Testing Team" click_on "Next" + click_on "Skip" if billing_enabled? unless freemium_enabled? diff --git a/test/system/authentication_test.rb b/test/system/authentication_test.rb index da2732041..a38cf9013 100644 --- a/test/system/authentication_test.rb +++ b/test/system/authentication_test.rb @@ -33,6 +33,7 @@ class AuthenticationSystemTest < ApplicationSystemTestCase fill_in "Last Name", with: "McTesterson" fill_in "Your Team Name", with: "The Testing Team" click_on "Next" + click_on "Skip" if billing_enabled? unless freemium_enabled? diff --git a/test/system/dates_helper_test.rb b/test/system/dates_helper_test.rb index 0124ec54d..e7cfb60bc 100644 --- a/test/system/dates_helper_test.rb +++ b/test/system/dates_helper_test.rb @@ -19,6 +19,7 @@ class DatesHelperTest < ApplicationSystemTestCase fill_in "Your Team Name", with: "The Testing Team" select "(GMT+00:00) UTC", from: "Your Time Zone" click_on "Next" + click_on "Skip" if billing_enabled? unless freemium_enabled? diff --git a/test/system/fields_test.rb b/test/system/fields_test.rb index 883ae82f6..31864c438 100644 --- a/test/system/fields_test.rb +++ b/test/system/fields_test.rb @@ -26,6 +26,7 @@ class AccountTest < ApplicationSystemTestCase fill_in "Your Team Name", with: "My Super Team" page.select "Brisbane", from: "Your Time Zone" click_on "Next" + click_on "Skip" if billing_enabled? unless freemium_enabled? diff --git a/test/system/invitations_test.rb b/test/system/invitations_test.rb index 4941480ec..74d1b9745 100644 --- a/test/system/invitations_test.rb +++ b/test/system/invitations_test.rb @@ -22,6 +22,7 @@ class InvitationDetailsTest < ApplicationSystemTestCase fill_in "Last Name", with: "Tanaka" fill_in "Your Team Name", with: "The Testing Team" click_on "Next" + click_on "Skip" if billing_enabled? unless freemium_enabled? diff --git a/test/system/membership_test.rb b/test/system/membership_test.rb index 9575b6346..c06b9d1c8 100644 --- a/test/system/membership_test.rb +++ b/test/system/membership_test.rb @@ -22,6 +22,7 @@ class MembershipSystemTest < ApplicationSystemTestCase fill_in "Last Name", with: "Smith" fill_in "Your Team Name", with: "The Testing Team" click_on "Next" + click_on "Skip" if billing_enabled? unless freemium_enabled? diff --git a/test/system/reactivity_system_test.rb b/test/system/reactivity_system_test.rb index e7cb62e87..13a2ddabf 100644 --- a/test/system/reactivity_system_test.rb +++ b/test/system/reactivity_system_test.rb @@ -19,6 +19,7 @@ class ReactivitySystemTest < ApplicationSystemTestCase fill_in "Your Team Name", with: "My Super Team" page.select "Brisbane", from: "Your Time Zone" click_on "Next" + click_on "Skip" if billing_enabled? unless freemium_enabled? diff --git a/test/system/tangible_thing_test.rb b/test/system/tangible_thing_test.rb index 08e334d77..46a4b8fda 100644 --- a/test/system/tangible_thing_test.rb +++ b/test/system/tangible_thing_test.rb @@ -19,6 +19,7 @@ class TangibleThingTest < ApplicationSystemTestCase fill_in "Your Team Name", with: "My Super Team" page.select "Brisbane", from: "Your Time Zone" click_on "Next" + click_on "Skip" if billing_enabled? unless freemium_enabled? From a7da93369d61b70b351d2150f179f82966d7086c Mon Sep 17 00:00:00 2001 From: gazayas Date: Sat, 19 Aug 2023 23:03:45 +0900 Subject: [PATCH 03/18] Add tests for bulk invitations --- test/system/invitations_test.rb | 29 +++++++++++++++++++++++++++++ 1 file changed, 29 insertions(+) diff --git a/test/system/invitations_test.rb b/test/system/invitations_test.rb index 74d1b9745..a94c6ac43 100644 --- a/test/system/invitations_test.rb +++ b/test/system/invitations_test.rb @@ -179,6 +179,29 @@ class InvitationDetailsTest < ApplicationSystemTestCase fill_in "Last Name", with: "Yamaguchi" click_on "Next" + # Click on next to show that bulk invitations will raise an error if not filled out properly. + click_on "Next" + assert page.has_content?("Please correct the errors below.") + + # Fill in the email addresses. + email_fields = page.all('label', text: 'Email Address') + email_fields.each_with_index do |field, idx| + field.sibling('div').find('input').fill_in with: "test-#{idx}@some-company.com" + end + + # Select roles + role_ids = ["Default", "Editor", "Admin"] + role_fields = page.all('label', text: 'Role ids') + role_fields.each_with_index do |role_field, idx| + select_field = role_field.sibling('div').find('select') + select_field.all('option').find {|opt| opt.text == role_ids[idx]}.select_option + end + + assert_difference(['Invitation.count', 'Membership.count'], 3) do + click_on "Next" + sleep 2 + end + assert page.has_content?("The Testing Team’s Dashboard") within_team_menu_for(display_details) do click_on "Team Members" @@ -186,6 +209,12 @@ class InvitationDetailsTest < ApplicationSystemTestCase assert page.has_content?("Hanako Tanaka") + 3.times do |idx| + assert page.has_content?("test-#{idx}@some-company.com") + invitation = Invitation.find_by(email: "test-#{idx}@some-company.com") + assert_equal invitation.membership.role_ids, [role_ids[idx].downcase] + end + membership_user = User.find_by(first_name: "Taka", last_name: "Yamaguchi") last_membership = Membership.find_by(user: membership_user) From 0ae8bed6f666c90413257af573508fab0e8cc1ec Mon Sep 17 00:00:00 2001 From: gazayas Date: Sat, 19 Aug 2023 23:04:23 +0900 Subject: [PATCH 04/18] Fixing Standard Ruby --- test/system/invitations_test.rb | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/test/system/invitations_test.rb b/test/system/invitations_test.rb index a94c6ac43..275a2cf37 100644 --- a/test/system/invitations_test.rb +++ b/test/system/invitations_test.rb @@ -184,20 +184,20 @@ class InvitationDetailsTest < ApplicationSystemTestCase assert page.has_content?("Please correct the errors below.") # Fill in the email addresses. - email_fields = page.all('label', text: 'Email Address') + email_fields = page.all("label", text: "Email Address") email_fields.each_with_index do |field, idx| - field.sibling('div').find('input').fill_in with: "test-#{idx}@some-company.com" + field.sibling("div").find("input").fill_in with: "test-#{idx}@some-company.com" end # Select roles role_ids = ["Default", "Editor", "Admin"] - role_fields = page.all('label', text: 'Role ids') + role_fields = page.all("label", text: "Role ids") role_fields.each_with_index do |role_field, idx| - select_field = role_field.sibling('div').find('select') - select_field.all('option').find {|opt| opt.text == role_ids[idx]}.select_option + select_field = role_field.sibling("div").find("select") + select_field.all("option").find { |opt| opt.text == role_ids[idx] }.select_option end - assert_difference(['Invitation.count', 'Membership.count'], 3) do + assert_difference(["Invitation.count", "Membership.count"], 3) do click_on "Next" sleep 2 end From 2355350bfa7409133eef955885e1e5b68e0e227a Mon Sep 17 00:00:00 2001 From: gazayas Date: Sat, 19 Aug 2023 23:16:43 +0900 Subject: [PATCH 05/18] Add another assertion for InvitationList --- test/system/invitations_test.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/test/system/invitations_test.rb b/test/system/invitations_test.rb index 275a2cf37..f18c824c1 100644 --- a/test/system/invitations_test.rb +++ b/test/system/invitations_test.rb @@ -182,6 +182,7 @@ class InvitationDetailsTest < ApplicationSystemTestCase # Click on next to show that bulk invitations will raise an error if not filled out properly. click_on "Next" assert page.has_content?("Please correct the errors below.") + assert page.has_content?("Invitations email can't be blank") # Fill in the email addresses. email_fields = page.all("label", text: "Email Address") From 232bdaaaf066f474c8ababa1e391e0a667181dbb Mon Sep 17 00:00:00 2001 From: gazayas Date: Mon, 21 Aug 2023 11:09:31 +0900 Subject: [PATCH 06/18] Extract invitation lists test logic to its own file --- test/system/invitation_lists_test.rb | 62 ++++++++++++++++++++++++++++ test/system/invitations_test.rb | 30 -------------- 2 files changed, 62 insertions(+), 30 deletions(-) create mode 100644 test/system/invitation_lists_test.rb diff --git a/test/system/invitation_lists_test.rb b/test/system/invitation_lists_test.rb new file mode 100644 index 000000000..56606ad61 --- /dev/null +++ b/test/system/invitation_lists_test.rb @@ -0,0 +1,62 @@ +require "application_system_test_case" + +class InvitationListsTest < ApplicationSystemTestCase + @@test_devices.each do |device_name, display_details| + test "visitors can send bulk invitations upon signing up" do + resize_for(display_details) + + sign_up_from_homepage_for(display_details) + fill_in "Your Email Address", with: "hanako.tanaka@gmail.com" + fill_in "Set Password", with: example_password + fill_in "Confirm Password", with: example_password + click_on "Sign Up" + + 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 + + # Click on next to show that bulk invitations will raise an error if not filled out properly. + click_on "Next" + assert page.has_content?("Please correct the errors below.") + assert page.has_content?("Invitations email can't be blank") + + # Fill in the email addresses. + email_fields = page.all("label", text: "Email Address") + email_fields.each_with_index do |field, idx| + field.sibling("div").find("input").fill_in with: "test-#{idx}@some-company.com" + end + + # Select roles from select element. + role_ids = ["Default", "Editor", "Admin"] + role_fields = page.all("label", text: "Role ids") + role_fields.each_with_index do |role_field, idx| + select_field = role_field.sibling("div").find("select") + select_field.all("option").find { |opt| opt.text == role_ids[idx] }.select_option + end + + assert_difference(["Invitation.count", "Membership.count"], 3) do + click_on "Next" + sleep 2 + end + + assert page.has_content?("The Testing Team’s Dashboard") + within_team_menu_for(display_details) do + click_on "Team Members" + end + + 3.times do |idx| + assert page.has_content?("test-#{idx}@some-company.com") + invitation = Invitation.find_by(email: "test-#{idx}@some-company.com") + assert_equal invitation.membership.role_ids, [role_ids[idx].downcase] + end + end + end +end diff --git a/test/system/invitations_test.rb b/test/system/invitations_test.rb index f18c824c1..74d1b9745 100644 --- a/test/system/invitations_test.rb +++ b/test/system/invitations_test.rb @@ -179,30 +179,6 @@ class InvitationDetailsTest < ApplicationSystemTestCase fill_in "Last Name", with: "Yamaguchi" click_on "Next" - # Click on next to show that bulk invitations will raise an error if not filled out properly. - click_on "Next" - assert page.has_content?("Please correct the errors below.") - assert page.has_content?("Invitations email can't be blank") - - # Fill in the email addresses. - email_fields = page.all("label", text: "Email Address") - email_fields.each_with_index do |field, idx| - field.sibling("div").find("input").fill_in with: "test-#{idx}@some-company.com" - end - - # Select roles - role_ids = ["Default", "Editor", "Admin"] - role_fields = page.all("label", text: "Role ids") - role_fields.each_with_index do |role_field, idx| - select_field = role_field.sibling("div").find("select") - select_field.all("option").find { |opt| opt.text == role_ids[idx] }.select_option - end - - assert_difference(["Invitation.count", "Membership.count"], 3) do - click_on "Next" - sleep 2 - end - assert page.has_content?("The Testing Team’s Dashboard") within_team_menu_for(display_details) do click_on "Team Members" @@ -210,12 +186,6 @@ class InvitationDetailsTest < ApplicationSystemTestCase assert page.has_content?("Hanako Tanaka") - 3.times do |idx| - assert page.has_content?("test-#{idx}@some-company.com") - invitation = Invitation.find_by(email: "test-#{idx}@some-company.com") - assert_equal invitation.membership.role_ids, [role_ids[idx].downcase] - end - membership_user = User.find_by(first_name: "Taka", last_name: "Yamaguchi") last_membership = Membership.find_by(user: membership_user) From 8bafc6ba7718e4d19fb577a87a116244d3cee248 Mon Sep 17 00:00:00 2001 From: gazayas Date: Mon, 21 Aug 2023 11:13:36 +0900 Subject: [PATCH 07/18] Add another skip in invitations test --- test/system/invitations_test.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/test/system/invitations_test.rb b/test/system/invitations_test.rb index 74d1b9745..a5c173107 100644 --- a/test/system/invitations_test.rb +++ b/test/system/invitations_test.rb @@ -178,6 +178,7 @@ class InvitationDetailsTest < ApplicationSystemTestCase fill_in "First Name", with: "Taka" fill_in "Last Name", with: "Yamaguchi" click_on "Next" + click_on "Skip" assert page.has_content?("The Testing Team’s Dashboard") within_team_menu_for(display_details) do From 70d72cd47c258d61661ae58b6369977f5541b1db Mon Sep 17 00:00:00 2001 From: gazayas Date: Wed, 23 Aug 2023 21:40:12 +0900 Subject: [PATCH 08/18] Add comment in BT initializer for bulk invitations --- config/initializers/bullet_train.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/config/initializers/bullet_train.rb b/config/initializers/bullet_train.rb index 2a7ffe795..8c11be16a 100644 --- a/config/initializers/bullet_train.rb +++ b/config/initializers/bullet_train.rb @@ -1,4 +1,7 @@ BulletTrain.configure do |config| # Uncomment this line if you want to bypass strong passwords. # config.strong_passwords = false + + # Uncomment this line to enable bulk invitations on the user onboarding step. + # config.enable_bulk_invitations = true end From 25f4dac0e65ea72812ad1ea1109c6ccb2f182e44 Mon Sep 17 00:00:00 2001 From: gazayas Date: Wed, 23 Aug 2023 21:44:53 +0900 Subject: [PATCH 09/18] Only test bulk invitations if enabled --- test/system/account_management_test.rb | 2 +- test/system/application_platform_test.rb | 2 +- test/system/authentication_test.rb | 2 +- test/system/dates_helper_test.rb | 2 +- test/system/fields_test.rb | 2 +- test/system/invitation_lists_test.rb | 98 ++++++++++++------------ test/system/invitations_test.rb | 4 +- test/system/membership_test.rb | 2 +- test/system/reactivity_system_test.rb | 2 +- test/system/tangible_thing_test.rb | 2 +- 10 files changed, 60 insertions(+), 58 deletions(-) diff --git a/test/system/account_management_test.rb b/test/system/account_management_test.rb index f7b3a1eba..80e9c3c54 100644 --- a/test/system/account_management_test.rb +++ b/test/system/account_management_test.rb @@ -22,7 +22,7 @@ class AccountManagementSystemTest < ApplicationSystemTestCase fill_in "Your Team Name", with: "The Testing Team" page.select "Brisbane", from: "Your Time Zone" click_on "Next" - click_on "Skip" + click_on "Skip" if bulk_invitations_enabled? if billing_enabled? unless freemium_enabled? diff --git a/test/system/application_platform_test.rb b/test/system/application_platform_test.rb index 7c52a916d..246f2fc63 100644 --- a/test/system/application_platform_test.rb +++ b/test/system/application_platform_test.rb @@ -22,7 +22,7 @@ class ApplicationPlatformSystemTest < ApplicationSystemTestCase fill_in "Last Name", with: "Smith" fill_in "Your Team Name", with: "The Testing Team" click_on "Next" - click_on "Skip" + click_on "Skip" if bulk_invitations_enabled? if billing_enabled? unless freemium_enabled? diff --git a/test/system/authentication_test.rb b/test/system/authentication_test.rb index a38cf9013..cc39b3bca 100644 --- a/test/system/authentication_test.rb +++ b/test/system/authentication_test.rb @@ -33,7 +33,7 @@ class AuthenticationSystemTest < ApplicationSystemTestCase fill_in "Last Name", with: "McTesterson" fill_in "Your Team Name", with: "The Testing Team" click_on "Next" - click_on "Skip" + click_on "Skip" if bulk_invitations_enabled? if billing_enabled? unless freemium_enabled? diff --git a/test/system/dates_helper_test.rb b/test/system/dates_helper_test.rb index e7cfb60bc..c72f8c6bc 100644 --- a/test/system/dates_helper_test.rb +++ b/test/system/dates_helper_test.rb @@ -19,7 +19,7 @@ class DatesHelperTest < ApplicationSystemTestCase fill_in "Your Team Name", with: "The Testing Team" select "(GMT+00:00) UTC", from: "Your Time Zone" click_on "Next" - click_on "Skip" + click_on "Skip" if bulk_invitations_enabled? if billing_enabled? unless freemium_enabled? diff --git a/test/system/fields_test.rb b/test/system/fields_test.rb index 31864c438..b94663319 100644 --- a/test/system/fields_test.rb +++ b/test/system/fields_test.rb @@ -26,7 +26,7 @@ class AccountTest < ApplicationSystemTestCase fill_in "Your Team Name", with: "My Super Team" page.select "Brisbane", from: "Your Time Zone" click_on "Next" - click_on "Skip" + click_on "Skip" if bulk_invitations_enabled? if billing_enabled? unless freemium_enabled? diff --git a/test/system/invitation_lists_test.rb b/test/system/invitation_lists_test.rb index 56606ad61..f59c9c200 100644 --- a/test/system/invitation_lists_test.rb +++ b/test/system/invitation_lists_test.rb @@ -1,61 +1,63 @@ require "application_system_test_case" class InvitationListsTest < ApplicationSystemTestCase - @@test_devices.each do |device_name, display_details| - test "visitors can send bulk invitations upon signing up" do - resize_for(display_details) - - sign_up_from_homepage_for(display_details) - fill_in "Your Email Address", with: "hanako.tanaka@gmail.com" - fill_in "Set Password", with: example_password - fill_in "Confirm Password", with: example_password - click_on "Sign Up" - - 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 + if bulk_invitations_enabled? + @@test_devices.each do |device_name, display_details| + test "visitors can send bulk invitations upon signing up" do + resize_for(display_details) - # Click on next to show that bulk invitations will raise an error if not filled out properly. - click_on "Next" - assert page.has_content?("Please correct the errors below.") - assert page.has_content?("Invitations email can't be blank") + sign_up_from_homepage_for(display_details) + fill_in "Your Email Address", with: "hanako.tanaka@gmail.com" + fill_in "Set Password", with: example_password + fill_in "Confirm Password", with: example_password + click_on "Sign Up" - # Fill in the email addresses. - email_fields = page.all("label", text: "Email Address") - email_fields.each_with_index do |field, idx| - field.sibling("div").find("input").fill_in with: "test-#{idx}@some-company.com" - end + 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" - # Select roles from select element. - role_ids = ["Default", "Editor", "Admin"] - role_fields = page.all("label", text: "Role ids") - role_fields.each_with_index do |role_field, idx| - select_field = role_field.sibling("div").find("select") - select_field.all("option").find { |opt| opt.text == role_ids[idx] }.select_option - end + if billing_enabled? + unless freemium_enabled? + complete_pricing_page + end + end - assert_difference(["Invitation.count", "Membership.count"], 3) do + # Click on next to show that bulk invitations will raise an error if not filled out properly. click_on "Next" - sleep 2 - end + assert page.has_content?("Please correct the errors below.") + assert page.has_content?("Invitations email can't be blank") - assert page.has_content?("The Testing Team’s Dashboard") - within_team_menu_for(display_details) do - click_on "Team Members" - end + # Fill in the email addresses. + email_fields = page.all("label", text: "Email Address") + email_fields.each_with_index do |field, idx| + field.sibling("div").find("input").fill_in with: "test-#{idx}@some-company.com" + end + + # Select roles from select element. + role_ids = ["Default", "Editor", "Admin"] + role_fields = page.all("label", text: "Role ids") + role_fields.each_with_index do |role_field, idx| + select_field = role_field.sibling("div").find("select") + select_field.all("option").find { |opt| opt.text == role_ids[idx] }.select_option + end + + assert_difference(["Invitation.count", "Membership.count"], 3) do + click_on "Next" + sleep 2 + end + + assert page.has_content?("The Testing Team’s Dashboard") + within_team_menu_for(display_details) do + click_on "Team Members" + end - 3.times do |idx| - assert page.has_content?("test-#{idx}@some-company.com") - invitation = Invitation.find_by(email: "test-#{idx}@some-company.com") - assert_equal invitation.membership.role_ids, [role_ids[idx].downcase] + 3.times do |idx| + assert page.has_content?("test-#{idx}@some-company.com") + invitation = Invitation.find_by(email: "test-#{idx}@some-company.com") + assert_equal invitation.membership.role_ids, [role_ids[idx].downcase] + end end end end diff --git a/test/system/invitations_test.rb b/test/system/invitations_test.rb index a5c173107..5b3d3c366 100644 --- a/test/system/invitations_test.rb +++ b/test/system/invitations_test.rb @@ -22,7 +22,7 @@ class InvitationDetailsTest < ApplicationSystemTestCase fill_in "Last Name", with: "Tanaka" fill_in "Your Team Name", with: "The Testing Team" click_on "Next" - click_on "Skip" + click_on "Skip" if bulk_invitations_enabled? if billing_enabled? unless freemium_enabled? @@ -178,7 +178,7 @@ class InvitationDetailsTest < ApplicationSystemTestCase fill_in "First Name", with: "Taka" fill_in "Last Name", with: "Yamaguchi" click_on "Next" - click_on "Skip" + click_on "Skip" if bulk_invitations_enabled? assert page.has_content?("The Testing Team’s Dashboard") within_team_menu_for(display_details) do diff --git a/test/system/membership_test.rb b/test/system/membership_test.rb index c06b9d1c8..7ace51de6 100644 --- a/test/system/membership_test.rb +++ b/test/system/membership_test.rb @@ -22,7 +22,7 @@ class MembershipSystemTest < ApplicationSystemTestCase fill_in "Last Name", with: "Smith" fill_in "Your Team Name", with: "The Testing Team" click_on "Next" - click_on "Skip" + click_on "Skip" if bulk_invitations_enabled? if billing_enabled? unless freemium_enabled? diff --git a/test/system/reactivity_system_test.rb b/test/system/reactivity_system_test.rb index 13a2ddabf..7957c0a16 100644 --- a/test/system/reactivity_system_test.rb +++ b/test/system/reactivity_system_test.rb @@ -19,7 +19,7 @@ class ReactivitySystemTest < ApplicationSystemTestCase fill_in "Your Team Name", with: "My Super Team" page.select "Brisbane", from: "Your Time Zone" click_on "Next" - click_on "Skip" + click_on "Skip" if bulk_invitations_enabled? if billing_enabled? unless freemium_enabled? diff --git a/test/system/tangible_thing_test.rb b/test/system/tangible_thing_test.rb index 46a4b8fda..198a08514 100644 --- a/test/system/tangible_thing_test.rb +++ b/test/system/tangible_thing_test.rb @@ -19,7 +19,7 @@ class TangibleThingTest < ApplicationSystemTestCase fill_in "Your Team Name", with: "My Super Team" page.select "Brisbane", from: "Your Time Zone" click_on "Next" - click_on "Skip" + click_on "Skip" if bulk_invitations_enabled? if billing_enabled? unless freemium_enabled? From bc794d5295d552406eb7cec7812568094e11bde8 Mon Sep 17 00:00:00 2001 From: gazayas Date: Wed, 23 Aug 2023 22:11:11 +0900 Subject: [PATCH 10/18] Enable bulk invitations on bin/configure step --- bin/configure | 9 +++++++++ config/initializers/bullet_train.rb | 2 +- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/bin/configure b/bin/configure index 4df51b29f..7cce9aae6 100755 --- a/bin/configure +++ b/bin/configure @@ -174,6 +174,15 @@ if File.exist?('.github/workflows/main.yml') File.delete('.github/workflows/main.yml') end +# Enable the bulk invitations configuration. +bt_config_lines = File.open("config/initializers/bullet_train.rb").readlines +new_lines = bt_config_lines.map do |line| + if line.match?("config.enable_bulk_invitations") + line.gsub!(/#\s*/, "") + end + line +end +File.write("config/initializers/bullet_train.rb", bt_config_lines.join) puts "Next, let's push your application to GitHub." puts "If you would like to use another service like Gitlab to manage your repository," diff --git a/config/initializers/bullet_train.rb b/config/initializers/bullet_train.rb index 8c11be16a..2b829a6b8 100644 --- a/config/initializers/bullet_train.rb +++ b/config/initializers/bullet_train.rb @@ -2,6 +2,6 @@ # Uncomment this line if you want to bypass strong passwords. # config.strong_passwords = false - # Uncomment this line to enable bulk invitations on the user onboarding step. + # Enable bulk invitations on the user onboarding step. # config.enable_bulk_invitations = true end From 723ce1f348e49446cac80fae16d81cf967d9666f Mon Sep 17 00:00:00 2001 From: gazayas Date: Wed, 23 Aug 2023 22:11:42 +0900 Subject: [PATCH 11/18] Fixing Standard Ruby --- test/system/invitations_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/system/invitations_test.rb b/test/system/invitations_test.rb index 5b3d3c366..2d4f9c269 100644 --- a/test/system/invitations_test.rb +++ b/test/system/invitations_test.rb @@ -178,7 +178,7 @@ class InvitationDetailsTest < ApplicationSystemTestCase fill_in "First Name", with: "Taka" fill_in "Last Name", with: "Yamaguchi" click_on "Next" - click_on "Skip" if bulk_invitations_enabled? + click_on "Skip" if bulk_invitations_enabled? assert page.has_content?("The Testing Team’s Dashboard") within_team_menu_for(display_details) do From 811fec2d0a66661e0adf9ab1f46760d315d74948 Mon Sep 17 00:00:00 2001 From: Gabriel Zayas Date: Tue, 29 Aug 2023 16:00:04 +0900 Subject: [PATCH 12/18] Edit tests to always run invitation lists system tests --- test/system/invitation_lists_test.rb | 106 +++++++++++++++------------ 1 file changed, 59 insertions(+), 47 deletions(-) diff --git a/test/system/invitation_lists_test.rb b/test/system/invitation_lists_test.rb index f59c9c200..b1eda8365 100644 --- a/test/system/invitation_lists_test.rb +++ b/test/system/invitation_lists_test.rb @@ -1,63 +1,75 @@ require "application_system_test_case" class InvitationListsTest < ApplicationSystemTestCase - if bulk_invitations_enabled? - @@test_devices.each do |device_name, display_details| - test "visitors can send bulk invitations upon signing up" do - resize_for(display_details) + @@test_devices.each do |device_name, display_details| + def setup + @current_bulk_invitations_setting = nil + BulletTrain.configure do |config| + @current_bulk_invitations_setting = config.enable_bulk_invitations + config.enable_bulk_invitations = true + end + end - sign_up_from_homepage_for(display_details) - fill_in "Your Email Address", with: "hanako.tanaka@gmail.com" - fill_in "Set Password", with: example_password - fill_in "Confirm Password", with: example_password - click_on "Sign Up" + def teardown + BulletTrain.configure do |config| + config.enable_bulk_invitations = @current_bulk_invitations_setting + end + end - 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" + test "visitors can send bulk invitations upon signing up" do + resize_for(display_details) - if billing_enabled? - unless freemium_enabled? - complete_pricing_page - end - end + sign_up_from_homepage_for(display_details) + fill_in "Your Email Address", with: "hanako.tanaka@gmail.com" + fill_in "Set Password", with: example_password + fill_in "Confirm Password", with: example_password + click_on "Sign Up" - # Click on next to show that bulk invitations will raise an error if not filled out properly. - click_on "Next" - assert page.has_content?("Please correct the errors below.") - assert page.has_content?("Invitations email can't be blank") + 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" - # Fill in the email addresses. - email_fields = page.all("label", text: "Email Address") - email_fields.each_with_index do |field, idx| - field.sibling("div").find("input").fill_in with: "test-#{idx}@some-company.com" + if billing_enabled? + unless freemium_enabled? + complete_pricing_page end + end - # Select roles from select element. - role_ids = ["Default", "Editor", "Admin"] - role_fields = page.all("label", text: "Role ids") - role_fields.each_with_index do |role_field, idx| - select_field = role_field.sibling("div").find("select") - select_field.all("option").find { |opt| opt.text == role_ids[idx] }.select_option - end + # Click on next to show that bulk invitations will raise an error if not filled out properly. + click_on "Next" + assert page.has_content?("Please correct the errors below.") + assert page.has_content?("Invitations email can't be blank") - assert_difference(["Invitation.count", "Membership.count"], 3) do - click_on "Next" - sleep 2 - end + # Fill in the email addresses. + email_fields = page.all("label", text: "Email Address") + email_fields.each_with_index do |field, idx| + field.sibling("div").find("input").fill_in with: "test-#{idx}@some-company.com" + end - assert page.has_content?("The Testing Team’s Dashboard") - within_team_menu_for(display_details) do - click_on "Team Members" - end + # Select roles from select element. + role_ids = ["Default", "Editor", "Admin"] + role_fields = page.all("label", text: "Role") + role_fields.each_with_index do |role_field, idx| + select_field = role_field.sibling("div").find("select") + select_field.all("option").find { |opt| opt.text == role_ids[idx] }.select_option + end - 3.times do |idx| - assert page.has_content?("test-#{idx}@some-company.com") - invitation = Invitation.find_by(email: "test-#{idx}@some-company.com") - assert_equal invitation.membership.role_ids, [role_ids[idx].downcase] - end + assert_difference(["Invitation.count", "Membership.count"], 3) do + click_on "Next" + sleep 2 + end + + assert page.has_content?("The Testing Team’s Dashboard") + within_team_menu_for(display_details) do + click_on "Team Members" + end + + 3.times do |idx| + assert page.has_content?("test-#{idx}@some-company.com") + invitation = Invitation.find_by(email: "test-#{idx}@some-company.com") + assert_equal invitation.membership.role_ids, [role_ids[idx].downcase] end end end From 61ad1f5b26453a05737f5766759c599e541c51bf Mon Sep 17 00:00:00 2001 From: Gabriel Zayas Date: Thu, 14 Sep 2023 21:08:48 +0900 Subject: [PATCH 13/18] Update schema --- db/schema.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/db/schema.rb b/db/schema.rb index b8ab47078..6a5e5e255 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema[7.0].define(version: 2023_01_23_162616) do +ActiveRecord::Schema[7.0].define(version: 2023_08_19_123854) do # These are extensions that must be enabled in order to support this database enable_extension "plpgsql" From 99fc86d8f27271bc1dabc5fddcf61d66bbec11d5 Mon Sep 17 00:00:00 2001 From: Gabriel Zayas Date: Thu, 14 Sep 2023 21:28:07 +0900 Subject: [PATCH 14/18] Remove non-existent error assertion --- test/system/invitation_lists_test.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/test/system/invitation_lists_test.rb b/test/system/invitation_lists_test.rb index b1eda8365..7e0b38a12 100644 --- a/test/system/invitation_lists_test.rb +++ b/test/system/invitation_lists_test.rb @@ -39,7 +39,6 @@ def teardown # Click on next to show that bulk invitations will raise an error if not filled out properly. click_on "Next" - assert page.has_content?("Please correct the errors below.") assert page.has_content?("Invitations email can't be blank") # Fill in the email addresses. From 3f40455a7a0a9880e49388847db46b63e6cd7e2f Mon Sep 17 00:00:00 2001 From: Gabriel Zayas Date: Thu, 14 Sep 2023 21:34:54 +0900 Subject: [PATCH 15/18] Show correct error message in invitation lists test --- test/system/invitation_lists_test.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/test/system/invitation_lists_test.rb b/test/system/invitation_lists_test.rb index 7e0b38a12..d63bd46af 100644 --- a/test/system/invitation_lists_test.rb +++ b/test/system/invitation_lists_test.rb @@ -39,7 +39,7 @@ def teardown # Click on next to show that bulk invitations will raise an error if not filled out properly. click_on "Next" - assert page.has_content?("Invitations email can't be blank") + assert page.has_content?("Email can't be blank") # Fill in the email addresses. email_fields = page.all("label", text: "Email Address") From b81488d211d94eb9646d27a432dd34fe5969fbb5 Mon Sep 17 00:00:00 2001 From: Gabriel Zayas Date: Thu, 14 Sep 2023 21:51:10 +0900 Subject: [PATCH 16/18] Try to fix invitation lists test --- test/system/invitation_lists_test.rb | 15 +++++++-------- 1 file changed, 7 insertions(+), 8 deletions(-) diff --git a/test/system/invitation_lists_test.rb b/test/system/invitation_lists_test.rb index d63bd46af..239564cdb 100644 --- a/test/system/invitation_lists_test.rb +++ b/test/system/invitation_lists_test.rb @@ -48,14 +48,14 @@ def teardown end # Select roles from select element. - role_ids = ["Default", "Editor", "Admin"] role_fields = page.all("label", text: "Role") - role_fields.each_with_index do |role_field, idx| + role_fields.each_with_index do |role_field| select_field = role_field.sibling("div").find("select") - select_field.all("option").find { |opt| opt.text == role_ids[idx] }.select_option + select_field.select 'admin' + select_field.select 'editor' end - assert_difference(["Invitation.count", "Membership.count"], 3) do + assert_difference(["Invitation.count", "Membership.count"], 1) do click_on "Next" sleep 2 end @@ -65,10 +65,9 @@ def teardown click_on "Team Members" end - 3.times do |idx| - assert page.has_content?("test-#{idx}@some-company.com") - invitation = Invitation.find_by(email: "test-#{idx}@some-company.com") - assert_equal invitation.membership.role_ids, [role_ids[idx].downcase] + assert page.has_content?("test-0@some-company.com") + invitation = Invitation.find_by(email: "test-0@some-company.com") + assert_equal invitation.membership.role_ids, ["admin", "editor"] end end end From 22eef51bd8ff3a2012b64cddd3f80b7c00b2289b Mon Sep 17 00:00:00 2001 From: Gabriel Zayas Date: Thu, 14 Sep 2023 21:56:23 +0900 Subject: [PATCH 17/18] Remove syntax error --- test/system/invitation_lists_test.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/test/system/invitation_lists_test.rb b/test/system/invitation_lists_test.rb index 239564cdb..e04359386 100644 --- a/test/system/invitation_lists_test.rb +++ b/test/system/invitation_lists_test.rb @@ -68,7 +68,6 @@ def teardown assert page.has_content?("test-0@some-company.com") invitation = Invitation.find_by(email: "test-0@some-company.com") assert_equal invitation.membership.role_ids, ["admin", "editor"] - end end end end From 9de755ef7aaeda2e2a361aaa1eb3d16a37a5778a Mon Sep 17 00:00:00 2001 From: Gabriel Zayas Date: Thu, 14 Sep 2023 22:01:56 +0900 Subject: [PATCH 18/18] Fixing Standard Ruby --- test/system/invitation_lists_test.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/test/system/invitation_lists_test.rb b/test/system/invitation_lists_test.rb index e04359386..12d4536f1 100644 --- a/test/system/invitation_lists_test.rb +++ b/test/system/invitation_lists_test.rb @@ -49,10 +49,10 @@ def teardown # Select roles from select element. role_fields = page.all("label", text: "Role") - role_fields.each_with_index do |role_field| + role_fields.each do |role_field| select_field = role_field.sibling("div").find("select") - select_field.select 'admin' - select_field.select 'editor' + select_field.select "admin" + select_field.select "editor" end assert_difference(["Invitation.count", "Membership.count"], 1) do