Maintenance: Improves QUnit tests usability

This commit is contained in:
Mantas Masalskis 2021-10-14 16:35:12 +02:00 committed by Thorsten Eckel
parent e26d3ecfd3
commit 77d147efaf
90 changed files with 12748 additions and 9860 deletions

View file

@ -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

View file

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

View file

@ -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' %>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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>

View file

@ -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_datetime.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>

View file

@ -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_extended.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>

View file

@ -1,16 +1,3 @@
<link rel="stylesheet" href="/assets/tests/qunit-1.21.0.css">
<%= javascript_include_tag "/assets/tests/qunit-1.21.0.js", "/assets/tests/form_find.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>

View file

@ -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_searchable_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>

View file

@ -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_skip_rendering.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>

View file

@ -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_sla_times.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>

View file

@ -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_ticket_perform_action.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>

View file

@ -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_timer.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>

View file

@ -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_tree_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>

View file

@ -1,16 +1,3 @@
<link rel="stylesheet" href="/assets/tests/qunit-1.21.0.css">
<%= javascript_include_tag "/assets/tests/qunit-1.21.0.js", "/assets/tests/form_trim.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>

View file

@ -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_validation.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>

View file

@ -1,16 +1,3 @@
<link rel="stylesheet" href="/assets/tests/qunit-1.21.0.css">
<%= javascript_include_tag "/assets/tests/qunit-1.21.0.js", "/assets/tests/html_utils.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 id="image2data1"></div>

View file

@ -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/i18n.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>

View file

@ -1,15 +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/image_service.js", nonce: true %>
<style type="text/css">
body {
padding-top: 0px;
}
</style>
<script type="text/javascript">
</script>
<div id="qunit" class="u-dontfold"></div>

View file

@ -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/kb_video_embeding.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>

View file

@ -1,16 +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/local_storage.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>

View file

@ -1,15 +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/model.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>

View file

@ -1,15 +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/model_binding.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>

View file

@ -1,15 +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/model_ticket.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>

View file

@ -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/sinon-9.2.4", "/assets/tests/model_ui.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>

View file

@ -1,15 +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/session.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>

View file

@ -0,0 +1 @@
<div id="qunit" class="u-dontfold"></div>

View file

@ -1,16 +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/table.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 id="table"></div>

View file

@ -1,16 +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/table_extended.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 id="table"></div>

View file

@ -1,16 +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/taskbar.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 id="taskbars"></div>

View file

@ -1,24 +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/text_module.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 class="js-textarea richtext-content articleNewEdit-body" contenteditable="true" data-name="body">
</div>
</div>
<button type="submit" class="btn btn-primary submit">Submit</button>
</form>
</div>

View file

@ -1,11 +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/sinon-9.2.4", "/assets/tests/ticket_macro.js", nonce: true %>
<style type="text/css">
body {
padding-top: 0px;
}
</style>
<div id="qunit" class="u-dontfold"></div>

View file

@ -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/ticket_selector.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>

View file

@ -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/ui.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>

View file

@ -520,6 +520,26 @@
"confidence": "Medium",
"note": "Admin configured RegExp"
},
{
"warning_type": "Dynamic Render Path",
"warning_code": 15,
"fingerprint": "c52f57d32456c9ab6dba6dfc93bd8effa16829a87a9ce9368da83a35fc6cf1a7",
"check_name": "Render",
"message": "Render path contains parameter value",
"file": "app/controllers/tests_controller.rb",
"line": 13,
"link": "https://brakemanscanner.org/docs/warning_types/dynamic_render_path/",
"code": "render(action => params[:name], {})",
"render_path": null,
"location": {
"type": "method",
"class": "TestsController",
"method": "show"
},
"user_input": "params[:name]",
"confidence": "High",
"note": "Running QUnit tests"
},
{
"warning_type": "SSL Verification Bypass",
"warning_code": 71,

View file

@ -1,43 +1,11 @@
# Copyright (C) 2012-2021 Zammad Foundation, http://zammad-foundation.org/
if !Rails.env.production?
Zammad::Application.routes.draw do
get '/tests_:name', to: 'tests#show'
match '/tests_core', to: 'tests#core', via: :get
match '/tests_session', to: 'tests#session', via: :get
match '/tests_local_storage', to: 'tests#local_storage', via: :get
match '/tests_ui', to: 'tests#ui', via: :get
match '/tests_i18n', to: 'tests#i18n', via: :get
match '/tests_model', to: 'tests#model', via: :get
match '/tests_model_binding', to: 'tests#model_binding', via: :get
match '/tests_model_ui', to: 'tests#model_ui', via: :get
match '/tests_model_ticket', to: 'tests#model_ticket', via: :get
match '/tests_form', to: 'tests#form', via: :get
match '/tests_form_tree_select', to: 'tests#form_tree_select', via: :get
match '/tests_form_find', to: 'tests#form_find', via: :get
match '/tests_form_trim', to: 'tests#form_trim', via: :get
match '/tests_form_extended', to: 'tests#form_extended', via: :get
match '/tests_form_timer', to: 'tests#form_timer', via: :get
match '/tests_form_color', to: 'tests#form_color', via: :get
match '/tests_form_validation', to: 'tests#form_validation', via: :get
match '/tests_form_column_select', to: 'tests#form_column_select', via: :get
match '/tests_form_searchable_select', to: 'tests#form_searchable_select', via: :get
match '/tests_form_autocompletion_ajax', to: 'tests#form_autocompletion_ajax', via: :get
match '/tests_form_ticket_perform_action', to: 'tests#form_ticket_perform_action', via: :get
match '/tests_form_sla_times', to: 'tests#form_sla_times', via: :get
match '/tests_form_skip_rendering', to: 'tests#form_skip_rendering', via: :get
match '/tests_form_datetime', to: 'tests#form_datetime', via: :get
match '/tests_form_core_workflow', to: 'tests#form_core_workflow', via: :get
match '/tests_table', to: 'tests#table', via: :get
match '/tests_table_extended', to: 'tests#table_extended', via: :get
match '/tests_html_utils', to: 'tests#html_utils', via: :get
match '/tests_ticket_macro', to: 'tests#ticket_macro', via: :get
match '/tests_ticket_selector', to: 'tests#ticket_selector', via: :get
match '/tests_taskbar', to: 'tests#taskbar', via: :get
match '/tests_image_service', to: 'tests#image_service', via: :get
match '/tests_text_module', to: 'tests#text_module', via: :get
match '/tests_color_object', to: 'tests#color_object', via: :get
match '/tests_kb_video_embeding', to: 'tests#kb_video_embeding', via: :get
match '/tests/wait/:sec', to: 'tests#wait', via: :get
match '/tests/raised_exception', to: 'tests#error_raised_exception', via: :get
end
end

View file

@ -1,21 +0,0 @@
test('test color object', function() {
let hex = new App.ColorObject('#09f609')
let hsl = new App.ColorObject([0.5, 0.2, 0.3])
deepEqual(hex.asHslArray(), [1/3, 0.9294117647058824, 0.5], 'HEX converted to HSL components')
deepEqual(hsl.asHslArray(), [0.5, 0.2, 0.3], 'HSL components returned as original input')
equal(hex.asString(), '#09f609', 'HEX represented as original input')
equal(hsl.asString(), 'hsl(180,20%,30%)', 'HSL components represented as HSL string')
hex.updateWithString('#fff')
equal(hex.asString(), '#fff', 'color updated')
hsl.updateWithHslComponent(0.25, 1)
deepEqual(hsl.asHslArray(), [0.5, 0.25, 0.3], 'given HSL component updated')
deepEqual(Array.from(App.ColorObject.anyToRgb('#ff0000')), [255, 0, 0, 255], 'any to RGB')
deepEqual(App.ColorObject.anyToHslArray('#ff0000'), [0,1,0.5], 'any to HSL components')
equal(App.ColorObject.anyToHslString('#ff0000'), 'hsl(0,100%,50%)', 'any to HSL string')
deepEqual(App.ColorObject.rgbToHslArray([255, 0, 0]), [0,1,0.5], 'RGB to HSL components')
equal(App.ColorObject.hslArrayToHslString([0.5, 0.25, 0.3]), 'hsl(180,25%,30%)', 'HSL components to HSL string')
})

View file

@ -1,59 +0,0 @@
// form
test( "find form check", function() {
$('#forms').append('<hr><h1>find form check</h1><form id="form1"></form>')
var form1 = App.ControllerForm.findForm($('#form1'))
equal(form1.is('form'), true)
$('#forms').append('<hr><h1>find form check</h1><form id="form2"><input class="js-input" value="test 123"></form>')
var form2 = App.ControllerForm.findForm($('#form2 .js-input'))
equal(form2.is('form'), true)
$('#forms').append('<hr><h1>find form check</h1><form id="form3"><input class="js-input" value="test 123"><button class="js-button">text</button></form>')
var form3 = App.ControllerForm.findForm($('#form3 .js-button'))
equal(form3.is('form'), true)
App.ControllerForm.disable($('#form3 .js-button'))
equal($('#form3 .js-button').prop('readonly'), true)
equal($('#form3 .js-button').prop('disabled'), true)
equal($('#form3 .js-input').prop('readonly'), true)
equal($('#form3 .js-input').prop('disabled'), false)
App.ControllerForm.enable($('#form3 .js-button'))
equal($('#form3 .js-button').prop('readonly'), false)
equal($('#form3 .js-button').prop('disabled'), false)
equal($('#form3 .js-input').prop('readonly'), false)
equal($('#form3 .js-input').prop('disabled'), false)
$('#forms').append('<hr><h1>find form check by only disable button</h1><form id="form31"><input class="js-input" value="test 123"><button class="js-button">text</button></form>')
var form31 = App.ControllerForm.findForm($('#form31 .js-button'))
App.ControllerForm.disable($('#form31 .js-button'), 'button')
equal($('#form31 .js-button').prop('readonly'), true)
equal($('#form31 .js-button').prop('disabled'), true)
equal($('#form31 .js-input').prop('readonly'), false)
equal($('#form31 .js-input').prop('disabled'), false)
App.ControllerForm.enable($('#form31 .js-button'))
equal($('#form31 .js-button').prop('readonly'), false)
equal($('#form31 .js-button').prop('disabled'), false)
equal($('#form31 .js-input').prop('readonly'), false)
equal($('#form31 .js-input').prop('disabled'), false)
$('#forms').append('<hr><h1>find form check</h1><div id="form4"><input class="js-input" value="test 123"><button class="js-button">text</button></div>')
var form4 = App.ControllerForm.findForm($('#form4 .js-button'))
equal(form4.is('form'), false)
App.ControllerForm.disable($('#form4 .js-button'))
equal($('#form4 .js-button').prop('readonly'), true)
equal($('#form4 .js-button').prop('disabled'), true)
equal($('#form4 .js-input').prop('readonly'), false)
equal($('#form4 .js-input').prop('disabled'), false)
App.ControllerForm.enable($('#form4 .js-button'))
equal($('#form4 .js-button').prop('readonly'), false)
equal($('#form4 .js-button').prop('disabled'), false)
equal($('#form4 .js-input').prop('readonly'), false)
equal($('#form4 .js-input').prop('disabled'), false)
});

View file

@ -1,230 +0,0 @@
test('i18n .detectBrowserLocale', function() {
var original_userLanguage = window.navigator.userLanguage
var original_language = window.navigator.language
var original_languages = window.navigator.languages
var reset = function(){
window.navigator.userLanguage = original_userLanguage
window.navigator.language = original_language
window.navigator.languages = original_languages
}
var mock = function(languages, language, userLanguage){
Object.defineProperty(window.navigator, 'language', {value: language, configurable: true });
Object.defineProperty(window.navigator, 'languages', {value: languages, configurable: true });
Object.defineProperty(window.navigator, 'userLanguage', {value: userLanguage, configurable: true });
}
mock(undefined, undefined, undefined)
equal(App.i18n.detectBrowserLocale(), 'en-us')
mock(undefined, undefined, 'non-existant');
equal(App.i18n.detectBrowserLocale(), 'en-us')
mock(undefined, undefined, 'en');
equal(App.i18n.detectBrowserLocale(), 'en-us')
mock(undefined, undefined, 'lt');
equal(App.i18n.detectBrowserLocale(), 'lt')
mock(undefined, 'lt', 'lv');
equal(App.i18n.detectBrowserLocale(), 'lt')
mock(undefined, 'en', 'lv');
equal(App.i18n.detectBrowserLocale(), 'en-us')
mock(['en'], 'lt', 'lv');
equal(App.i18n.detectBrowserLocale(), 'en-us')
mock(['en-us'], 'lt', 'lv');
equal(App.i18n.detectBrowserLocale(), 'en-us')
mock(['en-US'], 'lt', 'lv');
equal(App.i18n.detectBrowserLocale(), 'en-us')
mock(['lt', 'en-US'], 'lt', 'lv');
equal(App.i18n.detectBrowserLocale(), 'lt')
mock(['en-GB', 'en-US'], 'lt', 'lv');
equal(App.i18n.detectBrowserLocale(), 'en-gb')
mock(['en-XYZ'], 'lt', 'lv');
equal(App.i18n.detectBrowserLocale(), 'en-us')
mock(['xyz', 'lt'], 'lv', undefined);
equal(App.i18n.detectBrowserLocale(), 'lt')
reset()
// i18n
test('i18n', function() {
// de
App.i18n.set('de-de')
var translated = App.i18n.translateContent('yes')
equal(translated, 'ja', 'de-de - yes / ja translated correctly')
translated = App.i18n.translatePlain('yes')
equal(translated, 'ja', 'de-de - yes / ja translated correctly')
translated = App.i18n.translateInline('yes')
equal(translated, 'ja', 'de-de - yes / ja translated correctly')
translated = App.i18n.translateContent('%s ago', 123);
equal(translated, 'vor 123', 'de-de - %s')
translated = App.i18n.translateContent('%s ago', '<b>quote</b>')
equal(translated, 'vor &lt;b&gt;quote&lt;/b&gt;', 'de-de - %s - quote')
translated = App.i18n.translateContent('%s %s test', 123, 'xxx |B|')
equal(translated, '123 xxx |B| test', 'de-de - %s %s')
translated = App.i18n.translateContent('|%s| %s test', 123, 'xxx')
equal(translated, '<b>123</b> xxx test', 'de-de - *%s* %s')
translated = App.i18n.translateContent('||%s|| %s test', 123, 'xxx')
equal(translated, '<i>123</i> xxx test', 'de-de - *%s* %s')
translated = App.i18n.translateContent('_%s_ %s test', 123, 'xxx')
equal(translated, '<u>123</u> xxx test', 'de-de - _%s_ %s')
translated = App.i18n.translateContent('§%s§ %s test', 123, 'xxx')
equal(translated, '<kbd>123</kbd> xxx test', 'de-de - §%s§ %s')
translated = App.i18n.translateContent('//%s// %s test', 123, 'xxx')
equal(translated, '<del>123</del> xxx test', 'de-de - //%s// %s')
translated = App.i18n.translateContent('\'%s\' %s test', 123, 'xxx')
equal(translated, '&#39;123&#39; xxx test', 'de-de - \'%s\' %s')
translated = App.i18n.translateContent('<test&now>//*äöüß')
equal(translated, '&lt;test&amp;now&gt;//*äöüß', 'de - <test&now>//*äöüß')
translated = App.i18n.translateContent('some link [to what ever](http://lalala)')
equal(translated, 'some link <a href="http://lalala" target="_blank">to what ever</a>', 'de-de - link')
translated = App.i18n.translateContent('some link [to what ever](%s)', 'http://lalala')
equal(translated, 'some link <a href="http://lalala" target="_blank">to what ever</a>', 'de-de - link')
translated = App.i18n.translateContent('Enables user authentication via %s. Register your app first at [%s](%s).', 'XXX', 'YYY', 'http://lalala')
equal(translated, 'Aktivieren der Benutzeranmeldung über XXX. Registriere Deine Anwendung zuerst über <a href="http://lalala" target="_blank">YYY</a>.', 'en-us - link')
var time_local = new Date();
var offset = time_local.getTimezoneOffset();
var timestamp = App.i18n.translateTimestamp('2012-11-06T21:07:24Z', offset);
equal(timestamp, '06.11.2012 21:07', 'de-de - timestamp translated correctly')
var timestamp = App.i18n.translateTimestamp('2021-02-08 09:13:20 UTC', offset);
equal(timestamp, '08.02.2021 09:13', 'de-de - timestamp translated correctly with UTC format')
timestamp = App.i18n.translateTimestamp('', offset);
equal(timestamp, '', 'de-de - timestamp translated correctly')
timestamp = App.i18n.translateTimestamp(null, offset);
equal(timestamp, null, 'de-de - timestamp translated correctly')
timestamp = App.i18n.translateTimestamp(undefined, offset);
equal(timestamp, undefined, 'de-de - timestamp translated correctly')
var date = App.i18n.translateDate('2012-11-06', 0)
equal(date, '06.11.2012', 'de-de - date translated correctly')
date = App.i18n.translateDate('', 0)
equal(date, '', 'de-de - date translated correctly')
date = App.i18n.translateDate(null, 0)
equal(date, null, 'de-de - date translated correctly')
date = App.i18n.translateDate(undefined, 0)
equal(date, undefined, 'de-de - date translated correctly')
// en
App.i18n.set('en-us')
translated = App.i18n.translateContent('yes')
equal(translated, 'yes', 'en-us - yes translated correctly')
translated = App.i18n.translatePlain('yes')
equal(translated, 'yes', 'en-us - yes translated correctly')
translated = App.i18n.translateInline('yes')
equal(translated, 'yes', 'en-us - yes translated correctly')
translated = App.i18n.translateContent('%s ago', 123);
equal(translated, '123 ago', 'en-us - %s')
translated = App.i18n.translateContent('%s ago', '<b>quote</b>')
equal(translated, '&lt;b&gt;quote&lt;/b&gt; ago', 'en-us - %s - qupte')
translated = App.i18n.translateContent('%s %s test', 123, 'xxx')
equal(translated, '123 xxx test', 'en-us - %s %s')
translated = App.i18n.translateContent('|%s| %s test', 123, 'xxx |B|')
equal(translated, '<b>123</b> xxx |B| test', 'en-us - *%s* %s')
translated = App.i18n.translateContent('||%s|| %s test', 123, 'xxx')
equal(translated, '<i>123</i> xxx test', 'en-us - *%s* %s')
translated = App.i18n.translateContent('_%s_ %s test', 123, 'xxx')
equal(translated, '<u>123</u> xxx test', 'en-us - _%s_ %s')
translated = App.i18n.translateContent('§%s§ %s test', 123, 'xxx')
equal(translated, '<kbd>123</kbd> xxx test', 'en-us - §%s§ %s')
translated = App.i18n.translateContent('Here you can search for tickets, customers and organizations. Use the wildcard §*§ to find everything. E. g. §smi*§ or §rosent*l§. You also can use ||double quotes|| for searching phrases §"some phrase"§.')
equal(translated, 'Here you can search for tickets, customers and organizations. Use the wildcard <kbd>*</kbd> to find everything. E. g. <kbd>smi*</kbd> or <kbd>rosent*l</kbd>. You also can use <i>double quotes</i> for searching phrases <kbd>&quot;some phrase&quot;</kbd>.', 'en-us - §§ §§ §§ || §§')
translated = App.i18n.translateContent('//%s// %s test', 123, 'xxx')
equal(translated, '<del>123</del> xxx test', 'en-us - //%s// %s')
translated = App.i18n.translateContent('\'%s\' %s test', 123, 'xxx')
equal(translated, '&#39;123&#39; xxx test', 'en-us - \'%s\' %s')
translated = App.i18n.translateContent('<test&now>')
equal(translated, '&lt;test&amp;now&gt;', 'en-us - <test&now>')
translated = App.i18n.translateContent('some link [to what ever](http://lalala)')
equal(translated, 'some link <a href="http://lalala" target="_blank">to what ever</a>', 'en-us - link')
translated = App.i18n.translateContent('some link [to what ever](%s)', 'http://lalala')
equal(translated, 'some link <a href="http://lalala" target="_blank">to what ever</a>', 'en-us - link')
translated = App.i18n.translateContent('Enables user authentication via %s. Register your app first at [%s](%s).', 'XXX', 'YYY', 'http://lalala')
equal(translated, 'Enables user authentication via XXX. Register your app first at <a href="http://lalala" target="_blank">YYY</a>.', 'en-us - link')
timestamp = App.i18n.translateTimestamp('2012-11-06T21:07:24Z', offset)
equal(timestamp, '11/06/2012 21:07', 'en - timestamp translated correctly')
timestamp = App.i18n.translateTimestamp('', offset);
equal(timestamp, '', 'en - timestamp translated correctly')
timestamp = App.i18n.translateTimestamp(null, offset);
equal(timestamp, null, 'en - timestamp translated correctly')
timestamp = App.i18n.translateTimestamp(undefined, offset);
equal(timestamp, undefined, 'en - timestamp translated correctly')
date = App.i18n.translateDate('2012-11-06', 0)
equal(date, '11/06/2012', 'en - date translated correctly')
date = App.i18n.translateDate('', 0)
equal(date, '', 'en - date translated correctly')
date = App.i18n.translateDate(null, 0)
equal(date, null, 'en - date translated correctly')
date = App.i18n.translateDate(undefined, 0)
equal(date, undefined, 'en - date translated correctly')
// locale alias test
// de
App.i18n.set('de')
var translated = App.i18n.translateContent('yes')
equal(translated, 'ja', 'de - yes / ja translated correctly')
// locale detection test
// de-ch
App.i18n.set('de-ch')
var translated = App.i18n.translateContent('yes')
equal(translated, 'ja', 'de - yes / ja translated correctly')
});
})

View file

@ -1,65 +0,0 @@
window.onload = function() {
test('Test item removal from local storage', function() {
var key = 'test_key_1'
var value = 'test_value_1'
App.LocalStorage.set(key, value)
equal(App.LocalStorage.get(key), value)
App.LocalStorage.delete(key)
equal(App.LocalStorage.get(key), undefined)
});
test('Test user-specific item removal from local storage', function() {
var key = 'test_key_2'
var value = 'test_value_2'
var user_id = 2
App.LocalStorage.set(key, value, user_id)
equal(App.LocalStorage.get(key, user_id), value)
App.LocalStorage.delete(key, user_id)
equal(App.LocalStorage.get(key, user_id), undefined)
});
test('Test key lookup', function() {
App.LocalStorage.clear()
var key = 'test_key_3'
var value = 'test_value_3'
var user_id = 2
var alt_key = 'test_alt_key_3'
// verify no keys initially
equal(App.LocalStorage.keys().length, 0)
App.LocalStorage.set(key, value, user_id)
// has 1 key in total
equal(App.LocalStorage.keys().length, 1)
// doesn't return anything with wrong prefix
equal(App.LocalStorage.keys('a').length, 0)
// doesn't return anything since user id not given
equal(App.LocalStorage.keys('test').length, 0)
// correct
equal(App.LocalStorage.keys('test', user_id).length, 1)
// verify value
equal(App.LocalStorage.keys('test', user_id)[0].match(key + '$'), key)
App.LocalStorage.set(alt_key, value)
// returns 1 key without user id
equal(App.LocalStorage.keys('test').length, 1)
equal(App.LocalStorage.keys('test')[0], alt_key)
});
}

View file

@ -1,110 +0,0 @@
window.onload = function() {
// model
test( "model ui basic tests", function() {
// load ref object
App.Collection.loadAssets({
TicketState: {
1: {
name: 'new', id: 1, updated_at: "2014-11-07T23:43:08.000Z",
},
2: {
name: 'open', id: 2, updated_at: "2014-11-07T23:43:08.000Z",
},
3: {
name: 'closed <>&', id: 3, updated_at: "2014-11-07T23:43:08.000Z",
},
},
})
// create ticket
var attribute1 = {
name: 'date', display: 'date 1', tag: 'date', null: true
};
App.Ticket.configure_attributes.push( attribute1 )
var attribute2 = {
name: 'textarea', display: 'textarea 1', tag: 'textarea', null: true
};
App.Ticket.configure_attributes.push( attribute2 )
var attribute3 = {
name: 'link1', display: 'link 1', linktemplate: 'http://zammad.com', tag: 'input', null: true, translate: true
};
App.Ticket.configure_attributes.push( attribute3 )
var attribute4 = {
name: 'link2', display: 'link 1', linktemplate: 'http://zammad.com', tag: 'input', null: true
};
App.Ticket.configure_attributes.push( attribute4 )
var ticket = new App.Ticket()
ticket.load({
id: 1000,
title: 'some title <>&',
state_id: 2,
updated_at: '2014-11-07T23:43:08.000Z',
date: '2015-02-07',
textarea: "some new\nline",
link1: 'closed',
link2: 'closed',
})
App.i18n.set('en-us')
equal( App.viewPrint( ticket, 'id' ), 1000)
equal( App.viewPrint( ticket, 'title' ), 'some title &lt;&gt;&amp;')
equal( App.viewPrint( ticket, 'state' ), 'open')
equal( App.viewPrint( ticket, 'state_id' ), 'open')
equal( App.viewPrint( ticket, 'not_existing' ), '-')
equal( App.viewPrint( ticket, 'updated_at' ), '<time class="humanTimeFromNow " datetime="2014-11-07T23:43:08.000Z" title="11/07/2014 23:43">11/07/2014</time>')
equal( App.viewPrint( ticket, 'date' ), '02/07/2015')
equal( App.viewPrint( ticket, 'textarea' ), '<div>some new</div><div>line</div>')
equal( App.viewPrint( ticket, 'link1' ), '<a href="http://zammad.com" target="blank">closed</a>')
equal( App.viewPrint( ticket, 'link2' ), '<a href="http://zammad.com" target="blank">closed</a>')
let stub = sinon.stub(App.Config, 'get')
stub.withArgs('timezone_default').returns('Example/Timezone')
let attr = App.Ticket.configure_attributes.find(e => { return e.name == 'updated_at' })
attr.include_timezone = true
equal( App.viewPrint( ticket, 'updated_at' ), '<time class="humanTimeFromNow " datetime="2014-11-07T23:43:08.000Z" title="11/07/2014 23:43 Example/Timezone" timezone="Example/Timezone">11/07/2014</time>')
attr.include_timezone = false
stub.restore()
App.i18n.set('de-de')
equal( App.viewPrint( ticket, 'id' ), 1000)
equal( App.viewPrint( ticket, 'title' ), 'some title &lt;&gt;&amp;')
equal( App.viewPrint( ticket, 'state' ), 'offen')
equal( App.viewPrint( ticket, 'state_id' ), 'offen')
equal( App.viewPrint( ticket, 'not_existing' ), '-')
equal( App.viewPrint( ticket, 'updated_at' ), '<time class="humanTimeFromNow " datetime="2014-11-07T23:43:08.000Z" title="07.11.2014 23:43">07.11.2014</time>')
equal( App.viewPrint( ticket, 'date' ), '07.02.2015')
equal( App.viewPrint( ticket, 'textarea' ), '<div>some new</div><div>line</div>')
equal( App.viewPrint( ticket, 'link1' ), '<a href="http://zammad.com" target="blank">geschlossen</a>')
equal( App.viewPrint( ticket, 'link2' ), '<a href="http://zammad.com" target="blank">closed</a>')
App.i18n.set('en-us')
ticket.state_id = 3
equal( App.viewPrint( ticket, 'state' ), 'closed &lt;&gt;&amp;')
equal( App.viewPrint( ticket, 'state_id' ), 'closed &lt;&gt;&amp;')
App.i18n.set('de')
equal( App.viewPrint( ticket, 'state' ), 'closed &lt;&gt;&amp;')
equal( App.viewPrint( ticket, 'state_id' ), 'closed &lt;&gt;&amp;')
// normal string
data = {
a: 1,
b: 'abc',
c: {
displayName: function() { return "my displayName <>&" }
},
}
equal( App.viewPrint( data, 'a' ), 1)
equal( App.viewPrint( data, 'b' ), 'abc')
equal( App.viewPrint( data, 'c' ), 'my displayName &lt;&gt;&amp;')
});
}

File diff suppressed because it is too large Load diff

View file

@ -1,16 +1,25 @@
/*!
* QUnit 1.21.0
* QUnit 2.17.2
* https://qunitjs.com/
*
* Copyright jQuery Foundation and other contributors
* Copyright OpenJS Foundation and other contributors
* Released under the MIT license
* https://jquery.org/license
*
* Date: 2016-02-01T13:07Z
*/
/** Font Family and Sizes */
/* Style our buttons in a simple way, uninfluenced by the styles
the tested app might load. Don't affect buttons in #qunit-fixture!
https://github.com/qunitjs/qunit/pull/1395
https://github.com/qunitjs/qunit/issues/1437 */
#qunit-testrunner-toolbar button,
#qunit-testresult button {
font-size: initial;
border: initial;
background-color: buttonface;
}
#qunit-tests, #qunit-header, #qunit-banner, #qunit-testrunner-toolbar, #qunit-filteredTest, #qunit-userAgent, #qunit-testresult {
font-family: "Helvetica Neue Light", "HelveticaNeue-Light", "Helvetica Neue", Calibri, Helvetica, Arial, sans-serif;
}
@ -27,12 +36,39 @@
}
/** Header */
/** Fixed headers with scrollable tests */
@supports (display: flex) or (display: -webkit-box) {
@media (min-height: 500px) {
#qunit {
position: fixed;
left: 0px;
right: 0px;
top: 0px;
bottom: 0px;
padding: 8px;
display: -webkit-box;
display: flex;
flex-direction: column;
}
#qunit-tests {
overflow: scroll;
}
#qunit-banner {
flex: 5px 0 0;
}
}
}
/** Header (excluding toolbar) */
#qunit-header {
padding: 0.5em 0 0.5em 1em;
color: #8699A4;
color: #C2CCD1;
background-color: #0D3349;
font-size: 1.5em;
@ -44,7 +80,7 @@
#qunit-header a {
text-decoration: none;
color: #C2CCD1;
color: inherit;
}
#qunit-header a:hover,
@ -52,51 +88,165 @@
color: #FFF;
}
#qunit-testrunner-toolbar label {
display: inline-block;
padding: 0 0.5em 0 0.1em;
}
#qunit-banner {
height: 5px;
}
#qunit-filteredTest {
padding: 0.5em 1em 0.5em 1em;
color: #366097;
background-color: #F4FF77;
}
#qunit-userAgent {
padding: 0.5em 1em 0.5em 1em;
color: #FFF;
background-color: #2B81AF;
text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
}
/** Toolbar */
#qunit-testrunner-toolbar {
padding: 0.5em 1em 0.5em 1em;
color: #5E740B;
background-color: #EEE;
overflow: hidden;
}
#qunit-filteredTest {
padding: 0.5em 1em 0.5em 1em;
background-color: #F4FF77;
color: #366097;
#qunit-testrunner-toolbar .clearfix {
height: 0;
clear: both;
}
#qunit-userAgent {
padding: 0.5em 1em 0.5em 1em;
background-color: #2B81AF;
color: #FFF;
text-shadow: rgba(0, 0, 0, 0.5) 2px 2px 1px;
}
#qunit-modulefilter-container {
float: right;
padding: 0.2em;
}
.qunit-url-config {
#qunit-testrunner-toolbar label {
display: inline-block;
padding: 0.1em;
}
.qunit-filter {
display: block;
#qunit-testrunner-toolbar input[type=checkbox],
#qunit-testrunner-toolbar input[type=radio] {
margin: 3px;
vertical-align: -2px;
}
#qunit-testrunner-toolbar input[type=text] {
box-sizing: border-box;
height: 1.6em;
}
#qunit-toolbar-filters {
float: right;
}
.qunit-url-config,
.qunit-filter,
#qunit-modulefilter {
display: inline-block;
line-height: 2.1em;
}
.qunit-filter,
#qunit-modulefilter {
position: relative;
margin-left: 1em;
}
.qunit-url-config label {
margin-right: 0.5em;
}
#qunit-modulefilter-search {
box-sizing: border-box;
min-width: 400px;
}
#qunit-modulefilter-search-container:after {
position: absolute;
right: 0.3em;
content: "\25bc";
color: black;
}
#qunit-modulefilter-dropdown {
/* align with #qunit-modulefilter-search */
box-sizing: border-box;
min-width: 400px;
position: absolute;
right: 0;
top: 50%;
margin-top: 0.8em;
border: 1px solid #D3D3D3;
border-top: none;
border-radius: 0 0 .25em .25em;
color: #0D3349;
background-color: #F5F5F5;
z-index: 99;
}
#qunit-modulefilter-dropdown a {
color: inherit;
text-decoration: none;
}
#qunit-modulefilter-dropdown .clickable.checked {
font-weight: bold;
color: #0D3349;
background-color: #E2F0F7;
}
#qunit-modulefilter-dropdown .clickable:hover {
color: #FFF;
background-color: #0D3349;
}
#qunit-modulefilter-actions {
display: block;
overflow: auto;
/* align with #qunit-modulefilter-dropdown-list */
font: smaller/1.5em sans-serif;
}
#qunit-modulefilter-dropdown #qunit-modulefilter-actions > * {
box-sizing: border-box;
max-height: 2.8em;
display: block;
padding: 0.4em;
}
#qunit-modulefilter-dropdown #qunit-modulefilter-actions > button {
float: right;
font: inherit;
}
#qunit-modulefilter-dropdown #qunit-modulefilter-actions > :last-child {
/* insert padding to align with checkbox margins */
padding-left: 3px;
}
#qunit-modulefilter-dropdown-list {
max-height: 200px;
overflow-y: auto;
margin: 0;
border-top: 2px groove threedhighlight;
padding: 0.4em 0 0;
font: smaller/1.5em sans-serif;
}
#qunit-modulefilter-dropdown-list li {
white-space: nowrap;
overflow: hidden;
text-overflow: ellipsis;
}
#qunit-modulefilter-dropdown-list .clickable {
display: block;
padding-left: 0.15em;
padding-right: 0.5em;
}
/** Tests: Pass/Fail */
#qunit-tests {
@ -116,7 +266,8 @@
#qunit-tests li.running,
#qunit-tests li.pass,
#qunit-tests li.fail,
#qunit-tests li.skipped {
#qunit-tests li.skipped,
#qunit-tests li.aborted {
display: list-item;
}
@ -125,7 +276,7 @@
}
#qunit-tests.hidepass li.running,
#qunit-tests.hidepass li.pass {
#qunit-tests.hidepass li.pass:not(.todo) {
visibility: hidden;
position: absolute;
width: 0;
@ -145,17 +296,12 @@
#qunit-tests li a {
padding: 0.5em;
color: #C2CCD1;
text-decoration: none;
}
#qunit-tests li p a {
padding: 0.25em;
color: #6B6464;
color: inherit;
text-decoration: underline;
}
#qunit-tests li a:hover,
#qunit-tests li a:focus {
color: #000;
color: #0D3349;
}
#qunit-tests li .runtime {
@ -202,20 +348,20 @@
}
#qunit-tests del {
background-color: #E0F2BE;
color: #374E0C;
background-color: #E0F2BE;
text-decoration: none;
}
#qunit-tests ins {
background-color: #FFCACA;
color: #500;
background-color: #FFCACA;
text-decoration: none;
}
/*** Test Counts */
#qunit-tests b.counts { color: #000; }
#qunit-tests b.counts { color: #0D3349; }
#qunit-tests b.passed { color: #5E740B; }
#qunit-tests b.failed { color: #710909; }
@ -228,15 +374,22 @@
/*** Passing Styles */
#qunit-tests .pass {
color: #2F68DA;
background-color: #E2F0F7;
}
#qunit-tests .pass .test-name {
color: #366097;
}
#qunit-tests li li.pass {
color: #3C510C;
background-color: #FFF;
border-left: 10px solid #C6E746;
}
#qunit-tests .pass { color: #528CE0; background-color: #D2E0E6; }
#qunit-tests .pass .test-name { color: #366097; }
#qunit-tests .pass .test-actual,
#qunit-tests .pass .test-expected { color: #999; }
@ -244,6 +397,11 @@
/*** Failing Styles */
#qunit-tests .fail {
color: #000;
background-color: #EE5757;
}
#qunit-tests li li.fail {
color: #710909;
background-color: #FFF;
@ -255,21 +413,21 @@
border-radius: 0 0 5px 5px;
}
#qunit-tests .fail { color: #000; background-color: #EE5757; }
#qunit-tests .fail .test-name,
#qunit-tests .fail .module-name { color: #000; }
#qunit-tests .fail .test-actual { color: #EE5757; }
#qunit-tests .fail .test-expected { color: #008000; }
#qunit-banner.qunit-fail { background-color: #EE5757; }
/*** Aborted tests */
#qunit-tests .aborted { color: #000; background-color: orange; }
/*** Skipped tests */
#qunit-tests .skipped {
background-color: #EBECE9;
}
#qunit-tests .qunit-todo-label,
#qunit-tests .qunit-skipped-label {
background-color: #F4FF77;
display: inline-block;
@ -280,19 +438,38 @@
margin: -0.4em 0.4em -0.4em 0;
}
#qunit-tests .qunit-todo-label {
background-color: #EEE;
}
/** Result */
#qunit-testresult {
padding: 0.5em 1em 0.5em 1em;
color: #2B81AF;
background-color: #D2E0E6;
color: #366097;
background-color: #E2F0F7;
border-bottom: 1px solid #FFF;
}
#qunit-testresult a {
color: #2F68DA;
}
#qunit-testresult .clearfix {
height: 0;
clear: both;
}
#qunit-testresult .module-name {
font-weight: 700;
}
#qunit-testresult-display {
padding: 0.5em 1em 0.5em 1em;
width: 85%;
float:left;
}
#qunit-testresult-controls {
padding: 0.5em 1em 0.5em 1em;
width: 10%;
float:left;
}
/** Fixture */

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,21 @@
QUnit.test('test color object', assert => {
let hex = new App.ColorObject('#09f609')
let hsl = new App.ColorObject([0.5, 0.2, 0.3])
assert.deepEqual(hex.asHslArray(), [1/3, 0.9294117647058824, 0.5], 'HEX converted to HSL components')
assert.deepEqual(hsl.asHslArray(), [0.5, 0.2, 0.3], 'HSL components returned as original input')
assert.equal(hex.asString(), '#09f609', 'HEX represented as original input')
assert.equal(hsl.asString(), 'hsl(180,20%,30%)', 'HSL components represented as HSL string')
hex.updateWithString('#fff')
assert.equal(hex.asString(), '#fff', 'color updated')
hsl.updateWithHslComponent(0.25, 1)
assert.deepEqual(hsl.asHslArray(), [0.5, 0.25, 0.3], 'given HSL component updated')
assert.deepEqual(Array.from(App.ColorObject.anyToRgb('#ff0000')), [255, 0, 0, 255], 'any to RGB')
assert.deepEqual(App.ColorObject.anyToHslArray('#ff0000'), [0,1,0.5], 'any to HSL components')
assert.equal(App.ColorObject.anyToHslString('#ff0000'), 'hsl(0,100%,50%)', 'any to HSL string')
assert.deepEqual(App.ColorObject.rgbToHslArray([255, 0, 0]), [0,1,0.5], 'RGB to HSL components')
assert.equal(App.ColorObject.hslArrayToHslString([0.5, 0.25, 0.3]), 'hsl(180,25%,30%)', 'HSL components to HSL string')
})

View file

@ -1,4 +1,5 @@
test( "ajax get 200", function(assert) {
QUnit.test( "ajax get 200", assert => {
App.Config.set('api_path', '/api/v1')
var done = assert.async(1)
new Promise( (resolve, reject) => {
@ -9,16 +10,16 @@ test( "ajax get 200", function(assert) {
error: reject
});
}).then( function(data) {
ok( true, "File found!")
equal(data.success, true, "content parsable and ok!")
equal(data.success2, undefined, "content parsable and ok!")
assert.ok( true, "File found!")
assert.equal(data.success, true, "content parsable and assert.ok!")
assert.equal(data.success2, undefined, "content parsable and assert.ok!")
}, function(data) {
ok( false, "Failed!")
assert.ok( false, "Failed!")
})
.finally(done)
});
test( "ajax - queue - ajax get 200 1/2", function(assert) {
QUnit.test( "ajax - queue - ajax get 200 1/2", assert => {
var done = assert.async(1)
new Promise( (resolve, reject) => {
@ -30,17 +31,17 @@ test( "ajax - queue - ajax get 200 1/2", function(assert) {
error: reject
});
}).then( function(data) {
ok( !window.testAjax, 'ajax - queue - check queue')
assert.ok( !window.testAjax, 'ajax - queue - check queue')
window.testAjax = true;
equal(data.success, true, "ajax - queue - content parsable and ok!")
equal(data.success2, undefined, "ajax - queue - content parsable and ok!")
assert.equal(data.success, true, "ajax - queue - content parsable and assert.ok!")
assert.equal(data.success2, undefined, "ajax - queue - content parsable and assert.ok!")
}, function(data) {
ok( false, "Failed!")
assert.ok( false, "Failed!")
})
.finally(done)
});
test( "ajax - queue - ajax get 200 2/2", function(assert) {
QUnit.test( "ajax - queue - ajax get 200 2/2", assert => {
var done = assert.async(1)
new Promise( (resolve, reject) => {
@ -54,19 +55,19 @@ test( "ajax - queue - ajax get 200 2/2", function(assert) {
}).then( function(data) {
// check queue
ok( window.testAjax, 'ajax - queue - check queue')
assert.ok( window.testAjax, 'ajax - queue - check queue')
window.testAjax = undefined;
equal(data.success, true, "content parsable and ok!")
equal(data.success2, undefined, "content parsable and ok!")
assert.equal(data.success, true, "content parsable and assert.ok!")
assert.equal(data.success2, undefined, "content parsable and assert.ok!")
}, function(data) {
ok( false, "Failed!")
assert.ok( false, "Failed!")
})
.finally(done)
});
test( "ajax - parallel - ajax get 200", function(assert) {
var done = assert.async(1)
QUnit.test( "ajax - parallel - ajax get 200", assert => {
var done = assert.async(2)
new Promise( (resolve, reject) => {
App.Ajax.request({
@ -86,28 +87,29 @@ test( "ajax - parallel - ajax get 200", function(assert) {
}).then( function(data) {
// check queue
ok( !window.testAjaxQ, 'ajax - parallel - check queue')
assert.ok( !window.testAjaxQ, 'ajax - parallel - check queue')
window.testAjaxQ = true;
equal(data.success, true, "content parsable and ok!")
equal(data.success2, undefined, "content parsable and ok!")
assert.equal(data.success, true, "content parsable and assert.ok!")
assert.equal(data.success2, undefined, "content parsable and assert.ok!")
}, function(data) {
ok( false, "Failed!")
assert.ok( false, "Failed!")
})
.finally(done)
}).then( function(data) {
// check queue
ok( window.testAjaxQ, 'ajax - parallel - check queue')
assert.ok( window.testAjaxQ, 'ajax - parallel - check queue')
window.testAjaxQ = undefined;
equal(data.success, true, "ajax - parallel - content parsable and ok!")
equal(data.success2, undefined, "ajax - parallel - content parsable and ok!")
assert.equal(data.success, true, "ajax - parallel - content parsable and assert.ok!")
assert.equal(data.success2, undefined, "ajax - parallel - content parsable and assert.ok!")
done()
}, function(data) {
ok( false, "Failed!")
assert.ok( false, "Failed!")
})
});
test('delay - test', function(assert) {
QUnit.test('delay - test', assert => {
var done = assert.async(1)
window.testDelay1 = false
@ -117,24 +119,24 @@ test('delay - test', function(assert) {
new Promise( (resolve, reject) => {
App.Delay.set(resolve, 2000, 'delay-test1', 'level');
}).then( function() {
ok(!window.testDelay1, 'delay - 1/2')
assert.ok(!window.testDelay1, 'delay - 1/2')
window.testDelay1 = 1;
})
new Promise( (resolve, reject) => {
App.Delay.set(resolve, 3000, 'delay-test1-verify', 'level');
}).then( function() {
ok(window.testDelay1, 'delay - 2/2')
assert.ok(window.testDelay1, 'delay - 2/2')
window.testDelay1 = false;
})
.finally(done)
}).then( function() {
ok(false, 'delay - 1/2 - FAILED - should not be executed, will be reset by next set()')
assert.ok(false, 'delay - 1/2 - FAILED - should not be executed, will be reset by next set()')
window.testDelay1 = true;
})
});
test('delay - test 2', function(assert) {
QUnit.test('delay - test 2', assert => {
var done = assert.async(1)
new Promise( (resolve, reject) => {
@ -143,48 +145,48 @@ test('delay - test 2', function(assert) {
new Promise( (resolve, reject) => {
App.Delay.set(resolve, 1000);
}).then( function() {
ok(!window.testDelay2, 'delay - test 2 - 1/3')
assert.ok(!window.testDelay2, 'delay - test 2 - 1/3')
})
new Promise( (resolve, reject) => {
App.Delay.set(resolve, 3000);
}).then( function() {
ok(window.testDelay2, 'delay - test 2 - 3/3')
assert.ok(window.testDelay2, 'delay - test 2 - 3/3')
})
.finally(done)
}).then( function() {
ok(!window.testDelay2, 'delay - test 2 - 2/3')
assert.ok(!window.testDelay2, 'delay - test 2 - 2/3')
window.testDelay2 = 1;
})
});
test('delay - test 3', function(assert) {
QUnit.test('delay - test 3', assert => {
var done = assert.async(1)
new Promise( (resolve, reject) => {
App.Delay.set(resolve, 1000, 'delay3');
App.Delay.clear('delay3')
ok(true, 'delay - test 3 - 1/1')
assert.ok(true, 'delay - test 3 - 1/1')
done()
}).then( function() {
ok(false, 'delay - test 3 - 1/1 - FAILED')
assert.ok(false, 'delay - test 3 - 1/1 - FAILED')
})
});
test('delay - test 4', function(assert) {
QUnit.test('delay - test 4', assert => {
var done = assert.async(1)
new Promise( (resolve, reject) => {
App.Delay.set(resolve, 1000, undefined, 'Page');
App.Delay.clearLevel('Page')
ok(true, 'delay - test 4 - 1/1')
assert.ok(true, 'delay - test 4 - 1/1')
done()
}).then( function() {
ok(false, 'delay - test 4 - 1/1 - FAILED')
assert.ok(false, 'delay - test 4 - 1/1 - FAILED')
})
});
test('interval - test 1', function(assert) {
QUnit.test('interval - test 1', assert => {
var done = assert.async(1)
window.testInterval1 = 1
@ -201,17 +203,17 @@ test('interval - test 1', function(assert) {
new Promise( (resolve, reject) => {
App.Delay.set(resolve, 2000);
}).then( function() {
equal(window.testInterval1, window.testInterval1Backup, 'interval - did not change after clear interval')
assert.equal(window.testInterval1, window.testInterval1Backup, 'interval - did not change after clear interval')
})
.finally(done)
}).then( function() {
notEqual(window.testInterval1, 1, 'interval - interval moved up')
assert.notEqual(window.testInterval1, 1, 'interval - interval moved up')
App.Interval.clear('interval-test1')
window.testInterval1Backup = window.testInterval1;
})
})
test('interval - test 2', function(assert) {
QUnit.test('interval - test 2', assert => {
var done = assert.async(1)
window.testInterval1 = 1
@ -229,58 +231,58 @@ test('interval - test 2', function(assert) {
new Promise( (resolve, reject) => {
App.Delay.set(resolve, 2000);
}).then( function() {
equal(window.testInterval1, window.testInterval1Backup, 'interval - did not change after clear interval')
assert.equal(window.testInterval1, window.testInterval1Backup, 'interval - did not change after clear interval')
})
.finally(done)
}).then( function() {
notEqual(window.testInterval1, 1, 'interval - interval moved up')
assert.notEqual(window.testInterval1, 1, 'interval - interval moved up')
App.Interval.clearLevel('someLevel')
window.testInterval1Backup = window.testInterval1;
})
})
// events
test('events simple', function() {
QUnit.test('events simple', assert => {
// single bind
App.Event.bind('test1', function(data) {
ok(true, 'event received - single bind')
equal(data.success, true, 'event received - data ok - single bind')
assert.ok(true, 'event received - single bind')
assert.equal(data.success, true, 'event received - data assert.ok - single bind')
});
App.Event.bind('test2', function(data) {
ok(false, 'should not be triggered - single bind')
assert.ok(false, 'should not be triggered - single bind')
});
App.Event.trigger('test1', { success: true })
App.Event.unbind('test1')
App.Event.bind('test1', function(data) {
ok(false, 'should not be triggered - single bind')
assert.ok(false, 'should not be triggered - single bind')
});
App.Event.unbind('test1')
App.Event.trigger('test1', { success: true })
// multi bind
App.Event.bind('test1-1 test1-2', function(data) {
ok(true, 'event received - multi bind')
equal(data.success, true, 'event received - data ok - multi bind')
assert.ok(true, 'event received - multi bind')
assert.equal(data.success, true, 'event received - data assert.ok - multi bind')
});
App.Event.bind('test1-3', function(data) {
ok(false, 'should not be triggered - multi bind')
assert.ok(false, 'should not be triggered - multi bind')
});
App.Event.trigger('test1-2', { success: true })
App.Event.unbind('test1-1')
App.Event.bind('test1-1', function(data) {
ok(false, 'should not be triggered - multi bind')
assert.ok(false, 'should not be triggered - multi bind')
});
App.Event.trigger('test1-2', { success: true })
});
test('events level', function() {
QUnit.test('events level', assert => {
// bind with level
App.Event.bind('test3', function(data) {
ok(false, 'should not be triggered!')
assert.ok(false, 'should not be triggered!')
}, 'test-level')
// unbind with level
@ -288,15 +290,15 @@ test('events level', function() {
// bind with level
App.Event.bind('test3', function(data) {
ok(true, 'event received')
equal(data.success, true, 'event received - data ok - level bind')
assert.ok(true, 'event received')
assert.equal(data.success, true, 'event received - data assert.ok - level bind')
}, 'test-level')
App.Event.trigger('test3', { success: true})
});
// session store
test('session store', function() {
QUnit.test('session store', assert => {
var tests = [
'some 123äöüßadajsdaiosjdiaoidj',
@ -309,14 +311,14 @@ test('session store', function() {
_.each(tests, function(test) {
App.SessionStorage.set('test1', test)
var item = App.SessionStorage.get('test1')
deepEqual(test, item, 'write/get - compare stored and actual data')
assert.deepEqual(test, item, 'write/get - compare stored and actual data')
});
// undefined/get
App.SessionStorage.clear()
_.each(tests, function(test) {
var item = App.SessionStorage.get('test1')
deepEqual(undefined, item, 'undefined/get - compare not existing data and actual data')
assert.deepEqual(undefined, item, 'undefined/get - compare not existing data and actual data')
});
// write/get/delete
@ -333,16 +335,16 @@ test('session store', function() {
_.each(tests, function(test) {
var item = App.SessionStorage.get(test.key)
deepEqual(test.value, item, 'write/get/delete - compare stored and actual data')
assert.deepEqual(test.value, item, 'write/get/delete - compare stored and actual data')
App.SessionStorage.delete( test.key)
item = App.SessionStorage.get(test.key)
deepEqual(undefined, item, 'write/get/delete - compare deleted data')
assert.deepEqual(undefined, item, 'write/get/delete - compare deleted data')
});
});
// config
test('config', function() {
QUnit.test('config', assert => {
// simple
var tests = [
@ -357,7 +359,7 @@ test('config', function() {
_.each(tests, function(test) {
var item = App.Config.get(test.key )
deepEqual(item, test.value, 'set/get tests')
assert.deepEqual(item, test.value, 'set/get tests')
});
// group
@ -374,18 +376,18 @@ test('config', function() {
// verify whole group
var item = App.Config.get('group1')
deepEqual(item, group, 'group - verify group hash')
assert.deepEqual(item, group, 'group - verify group hash')
// verify each setting
_.each(test_groups, function(test) {
var item = App.Config.get(test.key, 'group1')
deepEqual(item, test.value, 'group set/get tests')
assert.deepEqual(item, test.value, 'group set/get tests')
});
});
// clone
test('clone', function() {
QUnit.test('clone', assert => {
// simple
var tests = [
@ -436,7 +438,7 @@ test('clone', function() {
_.each(tests, function(test) {
var item = clone( test )
deepEqual(item, test, 'clone')
assert.deepEqual(item, test, 'clone')
});
// complex test
@ -455,7 +457,7 @@ test('clone', function() {
// modify source later, should not have any result
source[0].name = 'some new name'
deepEqual(result, reference, 'clone')
assert.deepEqual(result, reference, 'clone')
// full test
var source = [
@ -474,19 +476,19 @@ test('clone', function() {
source[0].name = 'some new name'
source[2].fn = 'some new name'
deepEqual(result[0], reference[0], 'clone full')
deepEqual(result[1], reference[1], 'clone full')
assert.deepEqual(result[0], reference[0], 'clone full')
assert.deepEqual(result[1], reference[1], 'clone full')
equal(typeof reference[2].fn, 'function')
equal(typeof result[2].fn, 'function')
assert.equal(typeof reference[2].fn, 'function')
assert.equal(typeof result[2].fn, 'function')
equal(reference[2].fn(), 'test')
equal(result[2].fn(), 'test')
assert.equal(reference[2].fn(), 'test')
assert.equal(result[2].fn(), 'test')
});
// diff
test('difference', function() {
QUnit.test('difference', assert => {
// simple
var object1 = {
@ -501,7 +503,7 @@ test('difference', function() {
key2: 1235
}
var item = difference(object1, object2)
deepEqual(item, result)
assert.deepEqual(item, result)
object1 = {
key1: 123,
@ -513,7 +515,7 @@ test('difference', function() {
}
result = {}
item = difference(object1, object2)
deepEqual(item, result)
assert.deepEqual(item, result)
object1 = {
key1: 123,
@ -527,7 +529,7 @@ test('difference', function() {
key2: 123
}
item = difference(object1, object2)
deepEqual(item, result)
assert.deepEqual(item, result)
object1 = {
key1: 123,
@ -538,7 +540,7 @@ test('difference', function() {
}
result = {}
item = difference(object1, object2)
deepEqual(item, result)
assert.deepEqual(item, result)
object1 = {
key1: 123,
@ -549,7 +551,7 @@ test('difference', function() {
}
result = {}
item = difference(object1, object2)
deepEqual(item, result)
assert.deepEqual(item, result)
object1 = {
customer_id: 1,
@ -563,7 +565,7 @@ test('difference', function() {
organization_id: null,
}
item = difference(object1, object2)
deepEqual(item, result)
assert.deepEqual(item, result)
object1 = {
customer_id: 1,
@ -577,11 +579,11 @@ test('difference', function() {
organization_id: 2,
}
item = difference(object1, object2)
deepEqual(item, result)
assert.deepEqual(item, result)
});
test('auth - not existing user', function(assert) {
QUnit.test('auth - not existing user', assert => {
var done = assert.async(1)
new Promise( (resolve, reject) => {
@ -594,14 +596,15 @@ test('auth - not existing user', function(assert) {
error: reject
});
}).then( function(data) {
ok(false, 'ok')
assert.ok(false, 'ok')
}, function() {
ok(true, 'ok')
assert.ok(true, 'ok')
})
.finally(done)
})
test('auth - existing user', function(assert) {
QUnit.test('auth - existing user', assert => {
App.Config.set('api_path', '/api/v1')
var done = assert.async(1)
new Promise( (resolve, reject) => {
@ -614,11 +617,11 @@ test('auth - existing user', function(assert) {
error: reject
});
}).then( function(data) {
ok(true, 'authenticated')
assert.ok(true, 'authenticated')
var user = App.Session.get('login')
equal('admin@example.com', user, 'session login')
assert.equal('admin@example.com', user, 'session login')
}, function() {
ok(false, 'failed')
assert.ok(false, 'failed')
})
.finally(done)
})

View file

@ -1,16 +1,16 @@
// form
test("form without @el", function() {
QUnit.test("form without @el", assert => {
var form = new App.ControllerForm()
equal($(form.html()).is('div'), true)
equal($(form.html()).hasClass('alert'), true)
equal($(form.html()).hasClass('hide'), true)
assert.equal($(form.html()).is('div'), true)
assert.equal($(form.html()).hasClass('alert'), true)
assert.equal($(form.html()).hasClass('hide'), true)
})
test("form elements check", function() {
// deepEqual(item, test.value, 'group set/get tests' );
$('#forms').append('<hr><h1>form elements check</h1><form id="form1"></form>')
QUnit.test("form elements check", assert => {
// assert.deepEqual(item, test.value, 'group set/get tests' );
$('#qunit').append('<hr><h1>form elements check</h1><form id="form1"></form>')
var el = $('#form1')
var defaults = {
input2: '123abc',
@ -58,70 +58,70 @@ test("form elements check", function() {
},
autofocus: true
});
equal(el.find('[name="input1"]').val(), '', 'check input1 value')
equal(el.find('[name="input1"]').prop('required'), false, 'check input1 required')
// equal(el.find('[name="input1"]').is(":focus"), true, 'check input1 focus')
assert.equal(el.find('[name="input1"]').val(), '', 'check input1 value')
assert.equal(el.find('[name="input1"]').prop('required'), false, 'check input1 required')
// assert.equal(el.find('[name="input1"]').is(":focus"), true, 'check input1 focus')
equal(el.find('[name="input2"]').val(), '123abc', 'check input2 value')
equal(el.find('[name="input2"]').prop('required'), true, 'check input2 required')
equal(el.find('[name="input2"]').is(":focus"), false, 'check input2 focus')
assert.equal(el.find('[name="input2"]').val(), '123abc', 'check input2 value')
assert.equal(el.find('[name="input2"]').prop('required'), true, 'check input2 required')
assert.equal(el.find('[name="input2"]').is(":focus"), false, 'check input2 focus')
equal(el.find('[name="password1"]').val(), '', 'check password1 value')
equal(el.find('[name="password1_confirm"]').val(), '', 'check password1 value')
equal(el.find('[name="password1"]').prop('required'), false, 'check password1 required')
equal(el.find('[name="password1"]').is(":focus"), false, 'check password1 focus')
assert.equal(el.find('[name="password1"]').val(), '', 'check password1 value')
assert.equal(el.find('[name="password1_confirm"]').val(), '', 'check password1 value')
assert.equal(el.find('[name="password1"]').prop('required'), false, 'check password1 required')
assert.equal(el.find('[name="password1"]').is(":focus"), false, 'check password1 focus')
equal(el.find('[name="password2"]').val(), 'pw1234<l>', 'check password2 value')
equal(el.find('[name="password2_confirm"]').val(), 'pw1234<l>', 'check password2 value')
equal(el.find('[name="password2"]').prop('required'), true, 'check password2 required')
equal(el.find('[name="password2"]').is(":focus"), false, 'check password2 focus')
assert.equal(el.find('[name="password2"]').val(), 'pw1234<l>', 'check password2 value')
assert.equal(el.find('[name="password2_confirm"]').val(), 'pw1234<l>', 'check password2 value')
assert.equal(el.find('[name="password2"]').prop('required'), true, 'check password2 required')
assert.equal(el.find('[name="password2"]').is(":focus"), false, 'check password2 focus')
equal(el.find('[name="textarea1"]').val(), '', 'check textarea1 value')
equal(el.find('[name="textarea1"]').prop('required'), false, 'check textarea1 required')
equal(el.find('[name="textarea1"]').is(":focus"), false, 'check textarea1 focus')
assert.equal(el.find('[name="textarea1"]').val(), '', 'check textarea1 value')
assert.equal(el.find('[name="textarea1"]').prop('required'), false, 'check textarea1 required')
assert.equal(el.find('[name="textarea1"]').is(":focus"), false, 'check textarea1 focus')
equal(el.find('[name="textarea2"]').val(), 'lalu <l> lalu', 'check textarea2 value')
equal(el.find('[name="textarea2"]').prop('required'), true, 'check textarea2 required')
equal(el.find('[name="textarea2"]').is(":focus"), false, 'check textarea2 focus')
assert.equal(el.find('[name="textarea2"]').val(), 'lalu <l> lalu', 'check textarea2 value')
assert.equal(el.find('[name="textarea2"]').prop('required'), true, 'check textarea2 required')
assert.equal(el.find('[name="textarea2"]').is(":focus"), false, 'check textarea2 focus')
equal(el.find('[name="select1"]').val(), 'false', 'check select1 value')
equal(el.find('[name="select1"]').prop('required'), false, 'check select1 required')
equal(el.find('[name="select1"]').is(":focus"), false, 'check select1 focus')
assert.equal(el.find('[name="select1"]').val(), 'false', 'check select1 value')
assert.equal(el.find('[name="select1"]').prop('required'), false, 'check select1 required')
assert.equal(el.find('[name="select1"]').is(":focus"), false, 'check select1 focus')
equal(el.find('[name="select2"]').val(), 'true', 'check select2 value')
equal(el.find('[name="select2"]').prop('required'), true, 'check select2 required')
equal(el.find('[name="select2"]').is(":focus"), false, 'check select2 focus')
assert.equal(el.find('[name="select2"]').val(), 'true', 'check select2 value')
assert.equal(el.find('[name="select2"]').prop('required'), true, 'check select2 required')
assert.equal(el.find('[name="select2"]').is(":focus"), false, 'check select2 focus')
equal(el.find('[name="selectmulti1"]').val(), 'false', 'check selectmulti1 value')
equal(el.find('[name="selectmulti1"]').prop('required'), false, 'check selectmulti1 required')
equal(el.find('[name="selectmulti1"]').is(":focus"), false, 'check selectmulti1 focus')
assert.equal(el.find('[name="selectmulti1"]').val(), 'false', 'check selectmulti1 value')
assert.equal(el.find('[name="selectmulti1"]').prop('required'), false, 'check selectmulti1 required')
assert.equal(el.find('[name="selectmulti1"]').is(":focus"), false, 'check selectmulti1 focus')
equal(el.find('[name="selectmulti2"]').val()[0], 'true', 'check selectmulti2 value')
equal(el.find('[name="selectmulti2"]').val()[1], 'false', 'check selectmulti2 value')
equal(el.find('[name="selectmulti2"]').prop('required'), true, 'check selectmulti2 required')
equal(el.find('[name="selectmulti2"]').is(":focus"), false, 'check selectmulti2 focus')
assert.equal(el.find('[name="selectmulti2"]').val()[0], 'true', 'check selectmulti2 value')
assert.equal(el.find('[name="selectmulti2"]').val()[1], 'false', 'check selectmulti2 value')
assert.equal(el.find('[name="selectmulti2"]').prop('required'), true, 'check selectmulti2 required')
assert.equal(el.find('[name="selectmulti2"]').is(":focus"), false, 'check selectmulti2 focus')
//equal(el.find('[name="richtext1"]').val(), '', 'check textarea1 value')
//equal(el.find('[name="richtext1"]').prop('required'), false, 'check textarea1 required')
equal(el.find('[name="richtext1"]').is(":focus"), false, 'check textarea1 focus')
assert.equal(el.find('[name="richtext1"]').is(":focus"), false, 'check textarea1 focus')
//equal(el.find('[name="richtext2"]').val(), 'lalu <l> lalu', 'check textarea2 value')
//equal(el.find('[name="richtext2"]').prop('required'), true, 'check textarea2 required')
equal(el.find('[name="richtext2"]').is(":focus"), false, 'check textarea2 focus')
assert.equal(el.find('[name="richtext2"]').is(":focus"), false, 'check textarea2 focus')
equal(el.find('[name="checkbox1"]').first().is(":checked"), false)
equal(el.find('[name="checkbox1"]').last().is(":checked"), false)
equal(el.find('[name="checkbox2"]').is(":checked"), true)
assert.equal(el.find('[name="checkbox1"]').first().is(":checked"), false)
assert.equal(el.find('[name="checkbox1"]').last().is(":checked"), false)
assert.equal(el.find('[name="checkbox2"]').is(":checked"), true)
equal(el.find('[name="boolean1"]').val(), 'true')
equal(el.find('[name="boolean1"]').val(), 'true')
equal(el.find('[name="boolean2"]').val(), 'false')
assert.equal(el.find('[name="boolean1"]').val(), 'true')
assert.equal(el.find('[name="boolean1"]').val(), 'true')
assert.equal(el.find('[name="boolean2"]').val(), 'false')
});
test("form params check", function() {
// deepEqual(item, test.value, 'group set/get tests' );
QUnit.test("form params check", assert => {
// assert.deepEqual(item, test.value, 'group set/get tests' );
$('#forms').append('<hr><h1>form params check</h1><form id="form2"></form>')
$('#qunit').append('<hr><h1>form params check</h1><form id="form2"></form>')
var el = $('#form2')
var defaults = {
input2: '123abc',
@ -231,70 +231,70 @@ test("form params check", function() {
params: defaults,
autofocus: true
});
equal(el.find('[name="input1"]').val(), '', 'check input1 value')
equal(el.find('[name="input1"]').prop('required'), false, 'check input1 required')
// equal(el.find('[name="input1"]').is(":focus"), true, 'check input1 focus')
assert.equal(el.find('[name="input1"]').val(), '', 'check input1 value')
assert.equal(el.find('[name="input1"]').prop('required'), false, 'check input1 required')
// assert.equal(el.find('[name="input1"]').is(":focus"), true, 'check input1 focus')
equal(el.find('[name="input2"]').val(), '123abc', 'check input2 value')
equal(el.find('[name="input2"]').prop('required'), true, 'check input2 required')
equal(el.find('[name="input2"]').is(":focus"), false, 'check input2 focus')
assert.equal(el.find('[name="input2"]').val(), '123abc', 'check input2 value')
assert.equal(el.find('[name="input2"]').prop('required'), true, 'check input2 required')
assert.equal(el.find('[name="input2"]').is(":focus"), false, 'check input2 focus')
equal(el.find('[name="input3"]').prop("disabled"), true, 'check input3 disabled')
assert.equal(el.find('[name="input3"]').prop("disabled"), true, 'check input3 disabled')
equal(el.find('[name="password1"]').val(), '', 'check password1 value')
equal(el.find('[name="password1_confirm"]').val(), '', 'check password1 value')
equal(el.find('[name="password1"]').prop('required'), false, 'check password1 required')
equal(el.find('[name="password1"]').is(":focus"), false, 'check password1 focus')
assert.equal(el.find('[name="password1"]').val(), '', 'check password1 value')
assert.equal(el.find('[name="password1_confirm"]').val(), '', 'check password1 value')
assert.equal(el.find('[name="password1"]').prop('required'), false, 'check password1 required')
assert.equal(el.find('[name="password1"]').is(":focus"), false, 'check password1 focus')
equal(el.find('[name="password2"]').val(), 'pw1234<l>', 'check password2 value')
equal(el.find('[name="password2_confirm"]').val(), 'pw1234<l>', 'check password2 value')
equal(el.find('[name="password2"]').prop('required'), true, 'check password2 required')
equal(el.find('[name="password2"]').is(":focus"), false, 'check password2 focus')
assert.equal(el.find('[name="password2"]').val(), 'pw1234<l>', 'check password2 value')
assert.equal(el.find('[name="password2_confirm"]').val(), 'pw1234<l>', 'check password2 value')
assert.equal(el.find('[name="password2"]').prop('required'), true, 'check password2 required')
assert.equal(el.find('[name="password2"]').is(":focus"), false, 'check password2 focus')
equal(el.find('[name="textarea1"]').val(), '', 'check textarea1 value')
equal(el.find('[name="textarea1"]').prop('required'), false, 'check textarea1 required')
equal(el.find('[name="textarea1"]').is(":focus"), false, 'check textarea1 focus')
assert.equal(el.find('[name="textarea1"]').val(), '', 'check textarea1 value')
assert.equal(el.find('[name="textarea1"]').prop('required'), false, 'check textarea1 required')
assert.equal(el.find('[name="textarea1"]').is(":focus"), false, 'check textarea1 focus')
equal(el.find('[name="textarea2"]').val(), 'lalu <l> lalu', 'check textarea2 value')
equal(el.find('[name="textarea2"]').prop('required'), true, 'check textarea2 required')
equal(el.find('[name="textarea2"]').is(":focus"), false, 'check textarea2 focus')
assert.equal(el.find('[name="textarea2"]').val(), 'lalu <l> lalu', 'check textarea2 value')
assert.equal(el.find('[name="textarea2"]').prop('required'), true, 'check textarea2 required')
assert.equal(el.find('[name="textarea2"]').is(":focus"), false, 'check textarea2 focus')
equal(el.find('[name="textarea3"]').prop("disabled"), true, 'check textarea3 disabled')
assert.equal(el.find('[name="textarea3"]').prop("disabled"), true, 'check textarea3 disabled')
equal(el.find('[name="select1"]').val(), 'false', 'check select1 value')
equal(el.find('[name="select1"]').prop('required'), false, 'check select1 required')
equal(el.find('[name="select1"]').is(":focus"), false, 'check select1 focus')
assert.equal(el.find('[name="select1"]').val(), 'false', 'check select1 value')
assert.equal(el.find('[name="select1"]').prop('required'), false, 'check select1 required')
assert.equal(el.find('[name="select1"]').is(":focus"), false, 'check select1 focus')
equal(el.find('[name="select2"]').val(), 'true', 'check select2 value')
equal(el.find('[name="select2"]').prop('required'), true, 'check select2 required')
equal(el.find('[name="select2"]').is(":focus"), false, 'check select2 focus')
assert.equal(el.find('[name="select2"]').val(), 'true', 'check select2 value')
assert.equal(el.find('[name="select2"]').prop('required'), true, 'check select2 required')
assert.equal(el.find('[name="select2"]').is(":focus"), false, 'check select2 focus')
equal(el.find('[name="select3"]').val(), '', 'check select3 value')
equal(el.find('[name="select3"]').prop('required'), true, 'check select3 required')
equal(el.find('[name="select3"]').is(":focus"), false, 'check select3 focus')
assert.equal(el.find('[name="select3"]').val(), '', 'check select3 value')
assert.equal(el.find('[name="select3"]').prop('required'), true, 'check select3 required')
assert.equal(el.find('[name="select3"]').is(":focus"), false, 'check select3 focus')
equal(el.find('[name="select4"]').val(), '', 'check select4 value')
equal(el.find('[name="select4"]').prop('required'), true, 'check select4 required')
equal(el.find('[name="select4"]').is(":focus"), false, 'check select4 focus')
assert.equal(el.find('[name="select4"]').val(), '', 'check select4 value')
assert.equal(el.find('[name="select4"]').prop('required'), true, 'check select4 required')
assert.equal(el.find('[name="select4"]').is(":focus"), false, 'check select4 focus')
equal(el.find('[name="select5"]').prop("disabled"), true, 'check select5 disabled')
assert.equal(el.find('[name="select5"]').prop("disabled"), true, 'check select5 disabled')
equal(el.find('[name="selectmulti1"]').val(), 'false', 'check selectmulti1 value')
equal(el.find('[name="selectmulti1"]').prop('required'), false, 'check selectmulti1 required')
equal(el.find('[name="selectmulti1"]').is(":focus"), false, 'check selectmulti1 focus')
assert.equal(el.find('[name="selectmulti1"]').val(), 'false', 'check selectmulti1 value')
assert.equal(el.find('[name="selectmulti1"]').prop('required'), false, 'check selectmulti1 required')
assert.equal(el.find('[name="selectmulti1"]').is(":focus"), false, 'check selectmulti1 focus')
equal(el.find('[name="selectmulti2"]').val()[0], 'true', 'check selectmulti2 value')
equal(el.find('[name="selectmulti2"]').val()[1], 'false', 'check selectmulti2 value')
equal(el.find('[name="selectmulti2"]').prop('required'), true, 'check selectmulti2 required')
equal(el.find('[name="selectmulti2"]').is(":focus"), false, 'check selectmulti2 focus')
assert.equal(el.find('[name="selectmulti2"]').val()[0], 'true', 'check selectmulti2 value')
assert.equal(el.find('[name="selectmulti2"]').val()[1], 'false', 'check selectmulti2 value')
assert.equal(el.find('[name="selectmulti2"]').prop('required'), true, 'check selectmulti2 required')
assert.equal(el.find('[name="selectmulti2"]').is(":focus"), false, 'check selectmulti2 focus')
equal(el.find('[name="selectmulti3"]').prop("disabled"), true, 'check selectmulti3 disabled')
equal(el.find('[name="selectmultioption3"]').prop("disabled"), true, 'check selectmultioption3 disabled')
assert.equal(el.find('[name="selectmulti3"]').prop("disabled"), true, 'check selectmulti3 disabled')
assert.equal(el.find('[name="selectmultioption3"]').prop("disabled"), true, 'check selectmultioption3 disabled')
equal(el.find('[name="boolean4"]').prop("disabled"), true, 'check boolean4 disabled')
equal(el.find('[data-name="richtext9"]').prop("contenteditable"), "false", 'check richtext9 disabled')
equal(el.find('[name="checkbox5"]').prop("disabled"), true, 'check checkbox5 disabled')
equal(el.find('[name="radiobox3"]').prop("disabled"), true, 'check radiobox3 disabled')
assert.equal(el.find('[name="boolean4"]').prop("disabled"), true, 'check boolean4 disabled')
assert.equal(el.find('[data-name="richtext9"]').prop("contenteditable"), "false", 'check richtext9 disabled')
assert.equal(el.find('[name="checkbox5"]').prop("disabled"), true, 'check checkbox5 disabled')
assert.equal(el.find('[name="radiobox3"]').prop("disabled"), true, 'check radiobox3 disabled')
params = App.ControllerForm.params(el)
test_params = {
@ -359,12 +359,12 @@ test("form params check", function() {
boolean3: true,
boolean4: false,
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
});
test("form defaults + params check", function() {
// deepEqual(item, test.value, 'group set/get tests' );
QUnit.test("form defaults + params check", assert => {
// assert.deepEqual(item, test.value, 'group set/get tests' );
// mix default and params -> check it -> add note
// test auto completion
@ -373,7 +373,7 @@ test("form defaults + params check", function() {
// form params check
// add signature only if form_state is empty
$('#forms').append('<hr><h1>form defaults + params check</h1><form id="form3"></form>')
$('#qunit').append('<hr><h1>form defaults + params check</h1><form id="form3"></form>')
var el = $('#form3')
var defaults = {
input1: '',
@ -402,47 +402,47 @@ test("form defaults + params check", function() {
params: defaults,
autofocus: true
});
equal(el.find('[name="input1"]').val(), '', 'check input1 value')
equal(el.find('[name="input1"]').prop('required'), false, 'check input1 required')
// equal(el.find('[name="input1"]').is(":focus"), true, 'check input1 focus')
equal(el.find('[name="input2"]').val(), 'some used default', 'check input2 value')
equal(el.find('[name="input2"]').prop('required'), false, 'check input2 required')
assert.equal(el.find('[name="input1"]').val(), '', 'check input1 value')
assert.equal(el.find('[name="input1"]').prop('required'), false, 'check input1 required')
// assert.equal(el.find('[name="input1"]').is(":focus"), true, 'check input1 focus')
assert.equal(el.find('[name="input2"]').val(), 'some used default', 'check input2 value')
assert.equal(el.find('[name="input2"]').prop('required'), false, 'check input2 required')
equal(el.find('[name="password1"]').val(), 'some used pass', 'check password1 value')
equal(el.find('[name="password1_confirm"]').val(), 'some used pass', 'check password1 value')
equal(el.find('[name="password1"]').prop('required'), true, 'check password1 required')
equal(el.find('[name="password1"]').is(":focus"), false, 'check password1 focus')
assert.equal(el.find('[name="password1"]').val(), 'some used pass', 'check password1 value')
assert.equal(el.find('[name="password1_confirm"]').val(), 'some used pass', 'check password1 value')
assert.equal(el.find('[name="password1"]').prop('required'), true, 'check password1 required')
assert.equal(el.find('[name="password1"]').is(":focus"), false, 'check password1 focus')
equal(el.find('[name="password2"]').val(), 'pw1234<l>', 'check password2 value')
equal(el.find('[name="password2_confirm"]').val(), 'pw1234<l>', 'check password2 value')
equal(el.find('[name="password2"]').prop('required'), true, 'check password2 required')
equal(el.find('[name="password2"]').is(":focus"), false, 'check password2 focus')
assert.equal(el.find('[name="password2"]').val(), 'pw1234<l>', 'check password2 value')
assert.equal(el.find('[name="password2_confirm"]').val(), 'pw1234<l>', 'check password2 value')
assert.equal(el.find('[name="password2"]').prop('required'), true, 'check password2 required')
assert.equal(el.find('[name="password2"]').is(":focus"), false, 'check password2 focus')
equal(el.find('[name="textarea1"]').val(), 'some used text', 'check textarea1 value')
equal(el.find('[name="textarea1"]').prop('required'), true, 'check textarea1 required')
equal(el.find('[name="textarea1"]').is(":focus"), false, 'check textarea1 focus')
assert.equal(el.find('[name="textarea1"]').val(), 'some used text', 'check textarea1 value')
assert.equal(el.find('[name="textarea1"]').prop('required'), true, 'check textarea1 required')
assert.equal(el.find('[name="textarea1"]').is(":focus"), false, 'check textarea1 focus')
equal(el.find('[name="textarea2"]').val(), 'lalu <l> lalu', 'check textarea2 value')
equal(el.find('[name="textarea2"]').prop('required'), true, 'check textarea2 required')
equal(el.find('[name="textarea2"]').is(":focus"), false, 'check textarea2 focus')
assert.equal(el.find('[name="textarea2"]').val(), 'lalu <l> lalu', 'check textarea2 value')
assert.equal(el.find('[name="textarea2"]').prop('required'), true, 'check textarea2 required')
assert.equal(el.find('[name="textarea2"]').is(":focus"), false, 'check textarea2 focus')
equal(el.find('[name="select1"]').val(), 'false', 'check select1 value')
equal(el.find('[name="select1"]').prop('required'), false, 'check select1 required')
equal(el.find('[name="select1"]').is(":focus"), false, 'check select1 focus')
assert.equal(el.find('[name="select1"]').val(), 'false', 'check select1 value')
assert.equal(el.find('[name="select1"]').prop('required'), false, 'check select1 required')
assert.equal(el.find('[name="select1"]').is(":focus"), false, 'check select1 focus')
equal(el.find('[name="select2"]').val(), 'false', 'check select2 value')
equal(el.find('[name="select2"]').prop('required'), false, 'check select2 required')
equal(el.find('[name="select2"]').is(":focus"), false, 'check select2 focus')
assert.equal(el.find('[name="select2"]').val(), 'false', 'check select2 value')
assert.equal(el.find('[name="select2"]').prop('required'), false, 'check select2 required')
assert.equal(el.find('[name="select2"]').is(":focus"), false, 'check select2 focus')
equal(el.find('[name="selectmulti2"]').val()[0], 'true', 'check selectmulti2 value')
equal(el.find('[name="selectmulti2"]').val()[1], 'false', 'check selectmulti2 value')
equal(el.find('[name="selectmulti2"]').prop('required'), true, 'check selectmulti2 required')
equal(el.find('[name="selectmulti2"]').is(":focus"), false, 'check selectmulti2 focus')
assert.equal(el.find('[name="selectmulti2"]').val()[0], 'true', 'check selectmulti2 value')
assert.equal(el.find('[name="selectmulti2"]').val()[1], 'false', 'check selectmulti2 value')
assert.equal(el.find('[name="selectmulti2"]').prop('required'), true, 'check selectmulti2 required')
assert.equal(el.find('[name="selectmulti2"]').is(":focus"), false, 'check selectmulti2 focus')
});
test("form dependend fields check", function() {
// deepEqual(item, test.value, 'group set/get tests' );
QUnit.test("form dependend fields check", assert => {
// assert.deepEqual(item, test.value, 'group set/get tests' );
// mix default and params -> check it -> add note
// test auto completion
@ -451,7 +451,7 @@ test("form dependend fields check", function() {
// form params check
// add signature only if form_state is empty
$('#forms').append('<hr><h1>form dependend fields check</h1><form id="form4"></form>')
$('#qunit').append('<hr><h1>form dependend fields check</h1><form id="form4"></form>')
var el = $('#form4')
var defaults = {
input1: '',
@ -549,27 +549,27 @@ test("form dependend fields check", function() {
],
autofocus: true
});
equal(el.find('[name="input1"]').val(), '', 'check input1 value')
equal(el.find('[name="input1"]').prop('required'), false, 'check input1 required')
// equal(el.find('[name="input1"]').is(":focus"), true, 'check input1 focus')
equal(el.find('[name="input2"]').val(), 'some used default', 'check input2 value')
equal(el.find('[name="input2"]').prop('required'), false, 'check input2 required')
assert.equal(el.find('[name="input1"]').val(), '', 'check input1 value')
assert.equal(el.find('[name="input1"]').prop('required'), false, 'check input1 required')
// assert.equal(el.find('[name="input1"]').is(":focus"), true, 'check input1 focus')
assert.equal(el.find('[name="input2"]').val(), 'some used default', 'check input2 value')
assert.equal(el.find('[name="input2"]').prop('required'), false, 'check input2 required')
equal(el.find('[name="input3"]').val(), 'some used default', 'check input3 value')
equal(el.find('[name="input3"]').prop('required'), false, 'check input3 required')
assert.equal(el.find('[name="input3"]').val(), 'some used default', 'check input3 value')
assert.equal(el.find('[name="input3"]').prop('required'), false, 'check input3 required')
equal(el.find('[name="select1"]').val(), 'false', 'check select1 value')
equal(el.find('[name="select1"]').prop('required'), false, 'check select1 required')
equal(el.find('[name="select1"]').is(":focus"), false, 'check select1 focus')
assert.equal(el.find('[name="select1"]').val(), 'false', 'check select1 value')
assert.equal(el.find('[name="select1"]').prop('required'), false, 'check select1 required')
assert.equal(el.find('[name="select1"]').is(":focus"), false, 'check select1 focus')
equal(el.find('[name="select2"]').val(), 'false', 'check select2 value')
equal(el.find('[name="select2"]').prop('required'), false, 'check select2 required')
equal(el.find('[name="select2"]').is(":focus"), false, 'check select2 focus')
assert.equal(el.find('[name="select2"]').val(), 'false', 'check select2 value')
assert.equal(el.find('[name="select2"]').prop('required'), false, 'check select2 required')
assert.equal(el.find('[name="select2"]').is(":focus"), false, 'check select2 focus')
equal(el.find('[name="selectmulti2"]').val()[0], 'true', 'check selectmulti2 value')
equal(el.find('[name="selectmulti2"]').val()[1], 'false', 'check selectmulti2 value')
equal(el.find('[name="selectmulti2"]').prop('required'), true, 'check selectmulti2 required')
equal(el.find('[name="selectmulti2"]').is(":focus"), false, 'check selectmulti2 focus')
assert.equal(el.find('[name="selectmulti2"]').val()[0], 'true', 'check selectmulti2 value')
assert.equal(el.find('[name="selectmulti2"]').val()[1], 'false', 'check selectmulti2 value')
assert.equal(el.find('[name="selectmulti2"]').prop('required'), true, 'check selectmulti2 required')
assert.equal(el.find('[name="selectmulti2"]').is(":focus"), false, 'check selectmulti2 focus')
var params = App.ControllerForm.params(el)
var test_params = {
@ -589,14 +589,14 @@ test("form dependend fields check", function() {
date3: '2015-01-11',
date4: null,
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
errors = form.validate(params)
test_errors = {
datetime4: "is required",
date4: "is required",
}
deepEqual(errors, test_errors, 'validation errors check')
assert.deepEqual(errors, test_errors, 'validation errors check')
App.ControllerForm.validate({ errors: errors, form: el })
el.find('[name="select1"]').val('true')
@ -619,11 +619,11 @@ test("form dependend fields check", function() {
date3: '2015-01-11',
date4: null,
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
});
test("form handler check with and without fieldset", function() {
// deepEqual(item, test.value, 'group set/get tests' );
QUnit.test("form handler check with and without fieldset", assert => {
// assert.deepEqual(item, test.value, 'group set/get tests' );
// mix default and params -> check it -> add note
// test auto completion
@ -632,7 +632,7 @@ test("form handler check with and without fieldset", function() {
// form params check
// add signature only if form_state is empty
$('#forms').append('<hr><h1>form handler check with and without fieldset</h1><form id="form5"></form>')
$('#qunit').append('<hr><h1>form handler check with and without fieldset</h1><form id="form5"></form>')
var el = $('#form5')
var defaults = {
select1: 'a',
@ -683,18 +683,18 @@ test("form handler check with and without fieldset", function() {
],
//noFieldset: true,
});
equal(el.find('[name="select1"]').val(), 'a', 'check select1 value')
equal(el.find('[name="select1"]').prop('required'), false, 'check select1 required')
assert.equal(el.find('[name="select1"]').val(), 'a', 'check select1 value')
assert.equal(el.find('[name="select1"]').prop('required'), false, 'check select1 required')
equal(el.find('[name="select2"]').val(), '1', 'check select2 value')
equal(el.find('[name="select2"]').prop('required'), false, 'check select2 required')
assert.equal(el.find('[name="select2"]').val(), '1', 'check select2 value')
assert.equal(el.find('[name="select2"]').prop('required'), false, 'check select2 required')
var params = App.ControllerForm.params(el)
var test_params = {
select1: 'a',
select2: '1',
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
el.find('[name="select1"]').val('b')
el.find('[name="select1"]').trigger('change')
params = App.ControllerForm.params(el)
@ -702,7 +702,7 @@ test("form handler check with and without fieldset", function() {
select1: 'b',
select2: '3',
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
el.find('[name="select1"]').val('a')
el.find('[name="select1"]').trigger('change')
params = App.ControllerForm.params(el)
@ -710,7 +710,7 @@ test("form handler check with and without fieldset", function() {
select1: 'a',
select2: '1',
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
// test with noFieldset
el.empty()
@ -728,18 +728,18 @@ test("form handler check with and without fieldset", function() {
],
noFieldset: true,
});
equal(el.find('[name="select1"]').val(), 'a', 'check select1 value')
equal(el.find('[name="select1"]').prop('required'), false, 'check select1 required')
assert.equal(el.find('[name="select1"]').val(), 'a', 'check select1 value')
assert.equal(el.find('[name="select1"]').prop('required'), false, 'check select1 required')
equal(el.find('[name="select2"]').val(), '1', 'check select2 value')
equal(el.find('[name="select2"]').prop('required'), false, 'check select2 required')
assert.equal(el.find('[name="select2"]').val(), '1', 'check select2 value')
assert.equal(el.find('[name="select2"]').prop('required'), false, 'check select2 required')
var params = App.ControllerForm.params(el)
var test_params = {
select1: 'a',
select2: '1',
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
el.find('[name="select1"]').val('b')
el.find('[name="select1"]').trigger('change')
params = App.ControllerForm.params(el)
@ -747,7 +747,7 @@ test("form handler check with and without fieldset", function() {
select1: 'b',
select2: '3',
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
el.find('[name="select1"]').val('a')
el.find('[name="select1"]').trigger('change')
params = App.ControllerForm.params(el)
@ -755,11 +755,11 @@ test("form handler check with and without fieldset", function() {
select1: 'a',
select2: '1',
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
});
test("form postmaster filter", function() {
QUnit.test("form postmaster filter", assert => {
App.TicketPriority.refresh([
{
@ -782,7 +782,7 @@ test("form postmaster filter", function() {
},
] )
$('#forms').append('<hr><h1>form postmaster filter</h1><form id="form6"></form>')
$('#qunit').append('<hr><h1>form postmaster filter</h1><form id="form6"></form>')
var el = $('#form6')
var defaults = {
input2: 'some name',
@ -864,7 +864,7 @@ test("form postmaster filter", function() {
}
},
};
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
el.find('[name="set::x-zammad-ticket-priority_id::value"]').closest('.js-filterElement').find('.js-remove').click()
el.find('[name="set::x-zammad-ticket-customer_id::value"]').closest('.js-filterElement').find('.js-remove').click()
@ -897,7 +897,7 @@ test("form postmaster filter", function() {
},
},
};
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
el.find('.postmaster_set .js-filterElement').last().find('.filter-controls .js-add').click()
@ -932,10 +932,10 @@ test("form postmaster filter", function() {
},
},
};
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
App.Delay.set(function() {
test("form postmaster filter - needed to do delayed because of tag ui", function() {
QUnit.test("form postmaster filter - needed to do delayed because of tag ui", assert => {
el.find('[name="set::x-zammad-ticket-tags::value"]').closest('.js-filterElement').find('.token .close').last().click()
params = App.ControllerForm.params(el)
test_params = {
@ -968,13 +968,13 @@ test("form postmaster filter", function() {
},
},
};
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
})
}, 500);
});
test("form selector", function() {
$('#forms').append('<hr><h1>form selector</h1><div><form id="form7"></form></div>')
QUnit.test("form selector", assert => {
$('#qunit').append('<hr><h1>form selector</h1><div><form id="form7"></form></div>')
var el = $('#form7')
var defaults = {
input2: 'some name66',
@ -994,19 +994,19 @@ test("form selector", function() {
input2: 'some name66',
};
params = App.ControllerForm.params(el)
deepEqual(params, test_params, 'form param check via $("#form")')
assert.deepEqual(params, test_params, 'form param check via $("#form")')
params = App.ControllerForm.params(el.find('input'))
deepEqual(params, test_params, 'form param check via $("#form").find("input")')
assert.deepEqual(params, test_params, 'form param check via $("#form").find("input")')
params = App.ControllerForm.params(el.parent())
deepEqual(params, test_params, 'form param check via $("#form").parent()')
assert.deepEqual(params, test_params, 'form param check via $("#form").parent()')
});
test("form params check", function() {
QUnit.test("form params check", assert => {
$('#forms').append('<hr><h1>form params check</h1><form id="form9"></form>')
$('#qunit').append('<hr><h1>form params check</h1><form id="form9"></form>')
var el = $('#form9')
var defaults = {
select1: false,
@ -1038,13 +1038,13 @@ test("form params check", function() {
}
//console.log('params', params)
//console.log('test_params', test_params)
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
});
test("form params check direct", function() {
QUnit.test("form params check direct", assert => {
$('#forms').append('<hr><h1>form params check direct</h1><form id="form10"><input name="a" value="b"><input name="l::l::l1" value="d"><input name="l::l::" value><input name="f::f::" value><input name="f::f::f1" value="e"></form>')
$('#qunit').append('<hr><h1>form params check direct</h1><form id="form10"><input name="a" value="b"><input name="l::l::l1" value="d"><input name="l::l::" value><input name="f::f::" value><input name="f::f::f1" value="e"></form>')
var el = $('#form10')
params = App.ControllerForm.params(el)
@ -1065,12 +1065,12 @@ test("form params check direct", function() {
}
//console.log('params', params)
//console.log('test_params', test_params)
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
});
test("object manager form 1", function() {
QUnit.test("object manager form 1", assert => {
$('#forms').append('<hr><h1>object manager 1</h1><form id="form11"></form>')
$('#qunit').append('<hr><h1>object manager 1</h1><form id="form11"></form>')
var el = $('#form11')
var defaults = {}
@ -1118,7 +1118,7 @@ test("object manager form 1", function() {
}
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
el.find('[name=data_type]').val('datetime').trigger('change')
@ -1153,13 +1153,13 @@ test("object manager form 1", function() {
}
}
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
});
test("object manager form 2", function() {
QUnit.test("object manager form 2", assert => {
$('#forms').append('<hr><h1>object manager 2</h1><form id="form12"></form>')
$('#qunit').append('<hr><h1>object manager 2</h1><form id="form12"></form>')
var el = $('#form12')
var defaults = {
@ -1230,13 +1230,13 @@ test("object manager form 2", function() {
}
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
});
test("object manager form 3", function() {
QUnit.test("object manager form 3", assert => {
$('#forms').append('<hr><h1>object manager 3</h1><form id="form13"></form>')
$('#qunit').append('<hr><h1>object manager 3</h1><form id="form13"></form>')
var el = $('#form13')
var defaults = {}
@ -1284,7 +1284,7 @@ test("object manager form 3", function() {
}
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
el.find('[name="screens::create_middle::ticket.customer::shown"]').click()
el.find('[name="screens::edit::ticket.customer::shown"]').click()
@ -1321,13 +1321,13 @@ test("object manager form 3", function() {
}
}
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
});
test("check if select value is not existing but is shown", function() {
QUnit.test("check if select value is not existing but is shown", assert => {
$('#forms').append('<hr><h1>check if select value is not existing but is shown</h1><form id="form17"></form>')
$('#qunit').append('<hr><h1>check if select value is not existing but is shown</h1><form id="form17"></form>')
var el = $('#form17')
var defaults = {
select1: 'NOT EXISTING',
@ -1346,20 +1346,20 @@ test("check if select value is not existing but is shown", function() {
test_params = {
select1: 'NOT EXISTING',
}
deepEqual(params, test_params)
assert.deepEqual(params, test_params)
equal('AA', el.find('[name=select1] option')[0].text)
equal('äöü', el.find('[name=select1] option')[1].text)
equal('b', el.find('[name=select1] option')[2].text)
equal('B', el.find('[name=select1] option')[3].text)
equal('NOT EXISTING', el.find('[name=select1] option')[4].text)
equal('XX', el.find('[name=select1] option')[5].text)
assert.equal('AA', el.find('[name=select1] option')[0].text)
assert.equal('äöü', el.find('[name=select1] option')[1].text)
assert.equal('b', el.find('[name=select1] option')[2].text)
assert.equal('B', el.find('[name=select1] option')[3].text)
assert.equal('NOT EXISTING', el.find('[name=select1] option')[4].text)
assert.equal('XX', el.find('[name=select1] option')[5].text)
});
test("check if select value is not existing and is not shown", function() {
QUnit.test("check if select value is not existing and is not shown", assert => {
$('#forms').append('<hr><h1>check if select value is not existing and is not shown</h1><form id="form18"></form>')
$('#qunit').append('<hr><h1>check if select value is not existing and is not shown</h1><form id="form18"></form>')
var el = $('#form18')
var defaults = {
select1: 'NOT EXISTING',
@ -1379,19 +1379,19 @@ test("check if select value is not existing and is not shown", function() {
test_params = {
select1: 'XY',
}
deepEqual(params, test_params)
assert.deepEqual(params, test_params)
equal('AA', el.find('[name=select1] option')[0].text)
equal('äöü', el.find('[name=select1] option')[1].text)
equal('b', el.find('[name=select1] option')[2].text)
equal('B', el.find('[name=select1] option')[3].text)
equal('XX', el.find('[name=select1] option')[4].text)
assert.equal('AA', el.find('[name=select1] option')[0].text)
assert.equal('äöü', el.find('[name=select1] option')[1].text)
assert.equal('b', el.find('[name=select1] option')[2].text)
assert.equal('B', el.find('[name=select1] option')[3].text)
assert.equal('XX', el.find('[name=select1] option')[4].text)
});
test("time range form 1", function() {
QUnit.test("time range form 1", assert => {
$('#forms').append('<hr><h1>time range form 1</h1><form id="form14"></form>')
$('#qunit').append('<hr><h1>time range form 1</h1><form id="form14"></form>')
var el = $('#form14')
var defaults = {}
@ -1414,7 +1414,7 @@ test("time range form 1", function() {
}
}
deepEqual(params, test_params, 'base form param range check')
assert.deepEqual(params, test_params, 'base form param range check')
el.find('.js-range').val('minute').trigger('change')
el.find('.js-valueRangeSelector .js-value').val('120').trigger('change')
@ -1426,7 +1426,7 @@ test("time range form 1", function() {
"value": "120"
}
}
deepEqual(params, test_params, 'form param minute range check')
assert.deepEqual(params, test_params, 'form param minute range check')
el.find('.js-range').val('hour').trigger('change')
el.find('.js-valueRangeSelector .js-value').val('48').trigger('change')
@ -1438,7 +1438,7 @@ test("time range form 1", function() {
"value": "48"
}
}
deepEqual(params, test_params, 'form param hour range check')
assert.deepEqual(params, test_params, 'form param hour range check')
el.find('.js-range').val('day').trigger('change')
el.find('.js-valueRangeSelector .js-value').val('31').trigger('change')
@ -1450,7 +1450,7 @@ test("time range form 1", function() {
"value": "31"
}
}
deepEqual(params, test_params, 'form param day range check')
assert.deepEqual(params, test_params, 'form param day range check')
el.find('.js-range').val('month').trigger('change')
el.find('.js-valueRangeSelector .js-value').val('12').trigger('change')
@ -1462,7 +1462,7 @@ test("time range form 1", function() {
"value": "12"
}
}
deepEqual(params, test_params, 'form param month range check')
assert.deepEqual(params, test_params, 'form param month range check')
el.find('.js-range').val('year').trigger('change')
el.find('.js-valueRangeSelector .js-value').val('20').trigger('change')
@ -1474,12 +1474,12 @@ test("time range form 1", function() {
"value": "20"
}
}
deepEqual(params, test_params, 'form param year range check')
assert.deepEqual(params, test_params, 'form param year range check')
});
test("form select with empty option list", function() {
QUnit.test("form select with empty option list", assert => {
$('#forms').append('<hr><h1>form select with empty option list</h1><form id="form15"></form>')
$('#qunit').append('<hr><h1>form select with empty option list</h1><form id="form15"></form>')
var el = $('#form15')
var defaults = {}
new App.ControllerForm({
@ -1506,12 +1506,12 @@ test("form select with empty option list", function() {
select5: 'A',
select6: 'B',
}
deepEqual(params, test_params)
assert.deepEqual(params, test_params)
});
test("form elements with sort check", function() {
QUnit.test("form elements with sort check", assert => {
$('#forms').append('<hr><h1>form elements with sort check</h1><form id="form16"></form>')
$('#qunit').append('<hr><h1>form elements with sort check</h1><form id="form16"></form>')
var el = $('#form16')
var defaults = {}
new App.ControllerForm({
@ -1533,30 +1533,30 @@ test("form elements with sort check", function() {
checkbox1: 'A',
radio1: 'A',
}
deepEqual(params, test_params)
assert.deepEqual(params, test_params)
equal('AA', el.find('[name=select1] option')[0].text)
equal('äöü', el.find('[name=select1] option')[1].text)
equal('b', el.find('[name=select1] option')[2].text)
equal('B', el.find('[name=select1] option')[3].text)
equal('XX', el.find('[name=select1] option')[4].text)
assert.equal('AA', el.find('[name=select1] option')[0].text)
assert.equal('äöü', el.find('[name=select1] option')[1].text)
assert.equal('b', el.find('[name=select1] option')[2].text)
assert.equal('B', el.find('[name=select1] option')[3].text)
assert.equal('XX', el.find('[name=select1] option')[4].text)
equal('XX', el.find('[name=checkbox1]')[0].value)
equal('', el.find('[name=checkbox1]')[1].value)
equal('XY', el.find('[name=checkbox1]')[2].value)
equal('B', el.find('[name=checkbox1]')[3].value)
equal('A', el.find('[name=checkbox1]')[4].value)
assert.equal('XX', el.find('[name=checkbox1]')[0].value)
assert.equal('', el.find('[name=checkbox1]')[1].value)
assert.equal('XY', el.find('[name=checkbox1]')[2].value)
assert.equal('B', el.find('[name=checkbox1]')[3].value)
assert.equal('A', el.find('[name=checkbox1]')[4].value)
equal('XX', el.find('[name=radio1]')[0].value)
equal('', el.find('[name=radio1]')[1].value)
equal('XY', el.find('[name=radio1]')[2].value)
equal('B', el.find('[name=radio1]')[3].value)
equal('A', el.find('[name=radio1]')[4].value)
assert.equal('XX', el.find('[name=radio1]')[0].value)
assert.equal('', el.find('[name=radio1]')[1].value)
assert.equal('XY', el.find('[name=radio1]')[2].value)
assert.equal('B', el.find('[name=radio1]')[3].value)
assert.equal('A', el.find('[name=radio1]')[4].value)
});
test("form deep nesting", function() {
$('#forms').append('<hr><h1>form selector</h1><div><form id="form19"></form></div>')
QUnit.test("form deep nesting", assert => {
$('#qunit').append('<hr><h1>form selector</h1><div><form id="form19"></form></div>')
var el = $('#form19')
var defaults = {
a: {
@ -1580,11 +1580,11 @@ test("form deep nesting", function() {
});
params = App.ControllerForm.params(el)
deepEqual(params, defaults, 'nested params')
assert.deepEqual(params, defaults, 'nested params')
});
test("form with external links", function() {
$('#forms').append('<hr><h1>form with external links</h1><div><form id="form20"></form></div>')
QUnit.test("form with external links", assert => {
$('#qunit').append('<hr><h1>form with external links</h1><div><form id="form20"></form></div>')
var el = $('#form20')
var defaults = {
a: '133',
@ -1603,7 +1603,7 @@ test("form with external links", function() {
});
params = App.ControllerForm.params(el)
deepEqual(params, defaults)
equal('https://example.com/?q=133', el.find('input[name="a"]').parents('.controls').find('a[href]').attr('href'))
equal('https://example.com/?q=abc%20d', el.find('select[name="b"]').parents('.controls').find('a[href]').attr('href'))
assert.deepEqual(params, defaults)
assert.equal('https://example.com/?q=133', el.find('input[name="a"]').parents('.controls').find('a[href]').attr('href'))
assert.equal('https://example.com/?q=abc%20d', el.find('select[name="b"]').parents('.controls').find('a[href]').attr('href'))
});

View file

@ -1,4 +1,4 @@
function check_ajax_field(field, value, count, callback, waitTotal = 30000, wait = 0) {
function check_ajax_field(field, value, count, callback, assert, waitTotal = 30000, wait = 0) {
$elementInput = $('[name="' + field + '"].js-shadow + .js-input')
if ($elementInput.val() != value) {
$elementInput.focus().val(value).trigger('input')
@ -9,22 +9,22 @@ function check_ajax_field(field, value, count, callback, waitTotal = 30000, wait
var match = entries == count
if (match || wait >= waitTotal) {
equal(entries, count, 'search result found for email address ' + value)
assert.equal(entries, count, 'search result found for email address ' + value)
callback()
return
}
wait += 100
if (wait % 3000 == 0) {
ok(true, 'check_ajax_field for ' + field + ' waiting ' + wait)
assert.ok(true, 'check_ajax_field for ' + field + ' waiting ' + wait)
}
setTimeout(function() {
check_ajax_field(field, value, count, callback, waitTotal, wait)
check_ajax_field(field, value, count, callback, assert, waitTotal, wait)
}, 100)
}
test( "autocompletion_ajax check", function(assert) {
QUnit.test( "autocompletion_ajax check", assert => {
var done = assert.async(1)
$('#forms').append('<hr><h1>autocompletion_ajax check</h1><form id="form1"></form>')
@ -57,14 +57,14 @@ test( "autocompletion_ajax check", function(assert) {
})
.then( function() {
return new Promise( (resolve, reject) => {
notEqual(App.Session.get(), undefined, 'User is logged in so the api requests will work')
assert.notEqual(App.Session.get(), undefined, 'User is logged in so the api requests will work')
check_ajax_field('autocompletion_ajax1', 'admin@example.com', 1, resolve)
check_ajax_field('autocompletion_ajax1', 'admin@example.com', 1, resolve, assert)
})
})
.then( function() {
return new Promise( (resolve, reject) => {
check_ajax_field('autocompletion_ajax1', 'xxx@example.com', 0, resolve)
check_ajax_field('autocompletion_ajax1', 'xxx@example.com', 0, resolve, assert)
})
})
.finally(done)

View file

@ -1,4 +1,4 @@
test("form elements check", function(assert) {
QUnit.test("form elements check", assert => {
var done = assert.async(1)
$('#forms').append('<hr><h1>form elements check</h1><form id="form1"></form>')
@ -21,7 +21,7 @@ test("form elements check", function(assert) {
color: '#fff'
}
deepEqual(params, test_params, 'default param check')
assert.deepEqual(params, test_params, 'default param check')
var inputEl = el.find('.js-input')[0]
@ -37,7 +37,7 @@ test("form elements check", function(assert) {
color: ''
}
deepEqual(params, test_params, 'UI allows color field to be empty')
assert.deepEqual(params, test_params, 'UI allows color field to be empty')
})
.then( function() {
previousSwatchColor = getSwatchColor()
@ -51,8 +51,8 @@ test("form elements check", function(assert) {
color: 'rgb(0,100,100)'
}
deepEqual(params, test_params, 'UI allows to type in RGB colors')
notEqual(previousSwatchColor, getSwatchColor(), 'color in swatch was updated')
assert.deepEqual(params, test_params, 'UI allows to type in RGB colors')
assert.notEqual(previousSwatchColor, getSwatchColor(), 'color in swatch was updated')
})
.then( function() {
var circle = el.find('.js-colorpicker-circle')[0]
@ -68,15 +68,15 @@ test("form elements check", function(assert) {
color: 'hsl(169,100%,20%)'
}
deepEqual(params, test_params, 'Color is transformed to HSL after moving the circle')
notEqual(previousSwatchColor, getSwatchColor(), 'color in swatch was updated')
assert.deepEqual(params, test_params, 'Color is transformed to HSL after moving the circle')
assert.notEqual(previousSwatchColor, getSwatchColor(), 'color in swatch was updated')
})
.then( function() {
var slider = el.find('.js-colorpicker-slider')[0]
previousSwatchColor = getSwatchColor()
return new Promise( (resolve,reject) => {
syn.drag(slider, { to: '-0x-10'}, resolve)
syn.drag(slider, { to: '-0x-11'}, resolve)
})
})
.then( function() {
@ -85,8 +85,8 @@ test("form elements check", function(assert) {
color: 'hsl(169,100%,27%)'
}
deepEqual(params, test_params, 'Color code is changed after draging slider')
notEqual(previousSwatchColor, getSwatchColor(), 'color in swatch was updated')
assert.deepEqual(params, test_params, 'Color code is changed after draging slider')
assert.notEqual(previousSwatchColor, getSwatchColor(), 'color in swatch was updated')
})
.then( function() {
let circle = el.find('.js-colorpicker-circle').position()
@ -101,10 +101,10 @@ test("form elements check", function(assert) {
let new_circle = el.find('.js-colorpicker-circle').position()
let new_slider = el.find('.js-colorpicker-slider').position()
notDeepEqual(circle, new_circle, 'Color picker is updated after typing in color')
notDeepEqual(slider, new_slider, 'Color picker is updated after typing in color')
assert.notDeepEqual(circle, new_circle, 'Color picker is updated after typing in color')
assert.notDeepEqual(slider, new_slider, 'Color picker is updated after typing in color')
notEqual(previousSwatchColor, getSwatchColor(), 'color in swatch was updated')
assert.notEqual(previousSwatchColor, getSwatchColor(), 'color in swatch was updated')
})
})
.finally(done)

View file

@ -1,6 +1,6 @@
// column_select
test( "column_select check", function(assert) {
QUnit.test( "column_select check", assert => {
$('#forms').append('<hr><h1>column_select check</h1><form id="form1"></form>')
var el = $('#form1')
var defaults = {
@ -32,7 +32,7 @@ test( "column_select check", function(assert) {
column_select2: ['aaa', 'bbb'],
column_select3: ['1', '2'],
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
// add and remove selections
$('[data-name="column_select1"] .js-pool .js-option[data-value="bbb"]').click()
@ -43,7 +43,7 @@ test( "column_select check", function(assert) {
column_select2: ['aaa', 'bbb'],
column_select3: ['1', '2'],
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
var done = assert.async();
setTimeout(function() {
@ -58,7 +58,7 @@ test( "column_select check", function(assert) {
column_select2: ['1', 'bbb'],
column_select3: ['1', '2', 'aaa'],
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
done();
}, 400);

View file

@ -1,4 +1,4 @@
test("core_workflow_condition", function(assert) {
QUnit.test("core_workflow_condition", assert => {
var form = $('#forms')
var el = $('<div></div>').attr('id', 'form1')
@ -14,20 +14,20 @@ test("core_workflow_condition", function(assert) {
autofocus: true
});
equal(el.find('.js-remove.is-disabled').length, 1, 'find disabled button')
assert.equal(el.find('.js-remove.is-disabled').length, 1, 'find disabled button')
el.find('.js-add').click()
equal(el.find('.js-remove.is-disabled').length, 0, 'find no disabled button after add')
assert.equal(el.find('.js-remove.is-disabled').length, 0, 'find no disabled button after add')
el.find('.js-remove').click()
equal(el.find('.js-remove.is-disabled').length, 1, 'find disabled button after remove')
equal(typeof(App.ControllerForm.params(el).condition_selected), 'object', 'empty element results in a hash')
equal(_.isEmpty(App.ControllerForm.params(el).condition_selected), true, 'empty element results are empty')
assert.equal(el.find('.js-remove.is-disabled').length, 1, 'find disabled button after remove')
assert.equal(typeof(App.ControllerForm.params(el).condition_selected), 'object', 'empty element results in a hash')
assert.equal(_.isEmpty(App.ControllerForm.params(el).condition_selected), true, 'empty element results are empty')
el.find('.js-add').click()
el.find("option[value='ticket.owner_id']").prop('selected', true)
equal(el.find('.js-preCondition').length, 0, 'pre condition not available')
assert.equal(el.find('.js-preCondition').length, 0, 'pre condition not available')
});
test("core_workflow_perform", function(assert) {
QUnit.test("core_workflow_perform", assert => {
var form = $('#forms')
var el = $('<div></div>').attr('id', 'form1')
@ -43,17 +43,17 @@ test("core_workflow_perform", function(assert) {
autofocus: true
});
equal(el.find('.js-remove.is-disabled').length, 1, 'find disabled button')
assert.equal(el.find('.js-remove.is-disabled').length, 1, 'find disabled button')
el.find('.js-add').click()
equal(el.find('.js-remove.is-disabled').length, 0, 'find no disabled button after add')
assert.equal(el.find('.js-remove.is-disabled').length, 0, 'find no disabled button after add')
el.find('.js-remove').click()
equal(el.find('.js-remove.is-disabled').length, 1, 'find disabled button after remove')
equal(typeof(App.ControllerForm.params(el).perform), 'object', 'empty element results in a hash')
equal(_.isEmpty(App.ControllerForm.params(el).perform), true, 'empty element results are empty')
assert.equal(el.find('.js-remove.is-disabled').length, 1, 'find disabled button after remove')
assert.equal(typeof(App.ControllerForm.params(el).perform), 'object', 'empty element results in a hash')
assert.equal(_.isEmpty(App.ControllerForm.params(el).perform), true, 'empty element results are empty')
el.find('.js-add').click()
el.find("option[value='ticket.owner_id']").prop('selected', true)
equal(el.find('.js-preCondition').length, 0, 'pre condition not available')
assert.equal(el.find('.js-preCondition').length, 0, 'pre condition not available')
el.find('.js-add:last').click()
el.find("option[value='ticket.group_id']:last").prop('selected', true)
@ -67,5 +67,5 @@ test("core_workflow_perform", function(assert) {
attribute_count[$(this).val()] ||= 0
attribute_count[$(this).val()] += 1
})
equal(attribute_count['ticket.group_id'], 3, 'hasDuplicateSelector - its possible to select an attribute multiple times')
assert.equal(attribute_count['ticket.group_id'], 3, 'hasDuplicateSelector - its possible to select an attribute multiple times')
});

View file

@ -1,4 +1,4 @@
test("DateTime timepicker focuses hours", function(assert) {
QUnit.test("DateTime timepicker focuses hours", assert => {
var form = $('#forms')
var el = $('<div></div>').attr('id', 'form1')
@ -16,9 +16,9 @@ test("DateTime timepicker focuses hours", function(assert) {
autofocus: true
});
equal(el.find('[data-name=datetime1] [data-item=date]')[0].disabled, false)
equal(el.find('[data-name=datetime1] [data-item=time]')[0].disabled, false)
equal(el.find('[data-name=datetime2] [data-item=date]')[0].disabled, true)
equal(el.find('[data-name=datetime2] [data-item=time]')[0].disabled, true)
equal(el.find('[data-name=date3] [data-item=date]')[0].disabled, true)
assert.equal(el.find('[data-name=datetime1] [data-item=date]')[0].disabled, false)
assert.equal(el.find('[data-name=datetime1] [data-item=time]')[0].disabled, false)
assert.equal(el.find('[data-name=datetime2] [data-item=date]')[0].disabled, true)
assert.equal(el.find('[data-name=datetime2] [data-item=time]')[0].disabled, true)
assert.equal(el.find('[data-name=date3] [data-item=date]')[0].disabled, true)
});

View file

@ -1,6 +1,6 @@
// form
test('form checks', function() {
QUnit.test('form checks', assert => {
// use unsorted order to check if the frontend is sorting correctly
App.TicketPriority.refresh([
@ -222,42 +222,42 @@ test('form checks', function() {
},
},
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
// check possible options
equal(el.find('[name="priority1_id"] option').length, 3)
equal(el.find('[name="priority2_id"] option').length, 4)
equal(el.find('[name="priority3_id"] option').length, 4)
equal(el.find('[name="priority4_id"] option').length, 4)
equal(el.find('[name="priority5_id"] option').length, 3)
assert.equal(el.find('[name="priority1_id"] option').length, 3)
assert.equal(el.find('[name="priority2_id"] option').length, 4)
assert.equal(el.find('[name="priority3_id"] option').length, 4)
assert.equal(el.find('[name="priority4_id"] option').length, 4)
assert.equal(el.find('[name="priority5_id"] option').length, 3)
// check priority1_id selection order
equal(el.find('[name="priority1_id"] option:nth-child(1)').text(), '1 low')
equal(el.find('[name="priority1_id"] option:nth-child(2)').text(), '3 high')
equal(el.find('[name="priority1_id"] option:nth-child(3)').text(), '4 very high')
assert.equal(el.find('[name="priority1_id"] option:nth-child(1)').text(), '1 low')
assert.equal(el.find('[name="priority1_id"] option:nth-child(2)').text(), '3 high')
assert.equal(el.find('[name="priority1_id"] option:nth-child(3)').text(), '4 very high')
// check priority2_id selection order
equal(el.find('[name="priority2_id"] option:nth-child(1)').text(), '1 low')
equal(el.find('[name="priority2_id"] option:nth-child(2)').text(), '2 normal')
equal(el.find('[name="priority2_id"] option:nth-child(3)').text(), '3 high')
equal(el.find('[name="priority2_id"] option:nth-child(4)').text(), '4 very high')
assert.equal(el.find('[name="priority2_id"] option:nth-child(1)').text(), '1 low')
assert.equal(el.find('[name="priority2_id"] option:nth-child(2)').text(), '2 normal')
assert.equal(el.find('[name="priority2_id"] option:nth-child(3)').text(), '3 high')
assert.equal(el.find('[name="priority2_id"] option:nth-child(4)').text(), '4 very high')
// check priority3_id selection order
equal(el.find('[name="priority3_id"] option:nth-child(1)').text(), '1 low')
equal(el.find('[name="priority3_id"] option:nth-child(2)').text(), '2 normal')
equal(el.find('[name="priority3_id"] option:nth-child(3)').text(), '3 high')
equal(el.find('[name="priority3_id"] option:nth-child(4)').text(), '4 very high')
assert.equal(el.find('[name="priority3_id"] option:nth-child(1)').text(), '1 low')
assert.equal(el.find('[name="priority3_id"] option:nth-child(2)').text(), '2 normal')
assert.equal(el.find('[name="priority3_id"] option:nth-child(3)').text(), '3 high')
assert.equal(el.find('[name="priority3_id"] option:nth-child(4)').text(), '4 very high')
// check priority4_id selection order
equal(el.find('[name="priority4_id"] option:nth-child(1)').text(), '1 low')
equal(el.find('[name="priority4_id"] option:nth-child(2)').text(), '2 normal')
equal(el.find('[name="priority4_id"] option:nth-child(3)').text(), '3 high')
equal(el.find('[name="priority4_id"] option:nth-child(4)').text(), '4 very high')
assert.equal(el.find('[name="priority4_id"] option:nth-child(1)').text(), '1 low')
assert.equal(el.find('[name="priority4_id"] option:nth-child(2)').text(), '2 normal')
assert.equal(el.find('[name="priority4_id"] option:nth-child(3)').text(), '3 high')
assert.equal(el.find('[name="priority4_id"] option:nth-child(4)').text(), '4 very high')
// check priority5_id selection order
equal(el.find('[name="priority5_id"] option:nth-child(1)').text(), '1 low')
equal(el.find('[name="priority5_id"] option:nth-child(2)').text(), '3 high')
equal(el.find('[name="priority5_id"] option:nth-child(3)').text(), '4 very high')
assert.equal(el.find('[name="priority5_id"] option:nth-child(1)').text(), '1 low')
assert.equal(el.find('[name="priority5_id"] option:nth-child(2)').text(), '3 high')
assert.equal(el.find('[name="priority5_id"] option:nth-child(3)').text(), '4 very high')
// change sla times
el.find('[name="first_response_time_in_text"]').val('0:30').trigger('blur')
@ -325,7 +325,7 @@ test('form checks', function() {
update_time_enabled: undefined,
update_time_in_text: '',
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
/* empty params or defaults */
$('#forms').append('<hr><h1>form condition check</h1><form id="form2"></form>')
@ -354,7 +354,7 @@ test('form checks', function() {
},
},
}
deepEqual(params, test_params, 'form param check');
assert.deepEqual(params, test_params, 'form param check');
/* with params or defaults */
$('#forms').append('<hr><h1>form 3</h1><form id="form3"></form>')
@ -492,7 +492,7 @@ test('form checks', function() {
},
},
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
// change selector
el.find('[name="condition::ticket.priority_id::value"]').closest('.js-filterElement').find('.js-remove').click()
@ -554,7 +554,7 @@ test('form checks', function() {
},
},
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
// change selector
el.find('[name="executions::notification.email::subject"]').closest('.js-filterElement').find('.js-remove').click()
@ -608,7 +608,7 @@ test('form checks', function() {
},
},
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
// change selector
el.find('.js-attributeSelector').last().find('select').val('notification.email').trigger('change')
@ -668,7 +668,7 @@ test('form checks', function() {
},
},
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
/* with params or defaults */
$('#forms').append('<hr><h1>form 4</h1><form id="form4"></form>')
@ -720,7 +720,7 @@ test('form checks', function() {
},
},
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
$('#forms').append('<hr><h1>form 5</h1><form id="form5"></form>')
var el = $('#form5')
@ -770,5 +770,5 @@ test('form checks', function() {
},
},
}
deepEqual(params, test_params, 'form article body param check')
assert.deepEqual(params, test_params, 'form article body param check')
});

View file

@ -0,0 +1,59 @@
// form
QUnit.test( "find form check", assert => {
$('#forms').append('<hr><h1>find form check</h1><form id="form1"></form>')
var form1 = App.ControllerForm.findForm($('#form1'))
assert.equal(form1.is('form'), true)
$('#forms').append('<hr><h1>find form check</h1><form id="form2"><input class="js-input" value="test 123"></form>')
var form2 = App.ControllerForm.findForm($('#form2 .js-input'))
assert.equal(form2.is('form'), true)
$('#forms').append('<hr><h1>find form check</h1><form id="form3"><input class="js-input" value="test 123"><button class="js-button">text</button></form>')
var form3 = App.ControllerForm.findForm($('#form3 .js-button'))
assert.equal(form3.is('form'), true)
App.ControllerForm.disable($('#form3 .js-button'))
assert.equal($('#form3 .js-button').prop('readonly'), true)
assert.equal($('#form3 .js-button').prop('disabled'), true)
assert.equal($('#form3 .js-input').prop('readonly'), true)
assert.equal($('#form3 .js-input').prop('disabled'), false)
App.ControllerForm.enable($('#form3 .js-button'))
assert.equal($('#form3 .js-button').prop('readonly'), false)
assert.equal($('#form3 .js-button').prop('disabled'), false)
assert.equal($('#form3 .js-input').prop('readonly'), false)
assert.equal($('#form3 .js-input').prop('disabled'), false)
$('#forms').append('<hr><h1>find form check by only disable button</h1><form id="form31"><input class="js-input" value="test 123"><button class="js-button">text</button></form>')
var form31 = App.ControllerForm.findForm($('#form31 .js-button'))
App.ControllerForm.disable($('#form31 .js-button'), 'button')
assert.equal($('#form31 .js-button').prop('readonly'), true)
assert.equal($('#form31 .js-button').prop('disabled'), true)
assert.equal($('#form31 .js-input').prop('readonly'), false)
assert.equal($('#form31 .js-input').prop('disabled'), false)
App.ControllerForm.enable($('#form31 .js-button'))
assert.equal($('#form31 .js-button').prop('readonly'), false)
assert.equal($('#form31 .js-button').prop('disabled'), false)
assert.equal($('#form31 .js-input').prop('readonly'), false)
assert.equal($('#form31 .js-input').prop('disabled'), false)
$('#forms').append('<hr><h1>find form check</h1><div id="form4"><input class="js-input" value="test 123"><button class="js-button">text</button></div>')
var form4 = App.ControllerForm.findForm($('#form4 .js-button'))
assert.equal(form4.is('form'), false)
App.ControllerForm.disable($('#form4 .js-button'))
assert.equal($('#form4 .js-button').prop('readonly'), true)
assert.equal($('#form4 .js-button').prop('disabled'), true)
assert.equal($('#form4 .js-input').prop('readonly'), false)
assert.equal($('#form4 .js-input').prop('disabled'), false)
App.ControllerForm.enable($('#form4 .js-button'))
assert.equal($('#form4 .js-button').prop('readonly'), false)
assert.equal($('#form4 .js-button').prop('disabled'), false)
assert.equal($('#form4 .js-input').prop('readonly'), false)
assert.equal($('#form4 .js-input').prop('disabled'), false)
});

View file

@ -1,5 +1,5 @@
// searchable_select
test( "searchable_select check", function() {
QUnit.test( "searchable_select check", assert => {
$('#forms').append('<hr><h1>searchable_select check</h1><form id="form1"></form>')
var el = $('#form1')
@ -70,16 +70,16 @@ test( "searchable_select check", function() {
searchable_select3: '',
searchable_select4: 'ccc',
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
// change selection
$('[name="searchable_select1"].js-shadow + .js-input').focus().val('').trigger('input')
var $element = $('[name="searchable_select1"]').closest('.searchableSelect').find('.js-optionsList')
var entries = $element.find('li:not(.is-hidden)').length
equal(entries, 3, 'dropdown count')
assert.equal(entries, 3, 'dropdown count')
$('[name="searchable_select1"].js-shadow + .js-input').focus().val('ccc display').trigger('input')
var entries = $element.find('li:not(.is-hidden)').length
equal(entries, 1, 'dropdown count')
assert.equal(entries, 1, 'dropdown count')
$element.find('li:not(.is-hidden)').first().click()
params = App.ControllerForm.params(el)
test_params = {
@ -88,15 +88,15 @@ test( "searchable_select check", function() {
searchable_select3: '',
searchable_select4: 'ccc',
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
$('[name="searchable_select2"].js-shadow + .js-input').focus().val('').trigger('input')
var $element = $('[name="searchable_select2"]').closest('.searchableSelect').find('.js-optionsList')
var entries = $element.find('li:not(.is-hidden)').length
equal(entries, 3, 'dropdown count')
assert.equal(entries, 3, 'dropdown count')
$('[name="searchable_select2"].js-shadow + .js-input').focus().val('ccc display').trigger('input')
var entries = $element.find('li:not(.is-hidden)').length
equal(entries, 1, 'dropdown count')
assert.equal(entries, 1, 'dropdown count')
$element.find('li:not(.is-hidden)').first().click()
params = App.ControllerForm.params(el)
@ -106,20 +106,20 @@ test( "searchable_select check", function() {
searchable_select3: '',
searchable_select4: 'ccc',
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
$('[name="searchable_select3"].js-shadow + .js-input').focus().val('').trigger('input')
var $element = $('[name="searchable_select3"]').closest('.searchableSelect').find('.js-optionsList')
var entries = $element.find('li:not(.is-hidden)').length
equal(entries, 3, 'dropdown count')
assert.equal(entries, 3, 'dropdown count')
$('[name="searchable_select3"].js-shadow + .js-input').focus().val('ccc display').trigger('input')
var entries = $element.find('li:not(.is-hidden)').length
equal(entries, 1, 'dropdown count')
assert.equal(entries, 1, 'dropdown count')
$('[name="searchable_select3"].js-shadow + .js-input').focus().val('unknown value').trigger('input')
var entries = $element.find('li:not(.is-hidden)').length
equal(entries, 3, 'dropdown count')
assert.equal(entries, 3, 'dropdown count')
var entries = $element.find('li.is-active').length
equal(entries, 0, 'active count')
assert.equal(entries, 0, 'active count')
var e = $.Event('keydown')
e.which = 13 //enter
@ -133,7 +133,7 @@ test( "searchable_select check", function() {
searchable_select3: 'unknown value',
searchable_select4: 'ccc',
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
$('#forms').append('<hr><h1>searchable_select check for .js-input field values</h1><form id="form2"></form>')
var el = $('#form2')
@ -179,14 +179,14 @@ test( "searchable_select check", function() {
searchable_select1: 'ccc::aaa',
searchable_select2: 'ccc::ccc',
}
deepEqual(params, test_params, 'form param check')
equal(el.find('[name="searchable_select1"].js-shadow + .js-input').val(), 'aaa display L2', 'verify shown input')
equal(el.find('[name="searchable_select2"].js-shadow + .js-input').val(), 'ccc display L2', 'verify shown input')
assert.deepEqual(params, test_params, 'form param check')
assert.equal(el.find('[name="searchable_select1"].js-shadow + .js-input').val(), 'aaa display L2', 'verify shown input')
assert.equal(el.find('[name="searchable_select2"].js-shadow + .js-input').val(), 'ccc display L2', 'verify shown input')
});
asyncTest("searchable_select submenu and option list check", function() {
expect(3);
QUnit.test("searchable_select submenu and option list check", assert => {
var done = assert.async()
$('#forms').append('<hr><h1>searchable_select check for special charaters values</h1><form id="form3"></form>')
var el = $('#form3')
@ -232,10 +232,10 @@ asyncTest("searchable_select submenu and option list check", function() {
var optionsList = el.find(".searchableSelect .js-optionsList")
setTimeout( () => {
deepEqual(params, test_params, 'form param check')
equal(optionsSubmenu.is('[hidden]'), false, 'options submenu menu not hidden')
equal(optionsList.is('[hidden]'), true, 'options list is hidden')
start();
assert.deepEqual(params, test_params, 'form param check')
assert.equal(optionsSubmenu.is('[hidden]'), false, 'options submenu menu not hidden')
assert.equal(optionsList.is('[hidden]'), true, 'options list is hidden')
done()
}, 300)
});

View file

@ -1,4 +1,4 @@
test("form elements not rendered", function(assert) {
QUnit.test("form elements not rendered", assert => {
$('#forms').append('<hr><h1>form elements check</h1><form id="form1"></form>')
var el = $('#form1')
@ -14,6 +14,6 @@ test("form elements not rendered", function(assert) {
autofocus: true
});
ok(el.find('input[name=shown]').get(0), 'control element is visible')
notOk(el.find('input[name=hidden]').get(0), 'element with skipRendering is not shown')
assert.ok(el.find('input[name=shown]').get(0), 'control element is visible')
assert.notOk(el.find('input[name=hidden]').get(0), 'element with skipRendering is not shown')
});

View file

@ -1,4 +1,4 @@
test("form SLA times highlights first row and sets 2:00 by default for new item", function(assert) {
QUnit.test("form SLA times highlights first row and sets 2:00 by default for new item", function(assert) {
$('#forms').append('<hr><h1>SLA with defaults</h1><form id="form1"></form>')
var el = $('#form1')
@ -13,8 +13,8 @@ test("form SLA times highlights first row and sets 2:00 by default for new item"
var row = el.find('.sla_times tbody > tr:first')
ok(row.hasClass('is-active'))
equal(row.find('input[data-name=first_response_time]').val(), '02:00')
assert.ok(row.hasClass('is-active'))
assert.equal(row.find('input[data-name=first_response_time]').val(), '02:00')
$('#forms').append('<hr><h1>SLA with empty times</h1><form id="form2"></form>')
@ -31,11 +31,11 @@ test("form SLA times highlights first row and sets 2:00 by default for new item"
var row = el.find('.sla_times tbody > tr:first')
notOk(row.hasClass('is-active'))
equal(row.find('input[data-name=first_response_time]').val(), '')
assert.notOk(row.hasClass('is-active'))
assert.equal(row.find('input[data-name=first_response_time]').val(), '')
});
test("form SLA times highlights and shows settings accordingly", function(assert) {
QUnit.test("form SLA times highlights and shows settings accordingly", function(assert) {
$('#forms').append('<hr><h1>SLA with non-first time set</h1><form id="form3"></form>')
var el = $('#form3')
@ -53,13 +53,13 @@ test("form SLA times highlights and shows settings accordingly", function(assert
var firstRow = el.find('.sla_times tbody > tr:first')
var secondRow = el.find('.sla_times tbody > tr:nth-child(2)')
notOk(firstRow.hasClass('is-active'))
equal(firstRow.find('input[data-name=first_response_time]').val(), '')
ok(secondRow.hasClass('is-active'))
equal(secondRow.find('input[data-name=update_time]').val(), '04:00')
assert.notOk(firstRow.hasClass('is-active'))
assert.equal(firstRow.find('input[data-name=first_response_time]').val(), '')
assert.ok(secondRow.hasClass('is-active'))
assert.equal(secondRow.find('input[data-name=update_time]').val(), '04:00')
})
test("form SLA times clears field instead of 00:00", function(assert) {
QUnit.test("form SLA times clears field instead of 00:00", function(assert) {
$('#forms').append('<hr><h1>SLA placeholder instead of 00:00</h1><form id="form5"></form>')
var el = $('#form5')
@ -77,5 +77,5 @@ test("form SLA times clears field instead of 00:00", function(assert) {
input.val('asd').blur()
equal(input.val(), '', 'shows placeholder')
assert.equal(input.val(), '', 'shows placeholder')
});

View file

@ -1,5 +1,5 @@
// ticket_perform_action
test( "ticket_perform_action check", function(assert) {
QUnit.test( "ticket_perform_action check", assert => {
App.TicketPriority.refresh([
{
@ -120,7 +120,7 @@ test( "ticket_perform_action check", function(assert) {
}
}
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
// add email notification
$('[data-attribute-name="ticket_perform_action3"] .js-add').click()
@ -164,7 +164,7 @@ test( "ticket_perform_action check", function(assert) {
}
}
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
// remove recipient
$('[data-attribute-name="ticket_perform_action2"] .js-setNotification .js-recipient .js-remove.js-option[data-value="ticket_owner"]').click()
@ -204,7 +204,7 @@ test( "ticket_perform_action check", function(assert) {
}
}
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
// set notification to internal
$('[data-attribute-name="ticket_perform_action2"] .js-internal select').val('true').trigger('change')
@ -244,7 +244,7 @@ test( "ticket_perform_action check", function(assert) {
}
}
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
// add pending time
$('[data-attribute-name="ticket_perform_action3"] .js-add').last().click()
@ -302,7 +302,7 @@ test( "ticket_perform_action check", function(assert) {
setTimeout(function(){
params = App.ControllerForm.params(el)
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
done()
}, 0);
@ -352,11 +352,11 @@ test( "ticket_perform_action check", function(assert) {
}
}
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
});
// Test for backwards compatibility after issue is fixed https://github.com/zammad/zammad/issues/2782
test( "ticket_perform_action backwards check after issue #2782", function() {
QUnit.test( "ticket_perform_action backwards check after issue #2782", assert => {
$('#forms').append('<hr><h1>ticket_perform_action check</h1><form id="form2"></form>')
var el = $('#form2')
@ -401,10 +401,10 @@ test( "ticket_perform_action backwards check after issue #2782", function() {
}
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
});
test( "ticket_perform_action rows manipulation", function() {
QUnit.test( "ticket_perform_action rows manipulation", assert => {
App.TicketPriority.refresh([
{
id: 2,
@ -461,29 +461,29 @@ test( "ticket_perform_action rows manipulation", function() {
autofocus: true
})
equal(true, true)
assert.equal(true, true)
var selector = '[data-attribute-name="ticket_perform_action99"] '
$(selector + '.js-remove').click()
equal($(selector + '.js-filterElement').length, 1, 'prevents removing single initial row')
assert.equal($(selector + '.js-filterElement').length, 1, 'prevents removing single initial row')
$(selector + '.js-add').click()
equal($(selector + '.js-filterElement').length, 2, 'adds 2nd row')
assert.equal($(selector + '.js-filterElement').length, 2, 'adds 2nd row')
$(selector + ' .js-remove:last').click()
equal($(selector + '.js-filterElement').length, 1, 'removes 2nd row')
assert.equal($(selector + '.js-filterElement').length, 1, 'removes 2nd row')
$(selector + '.js-remove:last').click()
equal($(selector + ' .js-filterElement').length, 1, 'prevents removing last row')
assert.equal($(selector + ' .js-filterElement').length, 1, 'prevents removing last row')
});
// Test for backwards compatibility after PR https://github.com/zammad/zammad/pull/2862
test( "ticket_perform_action backwards check after PR#2862", function() {
QUnit.test( "ticket_perform_action backwards check after PR#2862", assert => {
$('#forms').append('<hr><h1>ticket_perform_action check</h1><form id="form3"></form>')
var el = $('#form3')
@ -522,10 +522,10 @@ test( "ticket_perform_action backwards check after PR#2862", function() {
}
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
});
test( "ticket_perform_action orphan time fields", function() {
QUnit.test( "ticket_perform_action orphan time fields", assert => {
$('#forms').append('<hr><h1>ticket_perform_action orphan time fields</h1><form id="form4"></form>')
var el = $('#form4')
@ -558,10 +558,10 @@ test( "ticket_perform_action orphan time fields", function() {
// change to another attribute
el.find('select:first').val('ticket.tags').trigger('change')
equal(el.find('.js-valueRangeSelector').length, 0)
assert.equal(el.find('.js-valueRangeSelector').length, 0)
});
test( "ticket_perform_action check possible owner selection", function() {
QUnit.test( "ticket_perform_action check possible owner selection", assert => {
$('#forms').append('<hr><h1>ticket_perform_action check possible owner selection</h1><form id="form5"></form>')
var el = $('#form5')
@ -601,7 +601,7 @@ test( "ticket_perform_action check possible owner selection", function() {
}
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
el.find('[name="ticket_perform_action5::ticket.owner_id::pre_condition"]').val('specific').trigger('change')
@ -616,11 +616,11 @@ test( "ticket_perform_action check possible owner selection", function() {
}
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
});
test( "ticket_perform_action check when there's no available webhook", function() {
QUnit.test( "ticket_perform_action check when there's no available webhook", assert => {
$('#forms').append('<hr><h1>ticket_perform_action check when there\'s no available webhook</h1><form id="form6"></form>')
var el = $('#form6')
@ -649,14 +649,14 @@ test( "ticket_perform_action check when there's no available webhook", function(
})
var params = App.ControllerForm.params(el)
deepEqual(params, {}, 'form param check')
assert.deepEqual(params, {}, 'form param check')
var testNoticeMessage = 'No available webhook, please create a new one or activate an existing one at "Manage > Webhook"'
var noticeMessage = el.find('.controls.js-webhooks div').text()
equal(noticeMessage, testNoticeMessage, 'form shows message when webhook is not available')
assert.equal(noticeMessage, testNoticeMessage, 'form shows message when webhook is not available')
});
test( "ticket_perform_action check when there's an available webhook", function() {
QUnit.test( "ticket_perform_action check when there's an available webhook", assert => {
$('#forms').append('<hr><h1>ticket_perform_action check when there\'s an available webhook</h1><form id="form7"></form>')
var el = $('#form7')
@ -702,12 +702,12 @@ test( "ticket_perform_action check when there's an available webhook", function(
}
}
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
var testNoticeMessage = 'No available webhook, please create a new one or activate an existing one at "Manage > Webhook"'
var noticeMessage = el.find('.controls.js-webhooks').text()
notEqual(noticeMessage, testNoticeMessage, 'form does not show notice message when webhook is available')
assert.notEqual(noticeMessage, testNoticeMessage, 'form does not show notice message when webhook is available')
var noticeMessage = el.find('.controls.js-webhooks select option').eq(1).text()
equal(noticeMessage, 'Webhook test (https://target.example.com/webhook)', 'form shows available webhook when webhook is available')
assert.equal(noticeMessage, 'Webhook test (https://target.example.com/webhook)', 'form shows available webhook when webhook is available')
});

View file

@ -1,5 +1,4 @@
test("form elements check", function() {
QUnit.test("form elements check", assert => {
$('#forms').append('<hr><h1>form elements check</h1><form id="form1"></form>')
var el = $('#form1')
@ -16,7 +15,7 @@ test("form elements check", function() {
autofocus: true
});
equal('Run every Monday at 00:00 in UTC time', el.find('.js-timerResult').text())
assert.equal('Run every Monday at 00:00 in UTC time', el.find('.js-timerResult').text())
var params = App.ControllerForm.params(el)
var test_params = {
@ -67,7 +66,7 @@ test("form elements check", function() {
},
},
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
$('#forms').append('<hr><h1>form elements check</h1><form id="form2"></form>')
var el = $('#form2')
@ -101,7 +100,7 @@ test("form elements check", function() {
autofocus: true
});
equal('Run every Monday and Friday at 00:00, 00:10, 00:50, 10:00, 10:10, 10:50, 16:00, 16:10 and 16:50 in UTC time', el.find('.js-timerResult').text())
assert.equal('Run every Monday and Friday at 00:00, 00:10, 00:50, 10:00, 10:10, 10:50, 16:00, 16:10 and 16:50 in UTC time', el.find('.js-timerResult').text())
var params = App.ControllerForm.params(el)
var test_params = {
@ -152,13 +151,13 @@ test("form elements check", function() {
},
},
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
$('#form2 .js-day [data-value="Sat"]').click()
$('#form2 .js-hour [data-value="16"]').click()
$('#form2 .js-minute [data-value="10"]').click()
equal('Run every Monday, Friday and Saturday at 00:00, 00:50, 10:00 and 10:50 in UTC time', el.find('.js-timerResult').text())
assert.equal('Run every Monday, Friday and Saturday at 00:00, 00:50, 10:00 and 10:50 in UTC time', el.find('.js-timerResult').text())
var params = App.ControllerForm.params(el)
var test_params = {
@ -209,6 +208,6 @@ test("form elements check", function() {
},
},
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
});

View file

@ -1,4 +1,4 @@
test("form elements check", function() {
QUnit.test("form elements check", assert => {
$('#forms').append('<hr><h1>form elements check</h1><form id="form1"></form>')
var el = $('#form1')
new App.ControllerForm({
@ -54,13 +54,13 @@ test("form elements check", function() {
},
autofocus: true
});
equal(el.find('[name="tree_select"]').val(), '', 'check tree_select value');
equal(el.find('[name="tree_select"]').closest('.searchableSelect').find('.js-input').val(), '', 'check tree_select .js-input value');
assert.equal(el.find('[name="tree_select"]').val(), '', 'check tree_select value');
assert.equal(el.find('[name="tree_select"]').closest('.searchableSelect').find('.js-input').val(), '', 'check tree_select .js-input value');
var params = App.ControllerForm.params(el)
var test_params = {
tree_select: ''
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
$('#forms').append('<hr><h1>form elements check</h1><form id="form2"></form>')
var el = $('#form2')
@ -119,13 +119,13 @@ test("form elements check", function() {
autofocus: true
});
equal(el.find('[name="tree_select"]').val(), 'aa', 'check tree_select value');
equal(el.find('[name="tree_select"]').closest('.searchableSelect').find('.js-input').val(), 'yes', 'check tree_select .js-input value');
assert.equal(el.find('[name="tree_select"]').val(), 'aa', 'check tree_select value');
assert.equal(el.find('[name="tree_select"]').closest('.searchableSelect').find('.js-input').val(), 'yes', 'check tree_select .js-input value');
var params = App.ControllerForm.params(el)
var test_params = {
tree_select: 'aa'
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
$('#forms').append('<hr><h1>form elements check</h1><form id="form3"></form>')
var el = $('#form3')
@ -183,13 +183,13 @@ test("form elements check", function() {
},
autofocus: true
});
equal(el.find('[name="tree_select"]').val(), 'aa::aab', 'check tree_select value');
equal(el.find('[name="tree_select"]').closest('.searchableSelect').find('.js-input').val(), 'yes2', 'check tree_select .js-input value');
assert.equal(el.find('[name="tree_select"]').val(), 'aa::aab', 'check tree_select value');
assert.equal(el.find('[name="tree_select"]').closest('.searchableSelect').find('.js-input').val(), 'yes2', 'check tree_select .js-input value');
var params = App.ControllerForm.params(el)
var test_params = {
tree_select: 'aa::aab'
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
$('#forms').append('<hr><h1>form elements check</h1><form id="form4"></form>')
var el = $('#form4')
@ -265,13 +265,12 @@ test("form elements check", function() {
var test_params = {
tree_select_search: ['aa::aab', 'aa::aac::33', 'bb'],
}
deepEqual(params, test_params, 'form param check')
assert.deepEqual(params, test_params, 'form param check')
});
asyncTest("searchable_select submenu and option list check", function() {
expect(3);
QUnit.test("searchable_select submenu and option list check", assert => {
var done = assert.async()
$('#forms').append('<hr><h1>form elements check</h1><form id="form5"></form>')
var el = $('#form5')
@ -344,10 +343,11 @@ asyncTest("searchable_select submenu and option list check", function() {
var optionsList = el.find(".searchableSelect .js-optionsList")
setTimeout( () => {
deepEqual(params, test_params, 'form param check')
equal(optionsSubmenu.is('[hidden]'), false, 'options submenu menu not hidden')
equal(optionsList.is('[hidden]'), true, 'options list is hidden')
start();
assert.deepEqual(params, test_params, 'form param check')
assert.equal(optionsSubmenu.is('[hidden]'), false, 'options submenu menu not hidden')
assert.equal(optionsList.is('[hidden]'), true, 'options list is hidden')
done()
}, 300)
});

View file

@ -1,5 +1,5 @@
test( 'form trim checks', function() {
QUnit.test( 'form trim checks', assert => {
var el = $('#form1')
var test_params = {
@ -28,6 +28,6 @@ test( 'form trim checks', function() {
var params = App.ControllerForm.params( el )
deepEqual( params, test_params, 'form param check' )
assert.deepEqual( params, test_params, 'form param check' )
})

View file

@ -1,4 +1,4 @@
test('form validation check', function() {
QUnit.test('form validation check', assert => {
$('#forms').append('<hr><h1>form params check</h1><form id="form1"></form>')
@ -22,27 +22,27 @@ test('form validation check', function() {
},
params: defaults,
});
equal(el.find('[name="input1"]').val(), '', 'check input1 value')
equal(el.find('[name="input1"]').prop('required'), true, 'check input1 required')
// equal(el.find('[name="input1"]').is(":focus"), true, 'check input1 focus')
assert.equal(el.find('[name="input1"]').val(), '', 'check input1 value')
assert.equal(el.find('[name="input1"]').prop('required'), true, 'check input1 required')
// assert.equal(el.find('[name="input1"]').is(":focus"), true, 'check input1 focus')
equal(el.find('[name="password1"]').val(), '', 'check password1 value')
equal(el.find('[name="password1_confirm"]').val(), '', 'check password1 value')
equal(el.find('[name="password1"]').prop('required'), true, 'check password1 required')
assert.equal(el.find('[name="password1"]').val(), '', 'check password1 value')
assert.equal(el.find('[name="password1_confirm"]').val(), '', 'check password1 value')
assert.equal(el.find('[name="password1"]').prop('required'), true, 'check password1 required')
equal(el.find('[name="textarea1"]').val(), '', 'check textarea1 value')
equal(el.find('[name="textarea1"]').prop('required'), true, 'check textarea1 required')
assert.equal(el.find('[name="textarea1"]').val(), '', 'check textarea1 value')
assert.equal(el.find('[name="textarea1"]').prop('required'), true, 'check textarea1 required')
equal(el.find('[name="select1"]').val(), '', 'check select1 value')
equal(el.find('[name="select1"]').prop('required'), true, 'check select1 required')
assert.equal(el.find('[name="select1"]').val(), '', 'check select1 value')
assert.equal(el.find('[name="select1"]').prop('required'), true, 'check select1 required')
equal(el.find('[name="selectmulti1"]').val(), '', 'check selectmulti1 value')
equal(el.find('[name="selectmulti1"]').prop('required'), true, 'check selectmulti1 required')
assert.equal(el.find('[name="selectmulti1"]').val(), '', 'check selectmulti1 value')
assert.equal(el.find('[name="selectmulti1"]').prop('required'), true, 'check selectmulti1 required')
equal(el.find('[name="autocompletion1"]').val(), '', 'check autocompletion1 value')
equal(el.find('[name="autocompletion1"]').prop('required'), true, 'check autocompletion1 required')
assert.equal(el.find('[name="autocompletion1"]').val(), '', 'check autocompletion1 value')
assert.equal(el.find('[name="autocompletion1"]').prop('required'), true, 'check autocompletion1 required')
equal(el.find('[data-name="richtext1"]').val(), '', 'check richtext1 value')
assert.equal(el.find('[data-name="richtext1"]').val(), '', 'check richtext1 value')
//equal(el.find('[data-name="richtext1"]').prop('required'), true, 'check richtext1 required')
params = App.ControllerForm.params(el)
@ -59,40 +59,40 @@ test('form validation check', function() {
datetime1: 'is required',
date1: 'is required',
}
deepEqual(errors, test_errors, 'validation errors check')
assert.deepEqual(errors, test_errors, 'validation errors check')
App.ControllerForm.validate({ errors: errors, form: el })
equal(el.find('[name="input1"]').closest('.form-group').hasClass('has-error'), true, 'check input1 has-error')
equal(el.find('[name="input1"]').closest('.form-group').find('.help-inline').text(), 'is required', 'check input1 error message')
assert.equal(el.find('[name="input1"]').closest('.form-group').hasClass('has-error'), true, 'check input1 has-error')
assert.equal(el.find('[name="input1"]').closest('.form-group').find('.help-inline').text(), 'is required', 'check input1 error message')
equal(el.find('[name="password1"]').closest('.form-group').hasClass('has-error'), true, 'check password1 has-error')
equal(el.find('[name="password1"]').closest('.form-group').find('.help-inline').text(), 'is required', 'check password1 error message')
assert.equal(el.find('[name="password1"]').closest('.form-group').hasClass('has-error'), true, 'check password1 has-error')
assert.equal(el.find('[name="password1"]').closest('.form-group').find('.help-inline').text(), 'is required', 'check password1 error message')
equal(el.find('[name="textarea1"]').closest('.form-group').hasClass('has-error'), true, 'check textarea1 has-error')
equal(el.find('[name="textarea1"]').closest('.form-group').find('.help-inline').text(), 'is required', 'check textarea1 error message')
assert.equal(el.find('[name="textarea1"]').closest('.form-group').hasClass('has-error'), true, 'check textarea1 has-error')
assert.equal(el.find('[name="textarea1"]').closest('.form-group').find('.help-inline').text(), 'is required', 'check textarea1 error message')
equal(el.find('[name="select1"]').closest('.form-group').hasClass('has-error'), true, 'check select1 has-error')
equal(el.find('[name="select1"]').closest('.form-group').find('.help-inline').text(), 'is required', 'check select1 error message')
assert.equal(el.find('[name="select1"]').closest('.form-group').hasClass('has-error'), true, 'check select1 has-error')
assert.equal(el.find('[name="select1"]').closest('.form-group').find('.help-inline').text(), 'is required', 'check select1 error message')
equal(el.find('[name="selectmulti1"]').closest('.form-group').hasClass('has-error'), true, 'check selectmulti1 has-error')
equal(el.find('[name="selectmulti1"]').closest('.form-group').find('.help-inline').text(), 'is required', 'check selectmulti1 error message')
assert.equal(el.find('[name="selectmulti1"]').closest('.form-group').hasClass('has-error'), true, 'check selectmulti1 has-error')
assert.equal(el.find('[name="selectmulti1"]').closest('.form-group').find('.help-inline').text(), 'is required', 'check selectmulti1 error message')
equal(el.find('[name="autocompletion1"]').closest('.form-group').hasClass('has-error'), true, 'check autocompletion1 has-error')
equal(el.find('[name="autocompletion1"]').closest('.form-group').find('.help-inline').text(), 'is required', 'check autocompletion1 error message')
assert.equal(el.find('[name="autocompletion1"]').closest('.form-group').hasClass('has-error'), true, 'check autocompletion1 has-error')
assert.equal(el.find('[name="autocompletion1"]').closest('.form-group').find('.help-inline').text(), 'is required', 'check autocompletion1 error message')
equal(el.find('[data-name="richtext1"]').closest('.form-group').hasClass('has-error'), true, 'check richtext1 has-error')
equal(el.find('[data-name="richtext1"]').closest('.form-group').find('.help-inline').text(), 'is required', 'check richtext1 error message')
assert.equal(el.find('[data-name="richtext1"]').closest('.form-group').hasClass('has-error'), true, 'check richtext1 has-error')
assert.equal(el.find('[data-name="richtext1"]').closest('.form-group').find('.help-inline').text(), 'is required', 'check richtext1 error message')
equal(el.find('[data-name="datetime1"]').closest('.form-group').hasClass('has-error'), true, 'check datetime1 has-error')
equal(el.find('[data-name="datetime1"]').closest('.form-group').find('.help-inline').text(), 'is required', 'check datetime1 error message')
assert.equal(el.find('[data-name="datetime1"]').closest('.form-group').hasClass('has-error'), true, 'check datetime1 has-error')
assert.equal(el.find('[data-name="datetime1"]').closest('.form-group').find('.help-inline').text(), 'is required', 'check datetime1 error message')
equal(el.find('[data-name="date1"]').closest('.form-group').hasClass('has-error'), true, 'check date1 has-error')
equal(el.find('[data-name="date1"]').closest('.form-group').find('.help-inline').text(), 'is required', 'check date1 error message')
assert.equal(el.find('[data-name="date1"]').closest('.form-group').hasClass('has-error'), true, 'check date1 has-error')
assert.equal(el.find('[data-name="date1"]').closest('.form-group').find('.help-inline').text(), 'is required', 'check date1 error message')
});
test('datetime validation check', function() {
QUnit.test('datetime validation check', assert => {
$('#forms').append('<hr><h1>datetime validation check</h1><form id="form2"></form>')
@ -113,17 +113,17 @@ test('datetime validation check', function() {
test_params = {
datetime1: null,
}
deepEqual(params, test_params, 'params check')
assert.deepEqual(params, test_params, 'params check')
errors = form.validate(params)
test_errors = {
datetime1: 'is required',
}
deepEqual(errors, test_errors, 'validation errors check')
assert.deepEqual(errors, test_errors, 'validation errors check')
App.ControllerForm.validate({ errors: errors, form: el })
equal(el.find('[data-name="datetime1"]').closest('.form-group').hasClass('has-error'), true, 'check datetime1 has-error')
equal(el.find('[data-name="datetime1"]').closest('.form-group').find('.help-inline').text(), 'is required', 'check datetime1 error message')
assert.equal(el.find('[data-name="datetime1"]').closest('.form-group').hasClass('has-error'), true, 'check datetime1 has-error')
assert.equal(el.find('[data-name="datetime1"]').closest('.form-group').find('.help-inline').text(), 'is required', 'check datetime1 error message')
//equal(el.find('[data-name="datetime1"]').closest('.form-group').find('.help-inline').text(), '', 'check datetime1 error message')
// set new values
@ -139,38 +139,38 @@ test('datetime validation check', function() {
test_params = {
datetime1: timeStamp.toISOString(),
}
deepEqual(params, test_params, 'params check')
assert.deepEqual(params, test_params, 'params check')
// check errors
errors = form.validate(params)
test_errors = undefined
deepEqual(errors, test_errors, 'validation errors check')
assert.deepEqual(errors, test_errors, 'validation errors check')
App.ControllerForm.validate({ errors: errors, form: el })
equal(el.find('[data-name="datetime1"]').closest('.form-group').hasClass('has-error'), false, 'check datetime1 has-error')
equal(el.find('[data-name="datetime1"]').closest('.form-group').find('.help-inline').text(), '', 'check datetime1 error message')
assert.equal(el.find('[data-name="datetime1"]').closest('.form-group').hasClass('has-error'), false, 'check datetime1 has-error')
assert.equal(el.find('[data-name="datetime1"]').closest('.form-group').find('.help-inline').text(), '', 'check datetime1 error message')
el.find('[data-name="datetime1"] [data-item="date"]').val('').trigger('blur')
el.find('[data-name="datetime1"] [data-item="date"]').datepicker('setDate')
el.find('[data-name="datetime1"] [data-item="time"]').val('12:42').trigger('blur')
el.find('[data-name="datetime1"] [data-item="time"]').trigger('change')
equal(el.find('[data-name="datetime1"]').closest('.form-group').hasClass('has-error'), true )
assert.equal(el.find('[data-name="datetime1"]').closest('.form-group').hasClass('has-error'), true )
params = App.ControllerForm.params(el)
errors = form.validate(params)
test_errors = {
datetime1: 'is required',
}
deepEqual(errors, test_errors, 'validation errors check')
assert.deepEqual(errors, test_errors, 'validation errors check')
App.ControllerForm.validate({ errors: errors, form: el })
equal(el.find('[data-name="datetime1"]').closest('.form-group').hasClass('has-error'), true, 'check datetime1 no has-error')
equal(el.find('[data-name="datetime1"]').closest('.form-group').find('.help-inline').text(), 'is required', 'check datetime1 error message')
assert.equal(el.find('[data-name="datetime1"]').closest('.form-group').hasClass('has-error'), true, 'check datetime1 no has-error')
assert.equal(el.find('[data-name="datetime1"]').closest('.form-group').find('.help-inline').text(), 'is required', 'check datetime1 error message')
});
test('date validation check', function() {
QUnit.test('date validation check', assert => {
$('#forms').append('<hr><h1>date validation check</h1><form id="form3"></form>')
@ -193,17 +193,17 @@ test('date validation check', function() {
test_params = {
date2: null,
}
deepEqual(params, test_params, 'params check')
assert.deepEqual(params, test_params, 'params check')
errors = form.validate(params)
test_errors = {
date2: 'is required',
}
deepEqual(errors, test_errors, 'validation errors check')
assert.deepEqual(errors, test_errors, 'validation errors check')
App.ControllerForm.validate({ errors: errors, form: el })
equal(el.find('[data-name="date2"]').closest('.form-group').hasClass('has-error'), true, 'check date2 has-error')
equal(el.find('[data-name="date2"]').closest('.form-group').find('.help-inline').text(), 'is required', 'check date2 error message')
assert.equal(el.find('[data-name="date2"]').closest('.form-group').hasClass('has-error'), true, 'check date2 has-error')
assert.equal(el.find('[data-name="date2"]').closest('.form-group').find('.help-inline').text(), 'is required', 'check date2 error message')
// set new values
el.find('[data-name="date2"] [data-item="date"]').val('01/01/2015').trigger('blur')
@ -215,42 +215,42 @@ test('date validation check', function() {
test_params = {
date2: '2015-01-01',
}
deepEqual(params, test_params, 'params check')
assert.deepEqual(params, test_params, 'params check')
// check errors
errors = form.validate(params)
test_errors = undefined
deepEqual(errors, test_errors, 'validation errors check')
assert.deepEqual(errors, test_errors, 'validation errors check')
App.ControllerForm.validate({ errors: errors, form: el })
equal(el.find('[data-name="date2"]').closest('.form-group').hasClass('has-error'), false, 'check date1 has-error')
equal(el.find('[data-name="date2"]').closest('.form-group').find('.help-inline').text(), '', 'check date1 error message')
assert.equal(el.find('[data-name="date2"]').closest('.form-group').hasClass('has-error'), false, 'check date1 has-error')
assert.equal(el.find('[data-name="date2"]').closest('.form-group').find('.help-inline').text(), '', 'check date1 error message')
// set invalid values
el.find('[data-name="date2"] [data-item="date"]').val('').trigger('blur')
el.find('[data-name="date2"] [data-item="date"]').datepicker('setDate')
el.find('[data-name="date2"] [data-item="date"]').trigger('change')
equal(el.find('[data-name="date2"]').closest('.form-group').hasClass('has-error'), true, 'check date2 has-error')
assert.equal(el.find('[data-name="date2"]').closest('.form-group').hasClass('has-error'), true, 'check date2 has-error')
// check params
params = App.ControllerForm.params(el)
test_params = {
date2: null,
}
deepEqual(params, test_params, 'params check')
assert.deepEqual(params, test_params, 'params check')
// check errors
errors = form.validate(params)
test_errors = {
date2: 'is required',
}
deepEqual(errors, test_errors, 'validation errors check')
assert.deepEqual(errors, test_errors, 'validation errors check')
App.ControllerForm.validate({ errors: errors, form: el })
equal(el.find('[data-name="date2"]').closest('.form-group').hasClass('has-error'), true, 'check date2 has-error')
equal(el.find('[data-name="date2"]').closest('.form-group').find('.help-inline').text(), 'is required', 'check date2 error message')
assert.equal(el.find('[data-name="date2"]').closest('.form-group').hasClass('has-error'), true, 'check date2 has-error')
assert.equal(el.find('[data-name="date2"]').closest('.form-group').find('.help-inline').text(), 'is required', 'check date2 error message')
});
test( "datetime selector check", function() {
QUnit.test( "datetime selector check", assert => {
$('#forms').append('<hr><h1>datetime selector check</h1><form id="form4"></form>')
@ -273,7 +273,7 @@ test( "datetime selector check", function() {
datetime1: null,
datetime2: null,
}
deepEqual(params, test_params, 'params check')
assert.deepEqual(params, test_params, 'params check')
var timeStamp1 = new Date()
timeStamp1.setMinutes(0)
@ -290,7 +290,7 @@ test( "datetime selector check", function() {
datetime1: timeStamp1.toISOString(),
datetime2: null,
}
deepEqual(params, test_params, 'params check')
assert.deepEqual(params, test_params, 'params check')
el.find('[data-name="datetime1"] .js-timepicker[data-item="time"]').val('9:00')
el.find('[data-name="datetime1"] .js-timepicker[data-item="time"]').trigger('blur')
@ -303,7 +303,7 @@ test( "datetime selector check", function() {
datetime1: timeStamp1.toISOString(),
datetime2: null,
}
deepEqual(params, test_params, 'params check')
assert.deepEqual(params, test_params, 'params check')
var timeStamp2 = new Date()
timeStamp2.setMinutes(0)
@ -322,7 +322,7 @@ test( "datetime selector check", function() {
datetime1: timeStamp1.toISOString(),
datetime2: timeStamp2.toISOString(),
}
deepEqual(params, test_params, 'params check')
assert.deepEqual(params, test_params, 'params check')
// Regression test for issue #2173 - Invalid date causes errors
el.find('[data-name="datetime1"] .js-datepicker').datepicker('setDate', '01/01/99999')
@ -330,7 +330,7 @@ test( "datetime selector check", function() {
el.find('[data-name="datetime1"] .js-datepicker').datepicker('setDate', '01/01/1äöüß')
});
test( "date selector check", function() {
QUnit.test( "date selector check", assert => {
$('#forms').append('<hr><h1>date selector check</h1><form id="form5"></form>')
@ -351,7 +351,7 @@ test( "date selector check", function() {
test_params = {
date3: null,
}
deepEqual(params, test_params, 'params check')
assert.deepEqual(params, test_params, 'params check')
timeStamp = new Date()
@ -371,6 +371,6 @@ test( "date selector check", function() {
test_params = {
date3: currentTime,
}
deepEqual(params, test_params, 'params check')
assert.deepEqual(params, test_params, 'params check')
});

File diff suppressed because one or more lines are too long

View file

@ -0,0 +1,230 @@
QUnit.test('i18n .detectBrowserLocale', assert => {
var original_userLanguage = window.navigator.userLanguage
var original_language = window.navigator.language
var original_languages = window.navigator.languages
var reset = function(){
window.navigator.userLanguage = original_userLanguage
window.navigator.language = original_language
window.navigator.languages = original_languages
}
var mock = function(languages, language, userLanguage){
Object.defineProperty(window.navigator, 'language', {value: language, configurable: true });
Object.defineProperty(window.navigator, 'languages', {value: languages, configurable: true });
Object.defineProperty(window.navigator, 'userLanguage', {value: userLanguage, configurable: true });
}
mock(undefined, undefined, undefined)
assert.equal(App.i18n.detectBrowserLocale(), 'en-us')
mock(undefined, undefined, 'non-existant');
assert.equal(App.i18n.detectBrowserLocale(), 'en-us')
mock(undefined, undefined, 'en');
assert.equal(App.i18n.detectBrowserLocale(), 'en-us')
mock(undefined, undefined, 'lt');
assert.equal(App.i18n.detectBrowserLocale(), 'lt')
mock(undefined, 'lt', 'lv');
assert.equal(App.i18n.detectBrowserLocale(), 'lt')
mock(undefined, 'en', 'lv');
assert.equal(App.i18n.detectBrowserLocale(), 'en-us')
mock(['en'], 'lt', 'lv');
assert.equal(App.i18n.detectBrowserLocale(), 'en-us')
mock(['en-us'], 'lt', 'lv');
assert.equal(App.i18n.detectBrowserLocale(), 'en-us')
mock(['en-US'], 'lt', 'lv');
assert.equal(App.i18n.detectBrowserLocale(), 'en-us')
mock(['lt', 'en-US'], 'lt', 'lv');
assert.equal(App.i18n.detectBrowserLocale(), 'lt')
mock(['en-GB', 'en-US'], 'lt', 'lv');
assert.equal(App.i18n.detectBrowserLocale(), 'en-gb')
mock(['en-XYZ'], 'lt', 'lv');
assert.equal(App.i18n.detectBrowserLocale(), 'en-us')
mock(['xyz', 'lt'], 'lv', undefined);
assert.equal(App.i18n.detectBrowserLocale(), 'lt')
reset()
})
// i18n
QUnit.test('i18n', assert => {
// de
App.i18n.set('de-de')
var translated = App.i18n.translateContent('yes')
assert.equal(translated, 'ja', 'de-de - yes / ja translated correctly')
translated = App.i18n.translatePlain('yes')
assert.equal(translated, 'ja', 'de-de - yes / ja translated correctly')
translated = App.i18n.translateInline('yes')
assert.equal(translated, 'ja', 'de-de - yes / ja translated correctly')
translated = App.i18n.translateContent('%s ago', 123);
assert.equal(translated, 'vor 123', 'de-de - %s')
translated = App.i18n.translateContent('%s ago', '<b>quote</b>')
assert.equal(translated, 'vor &lt;b&gt;quote&lt;/b&gt;', 'de-de - %s - quote')
translated = App.i18n.translateContent('%s %s test', 123, 'xxx |B|')
assert.equal(translated, '123 xxx |B| test', 'de-de - %s %s')
translated = App.i18n.translateContent('|%s| %s test', 123, 'xxx')
assert.equal(translated, '<b>123</b> xxx test', 'de-de - *%s* %s')
translated = App.i18n.translateContent('||%s|| %s test', 123, 'xxx')
assert.equal(translated, '<i>123</i> xxx test', 'de-de - *%s* %s')
translated = App.i18n.translateContent('_%s_ %s test', 123, 'xxx')
assert.equal(translated, '<u>123</u> xxx test', 'de-de - _%s_ %s')
translated = App.i18n.translateContent('§%s§ %s test', 123, 'xxx')
assert.equal(translated, '<kbd>123</kbd> xxx test', 'de-de - §%s§ %s')
translated = App.i18n.translateContent('//%s// %s test', 123, 'xxx')
assert.equal(translated, '<del>123</del> xxx test', 'de-de - //%s// %s')
translated = App.i18n.translateContent('\'%s\' %s test', 123, 'xxx')
assert.equal(translated, '&#39;123&#39; xxx test', 'de-de - \'%s\' %s')
translated = App.i18n.translateContent('<test&now>//*äöüß')
assert.equal(translated, '&lt;test&amp;now&gt;//*äöüß', 'de - <test&now>//*äöüß')
translated = App.i18n.translateContent('some link [to what ever](http://lalala)')
assert.equal(translated, 'some link <a href="http://lalala" target="_blank">to what ever</a>', 'de-de - link')
translated = App.i18n.translateContent('some link [to what ever](%s)', 'http://lalala')
assert.equal(translated, 'some link <a href="http://lalala" target="_blank">to what ever</a>', 'de-de - link')
translated = App.i18n.translateContent('Enables user authentication via %s. Register your app first at [%s](%s).', 'XXX', 'YYY', 'http://lalala')
assert.equal(translated, 'Aktivieren der Benutzeranmeldung über XXX. Registriere Deine Anwendung zuerst über <a href="http://lalala" target="_blank">YYY</a>.', 'en-us - link')
var time_local = new Date();
var offset = time_local.getTimezoneOffset();
var timestamp = App.i18n.translateTimestamp('2012-11-06T21:07:24Z', offset);
assert.equal(timestamp, '06.11.2012 21:07', 'de-de - timestamp translated correctly')
var timestamp = App.i18n.translateTimestamp('2021-02-08 09:13:20 UTC', offset);
assert.equal(timestamp, '08.02.2021 09:13', 'de-de - timestamp translated correctly with UTC format')
timestamp = App.i18n.translateTimestamp('', offset);
assert.equal(timestamp, '', 'de-de - timestamp translated correctly')
timestamp = App.i18n.translateTimestamp(null, offset);
assert.equal(timestamp, null, 'de-de - timestamp translated correctly')
timestamp = App.i18n.translateTimestamp(undefined, offset);
assert.equal(timestamp, undefined, 'de-de - timestamp translated correctly')
var date = App.i18n.translateDate('2012-11-06', 0)
assert.equal(date, '06.11.2012', 'de-de - date translated correctly')
date = App.i18n.translateDate('', 0)
assert.equal(date, '', 'de-de - date translated correctly')
date = App.i18n.translateDate(null, 0)
assert.equal(date, null, 'de-de - date translated correctly')
date = App.i18n.translateDate(undefined, 0)
assert.equal(date, undefined, 'de-de - date translated correctly')
// en
App.i18n.set('en-us')
translated = App.i18n.translateContent('yes')
assert.equal(translated, 'yes', 'en-us - yes translated correctly')
translated = App.i18n.translatePlain('yes')
assert.equal(translated, 'yes', 'en-us - yes translated correctly')
translated = App.i18n.translateInline('yes')
assert.equal(translated, 'yes', 'en-us - yes translated correctly')
translated = App.i18n.translateContent('%s ago', 123);
assert.equal(translated, '123 ago', 'en-us - %s')
translated = App.i18n.translateContent('%s ago', '<b>quote</b>')
assert.equal(translated, '&lt;b&gt;quote&lt;/b&gt; ago', 'en-us - %s - qupte')
translated = App.i18n.translateContent('%s %s test', 123, 'xxx')
assert.equal(translated, '123 xxx test', 'en-us - %s %s')
translated = App.i18n.translateContent('|%s| %s test', 123, 'xxx |B|')
assert.equal(translated, '<b>123</b> xxx |B| test', 'en-us - *%s* %s')
translated = App.i18n.translateContent('||%s|| %s test', 123, 'xxx')
assert.equal(translated, '<i>123</i> xxx test', 'en-us - *%s* %s')
translated = App.i18n.translateContent('_%s_ %s test', 123, 'xxx')
assert.equal(translated, '<u>123</u> xxx test', 'en-us - _%s_ %s')
translated = App.i18n.translateContent('§%s§ %s test', 123, 'xxx')
assert.equal(translated, '<kbd>123</kbd> xxx test', 'en-us - §%s§ %s')
translated = App.i18n.translateContent('Here you can search for tickets, customers and organizations. Use the wildcard §*§ to find everything. E. g. §smi*§ or §rosent*l§. You also can use ||double quotes|| for searching phrases §"some phrase"§.')
assert.equal(translated, 'Here you can search for tickets, customers and organizations. Use the wildcard <kbd>*</kbd> to find everything. E. g. <kbd>smi*</kbd> or <kbd>rosent*l</kbd>. You also can use <i>double quotes</i> for searching phrases <kbd>&quot;some phrase&quot;</kbd>.', 'en-us - §§ §§ §§ || §§')
translated = App.i18n.translateContent('//%s// %s test', 123, 'xxx')
assert.equal(translated, '<del>123</del> xxx test', 'en-us - //%s// %s')
translated = App.i18n.translateContent('\'%s\' %s test', 123, 'xxx')
assert.equal(translated, '&#39;123&#39; xxx test', 'en-us - \'%s\' %s')
translated = App.i18n.translateContent('<test&now>')
assert.equal(translated, '&lt;test&amp;now&gt;', 'en-us - <test&now>')
translated = App.i18n.translateContent('some link [to what ever](http://lalala)')
assert.equal(translated, 'some link <a href="http://lalala" target="_blank">to what ever</a>', 'en-us - link')
translated = App.i18n.translateContent('some link [to what ever](%s)', 'http://lalala')
assert.equal(translated, 'some link <a href="http://lalala" target="_blank">to what ever</a>', 'en-us - link')
translated = App.i18n.translateContent('Enables user authentication via %s. Register your app first at [%s](%s).', 'XXX', 'YYY', 'http://lalala')
assert.equal(translated, 'Enables user authentication via XXX. Register your app first at <a href="http://lalala" target="_blank">YYY</a>.', 'en-us - link')
timestamp = App.i18n.translateTimestamp('2012-11-06T21:07:24Z', offset)
assert.equal(timestamp, '11/06/2012 21:07', 'en - timestamp translated correctly')
timestamp = App.i18n.translateTimestamp('', offset);
assert.equal(timestamp, '', 'en - timestamp translated correctly')
timestamp = App.i18n.translateTimestamp(null, offset);
assert.equal(timestamp, null, 'en - timestamp translated correctly')
timestamp = App.i18n.translateTimestamp(undefined, offset);
assert.equal(timestamp, undefined, 'en - timestamp translated correctly')
date = App.i18n.translateDate('2012-11-06', 0)
assert.equal(date, '11/06/2012', 'en - date translated correctly')
date = App.i18n.translateDate('', 0)
assert.equal(date, '', 'en - date translated correctly')
date = App.i18n.translateDate(null, 0)
assert.equal(date, null, 'en - date translated correctly')
date = App.i18n.translateDate(undefined, 0)
assert.equal(date, undefined, 'en - date translated correctly')
// locale alias test
// de
App.i18n.set('de')
var translated = App.i18n.translateContent('yes')
assert.equal(translated, 'ja', 'de - yes / ja translated correctly')
// locale detection test
// de-ch
App.i18n.set('de-ch')
var translated = App.i18n.translateContent('yes')
assert.equal(translated, 'ja', 'de - yes / ja translated correctly')
});

View file

@ -1,11 +1,11 @@
// image service
test('test image resizing with defined height', function(assert) {
var async_done = assert.async(1)
QUnit.test('test image resizing with defined height', assert => {
var done = assert.async()
App.ImageService.resize(image_40x30, 'auto', 15, 1, 'image/png', 0.7, function(image, width, height) {
equal(width, 20)
assert.equal(width, 20)
async_done()
done()
})
});

View file

@ -1,38 +1,38 @@
test('kb video url parsing and converting to embeding url', function() {
QUnit.test('kb video url parsing and converting to embeding url', assert => {
var klass = App.UiElement.richtext.additions.RichTextToolPopupVideo;
var parsed = klass.detectProviderAndId('https://www.youtube.com/watch?v=vTTzwJsHpU8')
equal(parsed[0], 'youtube')
equal(parsed[1], 'vTTzwJsHpU8')
assert.equal(parsed[0], 'youtube')
assert.equal(parsed[1], 'vTTzwJsHpU8')
var parsed = klass.detectProviderAndId('https://www.youtube.com/watch?v=vTTzwJsHpU8&other=true')
equal(parsed[0], 'youtube')
equal(parsed[1], 'vTTzwJsHpU8')
assert.equal(parsed[0], 'youtube')
assert.equal(parsed[1], 'vTTzwJsHpU8')
var parsed = klass.detectProviderAndId('https://www.youtube.com/watch?v=vTTzwJsHpU8#hashtag')
equal(parsed[0], 'youtube')
equal(parsed[1], 'vTTzwJsHpU8')
assert.equal(parsed[0], 'youtube')
assert.equal(parsed[1], 'vTTzwJsHpU8')
var parsed = klass.detectProviderAndId('https://www.youtube.com/watch?v=_EYF1-2uiIg')
equal(parsed[0], 'youtube')
equal(parsed[1], '_EYF1-2uiIg')
assert.equal(parsed[0], 'youtube')
assert.equal(parsed[1], '_EYF1-2uiIg')
var parsed = klass.detectProviderAndId('https://www.youtu.be/vTTzwJsHpU8')
equal(parsed[0], 'youtube')
equal(parsed[1], 'vTTzwJsHpU8')
assert.equal(parsed[0], 'youtube')
assert.equal(parsed[1], 'vTTzwJsHpU8')
var parsed = klass.detectProviderAndId('https://www.youtube.com/embed/vTTzwJsHpU8')
equal(parsed[0], 'youtube')
equal(parsed[1], 'vTTzwJsHpU8')
assert.equal(parsed[0], 'youtube')
assert.equal(parsed[1], 'vTTzwJsHpU8')
var parsed = klass.detectProviderAndId('https://www.vimeo.com/358296442')
equal(parsed[0], 'vimeo')
equal(parsed[1], '358296442')
assert.equal(parsed[0], 'vimeo')
assert.equal(parsed[1], '358296442')
})

View file

@ -0,0 +1,65 @@
window.onload = function() {
QUnit.test('Test item removal from local storage', assert => {
var key = 'test_key_1'
var value = 'test_value_1'
App.LocalStorage.set(key, value)
assert.equal(App.LocalStorage.get(key), value)
App.LocalStorage.delete(key)
assert.equal(App.LocalStorage.get(key), undefined)
});
QUnit.test('Test user-specific item removal from local storage', assert => {
var key = 'test_key_2'
var value = 'test_value_2'
var user_id = 2
App.LocalStorage.set(key, value, user_id)
assert.equal(App.LocalStorage.get(key, user_id), value)
App.LocalStorage.delete(key, user_id)
assert.equal(App.LocalStorage.get(key, user_id), undefined)
});
QUnit.test('Test key lookup', assert => {
App.LocalStorage.clear()
var key = 'test_key_3'
var value = 'test_value_3'
var user_id = 2
var alt_key = 'test_alt_key_3'
// verify no keys initially
assert.equal(App.LocalStorage.keys().length, 0)
App.LocalStorage.set(key, value, user_id)
// has 1 key in total
assert.equal(App.LocalStorage.keys().length, 1)
// doesn't return anything with wrong prefix
assert.equal(App.LocalStorage.keys('a').length, 0)
// doesn't return anything since user id not given
assert.equal(App.LocalStorage.keys('test').length, 0)
// correct
assert.equal(App.LocalStorage.keys('test', user_id).length, 1)
// verify value
assert.equal(App.LocalStorage.keys('test', user_id)[0].match(key + '$'), key)
App.LocalStorage.set(alt_key, value)
// returns 1 key without user id
assert.equal(App.LocalStorage.keys('test').length, 1)
assert.equal(App.LocalStorage.keys('test')[0], alt_key)
});
}

View file

@ -1,7 +1,7 @@
window.onload = function() {
// search
test( "model search tests", function() {
QUnit.test( "model search tests", assert => {
App.TicketPriority.refresh( [
{
@ -34,32 +34,32 @@ test( "model search tests", function() {
},
] )
priorities = App.TicketPriority.search({sortBy:'created_at', order: 'ASC'})
equal('2 normal', priorities[0].name, 'check 1 entry')
equal('3 high', priorities[1].name, 'check 2 entry')
equal('4 very high', priorities[2].name, 'check 3 entry')
equal('1 low', priorities[3].name, 'check 4 entry')
equal(undefined, priorities[4], 'check 5 entry')
assert.equal('2 normal', priorities[0].name, 'check 1 entry')
assert.equal('3 high', priorities[1].name, 'check 2 entry')
assert.equal('4 very high', priorities[2].name, 'check 3 entry')
assert.equal('1 low', priorities[3].name, 'check 4 entry')
assert.equal(undefined, priorities[4], 'check 5 entry')
priorities = App.TicketPriority.search({sortBy:'created_at', order: 'DESC'})
equal('1 low', priorities[0].name, 'check 4 entry')
equal('4 very high', priorities[1].name, 'check 3 entry')
equal('3 high', priorities[2].name, 'check 2 entry')
equal('2 normal', priorities[3].name, 'check 1 entry')
equal(undefined, priorities[4], 'check 5 entry')
assert.equal('1 low', priorities[0].name, 'check 4 entry')
assert.equal('4 very high', priorities[1].name, 'check 3 entry')
assert.equal('3 high', priorities[2].name, 'check 2 entry')
assert.equal('2 normal', priorities[3].name, 'check 1 entry')
assert.equal(undefined, priorities[4], 'check 5 entry')
});
// model
test( "model loadAssets tests - 1", function() {
QUnit.test( "model loadAssets tests - 1", assert => {
window.refreshCounter1 = 0
var callback1 = function(state, triggerType) {
window.refreshCounter1 = window.refreshCounter1 + 1
equal(state.id, 9999, 'id check')
assert.equal(state.id, 9999, 'id check')
if (window.refreshCounter1 == 1) {
equal('full', triggerType, 'trigger type check')
assert.equal('full', triggerType, 'trigger type check')
}
else {
equal('refresh', triggerType, 'trigger type check')
assert.equal('refresh', triggerType, 'trigger type check')
}
if ( window.refreshCounter1 == 1 ) {
@ -96,23 +96,23 @@ test( "model loadAssets tests - 1", function() {
});
App.Delay.set( function() {
test( "model loadAssets tests - 1 / check refresh counter", function() {
equal(window.refreshCounter1, 2, 'check refresh counter')
QUnit.test( "model loadAssets tests - 1 / check refresh counter", assert => {
assert.equal(window.refreshCounter1, 2, 'check refresh counter')
});
},
1000
);
test( "model loadAssets tests - 2", function() {
QUnit.test( "model loadAssets tests - 2", assert => {
window.refreshCounter2 = 0
var callback2 = function(state, triggerType) {
window.refreshCounter2 = window.refreshCounter2 + 1
equal(state.id, 10000, 'id check')
assert.equal(state.id, 10000, 'id check')
if (window.refreshCounter2 == 1) {
equal('full', triggerType, 'trigger type check')
assert.equal('full', triggerType, 'trigger type check')
}
else {
equal('refresh', triggerType, 'trigger type check')
assert.equal('refresh', triggerType, 'trigger type check')
}
if ( window.refreshCounter2 == 1 ) {
App.Collection.loadAssets({
@ -147,23 +147,23 @@ test( "model loadAssets tests - 2", function() {
});
App.Delay.set( function() {
test( "model loadAssets tests - 2 / check refresh counter", function() {
equal(window.refreshCounter2, 2, 'check refresh counter')
QUnit.test( "model loadAssets tests - 2 / check refresh counter", assert => {
assert.equal(window.refreshCounter2, 2, 'check refresh counter')
});
},
1200
);
test( "model loadAssets tests - 3", function() {
QUnit.test( "model loadAssets tests - 3", assert => {
window.refreshCounter3 = 0
var callback3 = function(state, triggerType) {
window.refreshCounter3 = window.refreshCounter3 + 1
equal(state.id, 10001, 'id check')
assert.equal(state.id, 10001, 'id check')
if (window.refreshCounter3 == 1) {
equal('full', triggerType, 'trigger type check')
assert.equal('full', triggerType, 'trigger type check')
}
else {
equal('refresh', triggerType, 'trigger type check')
assert.equal('refresh', triggerType, 'trigger type check')
}
if ( window.refreshCounter3 == 1 ) {
@ -199,14 +199,14 @@ test( "model loadAssets tests - 3", function() {
});
App.Delay.set( function() {
test( "model loadAssets tests - 3 / check refresh counter", function() {
equal(window.refreshCounter3, 3, 'check refresh counter')
QUnit.test( "model loadAssets tests - 3 / check refresh counter", assert => {
assert.equal(window.refreshCounter3, 3, 'check refresh counter')
});
},
1400
);
test("updateAttributes will change existing attributes and add new ones", function() {
QUnit.test("updateAttributes will change existing attributes and add new ones", assert => {
App.Ticket.resetAttributes();
var attributesBefore = _.clone(App.Ticket.configure_attributes);
@ -226,15 +226,15 @@ test("updateAttributes will change existing attributes and add new ones", functi
var attributesAfterUpdate = _.clone(App.Ticket.configure_attributes);
equal(attributesAfterUpdate.length, attributesBefore.length + 1, 'new attributes list contains 1 more elements')
equal(attributesAfterUpdate[attributesAfterUpdate.length - 1]['name'], 'new_attribute_1010101', 'new attributes list contains the new element')
equal(attributesAfterUpdate[0]['new_option_1239393'], 1, 'first element of the new attributes got updated with the new option')
assert.equal(attributesAfterUpdate.length, attributesBefore.length + 1, 'new attributes list contains 1 more elements')
assert.equal(attributesAfterUpdate[attributesAfterUpdate.length - 1]['name'], 'new_attribute_1010101', 'new attributes list contains the new element')
assert.equal(attributesAfterUpdate[0]['new_option_1239393'], 1, 'first element of the new attributes got updated with the new option')
App.Ticket.resetAttributes();
var attributesAfterReset = _.clone(App.Ticket.configure_attributes);
equal(attributesAfterReset.length, attributesBefore.length, 'new attributes list has the same elements after reset')
equal(attributesAfterReset[0]['new_option_1239393'], undefined, 'first element of the new attributes has no attribute new_option_1239393')
assert.equal(attributesAfterReset.length, attributesBefore.length, 'new attributes list has the same elements after reset')
assert.equal(attributesAfterReset[0]['new_option_1239393'], undefined, 'first element of the new attributes has no attribute new_option_1239393')
});
}

View file

@ -1,51 +1,51 @@
window.onload = function() {
test("model bindings and rebinding", function() {
QUnit.test("model bindings and rebinding", assert => {
var callback_count1 = 0
var callbacks = App.Template._callbacks
Object.keys(callbacks).forEach(function(key) {
callback_count1 = callback_count1 + callbacks[key].length
});
equal(callback_count1, 2)
assert.equal(callback_count1, 2)
equal(App.Template.SUBSCRIPTION_COLLECTION, undefined)
assert.equal(App.Template.SUBSCRIPTION_COLLECTION, undefined)
App.Template.clearInMemory()
equal(App.Template.SUBSCRIPTION_COLLECTION, undefined)
assert.equal(App.Template.SUBSCRIPTION_COLLECTION, undefined)
var callback_count2 = 0
callbacks = App.Template._callbacks
Object.keys(callbacks).forEach(function(key) {
callback_count2 = callback_count2 + callbacks[key].length
});
equal(callback_count2, callback_count1)
assert.equal(callback_count2, callback_count1)
var render = function() {}
var subscribe_id = App.Template.subscribe(render, {initFetch: true})
ok(_.isObject(App.Template.SUBSCRIPTION_COLLECTION))
ok(!_.isEmpty(App.Template.SUBSCRIPTION_COLLECTION))
assert.ok(_.isObject(App.Template.SUBSCRIPTION_COLLECTION))
assert.ok(!_.isEmpty(App.Template.SUBSCRIPTION_COLLECTION))
var callback_count3 = 0
callbacks = App.Template._callbacks
Object.keys(callbacks).forEach(function(key) {
callback_count3 = callback_count3 + callbacks[key].length
});
equal(callback_count3, 6)
assert.equal(callback_count3, 6)
App.Template.clearInMemory()
ok(_.isObject(App.Template.SUBSCRIPTION_COLLECTION))
ok(_.isEmpty(App.Template.SUBSCRIPTION_COLLECTION))
assert.ok(_.isObject(App.Template.SUBSCRIPTION_COLLECTION))
assert.ok(_.isEmpty(App.Template.SUBSCRIPTION_COLLECTION))
var callback_count4 = 0
callbacks = App.Template._callbacks
Object.keys(callbacks).forEach(function(key) {
callback_count4 = callback_count4 + callbacks[key].length
});
equal(callback_count4, callback_count3)
assert.equal(callback_count4, callback_count3)
});

View file

@ -107,40 +107,40 @@ window.onload = function() {
},
])
test('ticket.editabe customer user #1', function() {
QUnit.test('ticket.editabe customer user #1', assert => {
App.Session.set(33)
ticket1 = App.Ticket.find(1);
ok(ticket1.editable(), 'access via customer_id');
assert.ok(ticket1.editable(), 'access via customer_id');
ticket2 = App.Ticket.find(2);
ok(ticket2.editable(), 'access via organization_id');
assert.ok(ticket2.editable(), 'access via organization_id');
ticket3 = App.Ticket.find(3);
ok(!ticket3.editable(), 'no access');
assert.ok(!ticket3.editable(), 'no access');
ticket4 = App.Ticket.find(4);
ok(!ticket4.editable(), 'no access');
assert.ok(!ticket4.editable(), 'no access');
});
test('ticket.editabe customer user #2', function() {
QUnit.test('ticket.editabe customer user #2', assert => {
App.Session.set(44)
ticket1 = App.Ticket.find(1);
ok(!ticket1.editable(), 'no access');
assert.ok(!ticket1.editable(), 'no access');
ticket2 = App.Ticket.find(2);
ok(ticket2.editable(), 'access via customer_id');
assert.ok(ticket2.editable(), 'access via customer_id');
ticket3 = App.Ticket.find(3);
ok(!ticket3.editable(), 'no access');
assert.ok(!ticket3.editable(), 'no access');
ticket4 = App.Ticket.find(4);
ok(!ticket4.editable(), 'no access');
assert.ok(!ticket4.editable(), 'no access');
});
test('ticket.editabe customer user #3', function() {
QUnit.test('ticket.editabe customer user #3', assert => {
App.Session.set(55)
ticket1 = App.Ticket.find(1);
ok(!ticket1.editable(), 'no access');
assert.ok(!ticket1.editable(), 'no access');
ticket2 = App.Ticket.find(2);
ok(!ticket2.editable(), 'no access');
assert.ok(!ticket2.editable(), 'no access');
ticket3 = App.Ticket.find(3);
ok(ticket3.editable(), 'access via customer_id');
assert.ok(ticket3.editable(), 'access via customer_id');
ticket4 = App.Ticket.find(4);
ok(!ticket4.editable(), 'no access');
assert.ok(!ticket4.editable(), 'no access');
});
}

View file

@ -0,0 +1,110 @@
window.onload = function() {
// model
QUnit.test( "model ui basic tests", assert => {
// load ref object
App.Collection.loadAssets({
TicketState: {
1: {
name: 'new', id: 1, updated_at: "2014-11-07T23:43:08.000Z",
},
2: {
name: 'open', id: 2, updated_at: "2014-11-07T23:43:08.000Z",
},
3: {
name: 'closed <>&', id: 3, updated_at: "2014-11-07T23:43:08.000Z",
},
},
})
// create ticket
var attribute1 = {
name: 'date', display: 'date 1', tag: 'date', null: true
};
App.Ticket.configure_attributes.push( attribute1 )
var attribute2 = {
name: 'textarea', display: 'textarea 1', tag: 'textarea', null: true
};
App.Ticket.configure_attributes.push( attribute2 )
var attribute3 = {
name: 'link1', display: 'link 1', linktemplate: 'http://zammad.com', tag: 'input', null: true, translate: true
};
App.Ticket.configure_attributes.push( attribute3 )
var attribute4 = {
name: 'link2', display: 'link 1', linktemplate: 'http://zammad.com', tag: 'input', null: true
};
App.Ticket.configure_attributes.push( attribute4 )
var ticket = new App.Ticket()
ticket.load({
id: 1000,
title: 'some title <>&',
state_id: 2,
updated_at: '2014-11-07T23:43:08.000Z',
date: '2015-02-07',
textarea: "some new\nline",
link1: 'closed',
link2: 'closed',
})
App.i18n.set('en-us')
assert.equal( App.viewPrint( ticket, 'id' ), 1000)
assert.equal( App.viewPrint( ticket, 'title' ), 'some title &lt;&gt;&amp;')
assert.equal( App.viewPrint( ticket, 'state' ), 'open')
assert.equal( App.viewPrint( ticket, 'state_id' ), 'open')
assert.equal( App.viewPrint( ticket, 'not_existing' ), '-')
assert.equal( App.viewPrint( ticket, 'updated_at' ), '<time class="humanTimeFromNow " datetime="2014-11-07T23:43:08.000Z" title="11/07/2014 23:43">11/07/2014</time>')
assert.equal( App.viewPrint( ticket, 'date' ), '02/07/2015')
assert.equal( App.viewPrint( ticket, 'textarea' ), '<div>some new</div><div>line</div>')
assert.equal( App.viewPrint( ticket, 'link1' ), '<a href="http://zammad.com" target="blank">closed</a>')
assert.equal( App.viewPrint( ticket, 'link2' ), '<a href="http://zammad.com" target="blank">closed</a>')
let stub = sinon.stub(App.Config, 'get')
stub.withArgs('timezone_default').returns('Example/Timezone')
let attr = App.Ticket.configure_attributes.find(e => { return e.name == 'updated_at' })
attr.include_timezone = true
assert.equal( App.viewPrint( ticket, 'updated_at' ), '<time class="humanTimeFromNow " datetime="2014-11-07T23:43:08.000Z" title="11/07/2014 23:43 Example/Timezone" timezone="Example/Timezone">11/07/2014</time>')
attr.include_timezone = false
stub.restore()
App.i18n.set('de-de')
assert.equal( App.viewPrint( ticket, 'id' ), 1000)
assert.equal( App.viewPrint( ticket, 'title' ), 'some title &lt;&gt;&amp;')
assert.equal( App.viewPrint( ticket, 'state' ), 'offen')
assert.equal( App.viewPrint( ticket, 'state_id' ), 'offen')
assert.equal( App.viewPrint( ticket, 'not_existing' ), '-')
assert.equal( App.viewPrint( ticket, 'updated_at' ), '<time class="humanTimeFromNow " datetime="2014-11-07T23:43:08.000Z" title="07.11.2014 23:43">07.11.2014</time>')
assert.equal( App.viewPrint( ticket, 'date' ), '07.02.2015')
assert.equal( App.viewPrint( ticket, 'textarea' ), '<div>some new</div><div>line</div>')
assert.equal( App.viewPrint( ticket, 'link1' ), '<a href="http://zammad.com" target="blank">geschlossen</a>')
assert.equal( App.viewPrint( ticket, 'link2' ), '<a href="http://zammad.com" target="blank">closed</a>')
App.i18n.set('en-us')
ticket.state_id = 3
assert.equal( App.viewPrint( ticket, 'state' ), 'closed &lt;&gt;&amp;')
assert.equal( App.viewPrint( ticket, 'state_id' ), 'closed &lt;&gt;&amp;')
App.i18n.set('de')
assert.equal( App.viewPrint( ticket, 'state' ), 'closed &lt;&gt;&amp;')
assert.equal( App.viewPrint( ticket, 'state_id' ), 'closed &lt;&gt;&amp;')
// normal string
data = {
a: 1,
b: 'abc',
c: {
displayName: function() { return "my displayName <>&" }
},
}
assert.equal( App.viewPrint( data, 'a' ), 1)
assert.equal( App.viewPrint( data, 'b' ), 'abc')
assert.equal( App.viewPrint( data, 'c' ), 'my displayName &lt;&gt;&amp;')
});
}

View file

@ -0,0 +1,82 @@
window.onload = function() {
QUnit.test('test current user behaviour by updating session user via assets', assert => {
// Wenn App.User updated through asset and set as session user
// expect App.Session.get with new values
App.User.refresh([{
"login": "hh@example.com",
"firstname": "Harald",
"lastname": "Habebe",
"email": "hh@example.com",
"role_ids": [ 1, 2, 4 ],
"group_ids": [ 1 ],
"active": true,
"updated_at": "2017-02-09T09:17:04.770Z",
"address": "",
"vip": false,
"custom_key": undefined,
"asdf": "",
"id": 6
}]);
App.Session.set(6)
assert.equal(App.Session.get('id'), 6)
assert.equal(App.Session.get('login'), 'hh@example.com')
assert.equal(App.Session.get('vip'), false)
assert.equal(App.Session.get('custom_key'), undefined)
assert.equal(App.Session.get().id, 6)
assert.equal(App.Session.get().login, 'hh@example.com')
assert.equal(App.Session.get().custom_key, undefined)
assert.equal(App.Session.get().not_existing, undefined)
// Wenn App.User updated through asset
// expect App.Session.get with new values
App.User.refresh([{
"login": "hh_new@example.com",
"firstname": "Harald",
"lastname": "Habebe",
"email": "hh_new@example.com",
"role_ids": [ 1, 2, 4 ],
"group_ids": [ 1 ],
"active": true,
"updated_at": "2017-02-09T09:17:04.770Z",
"address": "",
"vip": false,
"custom_key": undefined,
"asdf": "",
"id": 6
}]);
assert.equal(App.Session.get('id'), 6)
assert.equal(App.Session.get('login'), 'hh_new@example.com')
assert.equal(App.Session.get('vip'), false)
assert.equal(App.Session.get('custom_key'), undefined)
assert.equal(App.Session.get().id, 6)
assert.equal(App.Session.get().login, 'hh_new@example.com')
assert.equal(App.Session.get().custom_key, undefined)
assert.equal(App.Session.get().not_existing, undefined)
// Wenn App.Session is reseted to inital
// expect undefined for all
App.Session.init()
assert.equal(App.Session.get(), undefined)
assert.equal(App.Session.get('id'), undefined)
assert.equal(App.Session.get('login'), undefined)
assert.equal(App.Session.get('vip'), undefined)
assert.equal(App.Session.get('custom_key'), undefined)
// When App.Session is set and set to undefined or null,
// expect @current() to return null
App.Session.set(6)
App.Session.set(undefined)
assert.equal(App.User.current(), null, 'with no active session')
App.Session.set(null)
assert.equal(App.User.current(), null, 'with no active session')
// When App.Session is set with an invalid (not existing) user ID,
// expect @current() to return null
App.Session.set(100)
assert.equal(App.User.current(), null, 'with invalid session user ID')
});
}

View file

@ -0,0 +1,844 @@
// form
QUnit.test('table test', assert => {
App.i18n.set('de-de')
$('#qunit').append('<hr><h1>table simple I</h1><div id="table1"></div>')
var el = $('#table1')
App.TicketPriority.refresh( [
{
id: 1,
name: '1 low',
note: 'some note 1',
active: true,
created_at: '2014-06-10T11:17:34.000Z',
},
{
id: 2,
name: '2 normal',
note: 'some note 2',
active: false,
created_at: '2014-06-10T10:17:34.000Z',
},
] )
var rowClick = function (id, e) {
e.preventDefault()
console.log('rowClick', id, e.target)
};
var rowDblClick = function (id, e) {
e.preventDefault()
console.log('rowDblClick', id, e.target)
};
var rowMouseover = function (id, e) {
e.preventDefault()
console.log('rowMouseover', id, e.target)
};
var rowMouseout = function (id, e) {
e.preventDefault()
console.log('rowMouseout', id, e.target)
};
var colClick = function (id, e) {
e.preventDefault()
console.log('colClick', id, e.target)
};
var colDblClick = function (id, e) {
e.preventDefault()
console.log('colDblClick', id, e.target)
};
var colMouseover = function (id, e) {
e.preventDefault()
console.log('colMouseover', id, e.target)
};
var colMouseout = function (id, e) {
e.preventDefault()
console.log('colMouseout', id, e.target)
};
new App.ControllerTable({
el: el,
overview: ['name', 'created_at', 'active'],
model: App.TicketPriority,
objects: App.TicketPriority.search({sortBy:'name', order: 'ASC'}),
checkbox: false,
radio: false,
bindRow: {
events: {
'click': rowClick,
'mouseover': rowMouseover,
'mouseout': rowMouseout,
'dblclick': rowDblClick,
}
},
bindCol: {
name: {
events: {
'click': colClick,
'mouseover': colMouseover,
'mouseout': colMouseout,
'dblclick': colDblClick,
}
},
created_at: {
events: {
'mouseover': colMouseover,
'mouseout': colMouseout,
}
}
},
})
assert.equal(el.find('table > thead > tr').length, 1, 'row count')
assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '1 niedrig', 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true', 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '2 normal', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'false', 'check row 2')
$('#qunit').append('<hr><h1>table simple II</h1><div id="table2"></div>')
el = $('#table2')
new App.ControllerTable({
el: el,
overview: ['name', 'created_at', 'active'],
model: App.TicketPriority,
objects: App.TicketPriority.search({sortBy:'name', order: 'DESC'}),
checkbox: false,
radio: false,
})
assert.equal(el.find('table > thead > tr').length, 1, 'row count')
assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '2 normal', 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'false', 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '1 niedrig', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'true', 'check row 2')
$('#qunit').append('<hr><h1>table simple III</h1><div id="table3"></div>')
el = $('#table3')
new App.ControllerTable({
el: el,
model: App.TicketPriority,
objects: App.TicketPriority.search({sortBy:'created_at', order: 'DESC'}),
checkbox: false,
radio: false,
})
assert.equal(el.find('table > thead > tr').length, 1, 'row count')
assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
assert.notEqual( el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
assert.notEqual( el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 1, 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '2 normal', 'check row 2')
assert.notEqual( el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '?', 'check row 2')
assert.notEqual( el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'true', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 1, 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '1 niedrig', 'check row 1')
assert.notEqual( el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '?', 'check row 1')
assert.notEqual( el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'false', 'check row 1')
App.Group.refresh( [
{
id: 1,
name: 'group 1',
active: true,
created_at: '2014-06-10T11:17:34.000Z',
},
{
id: 2,
name: 'group 2',
active: true,
created_at: '2014-06-10T11:17:34.000Z',
},
])
App.User.refresh( [
{
id: 55,
login: 'login55',
firstname: 'firstname55',
lastname: 'lastname55',
email: 'email55',
active: true,
created_at: '2014-06-10T11:17:34.000Z',
},
{
id: 56,
login: 'login56',
firstname: 'firstname56',
lastname: 'lastname56',
email: 'email56',
active: true,
created_at: '2014-06-10T11:17:34.000Z',
},
])
App.TicketState.refresh( [
{
id: 1,
name: 'new',
active: true,
created_at: '2014-06-10T11:17:34.000Z',
},
{
id: 2,
name: 'open',
note: 'some note 2',
active: false,
created_at: '2014-06-10T10:17:34.000Z',
},
])
App.Ticket.refresh( [
{
id: 1,
title: 'some title 1',
number: '4711',
priority_id: 1,
owner_id: 55,
customer_id: 56,
state_id: 1,
group_id: 2,
created_at: '2014-06-10T11:17:34.000Z',
},
{
id: 3,
title: 'some title 3',
number: '4713',
priority_id: 2,
owner_id: 56,
state_id: 1,
group_id: 2,
created_at: '2014-07-11T11:19:34.000Z',
},
{
id: 2,
title: 'some title 2',
number: '4712',
priority_id: 1,
state_id: 2,
group_id: 1,
created_at: '2014-06-10T11:19:34.000Z',
},
])
$('#qunit').append('<hr><h1>table complex I</h1><div id="table4"></div>')
el = $('#table4')
new App.ControllerTable({
el: el,
overview: ['number', 'title', 'owner', 'customer', 'priority', 'group', 'state', 'created_at'],
model: App.Ticket,
objects: App.Ticket.search({sortBy:'created_at', order: 'DESC'}),
checkbox: true,
})
assert.equal(el.find('table > thead > tr').length, 1, 'row count')
assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), '', 'check header')
assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), '#', 'check header')
assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Titel', 'check header')
assert.equal(el.find('table > thead > tr > th:nth-child(4)').text().trim(), 'Besitzer', 'check header')
assert.equal(el.find('table > thead > tr > th:nth-child(5)').text().trim(), 'Kunde', 'check header')
assert.equal(el.find('table > thead > tr > th:nth-child(6)').text().trim(), 'Priorität', 'check header')
assert.equal(el.find('table > thead > tr > th:nth-child(7)').text().trim(), 'Gruppe', 'check header')
assert.equal(el.find('table > thead > tr > th:nth-child(8)').text().trim(), 'Status', 'check header')
assert.equal(el.find('table > thead > tr > th:nth-child(9)').text().trim(), 'Erstellt am', 'check header')
assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 9, 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(1) input').val(), '3', 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(1) input').prop('checked'), '', 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(1)').text().trim(), '', 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '4713', 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'some title 3', 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(4)').text().trim(), 'firstname56 lastname56', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(5)').text().trim(), '-', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(6)').text().trim(), '2 normal', 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(7)').text().trim(), 'group 2', 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(8)').text().trim(), 'neu', 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(9)').text().trim(), '11.07.2014', 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 9, 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(1) input').val(), '2', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(1) input').prop('checked'), '', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(1)').text().trim(), '', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '4712', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'some title 2', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(4)').text().trim(), '-', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(5)').text().trim(), '-', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(6)').text().trim(), '1 niedrig', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(7)').text().trim(), 'group 1', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(8)').text().trim(), 'offen', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(9)').text().trim(), '10.06.2014', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(3) > td').length, 9, 'check row 3')
assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(1) input').val(), '1', 'check row 3')
assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(1) input').prop('checked'), '', 'check row 3')
assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(1)').text().trim(), '', 'check row 3')
assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '4711', 'check row 3')
assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'some title 1', 'check row 3')
assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(4)').text().trim(), 'firstname55 lastname55', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(5)').text().trim(), 'firstname56 lastname56', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(6)').text().trim(), '1 niedrig', 'check row 3')
assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(7)').text().trim(), 'group 2', 'check row 3')
assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(8)').text().trim(), 'neu', 'check row 3')
assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(9)').text().trim(), '10.06.2014', 'check row 3')
el.find('input[name="bulk_all"]').click()
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(1) input').prop('checked'), true, 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(1) input').val(), '3', 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(1) input').prop('checked'), true, 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(1) input').val(), '2', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(1) input').prop('checked'), true, 'check row 3')
assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(1) input').val(), '1', 'check row 3')
$('#qunit').append('<hr><h1>table complex II</h1><div id="table5"></div>')
el = $('#table5')
var clickCheckbox = function (id, checked, e) {
console.log('clickCheckbox', id, checked, e.target)
};
new App.ControllerTable({
el: el,
overview: ['number', 'title', 'owner', 'customer', 'priority', 'group', 'state', 'created_at'],
model: App.Ticket,
objects: App.Ticket.search({sortBy:'created_at', order: 'DESC'}),
checkbox: true,
groupBy: 'group',
bindCheckbox: {
events: {
'click': clickCheckbox,
}
},
})
assert.equal(el.find('table > thead > tr').length, 1, 'row count')
assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), '', 'check header')
assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), '#', 'check header')
assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Titel', 'check header')
assert.equal(el.find('table > thead > tr > th:nth-child(4)').text().trim(), 'Besitzer', 'check header')
assert.equal(el.find('table > thead > tr > th:nth-child(5)').text().trim(), 'Kunde', 'check header')
assert.equal(el.find('table > thead > tr > th:nth-child(6)').text().trim(), 'Priorität', 'check header')
assert.equal(el.find('table > thead > tr > th:nth-child(7)').text().trim(), 'Status', 'check header')
assert.equal(el.find('table > thead > tr > th:nth-child(8)').text().trim(), 'Erstellt am', 'check header')
assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 1, 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(1)').text().trim(), 'group 1', 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 8, 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(1) input').val(), '2', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(1) input').prop('checked'), '', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(1)').text().trim(), '', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '4712', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'some title 2', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(4)').text().trim(), '-', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(5)').text().trim(), '-', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(6)').text().trim(), '1 niedrig', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(7)').text().trim(), 'offen', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(8)').text().trim(), '10.06.2014', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(3) > td').length, 1, 'check row 3')
assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(1)').text().trim(), 'group 2', 'check row 4')
assert.equal(el.find('tbody > tr:nth-child(4) > td').length, 8, 'check row 4')
assert.equal(el.find('tbody > tr:nth-child(4) > td:nth-child(1) input').val(), '3', 'check row 4')
assert.equal(el.find('tbody > tr:nth-child(4) > td:nth-child(1) input').prop('checked'), '', 'check row 4')
assert.equal(el.find('tbody > tr:nth-child(4) > td:nth-child(1)').text().trim(), '', 'check row 4')
assert.equal(el.find('tbody > tr:nth-child(4) > td:nth-child(2)').text().trim(), '4713', 'check row 4')
assert.equal(el.find('tbody > tr:nth-child(4) > td:nth-child(3)').text().trim(), 'some title 3', 'check row 4')
assert.equal(el.find('tbody > tr:nth-child(4) > td:nth-child(4)').text().trim(), 'firstname56 lastname56', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(4) > td:nth-child(5)').text().trim(), '-', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(4) > td:nth-child(6)').text().trim(), '2 normal', 'check row 4')
assert.equal(el.find('tbody > tr:nth-child(4) > td:nth-child(7)').text().trim(), 'neu', 'check row 4')
assert.equal(el.find('tbody > tr:nth-child(4) > td:nth-child(8)').text().trim(), '11.07.2014', 'check row 4')
el.find('input[name="bulk"]:eq(1)').click()
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(1) input').prop('checked'), '', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(1) input').val(), '2', 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(4) > td:nth-child(1) input').prop('checked'), true, 'check row 4')
assert.equal(el.find('tbody > tr:nth-child(4) > td:nth-child(1) input').val(), '3', 'check row 4')
assert.equal(el.find('tbody > tr:nth-child(5) > td:nth-child(1) input').prop('checked'), '', 'check row 5')
assert.equal(el.find('tbody > tr:nth-child(5) > td:nth-child(1) input').val(), '1', 'check row 5')
el.find('tbody > tr:nth-child(5) > td:nth-child(1) label').click()
assert.equal(el.find('tbody > tr:nth-child(5) > td:nth-child(1) input').prop('checked'), true, 'check row 5')
assert.equal(el.find('tbody > tr:nth-child(5) > td:nth-child(1) input').val(), '1', 'check row 5')
$('#qunit').append('<hr><h1>table Group By Direction DESC</h1><div id="table6"></div>')
el = $('#table6')
var clickCheckbox = function (id, checked, e) {
console.log('clickCheckbox', id, checked, e.target)
};
new App.ControllerTable({
el: el,
overview: ['number', 'title', 'owner', 'customer', 'priority', 'group', 'state', 'created_at'],
model: App.Ticket,
objects: App.Ticket.search({sortBy:'created_at', order: 'DESC'}),
groupBy: 'priority',
groupDirection: 'DESC',
})
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(1)').text().trim(), '2 normal', 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(3) > td:nth-child(1)').text().trim(), '1 niedrig', 'check row 3')
$('#qunit').append('<hr><h1>table Group By Direction ASC</h1><div id="table7"></div>')
el = $('#table7')
var clickCheckbox = function (id, checked, e) {
console.log('clickCheckbox', id, checked, e.target)
};
new App.ControllerTable({
el: el,
overview: ['number', 'title', 'owner', 'customer', 'priority', 'group', 'state', 'created_at'],
model: App.Ticket,
objects: App.Ticket.search({sortBy:'created_at', order: 'DESC'}),
groupBy: 'priority',
groupDirection: 'ASC',
})
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(1)').text().trim(), '1 niedrig', 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(4) > td:nth-child(1)').text().trim(), '2 normal', 'check row 4')
});
QUnit.test('table test 2.1', assert => {
App.i18n.set('de-de')
$('#qunit').append('<hr><h1>table with hash</h1><div id="table-hash2_1"></div>')
var el = $('#table-hash2_1')
App.Group.refresh( [
{
id: 5,
name: 'group 5',
active: true,
created_at: '2014-06-10T11:17:34.000Z',
},
])
App.Channel.configure_delete = true
App.Channel.configure_clone = false
App.Channel.configure_attributes = [
{ name: 'adapter', display: 'Type', tag: 'select', multiple: false, null: false, options: { IMAP: 'IMAP', POP3: 'POP3' } },
{ name: 'options::host', display: 'Host', tag: 'input', type: 'text', limit: 120, null: true, autocapitalize: false },
{ name: 'options::user', display: 'User', tag: 'input', type: 'text', limit: 120, null: true, autocapitalize: false },
{ name: 'options::password', display: 'Password', tag: 'input', type: 'password', limit: 120, null: true, autocapitalize: false },
{ name: 'options::ssl', display: 'SSL', tag: 'select', multiple: false, null: true, options: { true: 'yes', false: 'no' }, translate: true, default: true},
{ name: 'options::folder', display: 'Folder', tag: 'input', type: 'text', limit: 120, null: true, autocapitalize: false },
{ name: 'group_id', display: 'Group', tag: 'select', multiple: false, null: false, nulloption: true, relation: 'Group' },
{ name: 'active', display: 'Active', tag: 'select', multiple: false, null: false, options: { true: 'yes', false: 'no' }, translate: true, default: true },
]
App.Channel.refresh( [
{
id: 1,
adapter: 'adapter1',
options: {
host: 'host1',
user: 'user1',
},
group_id: 5,
active: true,
created_at: '2014-06-10T11:17:34.000Z',
},
{
id: 2,
adapter: 'adapter2',
options: {
host: 'host2',
user: 'user2',
},
group_id: 5,
active: true,
created_at: '2014-06-10T11:17:34.000Z',
},
] )
new App.ControllerTable({
el: el,
overview: ['adapter', 'options::host', 'options::user', 'active'],
model: App.Channel,
objects: App.Channel.search({sortBy:'adapter', order: 'ASC'}),
})
assert.equal(el.find('table > thead > tr').length, 1, 'row count')
assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Typ', 'check header')
assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Host', 'check header')
assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Benutzer', 'check header')
assert.equal(el.find('table > thead > tr > th:nth-child(4)').text().trim(), 'Aktiv', 'check header')
assert.equal(el.find('table > thead > tr > th:nth-child(5)').text().trim(), 'Aktion', 'check header')
assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 5, 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(1)').text().trim(), 'adapter1', 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), 'host1', 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'user1', 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(4)').text().trim(), 'ja', 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(5)').text().trim(), '', 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(5) .dropdown.dropdown--actions').length, 0, 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(5) .js-delete').length, 1, 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(5) .js-clone').length, 0, 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 5, 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(1)').text().trim(), 'adapter2', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), 'host2', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'user2', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(4)').text().trim(), 'ja', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(5)').text().trim(), '', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(5) .dropdown.dropdown--actions').length, 0, 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(5) .js-delete').length, 1, 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(5) .js-clone').length, 0, 'check row 1')
});
QUnit.test('table test 2.2', assert => {
App.i18n.set('de-de')
$('#qunit').append('<hr><h1>table with hash</h1><div id="table-hash2_2"></div>')
var el = $('#table-hash2_2')
App.Group.refresh( [
{
id: 5,
name: 'group 5',
active: true,
created_at: '2014-06-10T11:17:34.000Z',
},
])
App.Channel.configure_delete = false
App.Channel.configure_clone = true
App.Channel.configure_attributes = [
{ name: 'adapter', display: 'Type', tag: 'select', multiple: false, null: false, options: { IMAP: 'IMAP', POP3: 'POP3' } },
{ name: 'options::host', display: 'Host', tag: 'input', type: 'text', limit: 120, null: true, autocapitalize: false },
{ name: 'options::user', display: 'User', tag: 'input', type: 'text', limit: 120, null: true, autocapitalize: false },
{ name: 'options::password', display: 'Password', tag: 'input', type: 'password', limit: 120, null: true, autocapitalize: false },
{ name: 'options::ssl', display: 'SSL', tag: 'select', multiple: false, null: true, options: { true: 'yes', false: 'no' }, translate: true, default: true},
{ name: 'options::folder', display: 'Folder', tag: 'input', type: 'text', limit: 120, null: true, autocapitalize: false },
{ name: 'group_id', display: 'Group', tag: 'select', multiple: false, null: false, nulloption: true, relation: 'Group' },
{ name: 'active', display: 'Active', tag: 'select', multiple: false, null: false, options: { true: 'yes', false: 'no' }, translate: true, default: true },
]
App.Channel.refresh( [
{
id: 1,
adapter: 'adapter1',
options: {
host: 'host1',
user: 'user1',
},
group_id: 5,
active: true,
created_at: '2014-06-10T11:17:34.000Z',
},
{
id: 2,
adapter: 'adapter2',
options: {
host: 'host2',
user: 'user2',
},
group_id: 5,
active: true,
created_at: '2014-06-10T11:17:34.000Z',
},
] )
new App.ControllerTable({
el: el,
overview: ['adapter', 'options::host', 'options::user', 'active'],
model: App.Channel,
objects: App.Channel.search({sortBy:'adapter', order: 'ASC'}),
})
assert.equal(el.find('table > thead > tr').length, 1, 'row count')
assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Typ', 'check header')
assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Host', 'check header')
assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Benutzer', 'check header')
assert.equal(el.find('table > thead > tr > th:nth-child(4)').text().trim(), 'Aktiv', 'check header')
assert.equal(el.find('table > thead > tr > th:nth-child(5)').text().trim(), 'Aktion', 'check header')
assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 5, 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(1)').text().trim(), 'adapter1', 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), 'host1', 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'user1', 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(4)').text().trim(), 'ja', 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(5)').text().trim(), '', 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(5) .dropdown.dropdown--actions').length, 0, 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(5) .js-delete').length, 0, 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(5) .js-clone').length, 1, 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 5, 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(1)').text().trim(), 'adapter2', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), 'host2', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'user2', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(4)').text().trim(), 'ja', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(5)').text().trim(), '', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(5) .dropdown.dropdown--actions').length, 0, 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(5) .js-delete').length, 0, 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(5) .js-clone').length, 1, 'check row 1')
});
QUnit.test('table test 3', assert => {
App.i18n.set('de-de')
$('#qunit').append('<hr><h1>table with hash</h1><div id="table-hash2"></div>')
var el = $('#table-hash2')
App.Group.refresh( [
{
id: 5,
name: 'group 5',
active: true,
created_at: '2014-06-10T11:17:34.000Z',
},
])
App.Channel.configure_delete = true
App.Channel.configure_clone = true
App.Channel.configure_attributes = [
{ name: 'adapter', display: 'Type', tag: 'select', multiple: false, null: false, options: { IMAP: 'IMAP', POP3: 'POP3' } },
{ name: 'options::host', display: 'Host', tag: 'input', type: 'text', limit: 120, null: true, autocapitalize: false },
{ name: 'options::user', display: 'User', tag: 'input', type: 'text', limit: 120, null: true, autocapitalize: false },
{ name: 'options::password', display: 'Password', tag: 'input', type: 'password', limit: 120, null: true, autocapitalize: false },
{ name: 'options::ssl', display: 'SSL', tag: 'select', multiple: false, null: true, options: { true: 'yes', false: 'no' }, translate: true, default: true},
{ name: 'options::folder', display: 'Folder', tag: 'input', type: 'text', limit: 120, null: true, autocapitalize: false },
{ name: 'group_id', display: 'Group', tag: 'select', multiple: false, null: false, nulloption: true, relation: 'Group' },
{ name: 'active', display: 'Active', tag: 'select', multiple: false, null: false, options: { true: 'yes', false: 'no' }, translate: true, default: true },
]
App.Channel.refresh( [
{
id: 1,
adapter: 'adapter1',
options: {
host: 'host1',
user: 'user1',
},
group_id: 5,
active: true,
created_at: '2014-06-10T11:17:34.000Z',
},
{
id: 2,
adapter: 'adapter2',
options: {
host: 'host2',
user: 'user2',
},
group_id: 5,
active: true,
created_at: '2014-06-10T11:17:34.000Z',
},
] )
new App.ControllerTable({
el: el,
overview: ['adapter', 'options::host', 'options::user', 'active'],
model: App.Channel,
objects: App.Channel.search({sortBy:'adapter', order: 'ASC'}),
})
assert.equal(el.find('table > thead > tr').length, 1, 'row count')
assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Typ', 'check header')
assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Host', 'check header')
assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Benutzer', 'check header')
assert.equal(el.find('table > thead > tr > th:nth-child(4)').text().trim(), 'Aktiv', 'check header')
assert.equal(el.find('table > thead > tr > th:nth-child(5)').text().trim(), 'Aktion', 'check header')
assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 5, 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(1)').text().trim(), 'adapter1', 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), 'host1', 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'user1', 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(4)').text().trim(), 'ja', 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(5) .dropdown.dropdown--actions .js-delete').length, 1, 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(5) .dropdown.dropdown--actions .js-clone').length, 1, 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 5, 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(1)').text().trim(), 'adapter2', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), 'host2', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'user2', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(4)').text().trim(), 'ja', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(5) .dropdown.dropdown--actions .js-delete').length, 1, 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(5) .dropdown.dropdown--actions .js-clone').length, 1, 'check row 2')
});
QUnit.test('table test 4', assert => {
App.i18n.set('de-de')
$('#qunit').append('<hr><h1>table with link</h1><div id="table-link1"></div>')
var el = $('#table-link1')
App.EmailAddress.refresh( [
{
id: 55,
realname: 'realname 55',
email: 'email 55',
active: true,
created_at: '2014-06-10T11:17:34.000Z',
},
{
id: 56,
realname: 'realname 56',
email: 'email 56',
active: true,
created_at: '2014-06-10T11:17:34.000Z',
},
])
var callbackHeader = function (header) {
console.log('current header is', header);
// add new header item
var attribute = {
name: 'some name',
display: 'Some Name',
};
header.push(attribute);
console.log('new header is', header);
return header
}
var callbackAttributes = function(value, object, attribute, header, refObject) {
console.log('data of item col', value, object, attribute, header, refObject)
value = ' '
attribute.class = 'glyphicon glyphicon-user'
attribute.link = '#'
attribute.title = App.i18n.translateInline('Switch to')
if (object.id == 55) {
attribute.data = {
some: 'value55',
xxx: 55,
}
}
else {
attribute.data = {
some: 'value56',
xxx: 56,
}
}
return value
}
var switchTo = function(id, e) {
e.preventDefault()
console.log('switchTo with id', id, e.target)
//@disconnectClient()
//App.Auth._logout()
//window.location = App.Config.get('api_path') + '/sessions/switch/' + id
}
new App.ControllerTable({
el: el,
model: App.EmailAddress,
objects: App.EmailAddress.search({sortBy:'realname', order: 'ASC'}),
callbackHeader: [callbackHeader],
callbackAttributes: {
'some name': [ callbackAttributes ]
},
bindCol: {
'some name': {
events: {
'click': switchTo,
}
},
},
})
assert.equal(el.find('table > thead > tr').length, 1, 'row count')
assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Anzeigename', 'check header')
assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Some Name', 'check header')
assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(1)').text().trim(), 'realname 55', 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), 'email 55', 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), '', 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3) > a > span').hasClass('glyphicon-user'), true, 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3) > a > span').hasClass('glyphicon'), true, 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').attr('title'), 'Umschalten zu', 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3) > a > span').data('some'), 'value55', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3) > a > span').data('xxx'), '55', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(1)').text().trim(), 'realname 56', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), 'email 56', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), '', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3) > a > span').hasClass('glyphicon-user'), true, 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3) > a > span').hasClass('glyphicon'), true, 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').attr('title'), 'Umschalten zu', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3) > a > span').data('some'), 'value56', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3) > a > span').data('xxx'), '56', 'check row 2')
});
QUnit.test('table test 5', assert => {
App.i18n.set('de-de')
$('#qunit').append('<hr><h1>table with data</h1><div id="table-data1"></div>')
var el = $('#table-data1')
data = [
{ name: 'some name 1', data: 'some data 1', active: true },
{ name: 'some name 2', data: 'some data 2', active: false },
{ name: 'some name 3', data: 'some data 3', active: true },
]
new App.ControllerTable({
el: el,
overview: ['name', 'data', 'active'],
attribute_list: [
{ name: 'name', display: 'Name', type: 'text', style: 'width: 10%' },
{ name: 'data', display: 'Data', type: 'text' },
{ name: 'active', display: 'Active', type: 'text' },
],
objects: data
});
assert.equal(el.find('table > thead > tr').length, 1, 'row count')
assert.equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
assert.equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Data', 'check header')
assert.equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
assert.equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), 'some name 1', 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), 'some data 1', 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true', 'check row 1')
assert.equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), 'some name 2', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), 'some data 2', 'check row 2')
assert.equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'false', 'check row 2')
});
QUnit.test('table test 6/7', assert => {
$('#qunit').append('<hr><h1>sotable table with data</h1><div id="table-data6"></div>')
var el_head_sortable = $('#table-data6')
$('#qunit').append('<hr><h1>not sortable table with data</h1><div id="table-data7"></div>')
var el_not_head_sortable = $('#table-data7')
data = [
{ name: 'a item', data: 'g data', active: true },
{ name: 'b item', data: 'b data', active: false },
{ name: 'c item', data: 'z data', active: false },
{ name: 'd item', data: '', active: false },
]
new App.ControllerTable({
tableId: 'a',
el: el_head_sortable,
overview: ['name', 'data', 'active'],
attribute_list: [
{ name: 'name', display: 'Name', type: 'text', style: 'width: 10%', unsortable: true },
{ name: 'data', display: 'Data', type: 'text' },
{ name: 'active', display: 'Active', type: 'text' },
],
objects: data
});
new App.ControllerTable({
tableId: 'b',
el: el_not_head_sortable,
overview: ['name', 'data', 'active'],
attribute_list: [
{ name: 'name', display: 'Name', type: 'text', style: 'width: 10%', unsortable: true },
{ name: 'data', display: 'Data', type: 'text' },
{ name: 'active', display: 'Active', type: 'text' },
],
objects: data,
dndCallback: function() { return true }
});
assert.equal(el_head_sortable.find('tbody > tr:nth-child(1) > td:first').text().trim(), 'a item', 'check row 1')
assert.equal(el_not_head_sortable.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), 'a item', 'check row 1')
assert.ok(_.isEqual(list_items(el_head_sortable, 1), ['a item', 'b item', 'c item', 'd item']), 'sortable table is rendered correctly')
assert.ok(_.isEqual(list_items(el_not_head_sortable, 2), ['a item', 'b item', 'c item', 'd item']), 'unsortable table is rendered correctly')
click_sort(el_head_sortable, 2)
click_sort(el_not_head_sortable, 3)
assert.ok(_.isEqual(list_items(el_head_sortable, 1), ['b item', 'a item', 'c item', 'd item']), 'sortable table is sorted')
assert.ok(_.isEqual(list_items(el_not_head_sortable, 2), ['a item', 'b item', 'c item', 'd item']), 'unsortable table is not sorted')
click_sort(el_head_sortable, 3)
assert.ok(_.isEqual(list_items(el_head_sortable, 1), ['b item', 'c item', 'd item', 'a item']), 'sorting by boolean column works')
click_sort(el_head_sortable, 1)
assert.ok(_.isEqual(list_items(el_head_sortable, 1), ['b item', 'c item', 'd item', 'a item']), 'sorting on name column is disabled')
});
function click_sort(table, column_number) {
table
.find(`table > thead > tr > th:nth-child(${column_number}) > .js-sort`)
.click()
}
function list_items(table, column_number) {
return table
.find(`tbody > tr > td:nth-child(${column_number})`)
.text()
.split("\n")
.filter(elem => elem.match(/[\w]+/))
.map(elem => elem.trim())
}

File diff suppressed because it is too large Load diff

View file

@ -0,0 +1,316 @@
window.onload = function() {
QUnit.test( "taskbar basic tests", assert => {
// create task bar div
$('#qunit').append('<hr><h1>taskbar basic tests</h1><div id="taskbar1"></div>')
App.TaskManager.init({
el: $('#taskbar1'),
offlineModus: true,
force: true,
})
// add tasks
App.TaskManager.execute({
key: 'TestKey1',
controller: 'TestController1',
params: {
message: '#1',
},
show: true,
persistent: false,
})
assert.equal($('#qunit .content').length, 1, "check available active contents")
assert.equal($('#qunit .content.active').length, 1, "check available active contents")
assert.equal($('#qunit .content.active').text(), "some test controller message:'#1',show:'true',hide:'false',active:'true'", "check active content!")
// verify
task = App.TaskManager.get('TestKey1')
assert.equal(task.notify, false)
assert.deepEqual(task.state, undefined)
assert.deepEqual(task.params, { "message": "#1", "shown": true })
// update
App.TaskManager.update('TestKey1', { 'state': 'abc' })
App.TaskManager.update('TestKey1', { 'params': { a: 12 } })
App.TaskManager.notify('TestKey1')
// verify
task = App.TaskManager.get('TestKey1')
assert.equal(task.notify, true)
assert.deepEqual(task.state, 'abc')
assert.deepEqual(task.params, { "a": 12 })
App.TaskManager.execute({
key: 'TestKey2',
controller: 'TestController1',
params: {
message: '#2',
},
show: true,
persistent: false,
})
assert.equal($('#qunit .content').length, 2, "check available active contents")
assert.equal($('#qunit .content.active').length, 1, "check available active contents")
assert.equal($('#qunit .content.active').text(), "some test controller message:'#2',show:'true',hide:'false',active:'true'", "check active content!")
assert.equal($('#qunit #content_permanent_TestKey1').text(), "some test controller message:'#1',show:'true',hide:'true',active:'false'", "check active content!")
assert.equal($('#qunit #content_permanent_TestKey2').text(), "some test controller message:'#2',show:'true',hide:'false',active:'true'", "check active content!")
// check task history
assert.equal(App.TaskManager.nextTaskUrl(), '#/some/url/#2')
assert.equal(App.TaskManager.nextTaskUrl(), '#/some/url/#1')
App.TaskManager.execute({
key: 'TestKey3',
controller: 'TestController1',
params: {
message: '#3',
},
show: false,
persistent: false,
})
assert.equal($('#qunit .content').length, 2, "check available active contents")
assert.equal($('#qunit .content.active').length, 1, "check available active contents")
assert.equal($('#qunit .content.active').text(), "some test controller message:'#2',show:'true',hide:'false',active:'true'")
assert.equal($('#qunit #content_permanent_TestKey1').text(), "some test controller message:'#1',show:'true',hide:'true',active:'false'", "check active content!")
assert.equal($('#qunit #content_permanent_TestKey2').text(), "some test controller message:'#2',show:'true',hide:'false',active:'true'", "check active content!")
App.TaskManager.execute({
key: 'TestKey3',
controller: 'TestController1',
params: {
message: '#3',
},
show: true,
persistent: false,
})
assert.equal($('#qunit .content').length, 3, "check available active contents")
assert.equal($('#qunit .content.active').length, 1, "check available active contents")
assert.equal($('#qunit .content.active').text(), "some test controller message:'#3',show:'true',hide:'true',active:'true'", "check active content!")
assert.equal($('#qunit #content_permanent_TestKey1').text(), "some test controller message:'#1',show:'true',hide:'true',active:'false'", "check active content!")
assert.equal($('#qunit #content_permanent_TestKey2').text(), "some test controller message:'#2',show:'true',hide:'true',active:'false'", "check active content!")
assert.equal($('#qunit #content_permanent_TestKey3').text(), "some test controller message:'#3',show:'true',hide:'true',active:'true'", "check active content!")
App.TaskManager.execute({
key: 'TestKey4',
controller: 'TestController1',
params: {
message: '#4',
},
show: false,
persistent: true,
})
assert.equal($('#qunit .content').length, 3, "check available active contents")
assert.equal($('#qunit .content.active').length, 1, "check available active contents")
assert.equal($('#qunit .content.active').text(), "some test controller message:'#3',show:'true',hide:'true',active:'true'", "check active content!")
assert.equal($('#qunit #content_permanent_TestKey1').text(), "some test controller message:'#1',show:'true',hide:'true',active:'false'", "check active content!")
assert.equal($('#qunit #content_permanent_TestKey2').text(), "some test controller message:'#2',show:'true',hide:'true',active:'false'", "check active content!")
assert.equal($('#qunit #content_permanent_TestKey3').text(), "some test controller message:'#3',show:'true',hide:'true',active:'true'", "check active content!")
App.TaskManager.execute({
key: 'TestKey5',
controller: 'TestController1',
params: {
message: '#5',
},
show: true,
persistent: true,
})
assert.equal($('#qunit .content').length, 4, "check available active contents")
assert.equal($('#qunit .content.active').length, 1, "check available active contents")
assert.equal($('#qunit .content.active').text(), "some test controller message:'#5',show:'true',hide:'false',active:'true'")
assert.equal($('#qunit #content_permanent_TestKey1').text(), "some test controller message:'#1',show:'true',hide:'true',active:'false'", "check active content!")
assert.equal($('#qunit #content_permanent_TestKey2').text(), "some test controller message:'#2',show:'true',hide:'true',active:'false'", "check active content!")
assert.equal($('#qunit #content_permanent_TestKey3').text(), "some test controller message:'#3',show:'true',hide:'true',active:'false'", "check active content!")
assert.equal($('#qunit #content_permanent_TestKey5').text(), "some test controller message:'#5',show:'true',hide:'false',active:'true'", "check active content!")
App.TaskManager.execute({
key: 'TestKey6',
controller: 'TestController1',
params: {
message: '#6',
},
show: true,
persistent: false,
})
assert.equal($('#qunit .content').length, 5, "check available active contents")
assert.equal($('#qunit .content.active').length, 1, "check available active contents")
assert.equal($('#qunit .content.active').text(), "some test controller message:'#6',show:'true',hide:'false',active:'true'")
assert.equal($('#qunit #content_permanent_TestKey1').text(), "some test controller message:'#1',show:'true',hide:'true',active:'false'", "check active content!")
assert.equal($('#qunit #content_permanent_TestKey2').text(), "some test controller message:'#2',show:'true',hide:'true',active:'false'", "check active content!")
assert.equal($('#qunit #content_permanent_TestKey3').text(), "some test controller message:'#3',show:'true',hide:'true',active:'false'", "check active content!")
assert.equal($('#qunit #content_permanent_TestKey5').text(), "some test controller message:'#5',show:'true',hide:'true',active:'false'", "check active content!")
assert.equal($('#qunit #content_permanent_TestKey6').text(), "some test controller message:'#6',show:'true',hide:'false',active:'true'", "check active content!")
// remove task#2
App.TaskManager.remove('TestKey2')
assert.equal($('#qunit .content').length, 4, "check available active contents")
assert.equal($('#qunit .content.active').length, 1, "check available active contents")
assert.equal($('#qunit .content.active').text(), "some test controller message:'#6',show:'true',hide:'false',active:'true'")
assert.equal($('#qunit #content_permanent_TestKey1').text(), "some test controller message:'#1',show:'true',hide:'true',active:'false'", "check active content!")
assert.equal($('#qunit #content_permanent_TestKey3').text(), "some test controller message:'#3',show:'true',hide:'true',active:'false'", "check active content!")
assert.equal($('#qunit #content_permanent_TestKey5').text(), "some test controller message:'#5',show:'true',hide:'true',active:'false'", "check active content!")
assert.equal($('#qunit #content_permanent_TestKey6').text(), "some test controller message:'#6',show:'true',hide:'false',active:'true'", "check active content!")
// activate task#3
App.TaskManager.execute({
key: 'TestKey3',
controller: 'TestController1',
params: {
message: '#3',
},
show: true,
persistent: false,
})
assert.equal($('#qunit .content').length, 4, "check available active contents")
assert.equal($('#qunit .content.active').length, 1, "check available active contents")
assert.equal($('#qunit .content.active').text(), "some test controller message:'#3',show:'true',hide:'true',active:'true'")
assert.equal($('#qunit #content_permanent_TestKey1').text(), "some test controller message:'#1',show:'true',hide:'true',active:'false'", "check active content!")
assert.equal($('#qunit #content_permanent_TestKey3').text(), "some test controller message:'#3',show:'true',hide:'true',active:'true'", "check active content!")
assert.equal($('#qunit #content_permanent_TestKey5').text(), "some test controller message:'#5',show:'true',hide:'true',active:'false'", "check active content!")
assert.equal($('#qunit #content_permanent_TestKey6').text(), "some test controller message:'#6',show:'true',hide:'true',active:'false'", "check active content!")
// activate task#1
App.TaskManager.execute({
key: 'TestKey1',
controller: 'TestController1',
params: {
message: '#1',
},
show: true,
persistent: false,
})
assert.equal($('#qunit .content').length, 4, "check available active contents")
assert.equal($('#qunit .content.active').length, 1, "check available active contents")
assert.equal($('#qunit .content.active').text(), "some test controller message:'#1',show:'true',hide:'true',active:'true'")
assert.equal($('#qunit #content_permanent_TestKey1').text(), "some test controller message:'#1',show:'true',hide:'true',active:'true'", "check active content!")
assert.equal($('#qunit #content_permanent_TestKey3').text(), "some test controller message:'#3',show:'true',hide:'true',active:'false'", "check active content!")
assert.equal($('#qunit #content_permanent_TestKey5').text(), "some test controller message:'#5',show:'true',hide:'true',active:'false'", "check active content!")
assert.equal($('#qunit #content_permanent_TestKey6').text(), "some test controller message:'#6',show:'true',hide:'true',active:'false'", "check active content!")
// remove task#1
App.TaskManager.remove('TestKey1')
// verify if task#3 is active
assert.equal($('#qunit .content').length, 3, "check available active contents")
assert.equal($('#qunit .content.active').length, 0, "check available active contents")
assert.equal($('#qunit .content.active').text(), "")
// remove task#3
App.TaskManager.remove('TestKey3')
// verify if task#5 is active
assert.equal($('#qunit .content').length, 2, "check available active contents")
assert.equal($('#qunit .content.active').length, 0, "check available active contents")
assert.equal($('#qunit .content.active').text(), "")
// remove task#5 // can not get removed because of permanent task
App.TaskManager.remove('TestKey5')
// verify if task#5 is active
assert.equal($('#qunit .content').length, 2, "check available active contents")
assert.equal($('#qunit .content.active').length, 0, "check available active contents")
assert.equal($('#qunit .content.active').text(), "")
// create task#7
App.TaskManager.execute({
key: 'TestKey7',
controller: 'TestController1',
params: {
message: '#7',
},
show: true,
persistent: false,
})
assert.equal($('#qunit .content').length, 3, "check available active contents")
assert.equal($('#qunit .content.active').length, 1, "check available active contents")
assert.equal($('#qunit .content.active').text(), "some test controller message:'#7',show:'true',hide:'false',active:'true'", "check active content!")
// remove task#7
App.TaskManager.remove('TestKey7')
// verify if task#5 is active
assert.equal($('#qunit .content').length, 2, "check available active contents")
assert.equal($('#qunit .content.active').length, 0, "check available active contents")
assert.equal($('#qunit .content.active').text(), "")
// check task history
assert.equal(App.TaskManager.nextTaskUrl(), '#/some/url/#6')
assert.equal(App.TaskManager.nextTaskUrl(), '#/some/url/#5')
assert.equal(App.TaskManager.nextTaskUrl(), '#/some/url/#6')
assert.equal(App.TaskManager.nextTaskUrl(), '#/some/url/#6')
// remove task#6
App.TaskManager.remove('TestKey6')
// check task history
assert.equal(App.TaskManager.nextTaskUrl(), false)
assert.equal(App.TaskManager.nextTaskUrl(), false)
// check max tabs
var times = 5;
App.TaskManager.tasksAutoCleanupDelayTime(200)
App.TaskManager.tasksAutoCleanupTaskMax(3)
for(var i=0; i < times; i++){
App.TaskManager.execute({
key: 'TestKeyLoop' + i,
controller: 'TestController1',
params: {
message: "#" + i,
},
show: true,
persistent: false,
})
}
assert.equal(App.TaskManager.all().length, 5)
})
App.Delay.set(function() {
QUnit.test( "taskbar check max tabs 2", assert => {
assert.equal(App.TaskManager.all().length, 3)
var times = 5;
for(var i=0; i < times; i++){
App.TaskManager.execute({
key: 'TestKeyLoop2' + i,
controller: 'TestController1',
params: {
message: "#" + i,
changedState: true
},
show: true,
persistent: false,
})
}
assert.equal(App.TaskManager.all().length, 8)
})
}, 1000);
App.Delay.set(function() {
QUnit.test( "taskbar check max tabs 5", assert => {
assert.equal(App.TaskManager.all().length, 5)
// destroy task bar
App.TaskManager.reset()
// check if any taskar exists
assert.equal($('#qunit .content').length, 0, "check available active contents")
})
}, 2000);
}

View file

@ -1,5 +1,5 @@
// text module
test('test text module behaviour with group_ids', function() {
QUnit.test('test text module behaviour with group_ids', assert => {
// active textmodule without group_ids
App.TextModule.refresh([
@ -46,9 +46,9 @@ test('test text module behaviour with group_ids', function() {
var currentCollection = textModule.currentCollection();
equal(currentCollection.length, 2, 'active textmodule')
equal(currentCollection[0].id, 1)
equal(currentCollection[1].id, 3)
assert.equal(currentCollection.length, 2, 'active textmodule')
assert.equal(currentCollection[0].id, 1)
assert.equal(currentCollection[1].id, 3)
// trigered TextModulePreconditionUpdate with group_id
@ -59,9 +59,9 @@ test('test text module behaviour with group_ids', function() {
currentCollection = textModule.currentCollection();
equal(currentCollection.length, 2, 'trigered TextModulePreconditionUpdate with group_id')
equal(currentCollection[0].id, 1)
equal(currentCollection[1].id, 3)
assert.equal(currentCollection.length, 2, 'trigered TextModulePreconditionUpdate with group_id')
assert.equal(currentCollection[0].id, 1)
assert.equal(currentCollection[1].id, 3)
// trigered TextModulePreconditionUpdate with wrong group_id
@ -72,8 +72,8 @@ test('test text module behaviour with group_ids', function() {
currentCollection = textModule.currentCollection();
equal(currentCollection.length, 1, 'trigered TextModulePreconditionUpdate with wrong group_id')
equal(currentCollection[0].id, 1)
assert.equal(currentCollection.length, 1, 'trigered TextModulePreconditionUpdate with wrong group_id')
assert.equal(currentCollection[0].id, 1)
// trigered TextModulePreconditionUpdate with group_id but wrong taskKey
@ -84,8 +84,8 @@ test('test text module behaviour with group_ids', function() {
currentCollection = textModule.currentCollection();
equal(currentCollection.length, 1, 'trigered TextModulePreconditionUpdate with group_id but wrong taskKey - nothing has changed')
equal(currentCollection[0].id, 1)
assert.equal(currentCollection.length, 1, 'trigered TextModulePreconditionUpdate with group_id but wrong taskKey - nothing has changed')
assert.equal(currentCollection[0].id, 1)
// trigered TextModulePreconditionUpdate without group_id
@ -96,8 +96,8 @@ test('test text module behaviour with group_ids', function() {
currentCollection = textModule.currentCollection();
equal(currentCollection.length, 2, 'trigered TextModulePreconditionUpdate without group_id')
equal(currentCollection[0].id, 1)
equal(currentCollection[1].id, 3)
assert.equal(currentCollection.length, 2, 'trigered TextModulePreconditionUpdate without group_id')
assert.equal(currentCollection[0].id, 1)
assert.equal(currentCollection[1].id, 3)
});

View file

@ -20,7 +20,7 @@ QUnit.module("ticket macro pending time check", hooks => {
return new Date(ticket.pending_time) - new Date()
}
test("5 days", assert => {
QUnit.test("5 days", assert => {
var rules = {
operator: "relative",
range: "day",
@ -30,7 +30,7 @@ QUnit.module("ticket macro pending time check", hooks => {
assert.equal(calculate_travel_on_ticket(rules), 60 * 60 * 24 * 5 * 1000)
})
test("5 minutes", assert => {
QUnit.test("5 minutes", assert => {
var rules = {
operator: "relative",
range: "minute",
@ -40,7 +40,7 @@ QUnit.module("ticket macro pending time check", hooks => {
assert.equal(calculate_travel_on_ticket(rules), 60 * 3 * 1000)
});
test("10 hours", assert => {
QUnit.test("10 hours", assert => {
var rules = {
operator: "relative",
range: "hour",

View file

@ -186,7 +186,7 @@ window.onload = function() {
* ------------------------------------------------------------------------
*/
var testContains = function (key, value, ticket) {
var testContains = function (assert, key, value, ticket) {
setting = {
"condition": {
[key]: {
@ -196,7 +196,7 @@ window.onload = function() {
}
};
result = App.Ticket.selector(ticket, setting['condition']);
equal(result, true, result);
assert.equal(result, true, result);
setting = {
"condition": {
@ -207,10 +207,10 @@ window.onload = function() {
}
};
result = App.Ticket.selector(ticket, setting['condition']);
equal(result, false, result);
assert.equal(result, false, result);
};
var testIs = function (key, value, ticket) {
var testIs = function (assert, key, value, ticket) {
setting = {
"condition": {
[key]: {
@ -220,7 +220,7 @@ window.onload = function() {
}
};
result = App.Ticket.selector(ticket, setting['condition']);
equal(result, true, result);
assert.equal(result, true, result);
setting = {
"condition": {
@ -231,10 +231,10 @@ window.onload = function() {
}
};
result = App.Ticket.selector(ticket, setting['condition']);
equal(result, false, result);
assert.equal(result, false, result);
};
var testPreConditionUser = function (key, specificValue, ticket, session) {
var testPreConditionUser = function (assert, key, specificValue, ticket, session) {
App.Session.set(6);
setting = {
@ -248,7 +248,7 @@ window.onload = function() {
}
};
result = App.Ticket.selector(ticket, setting['condition']);
equal(result, true, result);
assert.equal(result, true, result);
setting = {
"condition": {
@ -261,7 +261,7 @@ window.onload = function() {
}
};
result = App.Ticket.selector(ticket, setting['condition']);
equal(result, false, result);
assert.equal(result, false, result);
setting = {
"condition": {
@ -275,7 +275,7 @@ window.onload = function() {
};
result = App.Ticket.selector(ticket, setting['condition']);
equal(result, true, result);
assert.equal(result, true, result);
setting = {
"condition": {
@ -288,7 +288,7 @@ window.onload = function() {
}
};
result = App.Ticket.selector(ticket, setting['condition']);
equal(result, false, result);
assert.equal(result, false, result);
setting = {
"condition": {
@ -301,7 +301,7 @@ window.onload = function() {
}
};
result = App.Ticket.selector(ticket, setting['condition']);
equal(result, false, result);
assert.equal(result, false, result);
setting = {
"condition": {
@ -312,7 +312,7 @@ window.onload = function() {
}
};
result = App.Ticket.selector(ticket, setting['condition']);
equal(result, false, result);
assert.equal(result, false, result);
setting = {
"condition": {
@ -323,10 +323,10 @@ window.onload = function() {
}
};
result = App.Ticket.selector(ticket, setting['condition']);
equal(result, true, result);
assert.equal(result, true, result);
};
var testPreConditionOrganization = function (key, specificValue, ticket, session) {
var testPreConditionOrganization = function (assert, key, specificValue, ticket, session) {
App.Session.set(6);
setting = {
@ -340,7 +340,7 @@ window.onload = function() {
}
};
result = App.Ticket.selector(ticket, setting['condition']);
equal(result, true, result);
assert.equal(result, true, result);
setting = {
"condition": {
@ -353,7 +353,7 @@ window.onload = function() {
}
};
result = App.Ticket.selector(ticket, setting['condition']);
equal(result, false, result);
assert.equal(result, false, result);
setting = {
"condition": {
@ -367,7 +367,7 @@ window.onload = function() {
};
result = App.Ticket.selector(ticket, setting['condition']);
equal(result, true, result);
assert.equal(result, true, result);
setting = {
"condition": {
@ -380,7 +380,7 @@ window.onload = function() {
}
};
result = App.Ticket.selector(ticket, setting['condition']);
equal(result, false, result);
assert.equal(result, false, result);
setting = {
"condition": {
@ -393,7 +393,7 @@ window.onload = function() {
}
};
result = App.Ticket.selector(ticket, setting['condition']);
equal(result, false, result);
assert.equal(result, false, result);
setting = {
"condition": {
@ -404,7 +404,7 @@ window.onload = function() {
}
};
result = App.Ticket.selector(ticket, setting['condition']);
equal(result, false, result);
assert.equal(result, false, result);
setting = {
"condition": {
@ -415,10 +415,10 @@ window.onload = function() {
}
};
result = App.Ticket.selector(ticket, setting['condition']);
equal(result, true, result);
assert.equal(result, true, result);
};
var testPreConditionTags = function (key, ticket) {
var testPreConditionTags = function (assert, key, ticket) {
App.Session.set(6);
setting = {
@ -430,7 +430,7 @@ window.onload = function() {
}
};
result = App.Ticket.selector(ticket, setting['condition']);
equal(result, true, result);
assert.equal(result, true, result);
setting = {
"condition": {
@ -441,7 +441,7 @@ window.onload = function() {
}
};
result = App.Ticket.selector(ticket, setting['condition']);
equal(result, false, result);
assert.equal(result, false, result);
setting = {
"condition": {
@ -452,7 +452,7 @@ window.onload = function() {
}
};
result = App.Ticket.selector(ticket, setting['condition']);
equal(result, true, result);
assert.equal(result, true, result);
setting = {
"condition": {
@ -463,7 +463,7 @@ window.onload = function() {
}
};
result = App.Ticket.selector(ticket, setting['condition']);
equal(result, false, result);
assert.equal(result, false, result);
setting = {
"condition": {
@ -474,7 +474,7 @@ window.onload = function() {
}
};
result = App.Ticket.selector(ticket, setting['condition']);
equal(result, false, result);
assert.equal(result, false, result);
setting = {
"condition": {
@ -485,7 +485,7 @@ window.onload = function() {
}
};
result = App.Ticket.selector(ticket, setting['condition']);
equal(result, false, result);
assert.equal(result, false, result);
setting = {
"condition": {
@ -496,7 +496,7 @@ window.onload = function() {
}
};
result = App.Ticket.selector(ticket, setting['condition']);
equal(result, false, result);
assert.equal(result, false, result);
setting = {
"condition": {
@ -507,7 +507,7 @@ window.onload = function() {
}
};
result = App.Ticket.selector(ticket, setting['condition']);
equal(result, true, result);
assert.equal(result, true, result);
setting = {
"condition": {
@ -518,7 +518,7 @@ window.onload = function() {
}
};
result = App.Ticket.selector(ticket, setting['condition']);
equal(result, true, result);
assert.equal(result, true, result);
setting = {
"condition": {
@ -529,7 +529,7 @@ window.onload = function() {
}
};
result = App.Ticket.selector(ticket, setting['condition']);
equal(result, false, result);
assert.equal(result, false, result);
setting = {
"condition": {
@ -540,7 +540,7 @@ window.onload = function() {
}
};
result = App.Ticket.selector(ticket, setting['condition']);
equal(result, true, result);
assert.equal(result, true, result);
setting = {
"condition": {
@ -551,11 +551,11 @@ window.onload = function() {
}
};
result = App.Ticket.selector(ticket, setting['condition']);
equal(result, true, result);
assert.equal(result, true, result);
};
var testTime = function (key, value, ticket) {
var testTime = function (assert, key, value, ticket) {
valueDate = new Date(value);
compareDate = new Date( valueDate.setHours( valueDate.getHours() - 1 ) ).toISOString();
setting = {
@ -567,7 +567,7 @@ window.onload = function() {
}
};
result = App.Ticket.selector(ticket, setting['condition']);
equal(result, true, result);
assert.equal(result, true, result);
valueDate = new Date(value);
compareDate = new Date( valueDate.setHours( valueDate.getHours() + 1 ) ).toISOString();
@ -580,7 +580,7 @@ window.onload = function() {
}
};
result = App.Ticket.selector(ticket, setting['condition']);
equal(result, false, result);
assert.equal(result, false, result);
valueDate = new Date(value);
compareDate = new Date( valueDate.setHours( valueDate.getHours() - 1 ) ).toISOString();
@ -593,7 +593,7 @@ window.onload = function() {
}
};
result = App.Ticket.selector(ticket, setting['condition']);
equal(result, false, result);
assert.equal(result, false, result);
valueDate = new Date(value);
compareDate = new Date( valueDate.setHours( valueDate.getHours() + 1 ) ).toISOString();
@ -606,7 +606,7 @@ window.onload = function() {
}
};
result = App.Ticket.selector(ticket, setting['condition']);
equal(result, true, result);
assert.equal(result, true, result);
valueDate = new Date(value);
compareDate = new Date( valueDate.setHours( valueDate.getHours() + 2 ) ).toISOString();
@ -620,10 +620,10 @@ window.onload = function() {
}
};
result = App.Ticket.selector(ticket, setting['condition']);
equal(result, true, result);
assert.equal(result, true, result);
};
var testTimeBeforeRelative = function (key, value, range, expectedResult, ticket) {
var testTimeBeforeRelative = function (assert, key, value, range, expectedResult, ticket) {
setting = {
"condition": {
[key]: {
@ -634,10 +634,10 @@ window.onload = function() {
}
};
result = App.Ticket.selector(ticket, setting['condition']);
equal(result, expectedResult, result);
assert.equal(result, expectedResult, result);
};
var testTimeAfterRelative = function (key, value, range, expectedResult, ticket) {
var testTimeAfterRelative = function (assert, key, value, range, expectedResult, ticket) {
setting = {
"condition": {
[key]: {
@ -648,10 +648,10 @@ window.onload = function() {
}
};
result = App.Ticket.selector(ticket, setting['condition']);
equal(result, expectedResult, result);
assert.equal(result, expectedResult, result);
};
var testTimeWithinNextRelative = function (key, value, range, expectedResult, ticket) {
var testTimeWithinNextRelative = function (assert, key, value, range, expectedResult, ticket) {
setting = {
"condition": {
[key]: {
@ -662,10 +662,10 @@ window.onload = function() {
}
};
result = App.Ticket.selector(ticket, setting['condition']);
equal(result, expectedResult, result);
assert.equal(result, expectedResult, result);
};
var testTimeWithinLastRelative = function (key, value, range, expectedResult, ticket) {
var testTimeWithinLastRelative = function (assert, key, value, range, expectedResult, ticket) {
setting = {
"condition": {
[key]: {
@ -676,7 +676,7 @@ window.onload = function() {
}
};
result = App.Ticket.selector(ticket, setting['condition']);
equal(result, expectedResult, result);
assert.equal(result, expectedResult, result);
};
/*
@ -685,64 +685,64 @@ window.onload = function() {
* ------------------------------------------------------------------------
*/
test("ticket number", function() {
QUnit.test("ticket number", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testContains('ticket.number', '72', ticket);
testContains(assert, 'ticket.number', '72', ticket);
});
test("ticket title", function() {
QUnit.test("ticket title", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testContains('ticket.title', 'asd', ticket);
testContains(assert, 'ticket.title', 'asd', ticket);
});
test("ticket customer_id", function() {
QUnit.test("ticket customer_id", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
App.Session.set(6);
testPreConditionUser('ticket.customer_id', '6', ticket, sessionData);
testPreConditionUser(assert, 'ticket.customer_id', '6', ticket, sessionData);
});
test("ticket organization_id", function() {
QUnit.test("ticket organization_id", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testPreConditionUser('ticket.organization_id', '6', ticket, sessionData);
testPreConditionUser(assert, 'ticket.organization_id', '6', ticket, sessionData);
});
test("ticket group_id", function() {
QUnit.test("ticket group_id", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testIs('ticket.group_id', ['1'], ticket, sessionData);
testIs(assert, 'ticket.group_id', ['1'], ticket, sessionData);
});
test("ticket owner_id", function() {
QUnit.test("ticket owner_id", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
App.Session.set(6);
testPreConditionUser('ticket.owner_id', '6', ticket, sessionData);
testPreConditionUser(assert, 'ticket.owner_id', '6', ticket, sessionData);
});
test("ticket state_id", function() {
QUnit.test("ticket state_id", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testIs('ticket.state_id', ['4'], ticket, sessionData);
testIs(assert, 'ticket.state_id', ['4'], ticket, sessionData);
});
test("ticket pending_time", function() {
QUnit.test("ticket pending_time", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testTime('ticket.pending_time', ticket.pending_time, ticket);
testTime(assert, 'ticket.pending_time', ticket.pending_time, ticket);
// -------------------------
// BEFORE TIME
@ -750,30 +750,30 @@ window.onload = function() {
// hour
ticket.pending_time = new Date().toISOString();
testTimeBeforeRelative('ticket.pending_time', 1, 'hour', false, ticket);
testTimeBeforeRelative(assert, 'ticket.pending_time', 1, 'hour', false, ticket);
compareDate = new Date();
compareDate.setTime( compareDate.getTime() - 60 * 60 * 2 * 1000);
ticket.pending_time = compareDate.toISOString();
testTimeBeforeRelative('ticket.pending_time', 1, 'hour', true, ticket);
testTimeBeforeRelative(assert, 'ticket.pending_time', 1, 'hour', true, ticket);
// day
ticket.pending_time = new Date().toISOString();
testTimeBeforeRelative('ticket.pending_time', 1, 'day', false, ticket);
testTimeBeforeRelative(assert, 'ticket.pending_time', 1, 'day', false, ticket);
compareDate = new Date();
compareDate.setTime( compareDate.getTime() - 60 * 60 * 48 * 1000);
ticket.pending_time = compareDate.toISOString();
testTimeBeforeRelative('ticket.pending_time', 1, 'day', true, ticket);
testTimeBeforeRelative(assert, 'ticket.pending_time', 1, 'day', true, ticket);
// year
ticket.pending_time = new Date().toISOString();
testTimeBeforeRelative('ticket.pending_time', 1, 'year', false, ticket);
testTimeBeforeRelative(assert, 'ticket.pending_time', 1, 'year', false, ticket);
compareDate = new Date();
compareDate.setTime( compareDate.getTime() - 60 * 60 * 365 * 2 * 1000);
ticket.pending_time = compareDate.toISOString();
testTimeBeforeRelative('ticket.pending_time', 1, 'year', true, ticket);
testTimeBeforeRelative(assert, 'ticket.pending_time', 1, 'year', true, ticket);
// -------------------------
// AFTER TIME
@ -781,30 +781,30 @@ window.onload = function() {
// hour
ticket.pending_time = new Date().toISOString();
testTimeAfterRelative('ticket.pending_time', 1, 'hour', false, ticket);
testTimeAfterRelative(assert, 'ticket.pending_time', 1, 'hour', false, ticket);
compareDate = new Date();
compareDate.setTime( compareDate.getTime() + 60 * 60 * 2 * 1000);
ticket.pending_time = compareDate.toISOString();
testTimeAfterRelative('ticket.pending_time', 1, 'hour', true, ticket);
testTimeAfterRelative(assert, 'ticket.pending_time', 1, 'hour', true, ticket);
// day
ticket.pending_time = new Date().toISOString();
testTimeAfterRelative('ticket.pending_time', 1, 'day', false, ticket);
testTimeAfterRelative(assert, 'ticket.pending_time', 1, 'day', false, ticket);
compareDate = new Date();
compareDate.setTime( compareDate.getTime() + 60 * 60 * 48 * 1000);
ticket.pending_time = compareDate.toISOString();
testTimeAfterRelative('ticket.pending_time', 1, 'day', true, ticket);
testTimeAfterRelative(assert, 'ticket.pending_time', 1, 'day', true, ticket);
// year
ticket.pending_time = new Date().toISOString();
testTimeAfterRelative('ticket.pending_time', 1, 'year', false, ticket);
testTimeAfterRelative(assert, 'ticket.pending_time', 1, 'year', false, ticket);
compareDate = new Date();
compareDate.setTime( compareDate.getTime() + 60 * 60 * 365 * 2 * 1000);
ticket.pending_time = compareDate.toISOString();
testTimeAfterRelative('ticket.pending_time', 1, 'year', true, ticket);
testTimeAfterRelative(assert, 'ticket.pending_time', 1, 'year', true, ticket);
// -------------------------
@ -815,12 +815,12 @@ window.onload = function() {
compareDate = new Date();
compareDate.setTime( compareDate.getTime() - 60 * 60 * 0.5 * 1000);
ticket.pending_time = compareDate.toISOString();
testTimeWithinLastRelative('ticket.pending_time', 1, 'hour', true, ticket);
testTimeWithinLastRelative(assert, 'ticket.pending_time', 1, 'hour', true, ticket);
compareDate = new Date();
compareDate.setTime( compareDate.getTime() - 60 * 60 * 2 * 1000);
ticket.pending_time = compareDate.toISOString();
testTimeWithinLastRelative('ticket.pending_time', 1, 'hour', false, ticket);
testTimeWithinLastRelative(assert, 'ticket.pending_time', 1, 'hour', false, ticket);
// -------------------------
// WITHIN NEXT TIME
@ -830,289 +830,289 @@ window.onload = function() {
compareDate = new Date();
compareDate.setTime( compareDate.getTime() + 60 * 60 * 0.5 * 1000);
ticket.pending_time = compareDate.toISOString();
testTimeWithinNextRelative('ticket.pending_time', 1, 'hour', true, ticket);
testTimeWithinNextRelative(assert, 'ticket.pending_time', 1, 'hour', true, ticket);
compareDate = new Date();
compareDate.setTime( compareDate.getTime() + 60 * 60 * 2 * 1000);
ticket.pending_time = compareDate.toISOString();
testTimeWithinNextRelative('ticket.pending_time', 1, 'hour', false, ticket);
testTimeWithinNextRelative(assert, 'ticket.pending_time', 1, 'hour', false, ticket);
});
test("ticket priority_id", function() {
QUnit.test("ticket priority_id", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testIs('ticket.priority_id', ['2'], ticket, sessionData);
testIs(assert, 'ticket.priority_id', ['2'], ticket, sessionData);
});
test("ticket escalation_at", function() {
QUnit.test("ticket escalation_at", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testTime('ticket.escalation_at', ticket.escalation_at, ticket);
testTime(assert, 'ticket.escalation_at', ticket.escalation_at, ticket);
});
test("ticket last_contact_agent_at", function() {
QUnit.test("ticket last_contact_agent_at", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testTime('ticket.last_contact_agent_at', ticket.last_contact_agent_at, ticket);
testTime(assert, 'ticket.last_contact_agent_at', ticket.last_contact_agent_at, ticket);
});
test("ticket last_contact_at", function() {
QUnit.test("ticket last_contact_at", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testTime('ticket.last_contact_at', ticket.last_contact_at, ticket);
testTime(assert, 'ticket.last_contact_at', ticket.last_contact_at, ticket);
});
test("ticket last_contact_customer_at", function() {
QUnit.test("ticket last_contact_customer_at", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testTime('ticket.last_contact_customer_at', ticket.last_contact_customer_at, ticket);
testTime(assert, 'ticket.last_contact_customer_at', ticket.last_contact_customer_at, ticket);
});
test("ticket first_response_at", function() {
QUnit.test("ticket first_response_at", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testTime('ticket.first_response_at', ticket.first_response_at, ticket);
testTime(assert, 'ticket.first_response_at', ticket.first_response_at, ticket);
});
test("ticket close_at", function() {
QUnit.test("ticket close_at", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testTime('ticket.close_at', ticket.close_at, ticket);
testTime(assert, 'ticket.close_at', ticket.close_at, ticket);
});
test("ticket created_by_id", function() {
QUnit.test("ticket created_by_id", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
App.Session.set(6);
testPreConditionUser('ticket.created_by_id', '6', ticket, sessionData);
testPreConditionUser(assert, 'ticket.created_by_id', '6', ticket, sessionData);
});
test("ticket created_at", function() {
QUnit.test("ticket created_at", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testTime('ticket.created_at', ticket.created_at, ticket);
testTime(assert, 'ticket.created_at', ticket.created_at, ticket);
});
test("ticket updated_at", function() {
QUnit.test("ticket updated_at", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testTime('ticket.updated_at', ticket.updated_at, ticket);
testTime(assert, 'ticket.updated_at', ticket.updated_at, ticket);
});
test("ticket updated_by_id", function() {
QUnit.test("ticket updated_by_id", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
App.Session.set(6);
testPreConditionUser('ticket.updated_by_id', '6', ticket, sessionData);
testPreConditionUser(assert, 'ticket.updated_by_id', '6', ticket, sessionData);
});
test("ticket tags", function() {
QUnit.test("ticket tags", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testPreConditionTags('ticket.tags', ticket);
testPreConditionTags(assert, 'ticket.tags', ticket);
});
test("article from", function() {
QUnit.test("article from", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testContains('article.from', 'Admin', ticket);
testContains(assert, 'article.from', 'Admin', ticket);
});
test("article to", function() {
QUnit.test("article to", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testContains('article.to', 'agent1', ticket);
testContains(assert, 'article.to', 'agent1', ticket);
});
test("article cc", function() {
QUnit.test("article cc", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testContains('article.cc', 'agent1+cc', ticket);
testContains(assert, 'article.cc', 'agent1+cc', ticket);
});
test("article subject", function() {
QUnit.test("article subject", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testContains('article.subject', 'asdf', ticket);
testContains(assert, 'article.subject', 'asdf', ticket);
});
test("article type_id", function() {
QUnit.test("article type_id", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testIs('article.type_id', ['1'], ticket);
testIs(assert, 'article.type_id', ['1'], ticket);
});
test("article sender_id", function() {
QUnit.test("article sender_id", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testIs('article.sender_id', ['1'], ticket);
testIs(assert, 'article.sender_id', ['1'], ticket);
});
test("article internal", function() {
QUnit.test("article internal", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testIs('article.internal', ['false'], ticket);
testIs(assert, 'article.internal', ['false'], ticket);
});
test("article created_by_id", function() {
QUnit.test("article created_by_id", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testPreConditionUser('article.created_by_id', '6', ticket, sessionData);
testPreConditionUser(assert, 'article.created_by_id', '6', ticket, sessionData);
});
test("customer login", function() {
QUnit.test("customer login", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testContains('customer.login', 'hc', ticket);
testContains(assert, 'customer.login', 'hc', ticket);
});
test("customer firstname", function() {
QUnit.test("customer firstname", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testContains('customer.firstname', 'Harald', ticket);
testContains(assert, 'customer.firstname', 'Harald', ticket);
});
test("customer lastname", function() {
QUnit.test("customer lastname", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testContains('customer.lastname', 'Customer', ticket);
testContains(assert, 'customer.lastname', 'Customer', ticket);
});
test("customer email", function() {
QUnit.test("customer email", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testContains('customer.email', 'hc', ticket);
testContains(assert, 'customer.email', 'hc', ticket);
});
test("customer organization_id", function() {
QUnit.test("customer organization_id", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testPreConditionOrganization('customer.organization_id', '6', ticket, sessionData);
testPreConditionOrganization(assert, 'customer.organization_id', '6', ticket, sessionData);
});
test("customer created_by_id", function() {
QUnit.test("customer created_by_id", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testPreConditionUser('customer.created_by_id', '6', ticket, sessionData);
testPreConditionUser(assert, 'customer.created_by_id', '6', ticket, sessionData);
});
test("customer created_at", function() {
QUnit.test("customer created_at", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testTime('customer.created_at', ticket.customer.created_at, ticket);
testTime(assert, 'customer.created_at', ticket.customer.created_at, ticket);
});
test("customer updated_by_id", function() {
QUnit.test("customer updated_by_id", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testPreConditionUser('customer.updated_by_id', '6', ticket, sessionData);
testPreConditionUser(assert, 'customer.updated_by_id', '6', ticket, sessionData);
});
test("customer missing_field", function() {
QUnit.test("customer missing_field", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testContains('customer.missing_field', '', ticket);
testContains(assert, 'customer.missing_field', '', ticket);
});
test("customer web", function() {
QUnit.test("customer web", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testContains('customer.web', 'cool', ticket);
testContains(assert, 'customer.web', 'cool', ticket);
});
test("organization name", function() {
QUnit.test("organization name", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testContains('organization.name', 'gmbh', ticket);
testContains(assert, 'organization.name', 'gmbh', ticket);
});
test("organization shared", function() {
QUnit.test("organization shared", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testIs('organization.shared', true, ticket);
testIs(assert, 'organization.shared', true, ticket);
});
test("organization created_by_id", function() {
QUnit.test("organization created_by_id", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testPreConditionUser('organization.created_by_id', 6, ticket);
testPreConditionUser(assert, 'organization.created_by_id', 6, ticket);
});
test("organization updated_by_id", function() {
QUnit.test("organization updated_by_id", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testPreConditionUser('organization.updated_by_id', 6, ticket);
testPreConditionUser(assert, 'organization.updated_by_id', 6, ticket);
});
test("organization created_at", function() {
QUnit.test("organization created_at", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testTime('organization.created_at', ticket.organization.created_at, ticket);
testTime(assert, 'organization.created_at', ticket.organization.created_at, ticket);
});
test("organization updated_at", function() {
QUnit.test("organization updated_at", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testTime('organization.updated_at', ticket.organization.updated_at, ticket);
testTime(assert, 'organization.updated_at', ticket.organization.updated_at, ticket);
});
test("organization domain_assignment", function() {
QUnit.test("organization domain_assignment", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testIs('organization.domain_assignment', false, ticket);
testIs(assert, 'organization.domain_assignment', false, ticket);
});
test("organization domain", function() {
QUnit.test("organization domain", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testContains('organization.domain', 'cool', ticket);
testContains(assert, 'organization.domain', 'cool', ticket);
});
test("ticket mention user_id", function() {
QUnit.test("ticket mention user_id", assert => {
ticket = new App.Ticket();
ticket.load(ticketData);
testPreConditionUser('ticket.mention_user_ids', '6', ticket, sessionData);
testPreConditionUser(assert, 'ticket.mention_user_ids', '6', ticket, sessionData);
});
}

View file

@ -1,5 +1,5 @@
// date picker timezone conversion for display
test("date picker", function() {
QUnit.test("date picker", assert => {
Date.prototype.getTimezoneOffset2 = Date.prototype.getTimezoneOffset
Date.prototype.getTimezoneOffset = function() { return -360 }
@ -12,7 +12,7 @@ test("date picker", function() {
date_time_parsed = new Date(Date.parse(obj_date_time.value))
date_time_input = el_date_time.find('.js-datepicker').datepicker('getDate')
equal(date_time_parsed.getDate(), date_time_input.getDate(), 'datetime matching day')
assert.equal(date_time_parsed.getDate(), date_time_input.getDate(), 'datetime matching day')
obj_date = {
name: 'test',
@ -23,14 +23,14 @@ test("date picker", function() {
date_parsed = new Date(Date.parse(obj_date.value))
date_input = el_date.find('.js-datepicker').datepicker('getUTCDate')
equal(date_parsed.getDate(), date_input.getDate(), 'date matching day')
assert.equal(date_parsed.getDate(), date_input.getDate(), 'date matching day')
Date.prototype.getTimezoneOffset = Date.prototype.getTimezoneOffset2
Date.prototype.getTimezoneOffset2 = undefined
})
// pretty date
test("check pretty date", function() {
QUnit.test("check pretty date", assert => {
var current = new Date()
// use date formatting as functions to make it more flexible
prettyDateRelative(current, '', true, 'relative');
@ -41,43 +41,43 @@ test("check pretty date", function() {
function prettyDateRelative(current, escalation, long, type) {
var result = App.PrettyDate.humanTime(current, escalation, long, type);
equal(result, 'just now', 'just now')
assert.equal(result, 'just now', 'just now')
result = App.PrettyDate.humanTime(current - 15000, escalation, long, type);
equal(result, 'just now', 'just now')
assert.equal(result, 'just now', 'just now')
result = App.PrettyDate.humanTime(current - 60000, escalation, long, type);
equal(result, '1 minute ago', '1 min ago')
assert.equal(result, '1 minute ago', '1 min ago')
result = App.PrettyDate.humanTime(current - (2 * 60000), escalation, long, type);
equal(result, '2 minutes ago', '2 min ago')
assert.equal(result, '2 minutes ago', '2 min ago')
result = App.PrettyDate.humanTime(current - (60000 * 60), escalation, long, type);
equal(result, '1 hour ago', '1 hour')
assert.equal(result, '1 hour ago', '1 hour')
result = App.PrettyDate.humanTime(current - (60000 * 60 * 2), escalation, long, type);
equal(result, '2 hours ago', '2 hours')
assert.equal(result, '2 hours ago', '2 hours')
result = App.PrettyDate.humanTime(current - (60000 * 60 * 2.5), escalation, long, type);
equal(result, '2 hours 30 minutes ago', '2.5 hours')
assert.equal(result, '2 hours 30 minutes ago', '2.5 hours')
result = App.PrettyDate.humanTime(current - (60000 * 60 * 12.5), escalation, long, type);
equal(result, '12 hours ago', '12.5 hours')
assert.equal(result, '12 hours ago', '12.5 hours')
result = App.PrettyDate.humanTime(current - (60000 * 60 * 24), escalation, long, type);
equal(result, '1 day ago', '1 day')
assert.equal(result, '1 day ago', '1 day')
result = App.PrettyDate.humanTime(current - (60000 * 60 * 24 * 2), escalation, long, type);
equal(result, '2 days ago', '2 days')
assert.equal(result, '2 days ago', '2 days')
result = App.PrettyDate.humanTime(current - (60000 * 60 * 24 * 2) - (60000 * 5), escalation, long, type);
equal(result, '2 days ago', '2 days')
assert.equal(result, '2 days ago', '2 days')
result = App.PrettyDate.humanTime(current - (60000 * 60 * 24 * 2.5), escalation, long, type);
equal(result, '2 days 12 hours ago', '2.5 days')
assert.equal(result, '2 days 12 hours ago', '2.5 days')
result = App.PrettyDate.humanTime(current - (60000 * 60 * 24 * 2.5) - (60000 * 5), escalation, long, type);
equal(result, '2 days 12 hours ago', '2.5 days')
assert.equal(result, '2 days 12 hours ago', '2.5 days')
result = App.PrettyDate.humanTime(current - (60000 * 60 * 24 * 10.5), escalation, long, type);
var pastDate = new Date(current - (60000 * 60 * 24 * 10.5))
@ -91,7 +91,7 @@ test("check pretty date", function() {
}
var yyyy = pastDate.getFullYear();
// mm/dd/yyyy
equal(result, mm+'/'+dd+'/'+yyyy, '10.5 days')
assert.equal(result, mm+'/'+dd+'/'+yyyy, '10.5 days')
result = App.PrettyDate.humanTime(current - (60000 * 60 * 24 * 30), escalation, long, type);
var pastDate = new Date(current - (60000 * 60 * 24 * 30))
@ -105,228 +105,228 @@ test("check pretty date", function() {
}
var yyyy = pastDate.getFullYear();
// mm/dd/yyyy
equal(result, mm+'/'+dd+'/'+yyyy, '30 days')
assert.equal(result, mm+'/'+dd+'/'+yyyy, '30 days')
// future
current = new Date()
result = App.PrettyDate.humanTime(current, escalation, long, type);
equal(result, 'just now', 'just now')
assert.equal(result, 'just now', 'just now')
result = App.PrettyDate.humanTime(current.getTime() + 55000, escalation, long, type);
equal(result, 'just now', 'just now')
assert.equal(result, 'just now', 'just now')
result = App.PrettyDate.humanTime(current.getTime() + 65000, escalation, long, type);
equal(result, 'in 1 minute', 'in 1 min')
assert.equal(result, 'in 1 minute', 'in 1 min')
result = App.PrettyDate.humanTime(current.getTime() + (2 * 65000), escalation, long, type);
equal(result, 'in 2 minutes', 'in 2 min')
assert.equal(result, 'in 2 minutes', 'in 2 min')
result = App.PrettyDate.humanTime(current.getTime() + (60500 * 60), escalation, long, type);
equal(result, 'in 1 hour', 'in 1 hour')
assert.equal(result, 'in 1 hour', 'in 1 hour')
result = App.PrettyDate.humanTime(current.getTime() + (60050 * 60 * 2), escalation, long, type);
equal(result, 'in 2 hours', 'in 2 hours')
assert.equal(result, 'in 2 hours', 'in 2 hours')
result = App.PrettyDate.humanTime(current.getTime() + (60050 * 60 * 2.5), escalation, long, type);
equal(result, 'in 2 hours 30 minutes', 'in 2.5 hours')
assert.equal(result, 'in 2 hours 30 minutes', 'in 2.5 hours')
result = App.PrettyDate.humanTime(current.getTime() + (60050 * 60 * 24), escalation, long, type) ;
equal(result, 'in 1 day', 'in 1 day')
assert.equal(result, 'in 1 day', 'in 1 day')
result = App.PrettyDate.humanTime(current.getTime() + (60050 * 60 * 24 * 2), escalation, long, type);
equal(result, 'in 2 days', 'in 2 days')
assert.equal(result, 'in 2 days', 'in 2 days')
result = App.PrettyDate.humanTime(current.getTime() + (60050 * 60 * 24 * 2.5), escalation, long, type);
equal(result, 'in 2 days 12 hours', 'in 2.5 days')
assert.equal(result, 'in 2 days 12 hours', 'in 2.5 days')
result = App.PrettyDate.humanTime(current.getTime() + (60050 * 60 * 24 * 5.5), escalation, long, type);
equal(result, 'in 5 days 12 hours', 'in 30.5 days')
assert.equal(result, 'in 5 days 12 hours', 'in 30.5 days')
result = App.PrettyDate.humanTime(current.getTime() + (60050 * 60 * 24 * 30.5), escalation, long, type);
equal(result, 'in 30 days', 'in 30.5 days')
assert.equal(result, 'in 30 days', 'in 30.5 days')
};
function prettyDateAbsolute(current, escalation, long, type) {
var result = App.PrettyDate.humanTime(current, escalation, long, type);
equal(result, 'just now', 'just now') // by defaul < 1 min is just now
assert.equal(result, 'just now', 'just now') // by defaul < 1 min is just now
result = App.PrettyDate.humanTime(current - 15000, escalation, long, type);
equal(result, 'just now', 'just now') // by default < 1 min is just now
assert.equal(result, 'just now', 'just now') // by default < 1 min is just now
result = App.PrettyDate.humanTime(current - 60000, escalation, long, type);
diff = 60
equal(result, getAbsolute(new Date(current - 60000), diff), '1 min ago')
assert.equal(result, getAbsolute(new Date(current - 60000), diff), '1 min ago')
result = App.PrettyDate.humanTime(current - (2 * 60000), escalation, long, type);
diff = 2 * 60
equal(result, getAbsolute(new Date(current - (2 * 60000)), diff), '2 min ago')
assert.equal(result, getAbsolute(new Date(current - (2 * 60000)), diff), '2 min ago')
result = App.PrettyDate.humanTime(current - (60000 * 60), escalation, long, type);
diff = 60 * 60
equal(result, getAbsolute(new Date(current - (60000 * 60)), diff), '1 hour')
assert.equal(result, getAbsolute(new Date(current - (60000 * 60)), diff), '1 hour')
result = App.PrettyDate.humanTime(current - (60000 * 60 * 2), escalation, long, type);
diff = 60 * 60 * 2
equal(result, getAbsolute(new Date(current - (60000 * 60 * 2)), diff), '2 hours')
assert.equal(result, getAbsolute(new Date(current - (60000 * 60 * 2)), diff), '2 hours')
result = App.PrettyDate.humanTime(current - (60000 * 60 * 2.5), escalation, long, type);
diff = 60 * 60 * 2.5
equal(result, getAbsolute(new Date(current - (60000 * 60 * 2.5)), diff), '2.5 hours')
assert.equal(result, getAbsolute(new Date(current - (60000 * 60 * 2.5)), diff), '2.5 hours')
result = App.PrettyDate.humanTime(current - (60000 * 60 * 12.5), escalation, long, type);
diff = 60 * 60 * 12.5
equal(result, getAbsolute(new Date(current - (60000 * 60 * 12.5)), diff), '12.5 hours')
assert.equal(result, getAbsolute(new Date(current - (60000 * 60 * 12.5)), diff), '12.5 hours')
result = App.PrettyDate.humanTime(current - (60000 * 60 * 24), escalation, long, type);
diff = 60 * 60 * 25
equal(result, getAbsolute(new Date(current - (60000 * 60 * 24)), diff), '1 day')
assert.equal(result, getAbsolute(new Date(current - (60000 * 60 * 24)), diff), '1 day')
result = App.PrettyDate.humanTime(current - (60000 * 60 * 24 * 2), escalation, long, type);
diff = 60 * 60 * 25 * 2
equal(result, getAbsolute(new Date(current - (60000 * 60 * 24 * 2)), diff), '2 days')
assert.equal(result, getAbsolute(new Date(current - (60000 * 60 * 24 * 2)), diff), '2 days')
result = App.PrettyDate.humanTime(current - (60000 * 60 * 24 * 2) - (60000 * 5), escalation, long, type);
diff = (60 * 60 * 24 * 2) - (60 * 5)
equal(result, getAbsolute(new Date(current - (60000 * 60 * 24 * 2) - (60000 * 5)), diff), '2 days')
assert.equal(result, getAbsolute(new Date(current - (60000 * 60 * 24 * 2) - (60000 * 5)), diff), '2 days')
result = App.PrettyDate.humanTime(current - (60000 * 60 * 24 * 2.5), escalation, long, type);
diff = (60 * 60 * 24 * 2.5)
equal(result, getAbsolute(new Date(current - (60000 * 60 * 24 * 2.5)), diff), '2.5 days')
assert.equal(result, getAbsolute(new Date(current - (60000 * 60 * 24 * 2.5)), diff), '2.5 days')
result = App.PrettyDate.humanTime(current - (60000 * 60 * 24 * 2.5) - (60000 * 5), escalation, long, type);
diff = (60 * 60 * 24 * 2.5) - (60 * 5)
equal(result, getAbsolute(new Date(current - (60000 * 60 * 24 * 2.5) - (60000 * 5)), diff), '2.5 days')
assert.equal(result, getAbsolute(new Date(current - (60000 * 60 * 24 * 2.5) - (60000 * 5)), diff), '2.5 days')
// future
current = new Date()
result = App.PrettyDate.humanTime(current, escalation, long, type);
equal(result, 'just now', 'just now') // no change, because < 1 min = just now
assert.equal(result, 'just now', 'just now') // no change, because < 1 min = just now
result = App.PrettyDate.humanTime(current.getTime() + 55000, escalation, long, type);
equal(result, 'just now', 'just now') // no change, because < 1 min = just now
assert.equal(result, 'just now', 'just now') // no change, because < 1 min = just now
result = App.PrettyDate.humanTime(current.getTime() + 65000, escalation, long, type);
diff = 60
equal(result, getAbsolute(new Date(current.getTime() + 65000), diff), 'in 1 min')
assert.equal(result, getAbsolute(new Date(current.getTime() + 65000), diff), 'in 1 min')
result = App.PrettyDate.humanTime(current.getTime() + (2 * 65000), escalation, long, type);
diff = 2 * 60
equal(result, getAbsolute(new Date(current.getTime() + (2 * 65000)), diff), 'in 2 min')
assert.equal(result, getAbsolute(new Date(current.getTime() + (2 * 65000)), diff), 'in 2 min')
result = App.PrettyDate.humanTime(current.getTime() + (60500 * 60), escalation, long, type) ;
diff = 60 * 60
equal(result, getAbsolute(new Date(current.getTime() + (60500 * 60)), diff), 'in 1 hour')
assert.equal(result, getAbsolute(new Date(current.getTime() + (60500 * 60)), diff), 'in 1 hour')
result = App.PrettyDate.humanTime(current.getTime() + (60050 * 60 * 2), escalation, long, type);
diff = 60 * 60 * 2
equal(result, getAbsolute(new Date(current.getTime() + (60050 * 60 * 2)), diff), 'in 2 hours')
assert.equal(result, getAbsolute(new Date(current.getTime() + (60050 * 60 * 2)), diff), 'in 2 hours')
result = App.PrettyDate.humanTime(current.getTime() + (60050 * 60 * 2.5), escalation, long, type);
diff = 60 * 60 * 2.5
equal(result, getAbsolute(new Date(current.getTime() + (60050 * 60 * 2.5)), diff), 'in 2.5 hours')
assert.equal(result, getAbsolute(new Date(current.getTime() + (60050 * 60 * 2.5)), diff), 'in 2.5 hours')
result = App.PrettyDate.humanTime(current.getTime() + (60050 * 60 * 24), escalation, long, type);
diff = 60 * 60 * 24
equal(result, getAbsolute(new Date(current.getTime() + (60050 * 60 * 24)), diff), 'in 1 day')
assert.equal(result, getAbsolute(new Date(current.getTime() + (60050 * 60 * 24)), diff), 'in 1 day')
result = App.PrettyDate.humanTime(current.getTime() + (60050 * 60 * 24 * 2), escalation, long, type);
diff = 60 * 60 * 24 * 2
equal(result, getAbsolute(new Date(current.getTime() + (60050 * 60 * 24 * 2)), diff), 'in 2 days')
assert.equal(result, getAbsolute(new Date(current.getTime() + (60050 * 60 * 24 * 2)), diff), 'in 2 days')
result = App.PrettyDate.humanTime(current.getTime() + (60050 * 60 * 24 * 2.5), escalation, long, type);
diff = 60 * 60 * 24 * 2.5
equal(result, getAbsolute(new Date(current.getTime() + (60050 * 60 * 24 * 2.5)), diff), 'in 2.5 days')
assert.equal(result, getAbsolute(new Date(current.getTime() + (60050 * 60 * 24 * 2.5)), diff), 'in 2.5 days')
result = App.PrettyDate.humanTime(current.getTime() + (60050 * 60 * 24 * 5.5), escalation, long, type);
diff = 60 * 60 * 24 * 5.5
equal(result, getAbsolute(new Date(current.getTime() + (60050 * 60 * 24 * 5.5)), diff), 'in 5.5 days')
assert.equal(result, getAbsolute(new Date(current.getTime() + (60050 * 60 * 24 * 5.5)), diff), 'in 5.5 days')
result = App.PrettyDate.humanTime(current.getTime() + (60050 * 60 * 24 * 30.5), escalation, long, type);
diff = (60 * 60 * 24 * 30.5);
equal(result, getAbsolute(new Date(current.getTime() + 60050 * 60 * 24 * 30.5), diff), 'in 30.5 days')
assert.equal(result, getAbsolute(new Date(current.getTime() + 60050 * 60 * 24 * 30.5), diff), 'in 30.5 days')
};
function prettyDateTimestamp(current, escalation, long, type) {
var result = App.PrettyDate.humanTime(current, escalation, long, type);
equal(result, 'just now', 'just now') // by defaul < 1 min is just now
assert.equal(result, 'just now', 'just now') // by defaul < 1 min is just now
result = App.PrettyDate.humanTime(current - 15000, escalation, long, type);
equal(result, 'just now', 'just now') // by default < 1 min is just now
assert.equal(result, 'just now', 'just now') // by default < 1 min is just now
result = App.PrettyDate.humanTime(current - 60000, escalation, long, type);
equal(result, getTimestamp(new Date(current - 60000)), '1 min ago')
assert.equal(result, getTimestamp(new Date(current - 60000)), '1 min ago')
result = App.PrettyDate.humanTime(current - (2 * 60000), escalation, long, type);
equal(result, getTimestamp(new Date(current - (2 * 60000))), '2 min ago')
assert.equal(result, getTimestamp(new Date(current - (2 * 60000))), '2 min ago')
result = App.PrettyDate.humanTime(current - (60000 * 60), escalation, long, type);
equal(result, getTimestamp(new Date(current - (60000 * 60))), '1 hour')
assert.equal(result, getTimestamp(new Date(current - (60000 * 60))), '1 hour')
result = App.PrettyDate.humanTime(current - (60000 * 60 * 2), escalation, long, type);
equal(result, getTimestamp(new Date(current - (60000 * 60 * 2))), '2 hours')
assert.equal(result, getTimestamp(new Date(current - (60000 * 60 * 2))), '2 hours')
result = App.PrettyDate.humanTime(current - (60000 * 60 * 2.5), escalation, long, type);
equal(result, getTimestamp(new Date(current - (60000 * 60 * 2.5))), '2.5 hours')
assert.equal(result, getTimestamp(new Date(current - (60000 * 60 * 2.5))), '2.5 hours')
result = App.PrettyDate.humanTime(current - (60000 * 60 * 12.5), escalation, long, type);
equal(result, getTimestamp(new Date(current - (60000 * 60 * 12.5))), '12.5 hours')
assert.equal(result, getTimestamp(new Date(current - (60000 * 60 * 12.5))), '12.5 hours')
result = App.PrettyDate.humanTime(current - (60000 * 60 * 24), escalation, long, type);
equal(result, getTimestamp(new Date(current - (60000 * 60 * 24))), '1 day')
assert.equal(result, getTimestamp(new Date(current - (60000 * 60 * 24))), '1 day')
result = App.PrettyDate.humanTime(current - (60000 * 60 * 24 * 2), escalation, long, type);
equal(result, getTimestamp(new Date(current - (60000 * 60 * 24 * 2))), '2 days')
assert.equal(result, getTimestamp(new Date(current - (60000 * 60 * 24 * 2))), '2 days')
result = App.PrettyDate.humanTime(current - (60000 * 60 * 24 * 2) - (60000 * 5), escalation, long, type);
equal(result, getTimestamp(new Date(current - (60000 * 60 * 24 * 2) - (60000 * 5))), '2 days')
assert.equal(result, getTimestamp(new Date(current - (60000 * 60 * 24 * 2) - (60000 * 5))), '2 days')
result = App.PrettyDate.humanTime(current - (60000 * 60 * 24 * 2.5), escalation, long, type);
equal(result, getTimestamp(new Date(current - (60000 * 60 * 24 * 2.5))), '2.5 days')
assert.equal(result, getTimestamp(new Date(current - (60000 * 60 * 24 * 2.5))), '2.5 days')
result = App.PrettyDate.humanTime(current - (60000 * 60 * 24 * 2.5) - (60000 * 5), escalation, long, type);
equal(result, getTimestamp(new Date(current - (60000 * 60 * 24 * 2.5) - (60000 * 5))), '2.5 days')
assert.equal(result, getTimestamp(new Date(current - (60000 * 60 * 24 * 2.5) - (60000 * 5))), '2.5 days')
// future
current = new Date()
result = App.PrettyDate.humanTime(current, escalation, long, type);
equal(result, 'just now', 'just now') // no change, because < 1 min = just now
assert.equal(result, 'just now', 'just now') // no change, because < 1 min = just now
result = App.PrettyDate.humanTime(current.getTime() + 55000, escalation, long, type);
equal(result, 'just now', 'just now') // no change, because < 1 min = just now
assert.equal(result, 'just now', 'just now') // no change, because < 1 min = just now
result = App.PrettyDate.humanTime(current.getTime() + 65000, escalation, long, type);
equal(result, getTimestamp(new Date(current.getTime() + 65000)), 'in 1 min')
assert.equal(result, getTimestamp(new Date(current.getTime() + 65000)), 'in 1 min')
result = App.PrettyDate.humanTime(current.getTime() + (2 * 65000), escalation, long, type);
equal(result, getTimestamp(new Date(current.getTime() + (2 * 65000))), 'in 2 min')
assert.equal(result, getTimestamp(new Date(current.getTime() + (2 * 65000))), 'in 2 min')
result = App.PrettyDate.humanTime(current.getTime() + (60500 * 60), escalation, long, type) ;
equal(result, getTimestamp(new Date(current.getTime() + (60500 * 60))), 'in 1 hour')
assert.equal(result, getTimestamp(new Date(current.getTime() + (60500 * 60))), 'in 1 hour')
result = App.PrettyDate.humanTime(current.getTime() + (60050 * 60 * 2), escalation, long, type);
equal(result, getTimestamp(new Date(current.getTime() + (60050 * 60 * 2))), 'in 2 hours')
assert.equal(result, getTimestamp(new Date(current.getTime() + (60050 * 60 * 2))), 'in 2 hours')
result = App.PrettyDate.humanTime(current.getTime() + (60050 * 60 * 2.5), escalation, long, type);
equal(result, getTimestamp(new Date(current.getTime() + (60050 * 60 * 2.5))), 'in 2.5 hours')
assert.equal(result, getTimestamp(new Date(current.getTime() + (60050 * 60 * 2.5))), 'in 2.5 hours')
result = App.PrettyDate.humanTime(current.getTime() + (60050 * 60 * 24), escalation, long, type);
equal(result, getTimestamp(new Date(current.getTime() + (60050 * 60 * 24))), 'in 1 day')
assert.equal(result, getTimestamp(new Date(current.getTime() + (60050 * 60 * 24))), 'in 1 day')
result = App.PrettyDate.humanTime(current.getTime() + (60050 * 60 * 24 * 2), escalation, long, type);
equal(result, getTimestamp(new Date(current.getTime() + (60050 * 60 * 24 * 2))), 'in 2 days')
assert.equal(result, getTimestamp(new Date(current.getTime() + (60050 * 60 * 24 * 2))), 'in 2 days')
result = App.PrettyDate.humanTime(current.getTime() + (60050 * 60 * 24 * 2.5), escalation, long, type);
equal(result, getTimestamp(new Date(current.getTime() + (60050 * 60 * 24 * 2.5))), 'in 2.5 days')
assert.equal(result, getTimestamp(new Date(current.getTime() + (60050 * 60 * 24 * 2.5))), 'in 2.5 days')
result = App.PrettyDate.humanTime(current.getTime() + (60050 * 60 * 24 * 5.5), escalation, long, type);
equal(result, getTimestamp(new Date(current.getTime() + (60050 * 60 * 24 * 5.5))), 'in 5.5 days')
assert.equal(result, getTimestamp(new Date(current.getTime() + (60050 * 60 * 24 * 5.5))), 'in 5.5 days')
result = App.PrettyDate.humanTime(current.getTime() + (60050 * 60 * 24 * 30.5), escalation, long, type);
equal(result, getTimestamp(new Date(current.getTime() + 60050 * 60 * 24 * 30.5)), 'in 30.5 days')
assert.equal(result, getTimestamp(new Date(current.getTime() + 60050 * 60 * 24 * 30.5)), 'in 30.5 days')
};
@ -369,9 +369,9 @@ test("check pretty date", function() {
});
test("PrettyDate getISOWeeks", function() {
equal(App.PrettyDate.getISOWeeks(2026), 53, '53 weeks')
equal(App.PrettyDate.getISOWeeks(2020), 53, 'leap year and 53 weeks')
equal(App.PrettyDate.getISOWeeks(2019), 52, '52 weeks')
equal(App.PrettyDate.getISOWeeks(2024), 52, 'leap year and 52 weeks')
QUnit.test("PrettyDate getISOWeeks", assert => {
assert.equal(App.PrettyDate.getISOWeeks(2026), 53, '53 weeks')
assert.equal(App.PrettyDate.getISOWeeks(2020), 53, 'leap year and 53 weeks')
assert.equal(App.PrettyDate.getISOWeeks(2019), 52, '52 weeks')
assert.equal(App.PrettyDate.getISOWeeks(2024), 52, 'leap year and 52 weeks')
})

View file

@ -1,82 +0,0 @@
window.onload = function() {
test('test current user behaviour by updating session user via assets', function() {
// Wenn App.User updated through asset and set as session user
// expect App.Session.get with new values
App.User.refresh([{
"login": "hh@example.com",
"firstname": "Harald",
"lastname": "Habebe",
"email": "hh@example.com",
"role_ids": [ 1, 2, 4 ],
"group_ids": [ 1 ],
"active": true,
"updated_at": "2017-02-09T09:17:04.770Z",
"address": "",
"vip": false,
"custom_key": undefined,
"asdf": "",
"id": 6
}]);
App.Session.set(6)
equal(App.Session.get('id'), 6)
equal(App.Session.get('login'), 'hh@example.com')
equal(App.Session.get('vip'), false)
equal(App.Session.get('custom_key'), undefined)
equal(App.Session.get().id, 6)
equal(App.Session.get().login, 'hh@example.com')
equal(App.Session.get().custom_key, undefined)
equal(App.Session.get().not_existing, undefined)
// Wenn App.User updated through asset
// expect App.Session.get with new values
App.User.refresh([{
"login": "hh_new@example.com",
"firstname": "Harald",
"lastname": "Habebe",
"email": "hh_new@example.com",
"role_ids": [ 1, 2, 4 ],
"group_ids": [ 1 ],
"active": true,
"updated_at": "2017-02-09T09:17:04.770Z",
"address": "",
"vip": false,
"custom_key": undefined,
"asdf": "",
"id": 6
}]);
equal(App.Session.get('id'), 6)
equal(App.Session.get('login'), 'hh_new@example.com')
equal(App.Session.get('vip'), false)
equal(App.Session.get('custom_key'), undefined)
equal(App.Session.get().id, 6)
equal(App.Session.get().login, 'hh_new@example.com')
equal(App.Session.get().custom_key, undefined)
equal(App.Session.get().not_existing, undefined)
// Wenn App.Session is reseted to inital
// expect undefined for all
App.Session.init()
equal(App.Session.get(), undefined)
equal(App.Session.get('id'), undefined)
equal(App.Session.get('login'), undefined)
equal(App.Session.get('vip'), undefined)
equal(App.Session.get('custom_key'), undefined)
// When App.Session is set and set to undefined or null,
// expect @current() to return null
App.Session.set(6)
App.Session.set(undefined)
equal(App.User.current(), null, 'with no active session')
App.Session.set(null)
equal(App.User.current(), null, 'with no active session')
// When App.Session is set with an invalid (not existing) user ID,
// expect @current() to return null
App.Session.set(100)
equal(App.User.current(), null, 'with invalid session user ID')
});
}

View file

@ -1,3 +1,35 @@
/*[process-shim]*/
(function(global, env) {
// jshint ignore:line
if (typeof process === "undefined") {
global.process = {
argv: [],
cwd: function() {
return "";
},
browser: true,
env: {
NODE_ENV: env || "development"
},
version: "",
platform:
global.navigator &&
global.navigator.userAgent &&
/Windows/.test(global.navigator.userAgent)
? "win"
: ""
};
}
})(
typeof self == "object" && self.Object == Object
? self
: typeof process === "object" &&
Object.prototype.toString.call(process) === "[object process]"
? global
: window,
"development"
);
/*[global-shim-start]*/
(function(exports, global, doEval) {
// jshint ignore:line
@ -74,8 +106,9 @@
};
args[1] = module.exports;
args[2] = module;
} else if (!args[0] && deps[0] === "exports") {
}
// Babel uses the exports and module object.
else if (!args[0] && deps[0] === "exports") {
module = { exports: {} };
args[0] = module.exports;
if (deps[1] === "module") {
@ -120,7 +153,12 @@
});
})(
{},
typeof self == "object" && self.Object == Object ? self : window,
typeof self == "object" && self.Object == Object
? self
: typeof process === "object" &&
Object.prototype.toString.call(process) === "[object process]"
? global
: window,
function(__$source__, __$global__) {
// jshint ignore:line
eval("(function() { " + __$source__ + " \n }).call(__$global__);");
@ -613,6 +651,52 @@ define('syn/synthetic', function (require, exports, module) {
}
module.exports = syn;
});
/*syn@0.14.1#keyboard-event-keys*/
define('syn/keyboard-event-keys', [
'require',
'exports',
'module',
'syn/synthetic'
], function (require, exports, module) {
var syn = require('syn/synthetic');
syn.key.keyboardEventKeys = {
'\b': 'Backspace',
'\t': 'Tab',
'\r': 'Enter',
'shift': 'Shift',
'ctrl': 'Control',
'alt': 'Alt',
'meta': 'Meta',
'pause-break': 'Pause',
'caps': 'CapsLock',
'escape': 'Escape',
'num-lock': 'NumLock',
'scroll-lock': 'ScrollLock',
'print': 'Print',
'page-up': 'PageUp',
'page-down': 'PageDown',
'end': 'End',
'home': 'Home',
'left': 'ArrowLeft',
'up': 'ArrowUp',
'right': 'ArrowRight',
'down': 'ArrowDown',
'insert': 'Insert',
'delete': 'Delete',
'f1': 'F1',
'f2': 'F2',
'f3': 'F3',
'f4': 'F4',
'f5': 'F5',
'f6': 'F6',
'f7': 'F7',
'f8': 'F8',
'f9': 'F9',
'f10': 'F10',
'f11': 'F11',
'f12': 'F12'
};
});
/*syn@0.14.1#mouse*/
define('syn/mouse', [
'require',
@ -702,6 +786,7 @@ define('syn/mouse', [
var doc = getWin(element).document || document, event;
if (doc.createEvent) {
try {
defaults.view = doc.defaultView;
event = doc.createEvent('MouseEvents');
event.initMouseEvent(type, defaults.bubbles, defaults.cancelable, defaults.view, defaults.detail, defaults.screenX, defaults.screenY, defaults.clientX, defaults.clientY, defaults.ctrlKey, defaults.altKey, defaults.shiftKey, defaults.metaKey, defaults.button, defaults.relatedTarget);
} catch (e) {
@ -1918,7 +2003,7 @@ define('syn/key', [
if (!keyData[event]) {
return null;
}
var charCode = keyData[event][0], keyCode = keyData[event][1], result = {};
var charCode = keyData[event][0], keyCode = keyData[event][1], result = { key: key };
if (keyCode === 'key') {
result.keyCode = syn.keycodes[key];
} else if (keyCode === 'char') {
@ -2220,7 +2305,15 @@ define('syn/key', [
},
event: function (type, options, element) {
var doc = h.getWindow(element).document || document, event;
if (doc.createEvent) {
if (typeof KeyboardEvent !== 'undefined') {
var keyboardEventKeys = syn.key.keyboardEventKeys;
if (options.key && keyboardEventKeys[options.key]) {
options.key = keyboardEventKeys[options.key];
}
event = new KeyboardEvent(type, options);
event.synthetic = true;
return event;
} else if (doc.createEvent) {
try {
event = doc.createEvent('KeyEvents');
event.initKeyEvent(type, true, true, window, options.ctrlKey, options.altKey, options.shiftKey, options.metaKey, options.keyCode, options.charCode);
@ -2425,25 +2518,54 @@ define('syn/drag', [
DragonDrop.cleanup();
});
},
_dragStart: function (node, options) {
_dragStart: function (node) {
var options = {
bubbles: false,
cancelable: false
};
this.createAndDispatchEvent(node, 'dragstart', options);
},
_drag: function (node, options) {
_drag: function (node) {
var options = {
bubbles: true,
cancelable: true
};
this.createAndDispatchEvent(node, 'drag', options);
},
_dragEnter: function (node, options) {
_dragEnter: function (node) {
var options = {
bubbles: true,
cancelable: true
};
this.createAndDispatchEvent(node, 'dragenter', options);
},
_dragOver: function (node, options) {
_dragOver: function (node) {
var options = {
bubbles: true,
cancelable: true
};
this.createAndDispatchEvent(node, 'dragover', options);
},
_dragLeave: function (node, options) {
_dragLeave: function (node) {
var options = {
bubbles: true,
cancelable: false
};
this.createAndDispatchEvent(node, 'dragleave', options);
},
_drop: function (node, options) {
_drop: function (node) {
var options = {
bubbles: true,
cancelable: true,
buttons: 1
};
this.createAndDispatchEvent(node, 'drop', options);
},
_dragEnd: function (node, options) {
_dragEnd: function (node) {
var options = {
bubbles: true,
cancelable: false
};
this.createAndDispatchEvent(node, 'dragend', options);
},
_mouseDown: function (node, options) {
@ -2797,12 +2919,14 @@ define('syn', [
'exports',
'module',
'syn/synthetic',
'syn/keyboard-event-keys',
'syn/mouse.support',
'syn/browsers',
'syn/key.support',
'syn/drag'
], function (require, exports, module) {
var syn = require('syn/synthetic');
require('syn/keyboard-event-keys');
require('syn/mouse.support');
require('syn/browsers');
require('syn/key.support');
@ -2815,4 +2939,4 @@ define('syn', [
global._define = global.define;
global.define = global.define.orig;
}
)(typeof self == "object" && self.Object == Object ? self : window);
)(typeof self == "object" && self.Object == Object ? self : (typeof process === "object" && Object.prototype.toString.call(process) === "[object process]") ? global : window);

View file

@ -1,844 +0,0 @@
// form
test('table test', function() {
App.i18n.set('de-de')
$('#table').append('<hr><h1>table simple I</h1><div id="table1"></div>')
var el = $('#table1')
App.TicketPriority.refresh( [
{
id: 1,
name: '1 low',
note: 'some note 1',
active: true,
created_at: '2014-06-10T11:17:34.000Z',
},
{
id: 2,
name: '2 normal',
note: 'some note 2',
active: false,
created_at: '2014-06-10T10:17:34.000Z',
},
] )
var rowClick = function (id, e) {
e.preventDefault()
console.log('rowClick', id, e.target)
};
var rowDblClick = function (id, e) {
e.preventDefault()
console.log('rowDblClick', id, e.target)
};
var rowMouseover = function (id, e) {
e.preventDefault()
console.log('rowMouseover', id, e.target)
};
var rowMouseout = function (id, e) {
e.preventDefault()
console.log('rowMouseout', id, e.target)
};
var colClick = function (id, e) {
e.preventDefault()
console.log('colClick', id, e.target)
};
var colDblClick = function (id, e) {
e.preventDefault()
console.log('colDblClick', id, e.target)
};
var colMouseover = function (id, e) {
e.preventDefault()
console.log('colMouseover', id, e.target)
};
var colMouseout = function (id, e) {
e.preventDefault()
console.log('colMouseout', id, e.target)
};
new App.ControllerTable({
el: el,
overview: ['name', 'created_at', 'active'],
model: App.TicketPriority,
objects: App.TicketPriority.search({sortBy:'name', order: 'ASC'}),
checkbox: false,
radio: false,
bindRow: {
events: {
'click': rowClick,
'mouseover': rowMouseover,
'mouseout': rowMouseout,
'dblclick': rowDblClick,
}
},
bindCol: {
name: {
events: {
'click': colClick,
'mouseover': colMouseover,
'mouseout': colMouseout,
'dblclick': colDblClick,
}
},
created_at: {
events: {
'mouseover': colMouseover,
'mouseout': colMouseout,
}
}
},
})
equal(el.find('table > thead > tr').length, 1, 'row count')
equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '1 niedrig', 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true', 'check row 1')
equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '2 normal', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'false', 'check row 2')
$('#table').append('<hr><h1>table simple II</h1><div id="table2"></div>')
el = $('#table2')
new App.ControllerTable({
el: el,
overview: ['name', 'created_at', 'active'],
model: App.TicketPriority,
objects: App.TicketPriority.search({sortBy:'name', order: 'DESC'}),
checkbox: false,
radio: false,
})
equal(el.find('table > thead > tr').length, 1, 'row count')
equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '2 normal', 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'false', 'check row 1')
equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '1 niedrig', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '10.06.2014', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'true', 'check row 2')
$('#table').append('<hr><h1>table simple III</h1><div id="table3"></div>')
el = $('#table3')
new App.ControllerTable({
el: el,
model: App.TicketPriority,
objects: App.TicketPriority.search({sortBy:'created_at', order: 'DESC'}),
checkbox: false,
radio: false,
})
equal(el.find('table > thead > tr').length, 1, 'row count')
equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
notEqual( el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Erstellt', 'check header')
notEqual( el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
equal(el.find('tbody > tr:nth-child(2) > td').length, 1, 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), '2 normal', 'check row 2')
notEqual( el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '?', 'check row 2')
notEqual( el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'true', 'check row 2')
equal(el.find('tbody > tr:nth-child(1) > td').length, 1, 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), '1 niedrig', 'check row 1')
notEqual( el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '?', 'check row 1')
notEqual( el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'false', 'check row 1')
App.Group.refresh( [
{
id: 1,
name: 'group 1',
active: true,
created_at: '2014-06-10T11:17:34.000Z',
},
{
id: 2,
name: 'group 2',
active: true,
created_at: '2014-06-10T11:17:34.000Z',
},
])
App.User.refresh( [
{
id: 55,
login: 'login55',
firstname: 'firstname55',
lastname: 'lastname55',
email: 'email55',
active: true,
created_at: '2014-06-10T11:17:34.000Z',
},
{
id: 56,
login: 'login56',
firstname: 'firstname56',
lastname: 'lastname56',
email: 'email56',
active: true,
created_at: '2014-06-10T11:17:34.000Z',
},
])
App.TicketState.refresh( [
{
id: 1,
name: 'new',
active: true,
created_at: '2014-06-10T11:17:34.000Z',
},
{
id: 2,
name: 'open',
note: 'some note 2',
active: false,
created_at: '2014-06-10T10:17:34.000Z',
},
])
App.Ticket.refresh( [
{
id: 1,
title: 'some title 1',
number: '4711',
priority_id: 1,
owner_id: 55,
customer_id: 56,
state_id: 1,
group_id: 2,
created_at: '2014-06-10T11:17:34.000Z',
},
{
id: 3,
title: 'some title 3',
number: '4713',
priority_id: 2,
owner_id: 56,
state_id: 1,
group_id: 2,
created_at: '2014-07-11T11:19:34.000Z',
},
{
id: 2,
title: 'some title 2',
number: '4712',
priority_id: 1,
state_id: 2,
group_id: 1,
created_at: '2014-06-10T11:19:34.000Z',
},
])
$('#table').append('<hr><h1>table complex I</h1><div id="table4"></div>')
el = $('#table4')
new App.ControllerTable({
el: el,
overview: ['number', 'title', 'owner', 'customer', 'priority', 'group', 'state', 'created_at'],
model: App.Ticket,
objects: App.Ticket.search({sortBy:'created_at', order: 'DESC'}),
checkbox: true,
})
equal(el.find('table > thead > tr').length, 1, 'row count')
equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), '', 'check header')
equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), '#', 'check header')
equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Titel', 'check header')
equal(el.find('table > thead > tr > th:nth-child(4)').text().trim(), 'Besitzer', 'check header')
equal(el.find('table > thead > tr > th:nth-child(5)').text().trim(), 'Kunde', 'check header')
equal(el.find('table > thead > tr > th:nth-child(6)').text().trim(), 'Priorität', 'check header')
equal(el.find('table > thead > tr > th:nth-child(7)').text().trim(), 'Gruppe', 'check header')
equal(el.find('table > thead > tr > th:nth-child(8)').text().trim(), 'Status', 'check header')
equal(el.find('table > thead > tr > th:nth-child(9)').text().trim(), 'Erstellt am', 'check header')
equal(el.find('tbody > tr:nth-child(1) > td').length, 9, 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(1) input').val(), '3', 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(1) input').prop('checked'), '', 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(1)').text().trim(), '', 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), '4713', 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'some title 3', 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(4)').text().trim(), 'firstname56 lastname56', 'check row 2')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(5)').text().trim(), '-', 'check row 2')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(6)').text().trim(), '2 normal', 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(7)').text().trim(), 'group 2', 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(8)').text().trim(), 'neu', 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(9)').text().trim(), '11.07.2014', 'check row 1')
equal(el.find('tbody > tr:nth-child(2) > td').length, 9, 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(1) input').val(), '2', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(1) input').prop('checked'), '', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(1)').text().trim(), '', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '4712', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'some title 2', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(4)').text().trim(), '-', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(5)').text().trim(), '-', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(6)').text().trim(), '1 niedrig', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(7)').text().trim(), 'group 1', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(8)').text().trim(), 'offen', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(9)').text().trim(), '10.06.2014', 'check row 2')
equal(el.find('tbody > tr:nth-child(3) > td').length, 9, 'check row 3')
equal(el.find('tbody > tr:nth-child(3) > td:nth-child(1) input').val(), '1', 'check row 3')
equal(el.find('tbody > tr:nth-child(3) > td:nth-child(1) input').prop('checked'), '', 'check row 3')
equal(el.find('tbody > tr:nth-child(3) > td:nth-child(1)').text().trim(), '', 'check row 3')
equal(el.find('tbody > tr:nth-child(3) > td:nth-child(2)').text().trim(), '4711', 'check row 3')
equal(el.find('tbody > tr:nth-child(3) > td:nth-child(3)').text().trim(), 'some title 1', 'check row 3')
equal(el.find('tbody > tr:nth-child(3) > td:nth-child(4)').text().trim(), 'firstname55 lastname55', 'check row 2')
equal(el.find('tbody > tr:nth-child(3) > td:nth-child(5)').text().trim(), 'firstname56 lastname56', 'check row 2')
equal(el.find('tbody > tr:nth-child(3) > td:nth-child(6)').text().trim(), '1 niedrig', 'check row 3')
equal(el.find('tbody > tr:nth-child(3) > td:nth-child(7)').text().trim(), 'group 2', 'check row 3')
equal(el.find('tbody > tr:nth-child(3) > td:nth-child(8)').text().trim(), 'neu', 'check row 3')
equal(el.find('tbody > tr:nth-child(3) > td:nth-child(9)').text().trim(), '10.06.2014', 'check row 3')
el.find('input[name="bulk_all"]').click()
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(1) input').prop('checked'), true, 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(1) input').val(), '3', 'check row 1')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(1) input').prop('checked'), true, 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(1) input').val(), '2', 'check row 2')
equal(el.find('tbody > tr:nth-child(3) > td:nth-child(1) input').prop('checked'), true, 'check row 3')
equal(el.find('tbody > tr:nth-child(3) > td:nth-child(1) input').val(), '1', 'check row 3')
$('#table').append('<hr><h1>table complex II</h1><div id="table5"></div>')
el = $('#table5')
var clickCheckbox = function (id, checked, e) {
console.log('clickCheckbox', id, checked, e.target)
};
new App.ControllerTable({
el: el,
overview: ['number', 'title', 'owner', 'customer', 'priority', 'group', 'state', 'created_at'],
model: App.Ticket,
objects: App.Ticket.search({sortBy:'created_at', order: 'DESC'}),
checkbox: true,
groupBy: 'group',
bindCheckbox: {
events: {
'click': clickCheckbox,
}
},
})
equal(el.find('table > thead > tr').length, 1, 'row count')
equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), '', 'check header')
equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), '#', 'check header')
equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Titel', 'check header')
equal(el.find('table > thead > tr > th:nth-child(4)').text().trim(), 'Besitzer', 'check header')
equal(el.find('table > thead > tr > th:nth-child(5)').text().trim(), 'Kunde', 'check header')
equal(el.find('table > thead > tr > th:nth-child(6)').text().trim(), 'Priorität', 'check header')
equal(el.find('table > thead > tr > th:nth-child(7)').text().trim(), 'Status', 'check header')
equal(el.find('table > thead > tr > th:nth-child(8)').text().trim(), 'Erstellt am', 'check header')
equal(el.find('tbody > tr:nth-child(1) > td').length, 1, 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(1)').text().trim(), 'group 1', 'check row 1')
equal(el.find('tbody > tr:nth-child(2) > td').length, 8, 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(1) input').val(), '2', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(1) input').prop('checked'), '', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(1)').text().trim(), '', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), '4712', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'some title 2', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(4)').text().trim(), '-', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(5)').text().trim(), '-', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(6)').text().trim(), '1 niedrig', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(7)').text().trim(), 'offen', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(8)').text().trim(), '10.06.2014', 'check row 2')
equal(el.find('tbody > tr:nth-child(3) > td').length, 1, 'check row 3')
equal(el.find('tbody > tr:nth-child(3) > td:nth-child(1)').text().trim(), 'group 2', 'check row 4')
equal(el.find('tbody > tr:nth-child(4) > td').length, 8, 'check row 4')
equal(el.find('tbody > tr:nth-child(4) > td:nth-child(1) input').val(), '3', 'check row 4')
equal(el.find('tbody > tr:nth-child(4) > td:nth-child(1) input').prop('checked'), '', 'check row 4')
equal(el.find('tbody > tr:nth-child(4) > td:nth-child(1)').text().trim(), '', 'check row 4')
equal(el.find('tbody > tr:nth-child(4) > td:nth-child(2)').text().trim(), '4713', 'check row 4')
equal(el.find('tbody > tr:nth-child(4) > td:nth-child(3)').text().trim(), 'some title 3', 'check row 4')
equal(el.find('tbody > tr:nth-child(4) > td:nth-child(4)').text().trim(), 'firstname56 lastname56', 'check row 2')
equal(el.find('tbody > tr:nth-child(4) > td:nth-child(5)').text().trim(), '-', 'check row 2')
equal(el.find('tbody > tr:nth-child(4) > td:nth-child(6)').text().trim(), '2 normal', 'check row 4')
equal(el.find('tbody > tr:nth-child(4) > td:nth-child(7)').text().trim(), 'neu', 'check row 4')
equal(el.find('tbody > tr:nth-child(4) > td:nth-child(8)').text().trim(), '11.07.2014', 'check row 4')
el.find('input[name="bulk"]:eq(1)').click()
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(1) input').prop('checked'), '', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(1) input').val(), '2', 'check row 1')
equal(el.find('tbody > tr:nth-child(4) > td:nth-child(1) input').prop('checked'), true, 'check row 4')
equal(el.find('tbody > tr:nth-child(4) > td:nth-child(1) input').val(), '3', 'check row 4')
equal(el.find('tbody > tr:nth-child(5) > td:nth-child(1) input').prop('checked'), '', 'check row 5')
equal(el.find('tbody > tr:nth-child(5) > td:nth-child(1) input').val(), '1', 'check row 5')
el.find('tbody > tr:nth-child(5) > td:nth-child(1) label').click()
equal(el.find('tbody > tr:nth-child(5) > td:nth-child(1) input').prop('checked'), true, 'check row 5')
equal(el.find('tbody > tr:nth-child(5) > td:nth-child(1) input').val(), '1', 'check row 5')
$('#table').append('<hr><h1>table Group By Direction DESC</h1><div id="table6"></div>')
el = $('#table6')
var clickCheckbox = function (id, checked, e) {
console.log('clickCheckbox', id, checked, e.target)
};
new App.ControllerTable({
el: el,
overview: ['number', 'title', 'owner', 'customer', 'priority', 'group', 'state', 'created_at'],
model: App.Ticket,
objects: App.Ticket.search({sortBy:'created_at', order: 'DESC'}),
groupBy: 'priority',
groupDirection: 'DESC',
})
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(1)').text().trim(), '2 normal', 'check row 1')
equal(el.find('tbody > tr:nth-child(3) > td:nth-child(1)').text().trim(), '1 niedrig', 'check row 3')
$('#table').append('<hr><h1>table Group By Direction ASC</h1><div id="table7"></div>')
el = $('#table7')
var clickCheckbox = function (id, checked, e) {
console.log('clickCheckbox', id, checked, e.target)
};
new App.ControllerTable({
el: el,
overview: ['number', 'title', 'owner', 'customer', 'priority', 'group', 'state', 'created_at'],
model: App.Ticket,
objects: App.Ticket.search({sortBy:'created_at', order: 'DESC'}),
groupBy: 'priority',
groupDirection: 'ASC',
})
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(1)').text().trim(), '1 niedrig', 'check row 1')
equal(el.find('tbody > tr:nth-child(4) > td:nth-child(1)').text().trim(), '2 normal', 'check row 4')
});
test('table test 2.1', function() {
App.i18n.set('de-de')
$('#table').append('<hr><h1>table with hash</h1><div id="table-hash2_1"></div>')
var el = $('#table-hash2_1')
App.Group.refresh( [
{
id: 5,
name: 'group 5',
active: true,
created_at: '2014-06-10T11:17:34.000Z',
},
])
App.Channel.configure_delete = true
App.Channel.configure_clone = false
App.Channel.configure_attributes = [
{ name: 'adapter', display: 'Type', tag: 'select', multiple: false, null: false, options: { IMAP: 'IMAP', POP3: 'POP3' } },
{ name: 'options::host', display: 'Host', tag: 'input', type: 'text', limit: 120, null: true, autocapitalize: false },
{ name: 'options::user', display: 'User', tag: 'input', type: 'text', limit: 120, null: true, autocapitalize: false },
{ name: 'options::password', display: 'Password', tag: 'input', type: 'password', limit: 120, null: true, autocapitalize: false },
{ name: 'options::ssl', display: 'SSL', tag: 'select', multiple: false, null: true, options: { true: 'yes', false: 'no' }, translate: true, default: true},
{ name: 'options::folder', display: 'Folder', tag: 'input', type: 'text', limit: 120, null: true, autocapitalize: false },
{ name: 'group_id', display: 'Group', tag: 'select', multiple: false, null: false, nulloption: true, relation: 'Group' },
{ name: 'active', display: 'Active', tag: 'select', multiple: false, null: false, options: { true: 'yes', false: 'no' }, translate: true, default: true },
]
App.Channel.refresh( [
{
id: 1,
adapter: 'adapter1',
options: {
host: 'host1',
user: 'user1',
},
group_id: 5,
active: true,
created_at: '2014-06-10T11:17:34.000Z',
},
{
id: 2,
adapter: 'adapter2',
options: {
host: 'host2',
user: 'user2',
},
group_id: 5,
active: true,
created_at: '2014-06-10T11:17:34.000Z',
},
] )
new App.ControllerTable({
el: el,
overview: ['adapter', 'options::host', 'options::user', 'active'],
model: App.Channel,
objects: App.Channel.search({sortBy:'adapter', order: 'ASC'}),
})
equal(el.find('table > thead > tr').length, 1, 'row count')
equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Typ', 'check header')
equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Host', 'check header')
equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Benutzer', 'check header')
equal(el.find('table > thead > tr > th:nth-child(4)').text().trim(), 'Aktiv', 'check header')
equal(el.find('table > thead > tr > th:nth-child(5)').text().trim(), 'Aktion', 'check header')
equal(el.find('tbody > tr:nth-child(1) > td').length, 5, 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(1)').text().trim(), 'adapter1', 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), 'host1', 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'user1', 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(4)').text().trim(), 'ja', 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(5)').text().trim(), '', 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(5) .dropdown.dropdown--actions').length, 0, 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(5) .js-delete').length, 1, 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(5) .js-clone').length, 0, 'check row 1')
equal(el.find('tbody > tr:nth-child(2) > td').length, 5, 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(1)').text().trim(), 'adapter2', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), 'host2', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'user2', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(4)').text().trim(), 'ja', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(5)').text().trim(), '', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(5) .dropdown.dropdown--actions').length, 0, 'check row 1')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(5) .js-delete').length, 1, 'check row 1')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(5) .js-clone').length, 0, 'check row 1')
});
test('table test 2.2', function() {
App.i18n.set('de-de')
$('#table').append('<hr><h1>table with hash</h1><div id="table-hash2_2"></div>')
var el = $('#table-hash2_2')
App.Group.refresh( [
{
id: 5,
name: 'group 5',
active: true,
created_at: '2014-06-10T11:17:34.000Z',
},
])
App.Channel.configure_delete = false
App.Channel.configure_clone = true
App.Channel.configure_attributes = [
{ name: 'adapter', display: 'Type', tag: 'select', multiple: false, null: false, options: { IMAP: 'IMAP', POP3: 'POP3' } },
{ name: 'options::host', display: 'Host', tag: 'input', type: 'text', limit: 120, null: true, autocapitalize: false },
{ name: 'options::user', display: 'User', tag: 'input', type: 'text', limit: 120, null: true, autocapitalize: false },
{ name: 'options::password', display: 'Password', tag: 'input', type: 'password', limit: 120, null: true, autocapitalize: false },
{ name: 'options::ssl', display: 'SSL', tag: 'select', multiple: false, null: true, options: { true: 'yes', false: 'no' }, translate: true, default: true},
{ name: 'options::folder', display: 'Folder', tag: 'input', type: 'text', limit: 120, null: true, autocapitalize: false },
{ name: 'group_id', display: 'Group', tag: 'select', multiple: false, null: false, nulloption: true, relation: 'Group' },
{ name: 'active', display: 'Active', tag: 'select', multiple: false, null: false, options: { true: 'yes', false: 'no' }, translate: true, default: true },
]
App.Channel.refresh( [
{
id: 1,
adapter: 'adapter1',
options: {
host: 'host1',
user: 'user1',
},
group_id: 5,
active: true,
created_at: '2014-06-10T11:17:34.000Z',
},
{
id: 2,
adapter: 'adapter2',
options: {
host: 'host2',
user: 'user2',
},
group_id: 5,
active: true,
created_at: '2014-06-10T11:17:34.000Z',
},
] )
new App.ControllerTable({
el: el,
overview: ['adapter', 'options::host', 'options::user', 'active'],
model: App.Channel,
objects: App.Channel.search({sortBy:'adapter', order: 'ASC'}),
})
equal(el.find('table > thead > tr').length, 1, 'row count')
equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Typ', 'check header')
equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Host', 'check header')
equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Benutzer', 'check header')
equal(el.find('table > thead > tr > th:nth-child(4)').text().trim(), 'Aktiv', 'check header')
equal(el.find('table > thead > tr > th:nth-child(5)').text().trim(), 'Aktion', 'check header')
equal(el.find('tbody > tr:nth-child(1) > td').length, 5, 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(1)').text().trim(), 'adapter1', 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), 'host1', 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'user1', 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(4)').text().trim(), 'ja', 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(5)').text().trim(), '', 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(5) .dropdown.dropdown--actions').length, 0, 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(5) .js-delete').length, 0, 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(5) .js-clone').length, 1, 'check row 1')
equal(el.find('tbody > tr:nth-child(2) > td').length, 5, 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(1)').text().trim(), 'adapter2', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), 'host2', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'user2', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(4)').text().trim(), 'ja', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(5)').text().trim(), '', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(5) .dropdown.dropdown--actions').length, 0, 'check row 1')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(5) .js-delete').length, 0, 'check row 1')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(5) .js-clone').length, 1, 'check row 1')
});
test('table test 3', function() {
App.i18n.set('de-de')
$('#table').append('<hr><h1>table with hash</h1><div id="table-hash2"></div>')
var el = $('#table-hash2')
App.Group.refresh( [
{
id: 5,
name: 'group 5',
active: true,
created_at: '2014-06-10T11:17:34.000Z',
},
])
App.Channel.configure_delete = true
App.Channel.configure_clone = true
App.Channel.configure_attributes = [
{ name: 'adapter', display: 'Type', tag: 'select', multiple: false, null: false, options: { IMAP: 'IMAP', POP3: 'POP3' } },
{ name: 'options::host', display: 'Host', tag: 'input', type: 'text', limit: 120, null: true, autocapitalize: false },
{ name: 'options::user', display: 'User', tag: 'input', type: 'text', limit: 120, null: true, autocapitalize: false },
{ name: 'options::password', display: 'Password', tag: 'input', type: 'password', limit: 120, null: true, autocapitalize: false },
{ name: 'options::ssl', display: 'SSL', tag: 'select', multiple: false, null: true, options: { true: 'yes', false: 'no' }, translate: true, default: true},
{ name: 'options::folder', display: 'Folder', tag: 'input', type: 'text', limit: 120, null: true, autocapitalize: false },
{ name: 'group_id', display: 'Group', tag: 'select', multiple: false, null: false, nulloption: true, relation: 'Group' },
{ name: 'active', display: 'Active', tag: 'select', multiple: false, null: false, options: { true: 'yes', false: 'no' }, translate: true, default: true },
]
App.Channel.refresh( [
{
id: 1,
adapter: 'adapter1',
options: {
host: 'host1',
user: 'user1',
},
group_id: 5,
active: true,
created_at: '2014-06-10T11:17:34.000Z',
},
{
id: 2,
adapter: 'adapter2',
options: {
host: 'host2',
user: 'user2',
},
group_id: 5,
active: true,
created_at: '2014-06-10T11:17:34.000Z',
},
] )
new App.ControllerTable({
el: el,
overview: ['adapter', 'options::host', 'options::user', 'active'],
model: App.Channel,
objects: App.Channel.search({sortBy:'adapter', order: 'ASC'}),
})
equal(el.find('table > thead > tr').length, 1, 'row count')
equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Typ', 'check header')
equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Host', 'check header')
equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Benutzer', 'check header')
equal(el.find('table > thead > tr > th:nth-child(4)').text().trim(), 'Aktiv', 'check header')
equal(el.find('table > thead > tr > th:nth-child(5)').text().trim(), 'Aktion', 'check header')
equal(el.find('tbody > tr:nth-child(1) > td').length, 5, 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(1)').text().trim(), 'adapter1', 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), 'host1', 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'user1', 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(4)').text().trim(), 'ja', 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(5) .dropdown.dropdown--actions .js-delete').length, 1, 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(5) .dropdown.dropdown--actions .js-clone').length, 1, 'check row 1')
equal(el.find('tbody > tr:nth-child(2) > td').length, 5, 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(1)').text().trim(), 'adapter2', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), 'host2', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'user2', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(4)').text().trim(), 'ja', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(5) .dropdown.dropdown--actions .js-delete').length, 1, 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(5) .dropdown.dropdown--actions .js-clone').length, 1, 'check row 2')
});
test('table test 4', function() {
App.i18n.set('de-de')
$('#table').append('<hr><h1>table with link</h1><div id="table-link1"></div>')
var el = $('#table-link1')
App.EmailAddress.refresh( [
{
id: 55,
realname: 'realname 55',
email: 'email 55',
active: true,
created_at: '2014-06-10T11:17:34.000Z',
},
{
id: 56,
realname: 'realname 56',
email: 'email 56',
active: true,
created_at: '2014-06-10T11:17:34.000Z',
},
])
var callbackHeader = function (header) {
console.log('current header is', header);
// add new header item
var attribute = {
name: 'some name',
display: 'Some Name',
};
header.push(attribute);
console.log('new header is', header);
return header
}
var callbackAttributes = function(value, object, attribute, header, refObject) {
console.log('data of item col', value, object, attribute, header, refObject)
value = ' '
attribute.class = 'glyphicon glyphicon-user'
attribute.link = '#'
attribute.title = App.i18n.translateInline('Switch to')
if (object.id == 55) {
attribute.data = {
some: 'value55',
xxx: 55,
}
}
else {
attribute.data = {
some: 'value56',
xxx: 56,
}
}
return value
}
var switchTo = function(id, e) {
e.preventDefault()
console.log('switchTo with id', id, e.target)
//@disconnectClient()
//App.Auth._logout()
//window.location = App.Config.get('api_path') + '/sessions/switch/' + id
}
new App.ControllerTable({
el: el,
model: App.EmailAddress,
objects: App.EmailAddress.search({sortBy:'realname', order: 'ASC'}),
callbackHeader: [callbackHeader],
callbackAttributes: {
'some name': [ callbackAttributes ]
},
bindCol: {
'some name': {
events: {
'click': switchTo,
}
},
},
})
equal(el.find('table > thead > tr').length, 1, 'row count')
equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Anzeigename', 'check header')
equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Some Name', 'check header')
equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(1)').text().trim(), 'realname 55', 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), 'email 55', 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), '', 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3) > a > span').hasClass('glyphicon-user'), true, 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3) > a > span').hasClass('glyphicon'), true, 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').attr('title'), 'Umschalten zu', 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3) > a > span').data('some'), 'value55', 'check row 2')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3) > a > span').data('xxx'), '55', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(1)').text().trim(), 'realname 56', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), 'email 56', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), '', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3) > a > span').hasClass('glyphicon-user'), true, 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3) > a > span').hasClass('glyphicon'), true, 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').attr('title'), 'Umschalten zu', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3) > a > span').data('some'), 'value56', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3) > a > span').data('xxx'), '56', 'check row 2')
});
test('table test 5', function() {
App.i18n.set('de-de')
$('#table').append('<hr><h1>table with data</h1><div id="table-data1"></div>')
var el = $('#table-data1')
data = [
{ name: 'some name 1', data: 'some data 1', active: true },
{ name: 'some name 2', data: 'some data 2', active: false },
{ name: 'some name 3', data: 'some data 3', active: true },
]
new App.ControllerTable({
el: el,
overview: ['name', 'data', 'active'],
attribute_list: [
{ name: 'name', display: 'Name', type: 'text', style: 'width: 10%' },
{ name: 'data', display: 'Data', type: 'text' },
{ name: 'active', display: 'Active', type: 'text' },
],
objects: data
});
equal(el.find('table > thead > tr').length, 1, 'row count')
equal(el.find('table > thead > tr > th:nth-child(1)').text().trim(), 'Name', 'check header')
equal(el.find('table > thead > tr > th:nth-child(2)').text().trim(), 'Data', 'check header')
equal(el.find('table > thead > tr > th:nth-child(3)').text().trim(), 'Aktiv', 'check header')
equal(el.find('tbody > tr:nth-child(1) > td').length, 3, 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:first').text().trim(), 'some name 1', 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), 'some data 1', 'check row 1')
equal(el.find('tbody > tr:nth-child(1) > td:nth-child(3)').text().trim(), 'true', 'check row 1')
equal(el.find('tbody > tr:nth-child(2) > td').length, 3, 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:first').text().trim(), 'some name 2', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(2)').text().trim(), 'some data 2', 'check row 2')
equal(el.find('tbody > tr:nth-child(2) > td:nth-child(3)').text().trim(), 'false', 'check row 2')
});
test('table test 6/7', function() {
$('#table').append('<hr><h1>sotable table with data</h1><div id="table-data6"></div>')
var el_head_sortable = $('#table-data6')
$('#table').append('<hr><h1>not sortable table with data</h1><div id="table-data7"></div>')
var el_not_head_sortable = $('#table-data7')
data = [
{ name: 'a item', data: 'g data', active: true },
{ name: 'b item', data: 'b data', active: false },
{ name: 'c item', data: 'z data', active: false },
{ name: 'd item', data: '', active: false },
]
new App.ControllerTable({
tableId: 'a',
el: el_head_sortable,
overview: ['name', 'data', 'active'],
attribute_list: [
{ name: 'name', display: 'Name', type: 'text', style: 'width: 10%', unsortable: true },
{ name: 'data', display: 'Data', type: 'text' },
{ name: 'active', display: 'Active', type: 'text' },
],
objects: data
});
new App.ControllerTable({
tableId: 'b',
el: el_not_head_sortable,
overview: ['name', 'data', 'active'],
attribute_list: [
{ name: 'name', display: 'Name', type: 'text', style: 'width: 10%', unsortable: true },
{ name: 'data', display: 'Data', type: 'text' },
{ name: 'active', display: 'Active', type: 'text' },
],
objects: data,
dndCallback: function() { return true }
});
equal(el_head_sortable.find('tbody > tr:nth-child(1) > td:first').text().trim(), 'a item', 'check row 1')
equal(el_not_head_sortable.find('tbody > tr:nth-child(1) > td:nth-child(2)').text().trim(), 'a item', 'check row 1')
ok(_.isEqual(list_items(el_head_sortable, 1), ['a item', 'b item', 'c item', 'd item']), 'sortable table is rendered correctly')
ok(_.isEqual(list_items(el_not_head_sortable, 2), ['a item', 'b item', 'c item', 'd item']), 'unsortable table is rendered correctly')
click_sort(el_head_sortable, 2)
click_sort(el_not_head_sortable, 3)
ok(_.isEqual(list_items(el_head_sortable, 1), ['b item', 'a item', 'c item', 'd item']), 'sortable table is sorted')
ok(_.isEqual(list_items(el_not_head_sortable, 2), ['a item', 'b item', 'c item', 'd item']), 'unsortable table is not sorted')
click_sort(el_head_sortable, 3)
ok(_.isEqual(list_items(el_head_sortable, 1), ['b item', 'c item', 'd item', 'a item']), 'sorting by boolean column works')
click_sort(el_head_sortable, 1)
ok(_.isEqual(list_items(el_head_sortable, 1), ['b item', 'c item', 'd item', 'a item']), 'sorting on name column is disabled')
});
function click_sort(table, column_number) {
table
.find(`table > thead > tr > th:nth-child(${column_number}) > .js-sort`)
.click()
}
function list_items(table, column_number) {
return table
.find(`tbody > tr > td:nth-child(${column_number})`)
.text()
.split("\n")
.filter(elem => elem.match(/[\w]+/))
.map(elem => elem.trim())
}

File diff suppressed because it is too large Load diff

View file

@ -1,316 +0,0 @@
window.onload = function() {
test( "taskbar basic tests", function() {
// create task bar div
$('#taskbars').append('<hr><h1>taskbar basic tests</h1><div id="taskbar1"></div>')
App.TaskManager.init({
el: $('#taskbar1'),
offlineModus: true,
force: true,
})
// add tasks
App.TaskManager.execute({
key: 'TestKey1',
controller: 'TestController1',
params: {
message: '#1',
},
show: true,
persistent: false,
})
equal($('#taskbars .content').length, 1, "check available active contents")
equal($('#taskbars .content.active').length, 1, "check available active contents")
equal($('#taskbars .content.active').text(), "some test controller message:'#1',show:'true',hide:'false',active:'true'", "check active content!")
// verify
task = App.TaskManager.get('TestKey1')
equal(task.notify, false)
deepEqual(task.state, undefined)
deepEqual(task.params, { "message": "#1", "shown": true })
// update
App.TaskManager.update('TestKey1', { 'state': 'abc' })
App.TaskManager.update('TestKey1', { 'params': { a: 12 } })
App.TaskManager.notify('TestKey1')
// verify
task = App.TaskManager.get('TestKey1')
equal(task.notify, true)
deepEqual(task.state, 'abc')
deepEqual(task.params, { "a": 12 })
App.TaskManager.execute({
key: 'TestKey2',
controller: 'TestController1',
params: {
message: '#2',
},
show: true,
persistent: false,
})
equal($('#taskbars .content').length, 2, "check available active contents")
equal($('#taskbars .content.active').length, 1, "check available active contents")
equal($('#taskbars .content.active').text(), "some test controller message:'#2',show:'true',hide:'false',active:'true'", "check active content!")
equal($('#taskbars #content_permanent_TestKey1').text(), "some test controller message:'#1',show:'true',hide:'true',active:'false'", "check active content!")
equal($('#taskbars #content_permanent_TestKey2').text(), "some test controller message:'#2',show:'true',hide:'false',active:'true'", "check active content!")
// check task history
equal(App.TaskManager.nextTaskUrl(), '#/some/url/#2')
equal(App.TaskManager.nextTaskUrl(), '#/some/url/#1')
App.TaskManager.execute({
key: 'TestKey3',
controller: 'TestController1',
params: {
message: '#3',
},
show: false,
persistent: false,
})
equal($('#taskbars .content').length, 2, "check available active contents")
equal($('#taskbars .content.active').length, 1, "check available active contents")
equal($('#taskbars .content.active').text(), "some test controller message:'#2',show:'true',hide:'false',active:'true'")
equal($('#taskbars #content_permanent_TestKey1').text(), "some test controller message:'#1',show:'true',hide:'true',active:'false'", "check active content!")
equal($('#taskbars #content_permanent_TestKey2').text(), "some test controller message:'#2',show:'true',hide:'false',active:'true'", "check active content!")
App.TaskManager.execute({
key: 'TestKey3',
controller: 'TestController1',
params: {
message: '#3',
},
show: true,
persistent: false,
})
equal($('#taskbars .content').length, 3, "check available active contents")
equal($('#taskbars .content.active').length, 1, "check available active contents")
equal($('#taskbars .content.active').text(), "some test controller message:'#3',show:'true',hide:'true',active:'true'", "check active content!")
equal($('#taskbars #content_permanent_TestKey1').text(), "some test controller message:'#1',show:'true',hide:'true',active:'false'", "check active content!")
equal($('#taskbars #content_permanent_TestKey2').text(), "some test controller message:'#2',show:'true',hide:'true',active:'false'", "check active content!")
equal($('#taskbars #content_permanent_TestKey3').text(), "some test controller message:'#3',show:'true',hide:'true',active:'true'", "check active content!")
App.TaskManager.execute({
key: 'TestKey4',
controller: 'TestController1',
params: {
message: '#4',
},
show: false,
persistent: true,
})
equal($('#taskbars .content').length, 3, "check available active contents")
equal($('#taskbars .content.active').length, 1, "check available active contents")
equal($('#taskbars .content.active').text(), "some test controller message:'#3',show:'true',hide:'true',active:'true'", "check active content!")
equal($('#taskbars #content_permanent_TestKey1').text(), "some test controller message:'#1',show:'true',hide:'true',active:'false'", "check active content!")
equal($('#taskbars #content_permanent_TestKey2').text(), "some test controller message:'#2',show:'true',hide:'true',active:'false'", "check active content!")
equal($('#taskbars #content_permanent_TestKey3').text(), "some test controller message:'#3',show:'true',hide:'true',active:'true'", "check active content!")
App.TaskManager.execute({
key: 'TestKey5',
controller: 'TestController1',
params: {
message: '#5',
},
show: true,
persistent: true,
})
equal($('#taskbars .content').length, 4, "check available active contents")
equal($('#taskbars .content.active').length, 1, "check available active contents")
equal($('#taskbars .content.active').text(), "some test controller message:'#5',show:'true',hide:'false',active:'true'")
equal($('#taskbars #content_permanent_TestKey1').text(), "some test controller message:'#1',show:'true',hide:'true',active:'false'", "check active content!")
equal($('#taskbars #content_permanent_TestKey2').text(), "some test controller message:'#2',show:'true',hide:'true',active:'false'", "check active content!")
equal($('#taskbars #content_permanent_TestKey3').text(), "some test controller message:'#3',show:'true',hide:'true',active:'false'", "check active content!")
equal($('#taskbars #content_permanent_TestKey5').text(), "some test controller message:'#5',show:'true',hide:'false',active:'true'", "check active content!")
App.TaskManager.execute({
key: 'TestKey6',
controller: 'TestController1',
params: {
message: '#6',
},
show: true,
persistent: false,
})
equal($('#taskbars .content').length, 5, "check available active contents")
equal($('#taskbars .content.active').length, 1, "check available active contents")
equal($('#taskbars .content.active').text(), "some test controller message:'#6',show:'true',hide:'false',active:'true'")
equal($('#taskbars #content_permanent_TestKey1').text(), "some test controller message:'#1',show:'true',hide:'true',active:'false'", "check active content!")
equal($('#taskbars #content_permanent_TestKey2').text(), "some test controller message:'#2',show:'true',hide:'true',active:'false'", "check active content!")
equal($('#taskbars #content_permanent_TestKey3').text(), "some test controller message:'#3',show:'true',hide:'true',active:'false'", "check active content!")
equal($('#taskbars #content_permanent_TestKey5').text(), "some test controller message:'#5',show:'true',hide:'true',active:'false'", "check active content!")
equal($('#taskbars #content_permanent_TestKey6').text(), "some test controller message:'#6',show:'true',hide:'false',active:'true'", "check active content!")
// remove task#2
App.TaskManager.remove('TestKey2')
equal($('#taskbars .content').length, 4, "check available active contents")
equal($('#taskbars .content.active').length, 1, "check available active contents")
equal($('#taskbars .content.active').text(), "some test controller message:'#6',show:'true',hide:'false',active:'true'")
equal($('#taskbars #content_permanent_TestKey1').text(), "some test controller message:'#1',show:'true',hide:'true',active:'false'", "check active content!")
equal($('#taskbars #content_permanent_TestKey3').text(), "some test controller message:'#3',show:'true',hide:'true',active:'false'", "check active content!")
equal($('#taskbars #content_permanent_TestKey5').text(), "some test controller message:'#5',show:'true',hide:'true',active:'false'", "check active content!")
equal($('#taskbars #content_permanent_TestKey6').text(), "some test controller message:'#6',show:'true',hide:'false',active:'true'", "check active content!")
// activate task#3
App.TaskManager.execute({
key: 'TestKey3',
controller: 'TestController1',
params: {
message: '#3',
},
show: true,
persistent: false,
})
equal($('#taskbars .content').length, 4, "check available active contents")
equal($('#taskbars .content.active').length, 1, "check available active contents")
equal($('#taskbars .content.active').text(), "some test controller message:'#3',show:'true',hide:'true',active:'true'")
equal($('#taskbars #content_permanent_TestKey1').text(), "some test controller message:'#1',show:'true',hide:'true',active:'false'", "check active content!")
equal($('#taskbars #content_permanent_TestKey3').text(), "some test controller message:'#3',show:'true',hide:'true',active:'true'", "check active content!")
equal($('#taskbars #content_permanent_TestKey5').text(), "some test controller message:'#5',show:'true',hide:'true',active:'false'", "check active content!")
equal($('#taskbars #content_permanent_TestKey6').text(), "some test controller message:'#6',show:'true',hide:'true',active:'false'", "check active content!")
// activate task#1
App.TaskManager.execute({
key: 'TestKey1',
controller: 'TestController1',
params: {
message: '#1',
},
show: true,
persistent: false,
})
equal($('#taskbars .content').length, 4, "check available active contents")
equal($('#taskbars .content.active').length, 1, "check available active contents")
equal($('#taskbars .content.active').text(), "some test controller message:'#1',show:'true',hide:'true',active:'true'")
equal($('#taskbars #content_permanent_TestKey1').text(), "some test controller message:'#1',show:'true',hide:'true',active:'true'", "check active content!")
equal($('#taskbars #content_permanent_TestKey3').text(), "some test controller message:'#3',show:'true',hide:'true',active:'false'", "check active content!")
equal($('#taskbars #content_permanent_TestKey5').text(), "some test controller message:'#5',show:'true',hide:'true',active:'false'", "check active content!")
equal($('#taskbars #content_permanent_TestKey6').text(), "some test controller message:'#6',show:'true',hide:'true',active:'false'", "check active content!")
// remove task#1
App.TaskManager.remove('TestKey1')
// verify if task#3 is active
equal($('#taskbars .content').length, 3, "check available active contents")
equal($('#taskbars .content.active').length, 0, "check available active contents")
equal($('#taskbars .content.active').text(), "")
// remove task#3
App.TaskManager.remove('TestKey3')
// verify if task#5 is active
equal($('#taskbars .content').length, 2, "check available active contents")
equal($('#taskbars .content.active').length, 0, "check available active contents")
equal($('#taskbars .content.active').text(), "")
// remove task#5 // can not get removed because of permanent task
App.TaskManager.remove('TestKey5')
// verify if task#5 is active
equal($('#taskbars .content').length, 2, "check available active contents")
equal($('#taskbars .content.active').length, 0, "check available active contents")
equal($('#taskbars .content.active').text(), "")
// create task#7
App.TaskManager.execute({
key: 'TestKey7',
controller: 'TestController1',
params: {
message: '#7',
},
show: true,
persistent: false,
})
equal($('#taskbars .content').length, 3, "check available active contents")
equal($('#taskbars .content.active').length, 1, "check available active contents")
equal($('#taskbars .content.active').text(), "some test controller message:'#7',show:'true',hide:'false',active:'true'", "check active content!")
// remove task#7
App.TaskManager.remove('TestKey7')
// verify if task#5 is active
equal($('#taskbars .content').length, 2, "check available active contents")
equal($('#taskbars .content.active').length, 0, "check available active contents")
equal($('#taskbars .content.active').text(), "")
// check task history
equal(App.TaskManager.nextTaskUrl(), '#/some/url/#6')
equal(App.TaskManager.nextTaskUrl(), '#/some/url/#5')
equal(App.TaskManager.nextTaskUrl(), '#/some/url/#6')
equal(App.TaskManager.nextTaskUrl(), '#/some/url/#6')
// remove task#6
App.TaskManager.remove('TestKey6')
// check task history
equal(App.TaskManager.nextTaskUrl(), false)
equal(App.TaskManager.nextTaskUrl(), false)
// check max tabs
var times = 5;
App.TaskManager.tasksAutoCleanupDelayTime(200)
App.TaskManager.tasksAutoCleanupTaskMax(3)
for(var i=0; i < times; i++){
App.TaskManager.execute({
key: 'TestKeyLoop' + i,
controller: 'TestController1',
params: {
message: "#" + i,
},
show: true,
persistent: false,
})
}
equal(App.TaskManager.all().length, 5)
})
App.Delay.set(function() {
test( "taskbar check max tabs 2", function() {
equal(App.TaskManager.all().length, 3)
var times = 5;
for(var i=0; i < times; i++){
App.TaskManager.execute({
key: 'TestKeyLoop2' + i,
controller: 'TestController1',
params: {
message: "#" + i,
changedState: true
},
show: true,
persistent: false,
})
}
equal(App.TaskManager.all().length, 8)
})
}, 1000);
App.Delay.set(function() {
test( "taskbar check max tabs 5", function() {
equal(App.TaskManager.all().length, 5)
// destroy task bar
App.TaskManager.reset()
// check if any taskar exists
equal($('#taskbars .content').length, 0, "check available active contents")
})
}, 2000);
}

View file

@ -2,174 +2,62 @@
require 'rails_helper'
RSpec.describe 'QUnit', type: :system, authenticated_as: false, set_up: true, websocket: false do
RSpec.describe 'QUnit', type: :system, authenticated_as: false, set_up: true, websocket: false, time_zone: 'Europe/London' do
matcher :pass_qunit_test do
match do
actual.has_css?('.total', wait: 120)
def q_unit_tests(test_name)
visit "/tests_#{test_name}"
yield if block_given?
expect(page).to have_css('.result', text: 'Tests completed')
expect(page).to have_css('.result .failed', text: '0')
actual.has_css? '.result .failed', text: '0', wait: 0
end
def async_q_unit_tests(*args)
q_unit_tests(*args) do
wait(120, interval: 3).until_constant do
page.has_css?('.total', wait: 0) ? find('.total').text : nil
failure_message do
messages = actual
.all('.qunit-assert-list li.fail')
.map { |elem| "> #{failure_name(elem)}\n#{failure_source(elem)}" }
.join("\n")
"Failed #{failed_count} out of #{total_count}:\n#{messages}"
end
def failure_source(row)
row
.find('.test-source pre')
.text
.strip
.lines[0, 2]
.reject { |line| line.include? 'qunit-' }
.join
end
def failure_name(row)
row
.find('.test-message')
.text
.strip
end
def failed_count
actual.find('.result .failed').text
end
def total_count
actual.find('.result .total').text
end
end
it 'Core' do
async_q_unit_tests('core')
files = if (basename = ENV['QUNIT_TEST'])
[basename]
else
Pathname
.glob('public/assets/tests/qunit/*.js')
.map { |elem| elem.basename(elem.extname).to_s }
.sort
end
it 'I18n' do
async_q_unit_tests('i18n')
end
context 'UI' do
it 'Base' do
q_unit_tests('ui')
end
it 'Local storage' do
q_unit_tests('local_storage')
end
it 'Model' do
async_q_unit_tests('model')
end
it 'Model binding' do
q_unit_tests('model_binding')
end
it 'Model UI' do
if !ENV['CI']
skip("Can't run locally because of dependence of special Timezone")
end
q_unit_tests('model_ui')
end
it 'Model Ticket' do
q_unit_tests('model_ticket')
end
it 'Ticket selector' do
q_unit_tests('ticket_selector')
end
it 'Image Service' do
q_unit_tests('image_service')
end
end
context 'Form' do
it 'Base' do
async_q_unit_tests('form')
end
it 'Trim' do
q_unit_tests('form_trim')
end
it 'Find' do
q_unit_tests('form_find')
end
it 'Timer' do
q_unit_tests('form_timer')
end
it 'Color' do
q_unit_tests('form_color')
end
it 'Extended' do
q_unit_tests('form_extended')
end
it 'Searchable select' do
q_unit_tests('form_searchable_select')
end
it 'Tree select' do
q_unit_tests('form_tree_select')
end
it 'Column select' do
q_unit_tests('form_column_select')
end
it 'Ticket perform action' do
async_q_unit_tests('form_ticket_perform_action')
end
it 'Ticket macro' do
q_unit_tests('ticket_macro')
end
it 'Validation' do
q_unit_tests('form_validation')
end
it 'Skip rendering' do
q_unit_tests('form_skip_rendering')
end
it 'SLA times' do
q_unit_tests('form_sla_times')
end
it 'DateTime' do
q_unit_tests('form_datetime')
end
it 'Core Workflow' do
q_unit_tests('form_core_workflow')
end
end
context 'Form AJAX', searchindex: true do
before do
configure_elasticsearch
rebuild_searchindex
end
it 'autocompletion ajax' do
async_q_unit_tests('form_autocompletion_ajax')
end
end
context 'Table' do
it 'Base' do
q_unit_tests('table')
end
it 'Extended' do
q_unit_tests('table_extended')
end
it 'HTML utils' do
q_unit_tests('html_utils')
end
it 'Taskbar' do
q_unit_tests('taskbar')
end
end
context 'Knowlede Base Editor' do
it 'Vdeo Embeding' do
q_unit_tests('kb_video_embeding')
files.each do |elem|
it elem.humanize do
visit "/tests_#{elem}"
expect(page).to pass_qunit_test
end
end
end