Skip to content

Commit

Permalink
Added navigation demonstration and test for weblocks pull request #15
Browse files Browse the repository at this point in the history
  • Loading branch information
html committed Feb 19, 2013
1 parent 9938005 commit cdb2269
Show file tree
Hide file tree
Showing 6 changed files with 83 additions and 1 deletion.
1 change: 1 addition & 0 deletions tests-server.sbclrc
@@ -1,4 +1,5 @@
(require :sb-posix)
(setf sb-impl::*default-external-format* :utf-8)
(defvar *port* (parse-integer (nth 1 *posix-argv*)))
(defvar *swank-port* (parse-integer (nth 2 *posix-argv*)))
(load ".quicklisp/setup.lisp")
Expand Down
17 changes: 17 additions & 0 deletions utils.lisp
Expand Up @@ -32,3 +32,20 @@
`(if (browser-is-google-chrome-p)
(progn ,@body)
(warn "Skipping test, browser is not google-chrome")))

(defun ensure-jquery-loaded-into-document ()
(do-get-eval
(remove #\Newline (format nil "
function addJavascript(jsname,pos, callback){
var th = window.document.getElementsByTagName(pos)[0];
var s = window.document.createElement('script');
s.setAttribute('type','text/javascript');
s.setAttribute('src',jsname);
s.onload = callback;
th.appendChild(s);
}
addJavascript('~Apub/scripts/jquery-1.8.2.js', 'body', function(){
window.jQuery.noConflict();
}); " *site-root-url*)))
(sleep 1))
8 changes: 8 additions & 0 deletions weblocks-selenium-tests-app/pub/stylesheets/main.css
Expand Up @@ -270,3 +270,11 @@ div.empty p span.caption
color:gray;
}

#toplevel-nav .menu {
float:left;
}

#toplevel-nav .navigation-body {
float: left;
padding-left: 10px;
}
41 changes: 41 additions & 0 deletions weblocks-selenium-tests-app/src/init-session.lisp
Expand Up @@ -31,6 +31,46 @@
"Close dialog")))))
(do-dialog "Dialog title" widget)))

(defun navigation-demonstration-action (&rest args)
(let ((widget)
(navigation))
(setf navigation (make-navigation
"toplevel-nav"
(list "First pane" (make-widget "First pane value") nil)
(list "Second pane" (make-widget "Second pane value") "second-pane")
(list "Third pane (first nested pane)"
(make-navigation
"second-level-nav-1"
(list "First nested pane" (make-widget "First nested pane") nil)
(list "Second nested pane" (make-widget "Second nested pane") "second-nested-pane")
(list "Third nested pane (with 2-level nesting)"
(make-navigation
"third-level-nav"
(list "First nested pane" (make-widget "First nested pane") nil)
(list "Second nested pane" (make-widget "Second nested pane") "second-nested-pane"))
"third-nested-pane")) "third-pane")
(list "Fourth pane (second nested pane)"
(make-navigation
"second-level-nav-2"
(list "First nested pane" (make-widget "First nested pane"))
(list "Second nested pane" (make-widget "Second nested pane") "second-nested-pane")) "fourth-pane")
(list "Fifth pane" (make-widget "Fifth pane") "fifth-pane")
(list "Sixth pane (third nested pane)"
(make-navigation
"second-level-nav-3"
(list "First nested pane" (make-widget "First nested pane"))
(list "Second nested pane" (make-widget "Second nested pane") "second-nested-pane")) "sixth-pane")))
(setf widget
(make-instance 'composite
:widgets (list
navigation
(lambda (&rest args)
(with-html
(:div :style "clear:both"
(render-link (lambda (&rest args)
(answer widget t)) "back")))))))
(do-page widget)))

(defun define-demo-action (link-name action &key (prototype-engine-p t) (jquery-engine-p t))
"Used to add action to demo list,
:prototype-engine-p and :jquery-engine-p keys
Expand All @@ -39,6 +79,7 @@

(define-demo-action "File field form presentation" #'file-field-demonstration-action :jquery-engine-p nil)
(define-demo-action "Dialog sample" #'dialog-demonstration-action :jquery-engine-p nil)
(define-demo-action "Navigation sample" #'navigation-demonstration-action)

;; Define callback function to initialize new sessions
(defun init-user-session-prototype (root)
Expand Down
2 changes: 1 addition & 1 deletion weblocks-selenium-tests.asd
Expand Up @@ -4,7 +4,7 @@
:serial t
:description "Selenium tests suite for weblocks"
:author "Olexiy Zamkoviy <olexiy.z@gmail.com>"
:version "0.2.0"
:version "0.2.1"
:license "LLGPL"
:depends-on (#:stefil #:selenium #:weblocks-selenium-tests-app)
:components
Expand Down
15 changes: 15 additions & 0 deletions weblocks-selenium-tests.lisp
Expand Up @@ -46,3 +46,18 @@
(do-open-and-wait *site-url*)
(sample-dialog-assertions)
(do-click-and-wait "link=Close dialog")))

(deftest selects-child-navigation-properly ()
(with-new-or-existing-selenium-session
(do-click-and-wait "link=Navigation sample")
(do-click-and-wait "link=Fourth pane (second nested pane)")
(do-click-and-wait "link=First pane")
(do-click-and-wait "link=Fourth pane (second nested pane)")
(ensure-jquery-loaded-into-document)
(is (string=
"true"
(do-get-eval
(ps:ps
(ps:chain
(window.j-query "#second-level-nav-2 li:first")
(has-class "selected-item"))))))))

0 comments on commit cdb2269

Please sign in to comment.