Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added a new page for manual tests #361

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 14 additions & 4 deletions test/server.rb
Original file line number Diff line number Diff line change
Expand Up @@ -6,19 +6,19 @@
use Rack::Static, :urls => ["/src"], :root => File.expand_path('..', settings.root)

helpers do
def jquery_link version
def jquery_link(version, path="/")
if params[:version] == version
"[#{version}]"
else
"<a href='/?version=#{version}&cdn=#{params[:cdn]}'>#{version}</a>"
"<a href='#{path}?version=#{version}&cdn=#{params[:cdn]}'>#{version}</a>"
end
end

def cdn_link cdn
def cdn_link(cdn, path="/")
if params[:cdn] == cdn
"[#{cdn}]"
else
"<a href='/?version=#{params[:version]}&cdn=#{cdn}'>#{cdn}</a>"
"<a href='#{path}?version=#{params[:version]}&cdn=#{cdn}'>#{cdn}</a>"
end
end

Expand Down Expand Up @@ -53,6 +53,16 @@ def jquery_versions
erb :index
end

get '/manual' do
params[:version] ||= '1.11.0'
params[:cdn] ||= 'jquery'
params[:sleep] ||= 0
sleep params[:sleep].to_i
@extra_params = "version=#{params[:version]}&cdn=#{params[:cdn]}"
erb :manual
end


[:get, :post, :put, :delete].each do |method|
send(method, '/echo') {
data = { :params => params }.update(request.env)
Expand Down
32 changes: 32 additions & 0 deletions test/views/manual.erb
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
<% @title = "jquery-ujs manual test" %>
<h1 id="qunit-header"><%= @title %></h1>
<div id="jquery-cdn">
CDN:
<%= cdn_link('jquery', '/manual') %> •
<%= cdn_link('googleapis', '/manual') %>
</div>
<div id="jquery-version">
jQuery version:

<% jquery_versions.each do |v| %>
<%= ' • ' if v != jquery_versions.first %>
<%= jquery_link(v, '/manual') %>
<% end %>
<%= (' • ' + jquery_link('edge', '/manual')) if File.exist?(settings.root + '/public/vendor/jquery.js') %>
</div>
<h2 id="qunit-banner"></h2>
<p>We just haven't figured out how to automate these yet.</p>

<h2>data-disable</h2>
<p>Clicking these links will reload this page with a short delay. During the delay, each link should become disabled and its text should change to "Please wait..."</p>
<ul>
<li><a href="/manual?sleep=1&<%= @extra_params %>" data-disable-with="Please wait...">link</a></li>
<li><a href="/manual?sleep=1&<%= @extra_params %>" data-disable-with="Please wait..."><div>div in link disabled with text</div></a></li>
<li><a href="/manual?sleep=1&<%= @extra_params %>" data-disable-with="<div>Please wait...</div>"><div>div in link disabled with div</div></a></li>
<li><a href="/manual?sleep=1&<%= @extra_params %>" data-disable-with="Please wait..." onclick="$('body').css('background-color', 'green')">link with inline handler which should turn body green</a></li>
<li><a href="/manual?sleep=1&<%= @extra_params %>" data-disable-with="Please wait..." target="_blank">link with _blank target (_top would be more realistic but is more effort to test) should open in new window</a></li>
</ul>
page loaded at: <span id="now"></span>
<script type="text/javascript" charset="utf-8">
$("#now").html(new Date().getTime());
</script>