From: Anton Khorev Date: Mon, 25 Dec 2023 16:07:00 +0000 (+0300) Subject: Add website oauth app registration to system tests X-Git-Tag: live~844^2 X-Git-Url: https://git.openstreetmap.org./rails.git/commitdiff_plain/f0b24cdc84debeea413caffdfd8d8d8bab1ef358?ds=sidebyside;hp=-c Add website oauth app registration to system tests --- f0b24cdc84debeea413caffdfd8d8d8bab1ef358 diff --git a/test/application_system_test_case.rb b/test/application_system_test_case.rb index f6546a550..c2de02781 100644 --- a/test/application_system_test_case.rb +++ b/test/application_system_test_case.rb @@ -10,4 +10,15 @@ class ApplicationSystemTestCase < ActionDispatch::SystemTestCase driven_by :selenium, :using => :headless_firefox do |options| options.add_preference("intl.accept_languages", "en") end + + def before_setup + super + osm_website_app = create(:oauth_application, :name => "OpenStreetMap Web Site", :scopes => "write_api write_notes") + Settings.oauth_application = osm_website_app.uid + end + + def after_teardown + Settings.reload! + super + end end diff --git a/test/system/note_comments_test.rb b/test/system/note_comments_test.rb index aa548059f..7666f69e2 100644 --- a/test/system/note_comments_test.rb +++ b/test/system/note_comments_test.rb @@ -18,17 +18,25 @@ class NoteCommentsTest < ApplicationSystemTestCase assert_no_link "Log in to comment on this note" end - def test_action_text + def test_add_comment note = create(:note_with_comments) - sign_in_as(create(:user)) + user = create(:user) + sign_in_as(user) visit note_path(note) + assert_no_content "Comment from #{user.display_name}" + assert_no_content "Some newly added note comment" assert_button "Resolve" assert_button "Comment", :disabled => true - fill_in "text", :with => "Some text" + fill_in "text", :with => "Some newly added note comment" assert_button "Comment & Resolve" - assert_button "Comment" + assert_button "Comment", :disabled => false + + click_button "Comment" + + assert_content "Comment from #{user.display_name}" + assert_content "Some newly added note comment" end end diff --git a/test/system/oauth2_test.rb b/test/system/oauth2_test.rb index ab4964052..ed5ec1532 100644 --- a/test/system/oauth2_test.rb +++ b/test/system/oauth2_test.rb @@ -5,6 +5,12 @@ class Oauth2Test < ApplicationSystemTestCase sign_in_as(create(:user)) visit oauth_authorized_applications_path + assert_text "OpenStreetMap Web Site" + + accept_alert do + click_link "Revoke Access" + end + assert_text "You have not yet authorized any OAuth 2 applications." end end