diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb index 332c73b0d6..ec4ed21338 100644 --- a/test/application_system_test_case.rb +++ b/test/application_system_test_case.rb @@ -129,6 +129,24 @@ def assert_html(html, within: "body") assert_includes formatted_context, formatted_html, error_msg end + # refute_text proxies to this, so it's better to override + # this than it is to override refute_text directly. + def assert_no_text(text, **options) + # If React's not fully loaded then things incorectly not + # be there. This isn't an issue with assert_text as that + # has the waiting built in. But for this, where it will + # immediately succeed if the text doesn't exist, we end + # in scenarios where it refutes the text simply because + # React hasn't loaded yet. We have the instance variable + # so that we only do this once per test. + unless @give_react_time_to_load + sleep(1) + @give_react_time_to_load = true + end + + super(:visible, text, **options) + end + def assert_text(text, **options) options[:normalize_ws] = true unless options.key?(:normalize_ws) super(:visible, text, **options) diff --git a/test/system/components/seniority_survey_modal_test.rb b/test/system/components/seniority_survey_modal_test.rb index 4966168ee4..ff2adddfa1 100644 --- a/test/system/components/seniority_survey_modal_test.rb +++ b/test/system/components/seniority_survey_modal_test.rb @@ -4,6 +4,8 @@ module Components class SenioritySurveyModalTest < ApplicationSystemTestCase test "shows it on dashboard page" do user = create :user, seniority: nil + create(:user_dismissed_introducer, user:, slug: "welcome-modal") + use_capybara_host do Exercism.without_bullet do sign_in!(user) @@ -14,16 +16,16 @@ class SenioritySurveyModalTest < ApplicationSystemTestCase end end - # TODO: check why this doesn't fail test "does not show if seniority is provided -- this should fail" do user = create :user, seniority: :mid + create(:user_dismissed_introducer, user:, slug: "welcome-modal") use_capybara_host do Exercism.without_bullet do sign_in!(user) visit dashboard_path - assert_text "How experienced a developer are you?" + refute_text "How experienced a developer are you?" end end end diff --git a/test/system/flows/notifications/dropdown_test.rb b/test/system/flows/notifications/dropdown_test.rb index dc8acdc2bb..40d3514fe4 100644 --- a/test/system/flows/notifications/dropdown_test.rb +++ b/test/system/flows/notifications/dropdown_test.rb @@ -9,7 +9,7 @@ class DrodpownTest < ApplicationSystemTestCase include WebsocketsHelpers test "user views notifications" do - user = create :user, seniority: :senior + user = create :user mentor = create :user, handle: "mr-mentor" discussion = create(:mentor_discussion, mentor:) create :mentor_started_discussion_notification, user:, params: { discussion: }, status: :unread @@ -27,7 +27,7 @@ class DrodpownTest < ApplicationSystemTestCase end test "refetches on websocket notification" do - user = create :user, seniority: :senior + user = create :user mentor = create :user, handle: "mrs-mentor" discussion = create(:mentor_discussion, mentor:) create(:user_dismissed_introducer, slug: "welcome-modal", user:) @@ -48,7 +48,7 @@ class DrodpownTest < ApplicationSystemTestCase end test "only loads notifications when dropdown is closed" do - user = create :user, seniority: :senior + user = create :user mentor = create :user, handle: "mrs-mentor" discussion = create(:mentor_discussion, mentor:) create(:user_dismissed_introducer, slug: "welcome-modal", user:) diff --git a/test/system/flows/student/track_menu/views_track_documentation_test.rb b/test/system/flows/student/track_menu/views_track_documentation_test.rb index 2d13b8d922..741a56bc78 100644 --- a/test/system/flows/student/track_menu/views_track_documentation_test.rb +++ b/test/system/flows/student/track_menu/views_track_documentation_test.rb @@ -8,7 +8,7 @@ class ViewsTrackDocumentationTest < ApplicationSystemTestCase include CapybaraHelpers test "student views track documentation" do - user = create :user, seniority: :senior + user = create :user track = create :track, title: "Ruby" create(:user_dismissed_introducer, slug: "track-welcome-modal-#{track.slug}", user:) create(:concept_exercise, track:) diff --git a/test/system/flows/student_requests_mentorship_test.rb b/test/system/flows/student_requests_mentorship_test.rb index b27e35cf4f..07f5d9c699 100644 --- a/test/system/flows/student_requests_mentorship_test.rb +++ b/test/system/flows/student_requests_mentorship_test.rb @@ -8,7 +8,7 @@ class StudentRequestsMentorship < ApplicationSystemTestCase include MarkdownEditorHelpers test "student requests mentorship" do - user = create :user, seniority: :mid + user = create :user track = create :track create(:user_dismissed_introducer, slug: "track-welcome-modal-#{track.slug}", user:) create(:user_track, user:, track:) @@ -45,7 +45,7 @@ class StudentRequestsMentorship < ApplicationSystemTestCase end test "form should be invalid when textarea value doesn't reach min length of 20 characters" do - user = create :user, seniority: :mid + user = create :user track = create :track create(:user_dismissed_introducer, slug: "track-welcome-modal-#{track.slug}", user:) create(:user_track, user:, track:) @@ -97,7 +97,7 @@ class StudentRequestsMentorship < ApplicationSystemTestCase end test "student can not request mentorship for hello-world" do - user = create :user, seniority: :mid + user = create :user track = create :track create(:user_dismissed_introducer, slug: "track-welcome-modal-#{track.slug}", user:) create(:user_track, user:, track:) @@ -130,7 +130,7 @@ class StudentRequestsMentorship < ApplicationSystemTestCase end test "student can not request mentorship for hello world" do - user = create :user, seniority: :mid + user = create :user track = create :track create(:user_track, user:, track:) hello_world = create :concept_exercise, track:, slug: "hello-world" @@ -152,7 +152,7 @@ class StudentRequestsMentorship < ApplicationSystemTestCase end test "student sees required number of completed exercises to request mentorship" do - user = create :user, seniority: :mid + user = create :user track = create :track, title: "Ruby" create(:user_track, user:, track:) create :concept_exercise, track:, slug: "hello-world" @@ -168,7 +168,7 @@ class StudentRequestsMentorship < ApplicationSystemTestCase end test "student requests mentorship when slots are full" do - user = create :user, seniority: :mid + user = create :user track = create :track create(:user_track, user:, track:) @@ -195,7 +195,7 @@ class StudentRequestsMentorship < ApplicationSystemTestCase end test "student edits empty comment" do - user = create :user, seniority: :mid + user = create :user track = create :track create(:user_track, user:, track:) diff --git a/test/system/flows/user_loads_reputation_test.rb b/test/system/flows/user_loads_reputation_test.rb index 56640de991..41dd315c2d 100644 --- a/test/system/flows/user_loads_reputation_test.rb +++ b/test/system/flows/user_loads_reputation_test.rb @@ -8,7 +8,7 @@ class UserLoadsReputationTest < ApplicationSystemTestCase include WebsocketsHelpers test "user views reputation" do - user = create :user, seniority: :senior + user = create :user external_url = "https://github.com/exercism/ruby/pulls/120" create :user_code_review_reputation_token, user:, @@ -37,7 +37,7 @@ class UserLoadsReputationTest < ApplicationSystemTestCase end test "mark token as seen on hover" do - user = create :user, seniority: :senior + user = create :user create :user_code_review_reputation_token, user:, created_at: 2.days.ago, @@ -64,7 +64,7 @@ class UserLoadsReputationTest < ApplicationSystemTestCase end test "mark token as seen on focus" do - user = create :user, seniority: :senior + user = create :user create :user_code_review_reputation_token, user:, created_at: 2.days.ago, @@ -92,7 +92,7 @@ class UserLoadsReputationTest < ApplicationSystemTestCase end test "refetches on websocket notification" do - user = create :user, seniority: :senior + user = create :user create(:user_dismissed_introducer, slug: "welcome-modal", user:) use_capybara_host do