Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 049db3eb69 | |||
| 395bf26a4b | |||
| d2be3a2347 | |||
| f0b49bc175 | |||
| d66a46f044 |
@@ -31,7 +31,7 @@ en:
|
|||||||
title: "Overview of %{ref}"
|
title: "Overview of %{ref}"
|
||||||
precious/views/search:
|
precious/views/search:
|
||||||
aria:
|
aria:
|
||||||
show_all: "Show all %{count} hits in this page"
|
show_all: Show all hits on this page
|
||||||
back_to_top: Back to Top
|
back_to_top: Back to Top
|
||||||
no_results: There are no results for your search
|
no_results: There are no results for your search
|
||||||
search_results_for: Search results for
|
search_results_for: Search results for
|
||||||
|
|||||||
@@ -0,0 +1,23 @@
|
|||||||
|
require_relative 'helper'
|
||||||
|
|
||||||
|
require 'selenium-webdriver'
|
||||||
|
require 'capybara/dsl'
|
||||||
|
|
||||||
|
Selenium::WebDriver::Chrome.path = ENV['CHROME_PATH'] if ENV['CHROME_PATH']
|
||||||
|
|
||||||
|
CAPYBARA_DRIVER =
|
||||||
|
if ENV['CI']
|
||||||
|
:selenium_chrome_headless
|
||||||
|
else
|
||||||
|
ENV.fetch('CAPYBARA_DRIVER', :selenium_chrome).to_sym
|
||||||
|
end
|
||||||
|
|
||||||
|
Capybara.default_driver = CAPYBARA_DRIVER
|
||||||
|
Capybara.enable_aria_label = true
|
||||||
|
Capybara.server = :webrick
|
||||||
|
|
||||||
|
def console_log(page, level = :severe)
|
||||||
|
page.driver.browser.logs.get(:browser).select { |log| log.level == level.to_s.upcase }
|
||||||
|
end
|
||||||
|
|
||||||
|
|
||||||
@@ -32,7 +32,6 @@ ENV['RACK_ENV'] = 'test'
|
|||||||
require 'gollum'
|
require 'gollum'
|
||||||
require 'gollum/app'
|
require 'gollum/app'
|
||||||
|
|
||||||
CAPYBARA_DRIVER = ENV['CI'] ? :selenium_chrome_headless : ENV.fetch('CAPYBARA_DRIVER', :selenium_chrome).to_sym
|
|
||||||
|
|
||||||
# Disable the metadata feature
|
# Disable the metadata feature
|
||||||
$METADATA = false
|
$METADATA = false
|
||||||
|
|||||||
@@ -1,9 +1,4 @@
|
|||||||
require File.expand_path(File.join(File.dirname(__FILE__), '..', 'helper'))
|
require_relative '../capybara_helper'
|
||||||
require 'selenium-webdriver'
|
|
||||||
require 'capybara/dsl'
|
|
||||||
|
|
||||||
Capybara.default_driver = ::CAPYBARA_DRIVER
|
|
||||||
Capybara.server = :webrick
|
|
||||||
|
|
||||||
def console_log(page, level = :severe)
|
def console_log(page, level = :severe)
|
||||||
page.driver.browser.logs.get(:browser).select{|log| log.level == level.to_s.upcase }
|
page.driver.browser.logs.get(:browser).select{|log| log.level == level.to_s.upcase }
|
||||||
@@ -21,7 +16,7 @@ end
|
|||||||
|
|
||||||
context 'Frontend with mathjax' do
|
context 'Frontend with mathjax' do
|
||||||
include Capybara::DSL
|
include Capybara::DSL
|
||||||
|
|
||||||
setup do
|
setup do
|
||||||
@path = cloned_testpath("examples/lotr.git")
|
@path = cloned_testpath("examples/lotr.git")
|
||||||
@wiki = Gollum::Wiki.new(@path)
|
@wiki = Gollum::Wiki.new(@path)
|
||||||
@@ -29,21 +24,21 @@ context 'Frontend with mathjax' do
|
|||||||
Precious::App.set(:wiki_options, {mathjax: true})
|
Precious::App.set(:wiki_options, {mathjax: true})
|
||||||
Capybara.app = Precious::App
|
Capybara.app = Precious::App
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'no unexpected errors on /' do
|
test 'no unexpected errors on /' do
|
||||||
visit '/'
|
visit '/'
|
||||||
log = console_log(page)
|
log = console_log(page)
|
||||||
assert_only_expected_errors(log)
|
assert_only_expected_errors(log)
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'no unexpected errors on /create/' do
|
test 'no unexpected errors on /create/' do
|
||||||
visit '/create/Foobar'
|
visit '/create/Foobar'
|
||||||
log = console_log(page)
|
log = console_log(page)
|
||||||
assert_only_expected_errors(log)
|
assert_only_expected_errors(log)
|
||||||
end
|
end
|
||||||
|
|
||||||
teardown do
|
teardown do
|
||||||
Capybara.reset_sessions!
|
Capybara.reset_sessions!
|
||||||
Capybara.use_default_driver
|
Capybara.use_default_driver
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -0,0 +1,61 @@
|
|||||||
|
require_relative '../capybara_helper'
|
||||||
|
|
||||||
|
context 'Localized frontend' do
|
||||||
|
include Capybara::DSL
|
||||||
|
|
||||||
|
setup do
|
||||||
|
@path = cloned_testpath "examples/lotr.git"
|
||||||
|
@wiki = Gollum::Wiki.new(@path)
|
||||||
|
|
||||||
|
Precious::App.set :gollum_path, @path
|
||||||
|
Precious::App.set :wiki_options, {mathjax: true}
|
||||||
|
|
||||||
|
Capybara.app = Precious::App
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'can visit search results page' do
|
||||||
|
visit '/gollum/search'
|
||||||
|
|
||||||
|
fill_in('Search', with: 'something-to-return-no-results')
|
||||||
|
.native
|
||||||
|
.send_keys(:return)
|
||||||
|
|
||||||
|
assert_includes page.text,
|
||||||
|
'Search results for something-to-return-no-results'
|
||||||
|
assert_includes page.text,
|
||||||
|
'There are no results for your search something-to-return-no-results.'
|
||||||
|
|
||||||
|
click_on 'Back to Top'
|
||||||
|
|
||||||
|
visit '/gollum/search'
|
||||||
|
|
||||||
|
fill_in('Search', with: 'Bilbo').native.send_keys(:return)
|
||||||
|
|
||||||
|
assert_includes page.text, 'Search results for Bilbo'
|
||||||
|
|
||||||
|
click_on 'Show all hits on this page'
|
||||||
|
click_on 'Bilbo-Baggins.md'
|
||||||
|
|
||||||
|
assert page.current_path, '/Bilbo-Baggins.md'
|
||||||
|
end
|
||||||
|
|
||||||
|
test 'can visit overview page' do
|
||||||
|
visit "/gollum/overview"
|
||||||
|
|
||||||
|
assert_includes page.text, 'Overview of master'
|
||||||
|
assert_includes page.text, 'Home'
|
||||||
|
|
||||||
|
click_on 'Back to Top'
|
||||||
|
click_on 'Bilbo-Baggins.md'
|
||||||
|
|
||||||
|
assert page.current_path, '/Bilbo-Baggins.md'
|
||||||
|
end
|
||||||
|
|
||||||
|
teardown do
|
||||||
|
@path = nil
|
||||||
|
@wiki = nil
|
||||||
|
|
||||||
|
Capybara.reset_sessions!
|
||||||
|
Capybara.use_default_driver
|
||||||
|
end
|
||||||
|
end
|
||||||
+24
-15
@@ -1082,59 +1082,68 @@ context "Default keybindings" do
|
|||||||
include Rack::Test::Methods
|
include Rack::Test::Methods
|
||||||
|
|
||||||
setup do
|
setup do
|
||||||
@path = cloned_testpath("examples/empty.git")
|
@path = cloned_testpath "examples/empty.git"
|
||||||
@wiki = Gollum::Wiki.new(@path)
|
@wiki = Gollum::Wiki.new @path
|
||||||
@url = '/gollum/create/test'
|
@url = '/gollum/create/test'
|
||||||
Precious::App.set(:gollum_path, @path)
|
|
||||||
|
Precious::App.set :gollum_path, @path
|
||||||
|
Precious::App.set :wiki_options, {default_keybinding: nil}
|
||||||
end
|
end
|
||||||
|
|
||||||
teardown do
|
teardown do
|
||||||
FileUtils.rm_rf(@path)
|
FileUtils.rm_rf @path
|
||||||
Precious::App.set(:wiki_options, {default_keybinding: nil})
|
|
||||||
|
@path = nil
|
||||||
|
@wiki = nil
|
||||||
|
@url = nil
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'keybinding unset' do
|
test 'keybinding unset' do
|
||||||
get @url
|
get @url
|
||||||
|
|
||||||
assert_equal last_response.body.include?('selected="selected" value="default"'), false
|
assert_equal last_response.body.include?('selected="selected" value="default"'), false
|
||||||
assert_equal last_response.body.include?('selected="selected" value="vim"'), false
|
assert_equal last_response.body.include?('selected="selected" value="vim"'), false
|
||||||
assert_equal last_response.body.include?('selected="selected" value="emacs"'), false
|
assert_equal last_response.body.include?('selected="selected" value="emacs"'), false
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'keybinding `dne`' do
|
test 'nonexistent keybinding' do
|
||||||
# dne := does not exist
|
Precious::App.set :wiki_options, {:default_keybinding => 'does-not-exist'}
|
||||||
Precious::App.set(:wiki_options, {:default_keybinding => 'dne'})
|
|
||||||
get @url
|
get @url
|
||||||
|
|
||||||
assert_equal last_response.body.include?('selected="selected" value="default"'), false
|
assert_equal last_response.body.include?('selected="selected" value="default"'), false
|
||||||
assert_equal last_response.body.include?('selected="selected" value="vim"'), false
|
assert_equal last_response.body.include?('selected="selected" value="vim"'), false
|
||||||
assert_equal last_response.body.include?('selected="selected" value="emacs"'), false
|
assert_equal last_response.body.include?('selected="selected" value="emacs"'), false
|
||||||
Precious::App.set(:wiki_options, {:default_keybinding => 'none'})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'keybinding `default`' do
|
test 'keybinding `default`' do
|
||||||
Precious::App.set(:wiki_options, {:default_keybinding => 'default'})
|
Precious::App.set :wiki_options, {:default_keybinding => 'default'}
|
||||||
|
|
||||||
get @url
|
get @url
|
||||||
|
|
||||||
assert_equal last_response.body.include?('selected="selected" value="default"'), true
|
assert_equal last_response.body.include?('selected="selected" value="default"'), true
|
||||||
assert_equal last_response.body.include?('selected="selected" value="vim"'), false
|
assert_equal last_response.body.include?('selected="selected" value="vim"'), false
|
||||||
assert_equal last_response.body.include?('selected="selected" value="emacs"'), false
|
assert_equal last_response.body.include?('selected="selected" value="emacs"'), false
|
||||||
Precious::App.set(:wiki_options, {:default_keybinding => 'none'})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'keybinding `vim`' do
|
test 'keybinding `vim`' do
|
||||||
Precious::App.set(:wiki_options, {:default_keybinding => 'vim'})
|
Precious::App.set :wiki_options, {:default_keybinding => 'vim'}
|
||||||
|
|
||||||
get @url
|
get @url
|
||||||
|
|
||||||
assert_equal last_response.body.include?('selected="selected" value="default"'), false
|
assert_equal last_response.body.include?('selected="selected" value="default"'), false
|
||||||
assert_equal last_response.body.include?('selected="selected" value="vim"'), true
|
assert_equal last_response.body.include?('selected="selected" value="vim"'), true
|
||||||
assert_equal last_response.body.include?('selected="selected" value="emacs"'), false
|
assert_equal last_response.body.include?('selected="selected" value="emacs"'), false
|
||||||
Precious::App.set(:wiki_options, {:default_keybinding => 'none'})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
test 'keybinding `emacs`' do
|
test 'keybinding `emacs`' do
|
||||||
Precious::App.set(:wiki_options, {:default_keybinding => 'emacs'})
|
Precious::App.set :wiki_options, {:default_keybinding => 'emacs'}
|
||||||
|
|
||||||
get @url
|
get @url
|
||||||
|
|
||||||
assert_equal last_response.body.include?('selected="selected" value="default"'), false
|
assert_equal last_response.body.include?('selected="selected" value="default"'), false
|
||||||
assert_equal last_response.body.include?('selected="selected" value="vim"'), false
|
assert_equal last_response.body.include?('selected="selected" value="vim"'), false
|
||||||
assert_equal last_response.body.include?('selected="selected" value="emacs"'), true
|
assert_equal last_response.body.include?('selected="selected" value="emacs"'), true
|
||||||
Precious::App.set(:wiki_options, {:default_keybinding => 'none'})
|
|
||||||
end
|
end
|
||||||
|
|
||||||
def app
|
def app
|
||||||
|
|||||||
Reference in New Issue
Block a user