This commit is contained in:
Christoph Haas 2025-06-26 23:34:51 +02:00
parent d40d2ff164
commit e1f42aee0c
3 changed files with 19 additions and 20 deletions

View file

@ -1,13 +1,13 @@
require 'test_helper' require 'test_helper'
class PackagesControllerTest < ActionController::TestCase class PackagesControllerTest < ActionController::TestCase
test "should get index and contain dummy package-4" do test 'should get index and contain dummy package-4' do
get :grid get :grid
assert_response :success assert_response :success
assert_select 'div', 'package-4' assert_select 'div', 'package-4'
end end
test "should get list view with_screenshots and find Firefox" do test 'should get list view with_screenshots and find Firefox' do
# package = Package.create!(name: 'firefox', description: 'A web browser.') # package = Package.create!(name: 'firefox', description: 'A web browser.')
# Screenshot.create!(package: package, approved: true, hidden: false) # Screenshot.create!(package: package, approved: true, hidden: false)
@ -20,7 +20,12 @@ class PackagesControllerTest < ActionController::TestCase
assert_select 'div', 'A program to browse web sites.' assert_select 'div', 'A program to browse web sites.'
end end
# test "should get without_screenshots" do # test 'should get thumbnail for a package and a desired version' do
# # get '/thumbnail-with-version/package-5/0.1'
# get thumbnail_with_version_url('package-5', '0.1')
# end
# test 'should get without_screenshots' do
# get :without_screenshots # get :without_screenshots
# assert_response :success # assert_response :success
# end # end
@ -56,7 +61,6 @@ class PackagesControllerTest < ActionController::TestCase
# byebug # byebug
# assert_equal newest_screenshot2.user, users(:normal) # assert_equal newest_screenshot2.user, users(:normal)
# # (name: 'firefox') # # (name: 'firefox')
# # img_count_before = page.find_all('img').count # # img_count_before = page.find_all('img').count
# # attach_file 'file[]', Rails.root.join('test/fixtures/files/large1.png') # # attach_file 'file[]', Rails.root.join('test/fixtures/files/large1.png')
@ -77,5 +81,4 @@ class PackagesControllerTest < ActionController::TestCase
# # newest_screenshot.destroy # # newest_screenshot.destroy
# # sign_out users(:normal) # # sign_out users(:normal)
# end # end
end end

View file

@ -1,4 +1,4 @@
require "application_system_test_case" require 'application_system_test_case'
class BrowsesTest < ApplicationSystemTestCase class BrowsesTest < ApplicationSystemTestCase
# test "visiting the index" do # test "visiting the index" do
@ -7,14 +7,13 @@ class BrowsesTest < ApplicationSystemTestCase
# assert_selector "h1", text: "Browse" # assert_selector "h1", text: "Browse"
# end # end
test "user can see home page" do test 'user can see home page' do
visit root_path visit root_path
assert_text /This website lets you browse screenshots of [\d,]+ software packages/ assert_text(/This website lets you browse screenshots of [\d,]+ software packages/)
end end
test "user can browse packages" do test 'user can browse packages' do
visit packages_grid_path visit packages_grid_path
has_link? href: packages_grid_path(page: 2) has_link? href: packages_grid_path(page: 2)
end end
end end

View file

@ -1,7 +1,7 @@
require "application_system_test_case" require 'application_system_test_case'
class UploadsTest < ApplicationSystemTestCase class UploadsTest < ApplicationSystemTestCase
test "upload broken screenshot anonymously and get error message" do test 'upload broken screenshot anonymously and get error message' do
visit package_path(name: 'firefox') visit package_path(name: 'firefox')
click_on 'Upload a screenshot' click_on 'Upload a screenshot'
# The actual file field is hidden in favor of a more beautiful button -> visible=false # The actual file field is hidden in favor of a more beautiful button -> visible=false
@ -10,10 +10,10 @@ class UploadsTest < ApplicationSystemTestCase
assert_text 'large-broken.png must be a valid' assert_text 'large-broken.png must be a valid'
end end
test "upload png screenshot anonymously and await moderation" do test 'upload png screenshot anonymously and await moderation' do
visit package_path(name: 'firefox') visit package_path(name: 'firefox')
img_count1 = page.find_all('img').count img_count1 = page.find_all('img').count
#Rails::logger.debug "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 1=#{img_count1}" # Rails::logger.debug "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 1=#{img_count1}"
click_on 'Upload a screenshot' click_on 'Upload a screenshot'
attach_file 'file[]', Rails.root.join('test/fixtures/files/large1.png'), visible: false attach_file 'file[]', Rails.root.join('test/fixtures/files/large1.png'), visible: false
@ -25,7 +25,7 @@ class UploadsTest < ApplicationSystemTestCase
assert page.has_content?('needs to be approved') assert page.has_content?('needs to be approved')
img_count2 = page.find_all('img').count img_count2 = page.find_all('img').count
#Rails::logger.debug "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 1=#{img_count2}" # Rails::logger.debug "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 1=#{img_count2}"
assert_equal img_count2, img_count1 + 1 assert_equal img_count2, img_count1 + 1
@ -40,13 +40,12 @@ class UploadsTest < ApplicationSystemTestCase
# Wait for redirect to details page # Wait for redirect to details page
assert page.has_content?('Homepage') assert page.has_content?('Homepage')
img_count3 = page.find_all('img').count img_count3 = page.find_all('img').count
#Rails::logger.debug "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 1=#{img_count3}" # Rails::logger.debug "ZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZZ 1=#{img_count3}"
assert_equal img_count3, img_count1 assert_equal img_count3, img_count1
end end
test "upload png screenshot as moderator and expect auto-approval" do test 'upload png screenshot as moderator and expect auto-approval' do
# Delete all screenshots for the Firefox package # Delete all screenshots for the Firefox package
Package.find_by_name(:firefox).screenshots.delete_all Package.find_by_name(:firefox).screenshots.delete_all
@ -83,7 +82,6 @@ class UploadsTest < ApplicationSystemTestCase
assert page.has_content?('Homepage') assert page.has_content?('Homepage')
end end
# test "upload screenshot as Debian SSO user and get auto-approval" do # test "upload screenshot as Debian SSO user and get auto-approval" do
# sign_in users(:debian) # sign_in users(:debian)
# visit upload_path(name: 'firefox') # visit upload_path(name: 'firefox')
@ -128,5 +126,4 @@ class UploadsTest < ApplicationSystemTestCase
# newest_screenshot.destroy # newest_screenshot.destroy
# sign_out users(:debian) # sign_out users(:debian)
# end # end
end end