diff --git a/test/system/browses_test.rb b/test/system/browses_test.rb new file mode 100644 index 0000000..36d75fc --- /dev/null +++ b/test/system/browses_test.rb @@ -0,0 +1,20 @@ +require "application_system_test_case" + +class BrowsesTest < ApplicationSystemTestCase + # test "visiting the index" do + # visit browses_url + # + # assert_selector "h1", text: "Browse" + # end + + test "user can see home page" do + visit root_path + assert_text /This website lets you browse screenshots of [\d,]+ software packages/ + end + + test "user can browse packages" do + visit packages_grid_path + has_link? href: packages_grid_path(page: 2) + end + +end diff --git a/test/system/uploads_test.rb b/test/system/uploads_test.rb new file mode 100644 index 0000000..0006b67 --- /dev/null +++ b/test/system/uploads_test.rb @@ -0,0 +1,74 @@ +require "application_system_test_case" + +class UploadsTest < ApplicationSystemTestCase + test "upload broken screenshot anonymously and get error message" do + visit package_path(name: 'firefox') + click_on 'Upload a screenshot' + attach_file 'file[]', Rails.root.join('test/fixtures/files/large-broken.png') + click_on 'Start upload' + assert_text 'large-broken.png is not valid' + end + + # test "upload png screenshot anonymously and await moderation" do + # visit package_path(name: 'firefox') + # click_on 'Upload a screenshot' + # img_count_before = page.find_all('img').count + # attach_file 'file[]', Rails.root.join('test/fixtures/files/large1.png') + # click_on 'Start upload' + # img_count_after = page.find_all('img').count + # assert_equal img_count_after, img_count_before + 1 + + # # Screenshot must be moderated + # newest_screenshot = Package.find_by_name(:firefox).screenshots.order(id: :desc).first + # assert_equal newest_screenshot.approved, false + + # # Clean up + # newest_screenshot.destroy + # end + + # test "upload screenshot as Debian SSO user and get auto-approval" do + # sign_in users(:debian) + # visit upload_path(name: 'firefox') + # img_count_before = page.find_all('img').count + # attach_file 'file[]', Rails.root.join('test/fixtures/files/large1.png') + # click_on 'Start upload' + # img_count_after = page.find_all('img').count + # assert_equal img_count_after, img_count_before + 1 + + # # Screenshot is instantly public + # newest_screenshot = Package.find_by_name(:firefox).screenshots.order(id: :desc).first + # assert_equal newest_screenshot.approved, true + + # # Clean up + # newest_screenshot.destroy + # sign_out users(:debian) + # end + + # test "upload screenshot anonymously, login in, get screenshots assigned" do + # visit upload_path(name: 'firefox') + # attach_file 'file[]', Rails.root.join('test/fixtures/files/large1.png') + # click_on 'Start upload' + + # # Screenshot has not yet a user assigned + # newest_screenshot = Package.find_by_name(:firefox).screenshots.order(id: :desc).first + # assert_nil newest_screenshot.user + + # # Login (sign_in is just a stub and would not call the callbacks!) + # visit root_path + # click_link 'Login' + # within 'form' do + # fill_in 'email address', with: users(:normal).email + # fill_in 'password', with: 'normalsecret' + # click_button 'Log in' + # end + + # # Check if screenshot was assigned to the user + # newest_screenshot = Package.find_by_name(:firefox).screenshots.order(id: :desc).first + # assert_equal newest_screenshot.user, users(:normal) + + # # Clean up + # newest_screenshot.destroy + # sign_out users(:debian) + # end + +end