Browse Source

Maintenance: Improves QUnit tests usability

Mantas Masalskis 3 years ago
parent
commit
77d147efaf

+ 14 - 0
app/controllers/tests_controller.rb

@@ -4,6 +4,20 @@ class TestsController < ApplicationController
 
   prepend_before_action -> { authentication_check_only }
 
+  layout 'tests', except: %i[wait raised_exception]
+
+  def show
+    @filename = params[:name]
+
+    if lookup_context.exists? @filename, 'tests'
+      render @filename
+    elsif @filename.starts_with? 'form'
+      render 'form'
+    else
+      render
+    end
+  end
+
   # GET /test/wait
   def wait
     sleep params[:sec].to_i

+ 1 - 1
app/views/layouts/application.html.erb

@@ -17,7 +17,7 @@
 </head>
 <body>
 
-<%= yield %>
+  <%= content_for?(:content) ? yield(:content) : yield %>
 
 </body>
 </html>

+ 22 - 0
app/views/layouts/tests.html.erb

@@ -0,0 +1,22 @@
+<% content_for :content do %>
+  <link rel="stylesheet" href="/assets/tests/qunit-2.17.2.css">
+  <%= javascript_include_tag "/assets/tests/qunit-2.17.2.js",
+    "/assets/tests/sinon-9.2.4",
+    "/assets/tests/syn-0.15.0",
+    "/assets/tests/qunit/#{@filename}.js",
+    nonce: true %>
+
+  <style type="text/css">
+    body {
+      padding-top: 0px;
+    }
+
+    #qunit {
+      position: initial;
+    }
+  </style>
+
+  <%= yield %>
+<% end %>
+
+<%= render template: 'layouts/application' %>

+ 0 - 13
app/views/tests/color_object.html.erb

@@ -1,13 +0,0 @@
-<link rel="stylesheet" href="/assets/tests/qunit-1.21.0.css">
-<%= javascript_include_tag "/assets/tests/qunit-1.21.0.js", "/assets/tests/color_object.js", nonce: true %>
-
-<style type="text/css">
-body {
-  padding-top: 0px;
-}
-</style>
-
-<%= javascript_tag nonce: true do -%>
-<% end -%>
-
-<div id="qunit" class="u-dontfold"></div>

+ 0 - 14
app/views/tests/core.html.erb

@@ -1,14 +0,0 @@
-<link rel="stylesheet" href="/assets/tests/qunit-1.21.0.css">
-<%= javascript_include_tag "/assets/tests/qunit-1.21.0.js", "/assets/tests/core.js", nonce: true %>
-
-<style type="text/css">
-body {
-  padding-top: 0px;
-}
-</style>
-
-<%= javascript_tag nonce: true do -%>
-<% end -%>
-
-<div id="qunit" class="u-dontfold"></div>
-

+ 0 - 14
app/views/tests/form.html.erb

@@ -1,21 +1,7 @@
-
-<link rel="stylesheet" href="/assets/tests/qunit-1.21.0.css">
-<%= javascript_include_tag "/assets/tests/qunit-1.21.0.js", "/assets/tests/form.js", nonce: true %>
-
-<style type="text/css">
-body {
-  padding-top: 0px;
-}
-</style>
-
-<%= javascript_tag nonce: true do -%>
-<% end -%>
-
 <div id="qunit" class="u-dontfold"></div>
 
 <div>
   <form class="form-stacked pull-left">
     <div id="forms"></div>
-    <button type="submit" class="btn btn-primary submit">Submit</button>
   </form>
 </div>

+ 0 - 21
app/views/tests/form_autocompletion_ajax.html.erb

@@ -1,21 +0,0 @@
-
-<link rel="stylesheet" href="/assets/tests/qunit-1.21.0.css">
-<%= javascript_include_tag "/assets/tests/qunit-1.21.0.js", "/assets/tests/form_autocompletion_ajax.js", nonce: true %>
-
-<style type="text/css">
-body {
-  padding-top: 0px;
-}
-</style>
-
-<%= javascript_tag nonce: true do -%>
-<% end -%>
-
-<div id="qunit" class="u-dontfold"></div>
-
-<div>
-  <form class="form-stacked pull-left">
-    <div id="forms"></div>
-    <button type="submit" class="btn btn-primary submit">Submit</button>
-  </form>
-</div>

+ 0 - 21
app/views/tests/form_color.html.erb

@@ -1,21 +0,0 @@
-<link rel="stylesheet" href="/assets/tests/qunit-1.21.0.css">
-<%= javascript_include_tag "/assets/tests/qunit-1.21.0.js", "/assets/tests/syn-0.14.1.js", "/assets/tests/form_color.js", nonce: true %>
-
-<style type="text/css">
-body {
-  padding-top: 0px;
-}
-</style>
-
-<%= javascript_tag nonce: true do -%>
-<% end -%>
-
-<div id="qunit" class="u-dontfold"></div>
-
-<div>
-  <form class="form-stacked pull-left">
-    <div id="forms"></div>
-    <button type="submit" class="btn btn-primary submit">Submit</button>
-  </form>
-</div>
-

+ 0 - 21
app/views/tests/form_column_select.html.erb

@@ -1,21 +0,0 @@
-
-<link rel="stylesheet" href="/assets/tests/qunit-1.21.0.css">
-<%= javascript_include_tag "/assets/tests/qunit-1.21.0.js", "/assets/tests/form_column_select.js", nonce: true %>
-
-<style type="text/css">
-body {
-  padding-top: 0px;
-}
-</style>
-
-<%= javascript_tag nonce: true do -%>
-<% end -%>
-
-<div id="qunit" class="u-dontfold"></div>
-
-<div>
-  <form class="form-stacked pull-left">
-    <div id="forms"></div>
-    <button type="submit" class="btn btn-primary submit">Submit</button>
-  </form>
-</div>

+ 0 - 21
app/views/tests/form_core_workflow.html.erb

@@ -1,21 +0,0 @@
-
-<link rel="stylesheet" href="/assets/tests/qunit-1.21.0.css">
-<%= javascript_include_tag "/assets/tests/qunit-1.21.0.js", "/assets/tests/form_core_workflow.js", nonce: true %>
-
-<style type="text/css">
-body {
-  padding-top: 0px;
-}
-</style>
-
-<%= javascript_tag nonce: true do -%>
-<% end -%>
-
-<div id="qunit" class="u-dontfold"></div>
-
-<div>
-  <form class="form-stacked pull-left">
-    <div id="forms"></div>
-    <button type="submit" class="btn btn-primary submit">Submit</button>
-  </form>
-</div>

Some files were not shown because too many files changed in this diff