--- a/test-suite/README.txt Sat Apr 19 13:10:09 2014 +0200
+++ b/test-suite/README.txt Sat Apr 19 17:00:40 2014 +0200
@@ -17,7 +17,8 @@
--------------
apt-get install npm
sudo ln /usr/bin/nodejs /usr/bin/node # /usr/share/doc/nodejs/README.Debian
-sudo npm install -g karma karma-mocha karma-e2e-dsl # goes here /usr/local/lib/node_modules/
+sudo npm install -g karma karma-mocha # install things in /usr/local/lib/node_modules/
+sudo npm install -g git://github.com/Siltaar/karma-e2e-dsl # to get the improved karma-e2e-dsl
Starting comt :
--- a/test-suite/karma.conf.js Sat Apr 19 13:10:09 2014 +0200
+++ b/test-suite/karma.conf.js Sat Apr 19 17:00:40 2014 +0200
@@ -3,7 +3,7 @@
// SID: get WORKSPACE_URL configuration from one single file to customize
-var w = require ('./workspace.info.js');
+var W = require ('./workspace.info.js');
module.exports = function(config) {
config.set({
@@ -17,20 +17,20 @@
// - Firefox ; Safari (only Mac; run `npm install karma-safari-launcher` first)
// - Chrome ; ChromeCanary ; Opera (run `npm install karma-opera-launcher` first)
// - PhantomJS ; IE (only Windows; run `npm install karma-ie-launcher` first)
- browsers: w.BROWSERS,
+ browsers: W.BROWSERS,
// frameworks to use. SID: choosen mocha, added karma-e2e-dsl (end-to-end testing)
frameworks: ['mocha', 'karma-e2e-dsl'],
// SID: Karma will start and run somewhere else than '/', to allow proxying '/'
urlRoot: '/karma/',
// SID: directive added on karma-e2e-dsl purpose. Map of path-proxy pairs.
proxies: {
- '/': w.WORKSPACE_URL
+ '/': W.WORKSPACE_URL
},
client: {
mocha: {
ui: 'tdd'
},
- w: w // SID: exports the variable in the test execution browser window
+ W: W // SID: exports the variable in the test execution browser window
},
// test results reporter to use : 'dots', 'progress', 'junit', 'growl', 'coverage'
reporters: ['progress'],
--- a/test-suite/start-test-suite.sh Sat Apr 19 13:10:09 2014 +0200
+++ b/test-suite/start-test-suite.sh Sat Apr 19 17:00:40 2014 +0200
@@ -1,35 +1,88 @@
#!/bin/bash
+echo "Starting test server"
+
+TESTSERVER_LOGS="/tmp/django_test_server_logs.`date +%F_%T`"
+
+cd ..
+nohup ./bin/django testserver --noinput localhost:8000 initial_data roles_generic test_suite > $TESTSERVER_LOGS 2>&1 &
+TESTSERVER_PID=$!
+cd "test-suite"
+
+# Exports browsers _BIN variables for karma
export CHROME_BIN=`which chromium`
if [ -z "$CHROME_BIN" ]; then
- export CHROME_BIN=`which chrome`
+ export CHROME_BIN=`which chrome`
fi
if [[ -z "$CHROME_BIN" && $OSTYPE =~ ^darwin ]]; then
- CHROME_BIN_BASE=`mdfind "kMDItemCFBundleIdentifier == 'com.google.Chrome'"`
- export CHROME_BIN="$CHROME_BIN_BASE/Contents/MacOS/Google Chrome"
+ CHROME_BIN_BASE=`mdfind "kMDItemCFBundleIdentifier == 'com.google.Chrome'"`
+ export CHROME_BIN="$CHROME_BIN_BASE/Contents/MacOS/Google Chrome"
fi
export PHANTOMJS_BIN=`which phantomjs`
export FIREFOX_BIN=`which firefox`
if [[ -z "$FIREFOX_BIN" && $OSTYPE =~ ^darwin ]]; then
- FIREFOX_BIN_BASE=`mdfind "kMDItemCFBundleIdentifier == 'org.mozilla.firefox'"`
- export FIREFOX_BIN="$FIREFOX_BIN_BASE/Contents/MacOS/firefox"
+ FIREFOX_BIN_BASE=`mdfind "kMDItemCFBundleIdentifier == 'org.mozilla.firefox'"`
+ export FIREFOX_BIN="$FIREFOX_BIN_BASE/Contents/MacOS/firefox"
fi
export SAFARI_BIN=`which safari`
if [[ -z "$SAFARI_BIN" && $OSTYPE =~ ^darwin ]]; then
- SAFARI_BIN_BASE=`mdfind "kMDItemCFBundleIdentifier == 'com.apple.Safari'"`
- export SAFARI_BIN="$SAFARI_BIN_BASE/Contents/MacOS/safari"
+ SAFARI_BIN_BASE=`mdfind "kMDItemCFBundleIdentifier == 'com.apple.Safari'"`
+ export SAFARI_BIN="$SAFARI_BIN_BASE/Contents/MacOS/safari"
fi
-
-
if [ -x ./node_modules/.bin/karma ]; then
KARMA=./node_modules/.bin/karma
else
KARMA=`which karma`
fi
+
+CONNECTION_TIMEOUT=10
+TESTSERVER_START_WAIT=15
+TESTSERVER_LOOP_WAIT=5
+TESTSERVER_WAIT_LOOP_NB=5
+
+SERVER_IP=`grep WORKSPACE_URL workspace.info.js | sed "s|^.*http://\([-._[:alnum:]]*\):.*$|\1|"`
+SERVER_PORT=`grep WORKSPACE_URL workspace.info.js | sed "s|^.*http://[-._[:alnum:]]*:\([0-9]*\)/.*$|\1|"`
+
+if [[ -x `which nc` ]]; then
+ SERVER_TEST_CMD="nc -w $CONNECTION_TIMEOUT -z $SERVER_IP $SERVER_PORT"
+elif [[ -x `which curl` ]]; then
+ SERVER_TEST_CMD="curl -m $CONNECTION_TIMEOUT --output /dev/null --silent --head --fail http://$SERVER_IP:$SERVER_PORT"
+elif [[ -x `which wget` ]]; then
+ SERVER_TEST_CMD="wget --timeout=$CONNECTION_TIMEOUT -q --spider http://$SERVER_IP:$SERVER_PORT"
+fi
+
+echo "Using '$SERVER_TEST_CMD' to probe test server $SERVER_IP:$SERVER_PORT availability"
+
+if [[ -z "$SERVER_TEST_CMD" ]]; then
+ echo "No http tool available so blindly waiting $TESTSERVER_START_WAIT seconds to let test server start"
+ sleep $TESTSERVER_START_WAIT
+else
+ for i in $(seq 1 $TESTSERVER_WAIT_LOOP_NB); do
+ echo "and waiting $TESTSERVER_LOOP_WAIT seconds"
+ sleep $TESTSERVER_LOOP_WAIT
+ if $SERVER_TEST_CMD; then
+ break
+ fi
+ done
+ if [ $i -eq $TESTSERVER_WAIT_LOOP_NB ]; then
+ echo "timeouted waiting for test server $SERVER_IP:$SERVER_PORT to start"
+ exit 1
+ fi
+fi
+
+echo "---------------------"
+echo "$KARMA start $@"
"$KARMA" start $@
+read -p "Keep testserver (PID $TESTSERVER_PID) running ? (y/N)" -n 1 -r -t 5
+echo # (optional) move to a new line
+if [[ $REPLY =~ ^[Yy]$ ]]; then
+ exit 0
+fi
+
+kill $TESTSERVER_PID
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/000_e2e_test_helpers.js Sat Apr 19 17:00:40 2014 +0200
@@ -0,0 +1,189 @@
+// Test helpers for karma-e2e-dsl environment
+//
+// https://github.com/winsonwq/karma-e2e-dsl
+//
+// " Vim settings
+// set tabstop=4 " number of spaces in a tab
+// set softtabstop=4 " as above
+// set shiftwidth=4 " as above
+
+
+function test_page_loading (url, title) {
+ test (url+' loads', dsl(function () {
+ // here we are in Karma page
+ browser.navigateTo (url);
+ expect (element ('title').text ()).toMatch (new RegExp (title,'m'));
+ // The same test agin vaniller javascript
+ element ('title').text (function (page_title) {
+ // here we got a value from the test iframe
+ // to display the tested value : console.log (page_title);
+ if (!(new RegExp (title, 'm').test (page_title))) throw 'got page '+page_title+' instead';
+ });
+ }));
+}
+
+/** Test if it's possible to change lang to the specified :
+ * c : lang code
+ * l : help label
+ */
+function test_i18n (c, l) {
+ test ('to '+c, dsl(function () {
+ element ('#footer a[href="/i18n/setlang/'+c+'/"]').click ();
+ browser.navigateTo ('/');
+ expect (elt ('#footer a[href="/help/"]').text ()).toMatch (new RegExp (l, 'm'));
+ }));
+}
+
+/** Test if the selected DOM element .text() value match the given regexp
+ * s : CSS selector
+ * r : regexp to match
+ */
+function test_match (s, r) {
+ test (s+' text match '+r, dsl(function () {
+ expect (elt (s).text ()).toMatch (r);
+ }));
+}
+
+/** Test if the selected DOM element has a given value : .val()
+ * s : CSS selector
+ * e : expected value, if omited, test existence
+ */
+function test_val (s, e) {
+ e = typeof e == 'undefined' ? '' : e; // .val() returns defined ? '' : undefined; // if no value
+ test (s+' is '+e, dsl(function () {
+ expect (elt (s).val ()).toMatch (new RegExp (e, 'm'));
+ }));
+}
+
+/**
+ *
+ */
+function test_exist (s) {
+ test_val (s);
+}
+
+/** Test if the selected DOM element has the given text : .text()
+ * s : CSS selector
+ * e : expected value
+ * v : should we test a visible value ?
+ */
+function test_text (s, e, v) {
+ v = typeof v == 'undefined' ? true : v;
+ test (s+' has text '+e, dsl(function () {
+ expect (elt (s, v).text ()).toBe (e);
+ }));
+}
+
+/** Count selector occurences
+ * s : CSS selector
+ * e : expected count
+ */
+function test_count (s, e) {
+ test (s+' count is '+e, dsl(function () {
+ expect (elt (s).count ()).toBe (e);
+ }));
+}
+
+/** Test Django form field presence
+ */
+function test_field (form_id, field_id, type, position, label, mandatory) {
+ test ('has a '+label+' form field', dsl(function () {
+ var s = '';
+
+ switch (type) {
+ case 'textarea':s = 'textarea#'+field_id; break;
+ case 'select': s = 'select#'+field_id; break;
+ default: s = 'input#'+field_id+'[type="'+type+'"]';
+ }
+
+ expect (elt (s).val ()).toBeDefined ();
+ expect (elt ('#'+form_id+' :input:eq('+position+')#'+field_id).val ()).toBeDefined ();
+ expect (elt ('label[for='+field_id+']').text ()).toBe (label);
+
+ if (mandatory)
+ expect (elt ('label[for='+field_id+'] + span.required_star').val ()).toBeDefined ();
+ }));
+}
+
+/**
+ * Fill form field
+ * s : form field id
+ * v : array containing the value to use
+ */
+function test_fill_field (s, v) {
+ test ('set '+s, dsl(function () {
+ input (s).enter (v[s]);
+ }));
+}
+
+/**
+ * Click on something
+ * s : selector of the item to click on
+ * w : should we wait for a page to load in the browser after the click
+ * v : is the element visible or not
+ */
+function test_click (s, w, v) {
+ var t = 'click '+ w ? 'to submit form ' : '';
+ test (t+s, dsl(function () {
+ elt (s, v).click ();
+ if (w)
+ browser.waitForPageLoad ();
+ }));
+}
+
+/**
+ * Send submit event to the given form
+ * s : selector of the form to submit
+ */
+function test_submit (s) {
+ test ('send submit event to '+s, dsl(function () {
+ elt (s).submit ();
+ browser.waitForPageLoad ();
+ }));
+}
+
+
+/**
+ * Reload a page
+ */
+function test_reload () {
+ test ('reload current page', dsl(function () {
+ browser.reload ();
+ }));
+}
+
+/**
+ * Fails a test
+ */
+function test_fail () {
+ test ('must fail', dsl(function () {
+ throw 'have been programmed to fail now';
+ }));
+}
+
+/**
+ * Have the browser waiting while you inspect what's going on
+ */
+function test_pause () {
+ test ('pause', dsl(function () {
+ browser.pause ();
+ }));
+}
+
+/**
+ * Start back the testcases
+ */
+function test_resume () {
+ test ('resume', dsl(function (){
+ browser.resume ();
+ }));
+}
+
+/** Ensure the given element is visible
+ * s : CSS selector of the DOM element to check
+ * v : should the element being visible
+ */
+function elt (s, v) {
+ return element (s + (v ? ':visible' : ''));
+}
+
--- a/test-suite/tests/000_test_helpers.js Sat Apr 19 13:10:09 2014 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,176 +0,0 @@
-// Test helpers for karma-e2e-dsl environment
-//
-// https://github.com/winsonwq/karma-e2e-dsl
-
-
-function test_page_loading (url, title) {
- test (url+' loads', dsl(function () {
- // here we are in Karma page
- browser.navigateTo (url);
- expect (element ('title').text ()).toMatch (new RegExp (title,'m'));
- // The same test agin vaniller javascript
- element ('title').text (function (page_title) {
- // here we got a value from the test iframe
- // to display the tested value : console.log (page_title);
- if (!(new RegExp (title, 'm').test (page_title))) throw 'got page '+page_title+' instead';
- });
- }));
-}
-
-/** Test if it's possible to change lang to the specified :
- * c : lang code
- * l : help label
- */
-function test_i18n (c, l) {
- test ('to '+c, dsl(function () {
- element ('#footer a[href="/i18n/setlang/'+c+'/"]').click ();
- browser.navigateTo ('/');
- expect (elt ('#footer a[href="/help/"]').text ()).toMatch (new RegExp (l, 'm'));
- }));
-}
-
-/** Test if the selected DOM element is defined or has a given value : .val()
- * s : CSS selector
- * e : expected value, if omited, test existence
- */
-function test_val (s, e) {
- e = typeof e == 'undefined' ? '' : e; // .val() returns defined ? '' : undefined; // if no value
- test (s+' is '+e, dsl(function () {
- expect (elt (s).val ()).toMatch (new RegExp (e, 'm'));
- }));
-}
-
-function test_exist (s) {
- test_val (s);
-}
-
-/** Test if the selected DOM element has the given text : .text()
- * s : CSS selector
- * e : expected value
- * v : should we test a visible value ?
- */
-function test_text (s, e, v) {
- v = typeof v == 'undefined' ? true : v;
- test (s+' has text '+e, dsl(function () {
- expect (elt (s, v).text ()).toBe (e);
- }));
-}
-
-/** Test if the selected DOM element .text() value match the given regexp
- * s : CSS selector
- * r : regexp to match
- */
-function test_match (s, r) {
- test (s+' text match '+r, dsl(function () {
- expect (elt (s).text ()).toMatch (r);
- }));
-}
-
-/** Count selector occurences
- * s : CSS selector
- * e : expected count
- */
-function test_count (s, e) {
- test (s+' count is '+e, dsl(function () {
- expect (elt (s).count ()).toBe (e);
- }));
-}
-
-/** Test Django form field presence
- */
-function test_field (form_id, field_id, type, position, label, mandatory) {
- test ('has a '+label+' form field', dsl(function () {
- var s = '';
-
- switch (type) {
- case 'textarea':s = 'textarea#'+field_id; break;
- case 'select': s = 'select#'+field_id; break;
- default: s = 'input#'+field_id+'[type="'+type+'"]';
- }
-
- expect (elt (s).val ()).toBeDefined ();
- expect (elt ('#'+form_id+' :input:eq('+position+')#'+field_id).val ()).toBeDefined ();
- expect (elt ('label[for='+field_id+']').text ()).toBe (label);
-
- if (mandatory)
- expect (elt ('label[for='+field_id+'] + span.required_star').val ()).toBeDefined ();
- }));
-}
-
-/**
- * Fill form field
- * s : form field id
- * v : array containing the value to use
- */
-function test_fill_field (s, v) {
- test ('set '+s, dsl(function () {
- input (s).enter (v[s]);
- }));
-}
-
-/**
- * Click somewhere
- * s : selector of the item to click on
- * v : is the element visible or not
- */
-function test_click (s, v) {
- test ('click '+s, dsl(function () {
- elt (s, v).click ();
- }));
-}
-
-/**
- * Submit a form
- * s : selector of the submit button
- */
-function test_submit (s) {
- test ('submit '+s, dsl(function () {
- elt (s).click ();
- browser.waitForPageLoad ();
- }));
-}
-
-/**
- * Reload a page
- */
-function test_reload () {
- test ('reload current page', dsl(function () {
- browser.reload ();
- }));
-}
-
-/**
- * Fails a test
- */
-function test_fail () {
- test ('must fail', dsl(function () {
- throw 'have been programmed to fail now';
- }));
-}
-
-/**
- * Have the browser waiting while you inspect what's going on
- */
-function test_pause () {
- test ('pause', dsl(function () {
- browser.pause ();
- }));
-}
-
-/**
- * Start back the testcases
- */
-function test_resume () {
- test ('resume', dsl(function (){
- browser.resume ();
- }));
-}
-
-/** Ensure the given element is visible
- * s : CSS selector of the DOM element to check
- * v : should the element being visible
- */
-function elt (s, v) {
- return element (s + (v ? ':visible' : ''));
-}
-
--- a/test-suite/tests/001_comt-unlogged-prelude.js Sat Apr 19 13:10:09 2014 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,112 +0,0 @@
-
-// " Vim settings
-// set tabstop=4 " number of spaces in a tab
-// set softtabstop=4 " as above
-// set shiftwidth=4 " as above
-
-suite.skip ('comt unlogged prelude', function () {
-
- this.timeout(20000);
-
- suite ('contact page conformity', function () {
- test_page_loading ('/contact/', 'Contact');
- test_unlogged_header ();
- test_exist ('form#profile[action="."]'); // the form exists
- test_count ('form#profile :input', 7); // it has no more than 5 labels (may be no more fields)
- test_field ('profile', 'id_name', 'text', 0, 'Your name', true); // the field id_name is…
- test_field ('profile', 'id_email', 'text', 1, 'Your email address', true);
- test_field ('profile', 'id_title', 'text', 2, 'Subject of the message', true);
- test_field ('profile', 'id_body', 'textarea', 3, 'Body of the message', true);
- test_field ('profile', 'id_copy', 'checkbox', 4, 'Send me a copy of the email', false);
- test_val ('#profile input[type=submit]','Send'); // test that a the .val() of the element is
- test_val ('input#cancel_button[type=button]', 'Cancel');
- test_unlogged_footer ();
- test ('to check that toBeDefined test still works', dsl(function () {
- expect (test_elt ('#header_controls a[href="/xxx/"]').val ()).not ().toBeDefined ();
- }));
- test ('get back to / to avoid bugging next page load', dsl(function () { browser.navigateTo ('/'); }));
- });
-
- suite ('help page conformity', function () {
- test_page_loading ('/help/', 'Help');
- test_unlogged_header ();
- test_unlogged_footer ();
- });
-
- suite ('can change lang', function () {
- test ('get back to / to avoid bugging next page load', dsl(function () { browser.navigateTo ('/'); }));
- test_i18n ('fr', 'Aide');
- test_i18n ('en', 'Help');
- test_i18n ('es', 'Ayuda');
- test_i18n ('it', 'Aiuto');
- test_i18n ('de', 'Hilfe');
- test_i18n ('pt_BR', 'Ajuda');
- test_i18n ('nb', 'Hjelp');
- test_i18n ('bg', 'Помощ');
- test_i18n ('en', 'Help');
- });
-
- suite ('contact page mandatory field test', function () {
- test_page_loading ('/contact/', 'Contact');
- test_submit('#profile input[type="submit"]');
- test_count ('div.help_text span.error-text', 4);
- test_field ('profile div.error', 'id_name', 'text', 0, 'Your name', true); // the field id_name is…
- test_field ('profile div.error', 'id_email', 'text', 1, 'Your email address', true);
- test_field ('profile div.error', 'id_title', 'text', 2, 'Subject of the message', true);
- test_field ('profile div.error', 'id_body', 'textarea', 3, 'Body of the message', true);
- test_field ('profile', 'id_copy', 'checkbox', 4, 'Send me a copy of the email', false);
- });
-
- suite ('reset password page conformity', function () {
- test_page_loading ('/password_reset/', 'Reset my password');
- test_unlogged_header ();
- test_count ('form#profile :input', 3);
- test_field ('profile', 'id_email', 'text', 1, 'E-mail', true);
- test_val ('#profile input[type=submit]', 'Reset my password');
- test_unlogged_footer ();
- test_submit('#profile input[type="submit"]');
- test_count ('div.help_text span.error-text', 1);
- test_field ('profile div.error', 'id_email', 'text', 0, 'E-mail', true);
- });
-
- suite ('login page conformity', function () {
- test_page_loading ('/', 'Home');
- test_unlogged_header ();
- test_count ('form#login[action="/login/"] :input', 3);
- test_field ('login', 'id_username', 'text', 0, 'Username', true);
- test_field ('login', 'id_password', 'password', 1, 'Password', true);
- test_val ('form#login input[type=submit]', 'Login');
- test_text ('form#login a[href="/password_reset/"]', 'Forgot password?');
- test_unlogged_footer ();
- // test_i18n ();
-
- test ('get back to / to avoid bugging next page load', dsl(function () {
- browser.navigateTo ('/');
- }));
- test_page_loading ('/login/', 'Login');
- test_submit('#login input[type="submit"]');
- test_field ('login div.error', 'id_username', 'text', 0, 'Username', true);
- test_field ('login div.error', 'id_password', 'password', 1, 'Password', true);
- });
-});
-
-function test_unlogged_header () {
- test_count ('#header_controls a', 2);
- test_text ('#header_controls a[href="/"]', 'Home');
- test_text ('#header_controls a[href="/login/"]', 'Login');
-}
-
-function test_unlogged_footer (url) {
- test_count ('#footer a', 10);
- test_text ('#footer a:nth-of-type(1)[href="/contact/"]', 'Contact');
- test_match ('#footer #comentlink[href="http://www.co-ment.com"]', /Powered by/m);
- test_text ('#footer a:nth-of-type(3)[href="/help/"]', 'Help');
- test_text ('#footer a:nth-of-type(4)[href="/i18n/setlang/fr/"]', 'Français');
- test_text ('#footer a:nth-of-type(5)[href="/i18n/setlang/es/"]', 'Español');
- test_text ('#footer a:nth-of-type(6)[href="/i18n/setlang/it/"]', 'Italiano');
- test_text ('#footer a:nth-of-type(7)[href="/i18n/setlang/de/"]', 'Deutsch');
- test_text ('#footer a:nth-of-type(8)[href="/i18n/setlang/pt_BR/"]', 'Português Brasileiro');
- test_text ('#footer a:nth-of-type(9)[href="/i18n/setlang/nb/"]', 'Norsk');
- test_text ('#footer a:nth-of-type(10)[href="/i18n/setlang/bg/"]', 'Български');
-}
-
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/001_comt_test_utils.js Sat Apr 19 17:00:40 2014 +0200
@@ -0,0 +1,135 @@
+
+// " Vim settings
+// set tabstop=4 " number of spaces in a tab
+// set softtabstop=4 " as above
+// set shiftwidth=4 " as above
+
+/**
+ * Constants and variables
+ */
+
+var test_comt = { 'text_nb': 0, 'user_nb': 4 };
+
+const C = { 'HIDDEN': false,
+ 'NO_TAGLINE': false,
+ 'WAIT_PAGE_LOAD': true,
+ 'W': __karma__.config.W,
+ '#id_workspace_name': 'Test workspace name',
+ '#id_workspace_tagline': 'Test workspace tagline',
+ '#id_workspace_registration': 'on', // registration
+ '#id_workspace_registration_moderation':'on', // registration moderation
+ '#id_workspace_role_model': 'generic',
+ '#id_workspace_category_1': 'ws_cat_1',
+ '#id_workspace_category_2': 'ws_cat_2',
+ '#id_workspace_category_3': 'ws_cat_3',
+ '#id_workspace_category_4': 'ws_cat_4',
+ '#id_workspace_category_5': 'ws_cat_5',
+ '#id_custom_css': "h2 { font-family: Test_Sopinspace !important; }",
+ '#id_custom_font': 'Test_Sopinspace_custom_font',
+ '#id_custom_titles_font': 'Test_Sopinspace_custom_titles_font'
+};
+
+
+/**
+ * COMT test API
+ */
+
+function test_comt_login (user, pass) {
+ test ('with '+user+' - '+pass, dsl(function () {
+ browser.navigateTo ('/');
+ input ('#id_username').enter (user);
+ input ('#id_password').enter (pass);
+ elt ('#login input[type=submit]').click ();
+ browser.waitForPageLoad (); // Must be done here in this test() block
+ browser.navigateTo ('/');
+ expect (element ('title').text ()).toMatch (/Dashboard/m);
+ }));
+}
+
+function test_comt_logout () {
+ test_page_loading ('/logout/', 'Home - '+C['#id_workspace_name']);
+};
+
+function test_comt_create_text (t) {
+ test_page_loading ('/create/content/', 'Create a text - '+C['#id_workspace_name']);
+ test ('test creation', dsl(function () {
+ dropdownlist ('#id_format').option (t['#id_format']);
+ }));
+
+ test_fill_field ('#id_title', t);
+ test ('fill content', dsl(function (){
+ elt ('#id_content').val (t['#id_content']);
+ }));
+
+ test_fill_field ('#id_tags', t);
+ test_click ('#save_button', C.WAIT_PAGE_LOAD);
+ test_comt.text_nb++;
+}
+
+
+/**
+ * Other factorized tests
+ */
+
+
+
+function test_comt_default_tabs (txt_nb, usr_nb) {
+ test_count ('#main-tabs a', 5);
+ test_text ('#main-tabs li:nth-of-type(1) a[href="/"]', 'Dashboard');
+ test_match ('#main-tabs li:nth-of-type(2) a[href="/text/"]', /^Texts \(\d+\) $/);
+ test_match ('#main-tabs li:nth-of-type(3) a[href="/user/"]', /^People \(\d+\)$/);
+ test_text ('#main-tabs li:nth-of-type(4) a[href="/settings/"]', 'Settings');
+ test_text ('#main-tabs li:nth-of-type(5) a[href="/followup/"]', 'Followup');
+ test_match ('#main-tabs a[href="/text/"]', new RegExp ('^Texts\\s*\\('+txt_nb+'\\)\\s*$'));
+ test_match ('#main-tabs a[href="/user/"]', new RegExp ('^People\\s*\\('+usr_nb+'\\)\\s*$'));
+}
+
+function test_comt_logged_header (username, is_tagline) {
+ is_tagline = typeof is_tagline == 'undefined' ? true : is_tagline;
+
+ test_text ('#header_controls b', username)
+ test_count ('#header_controls a', 6);
+ test_text ('#header_controls a:nth-of-type(1)[href="/"]', 'Home');
+ test_text ('#header_controls a:nth-of-type(2)[href="/create/content/"]', 'Create a text');
+ test_text ('#header_controls a:nth-of-type(3)[href="/create/upload/"]', 'Upload a text');
+ test_text ('#header_controls a:nth-of-type(4)[href="/create/import/"]', 'Import a co-mented text');
+ test_text ('#header_controls a:nth-of-type(5)[href="/profile/"]', 'Profile');
+ test_text ('#header_controls a:nth-of-type(6)[href="/logout/"]', 'Logout');
+ test_text ('#content h1.main_title a[href="/"]', C['#id_workspace_name']);
+
+ if (is_tagline) {
+ test_match ('#content h1.main_title + div', new RegExp (C['#id_workspace_tagline'], 'm'));
+ }
+}
+
+function test_comt_fill_settings (s) {
+ test_fill_field ('#id_workspace_name', s);
+ test_fill_field ('#id_workspace_tagline', s);
+ test_fill_field ('#id_workspace_registration', s);
+ test_fill_field ('#id_workspace_registration_moderation', s);
+ test_fill_field ('#id_workspace_role_model', s);
+ test_fill_field ('#id_workspace_category_1', s);
+ test_fill_field ('#id_workspace_category_2', s);
+ test_fill_field ('#id_workspace_category_3', s);
+ test_fill_field ('#id_workspace_category_4', s);
+ test_fill_field ('#id_workspace_category_5', s);
+}
+
+function test_comt_fill_design (s) {
+ test_fill_field ('#id_custom_css', s);
+ test_fill_field ('#id_custom_font', s);
+ test_fill_field ('#id_custom_titles_font', s);
+}
+
+/** Test if it's possible to change lang to the specified :
+ * c : lang code
+ * l : help label
+ */
+function test_comt_i18n (c, l) {
+ test ('to '+c, dsl(function () {
+ element ('#footer a[href="/i18n/setlang/'+c+'/"]').click ();
+ browser.navigateTo ('/');
+ expect (elt ('#footer a[href="/help/"]').text ()).toMatch (new RegExp (l, 'm'));
+ }));
+}
+
--- a/test-suite/tests/002_comt-logged-admin.js Sat Apr 19 13:10:09 2014 +0200
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,526 +0,0 @@
-
-// " Vim settings
-// set tabstop=4 " number of spaces in a tab
-// set softtabstop=4 " as above
-// set shiftwidth=4 " as above
-
-var w = __karma__.config.w,
- t = {'text_nb': 12, 'user_nb': 4},
- long_text = '';
-
-for (var i = 20; i--;)
- long_text += 'Contenu du troisième texte.<br/>Sur <b>plusieurs</b> lignes<br/>';
-
-const non_visible = false,
- no_tagline = false,
- c = {
- '#id_workspace_name': 'Test workspace name',
- '#id_workspace_tagline': 'Test workspace tagline',
- '#id_workspace_registration': 'on', // registration
- '#id_workspace_registration_moderation':'on', // registration moderation
- '#id_workspace_role_model': 'generic',
- '#id_workspace_category_1': 'ws_cat_1',
- '#id_workspace_category_2': 'ws_cat_2',
- '#id_workspace_category_3': 'ws_cat_3',
- '#id_workspace_category_4': 'ws_cat_4',
- '#id_workspace_category_5': 'ws_cat_5',
- '#id_custom_css': "h2 { font-family: Test_Sopinspace !important; }",
- '#id_custom_font': 'Test_Sopinspace_custom_font',
- '#id_custom_titles_font': 'Test_Sopinspace_custom_titles_font',
- 'texts': [
- {
- '#id_title': 'Text One Sopinspace-Test éléguant',
- '#id_format': 'markdown',
- '#id_content': 'Contenu du premier texte.\nSur plusieurs lignes\nPour tester un cas réaliste',
- '#id_tags': 'test_text, Text Premier'
- },
- {
- '#id_title': 'Text Two Sopinspace-Test éléguant',
- '#id_format': 'rst',
- '#id_content': 'Contenu du deuxième texte.\nSur plusieurs lignes aussi\nPour tester un cas réaliste',
- '#id_tags': 'test_text, Text Second'
- },
- {
- '#id_title': 'Text Three Sopinspace-Test éléguant',
- '#id_format': 'html',
- '#id_content': long_text,
- '#id_tags': 'test_text, Text Troisième'
- }
- ]
-};
-
-suite ('comt logged admin', function () {
-
- this.timeout(20000);
-
- suite ('logs as an admin', function () {
- test ('logs an admin in', dsl(function () {
- browser.navigateTo ('/');
- input ('#id_username').enter (w.USER_ADMIN);
- input ('#id_password').enter (w.PASS_ADMIN);
- elt ('#login input[type=submit]').click ();
- browser.waitForPageLoad (); // Must be done here in this test() block
- browser.navigateTo ('/');
- expect (element ('title').text ()).toMatch (/Dashboard/m);
- }));
- });
-
- suite ('setting settings to test-values', function () {
- test_page_loading ('/settings/', 'Settings');
- test_fill_settings (c);
- test_val ('#id_workspace_name', c['#id_workspace_name']);
- test_submit ('#settings input[type="submit"]');
- test_page_loading ('/settings/', 'Settings');
- test_text ('#content h1.main_title a[href="/"]', c['#id_workspace_name']);
- test_page_loading ('/settings/design/', 'Settings');
- test_fill_design (c);
- test_submit ('#settings input[type="submit"]');
- });
-
- suite ('admin dashboard page conformity', function () {
- test_page_loading ('/', 'Dashboard\n - '+c['#id_workspace_name']);
- test_logged_header (w.USER_ADMIN);
- test_default_tabs (t.text_nb, t.user_nb);
- test_count ('table.dash_table', 5);
- test_text ('table.dash_table th:eq(0)', 'Actions');
- test_match ('table.dash_table:eq(0) a:eq(0)[href="/create/content/"]', /\sCreate a text/);
- test_text ('table.dash_table:eq(0) a:eq(1).tip[href="#"]', '\xa0');
- test_match ('table.dash_table:eq(0) a:eq(2)[href="/create/upload/"]', /\sUpload a text/);
- test_text ('table.dash_table:eq(0) a:eq(3).tip[href="#"]', '\xa0');
- test_match ('table.dash_table:eq(0) a:eq(4)[href="/create/import/"]', /\sImport a co-mented text/);
- test_text ('table.dash_table:eq(0) a:eq(5).tip[href="#"]', '\xa0');
- test_match ('table.dash_table:eq(0) a:eq(6)[href="/user/add/"]', /\sInvite user/);
- test_match ('table.dash_table:eq(0) a:eq(7)[href="/profile/"]', /\sEdit your profile/);
- test_match ('table.dash_table:eq(0) a:eq(8)[href="/text/"]', /\sView text list/);
- test_match ('table.dash_table:eq(0) a:eq(9)[href="/settings/"]', /\sConfigure workspace/);
- test_text ('table.dash_table th:eq(1)', 'Recent texts (all)');
- test_text ('table.dash_table:eq(1) a:eq(0)[href="/text/"]', 'all');
- test_text ('table.dash_table th:eq(2)', 'Recent comments');
- test_match ('table.dash_table th:eq(3)', /^Workspace activity\n\s+\(month\/week\/24 hours\)$/m);
- test_text ('table.dash_table:eq(3) a:eq(0)[href="?span=month"]', 'month');
- test_text ('table.dash_table:eq(3) a:eq(1)[href="?span=day"]', '24 hours');
- test_text ('table.dash_table th:eq(4) span.em', 'Activities');
- test_unlogged_footer ();
- });
-
- suite.skip ('empty texts list page conformity', function () {
- test_page_loading ('/text/', 'Texts\n - '+c['#id_workspace_name']);
- test_logged_header (w.USER_ADMIN);
- test_default_tabs (t.text_nb, t.user_nb);
- test_count ('#text ul.sub_list:eq(0) a', 3);
- test_text ('#text ul.sub_list:eq(0) a:eq(0)[href="/create/content/"]', 'Create a text');
- test_text ('#text ul.sub_list:eq(0) a:eq(1)[href="/create/upload/"]', 'Upload a text');
- test_text ('#text ul.sub_list:eq(0) a:eq(2)[href="/create/import/"]', 'Import a co-mented text');
- test_match ('#text', /No texts yet/m);
- test_count ('#texts_form :input', 0);
- });
-
- suite ('create a text page conformity', function () {
- test_page_loading ('/create/content/', 'Create a text - '+c['#id_workspace_name']);
- test_logged_header (w.USER_ADMIN);
- test_default_tabs (t.text_nb, t.user_nb);
- test_count ('#text ul.sub_list:eq(0) a', 3);
- test_text ('#text ul.sub_list:eq(0) a:eq(0)[href="/text/"]', 'Text list');
- test_text ('#text ul.sub_list:eq(0) a:eq(1)[href="/create/upload/"]', 'Upload a text');
- test_text ('#text ul.sub_list:eq(0) a:eq(2)[href="/create/import/"]', 'Import a co-mented text');
- test_count ('#text form[action="."]:eq(0) :input', 6);
- test_field ('text', 'id_title', 'text', 0, 'Title', true);
- test_field ('text', 'id_format', 'select', 1, 'Format', true);
- test_field ('text', 'id_content', 'textarea', 2, 'Content', true);
- test_field ('text', 'id_tags', 'text', 3, 'Tags');
- test_val ('#text :input:eq(4)[type=submit]', 'Save');
- test_val ('#text :input:eq(5)#cancel_button[type=button]', 'Cancel');
- test_count ('select#id_format option', 3);
- test_text ('select#id_format option:eq(0)[value="markdown"][selected]', 'markdown', non_visible);
- test_text ('select#id_format option:eq(1)[value="rst"]', 'rst', non_visible);
- test_text ('select#id_format option:eq(2)[value="html"]', 'html', non_visible);
- test_count ('.markdown #markItUpId_content li', 20); // How many buttons in the WYSIWYG editor toolbar ?
- test_unlogged_footer ();
- test_submit('#text input[type="submit"]');
- test_count ('div.help_text span.error-text', 2);
- test_field ('text div.error', 'id_title', 'text', 0, 'Title', true);
- test_field ('text div.error', 'id_content', 'textarea', 1, 'Content', true);
- });
-
- suite ('upload text page conformity', function () {
- test_page_loading ('/create/upload/', 'Upload a text - '+c['#id_workspace_name']);
- test_logged_header (w.USER_ADMIN);
- test_default_tabs (t.text_nb, t.user_nb);
- test_count ('#text ul.sub_list:eq(0) a', 3);
- test_text ('#text ul.sub_list:eq(0) a:eq(0)[href="/text/"]', 'Text list');
- test_text ('#text ul.sub_list:eq(0) a:eq(1)[href="/create/content/"]', 'Create a text');
- test_text ('#text ul.sub_list:eq(0) a:eq(2)[href="/create/import/"]', 'Import a co-mented text');
- test_count ('#text form[action="."]:eq(0) :input', 6);
- test_field ('text', 'id_title', 'text', 0, 'Title');
- test_field ('text', 'id_format', 'select', 1, 'Format', true);
- test_field ('text', 'id_tags', 'text', 2, 'Tags');
- test_field ('text', 'id_file', 'file', 3, 'Upload file');
- test_val ('#text :input:eq(4)[type=submit]', 'Save');
- test_val ('#text :input:eq(5)#cancel_button[type=button]', 'Cancel');
- test_count ('select#id_format option', 3);
- test_text ('select#id_format option:eq(0)[value="markdown"][selected]', 'markdown', non_visible);
- test_text ('select#id_format option:eq(1)[value="rst"]', 'rst', non_visible);
- test_text ('select#id_format option:eq(2)[value="html"]', 'html', non_visible);
- test_unlogged_footer ();
- test_submit('#text input[type="submit"]');
- test_count ('div.help_text span.error-text', 1);
- test_field ('text div.error', 'id_file', 'file', 0, 'Upload file');
- test_match ('#text div.help_text:eq(3) span.error-text:eq(0)', /You should specify a file to upload/m);
- });
-
- suite ('import a co-mented text page conformity', function () {
- test_page_loading ('/create/import/', 'Import a co-mented text - '+c['#id_workspace_name']);
- test_logged_header (w.USER_ADMIN);
- test_default_tabs (t.text_nb, t.user_nb);
- test_count ('#text ul.sub_list:eq(0) a', 3);
- test_text ('#text ul.sub_list:eq(0) a:eq(0)[href="/text/"]', 'Text list');
- test_text ('#text ul.sub_list:eq(0) a:eq(1)[href="/create/content/"]', 'Create a text');
- test_text ('#text ul.sub_list:eq(0) a:eq(2)[href="/create/upload/"]', 'Upload a text');
- test_count ('#text form[action="."]:eq(0) :input', 3);
- test_field ('text', 'id_file', 'file', 0, 'Upload XML file', true);
- test_val ('#text :input:eq(1)[type=submit]', 'Save');
- test_val ('#text :input:eq(2)#cancel_button[type=button]', 'Cancel');
- test_unlogged_footer ();
- test_submit('#text input[type="submit"]');
- test_count ('div.help_text span.error-text', 1);
- test_field ('text div.error', 'id_file', 'file', 0, 'Upload XML file', true);
- test_match ('#text div.help_text:eq(0) span.error-text:eq(0)', /You should specify a file to upload/m);
- });
-
- suite.skip ('create texts', function () {
-/* for (var j=4; j--;)
- for (var i=3; i--;)
- create_text (i);*/
- });
-
- // check that public texts still worwhile unlogged
- // check that non public texts are unavailable
- // Are the public texts displayed in the login page ?
-
- // vérifier les valeurs de settings sauvées
- // Tester les liens masqués des textes listés si bien créés
- // Tester suppression de text
- // Tester bulk actions sur les textes
-
- // tester l'affichage d'un texte
- // tester que : #textcontainer.custom h1 font: Test_Sopinspace_custom_titles_font
- // tester que si Text preferences -> custom -> #textcontainer.custom font: Test_Sopinspace_custom_font
- // #textcontainer #add_comment_btn span -> #textcontainer font-family: Test_Sopinspace
-
- suite ('texts list page conformity', function () {
- test_page_loading ('/text/', 'Texts\n - '+c['#id_workspace_name']);
- test_logged_header (w.USER_ADMIN);
- test_default_tabs (t.text_nb, t.user_nb);
- test_count ('#text ul.sub_list:eq(0) a', 3);
- test_text ('#text ul.sub_list:eq(0) a:eq(0)[href="/create/content/"]', 'Create a text');
- test_text ('#text ul.sub_list:eq(0) a:eq(1)[href="/create/upload/"]', 'Upload a text');
- test_text ('#text ul.sub_list:eq(0) a:eq(2)[href="/create/import/"]', 'Import a co-mented text');
- test_count ('form#filter_form[action="."] :input', 1);
- test_text ('select#tag_selected option:eq(0)[selected][value="0"]', '- All -', non_visible);
- test_page_loading ('/text/?tag_selected=Text+Troisième', 'Texts\n - '+c['#id_workspace_name']);
- test_count ('#texts_form :input', 4 + 3);
- test_match ('#paginator', /\s1-4 of 4\s/m);
-
- for (var i=4; i--;) {
- test_text ('a.main_object_title:eq('+i+')', c.texts[2]['#id_title']);
- test_match ('.tag_list:eq('+i+')', /tags: test_text Text Troisième /);
- test_text ('.tag_list:eq('+i+') a:eq(0)[href="?tag_selected=test_text"]', 'test_text');
- test_text ('.tag_list:eq('+i+') a:eq(1)[href="?tag_selected=Text+Troisi%C3%A8me"]','Text Troisième');
- test_text ('#text .hidden-text-actions:eq('+i+') a:eq(0)[href^="/text/"][href$="/view/"]', 'View');
- test_text ('#text .hidden-text-actions:eq('+i+') a:eq(1)[href^="/text/"][href$="/edit/"]', 'Edit');
- test_text ('#text .hidden-text-actions:eq('+i+') a:eq(2)[href$="#"][id*=delete]', 'Delete');
- test_text ('#text .hidden-text-actions:eq('+i+') a:eq(3)[href^="/text/"][href$="/share/"]', 'Users');
- test_text ('#text .hidden-text-actions:eq('+i+') a:eq(4)[href^="/text/"][href$="/settings/"]', 'Settings');
- test_text ('#text a[title="Edit user"][href^="/user/"][href$="/edit/"]:eq('+i+')', 'admin');
- test_text ('#text table[summary="text list"] tr:eq('+(i+1)+') td:eq(4)', '0');
- }
-
- test_page_loading ('/text/', 'Texts\n - '+c['#id_workspace_name']);
- test_count ('#texts_form :input', (t.text_nb < 10 ? t.text_nb : 10) + 3);
- test_match ('#paginator', new RegExp ('\\s1-10 of '+t.text_nb+'\\s','m'));
- test_text ('#paginator a:eq(0)[href="?page=2"]', '»');
- test_text ('#paginator a:eq(1)[href="?paginate=0"]', 'all');
- test_click ('#paginator a:eq(0)[href="?page=2"]');
- test_match ('#paginator', new RegExp ('\\s11-12 of '+t.text_nb+'\\s','m'));
- test_count ('#texts_form :input', t.text_nb % 10 + 3);
- test_click ('#paginator a:eq(0)[href="?page=1"]');
- test_match ('#paginator', new RegExp ('\\s1-10 of '+t.text_nb+'\\s','m'));
- test_count ('#texts_form :input', (t.text_nb < 10 ? t.text_nb : 10) + 3);
- test_click ('#paginator a:eq(1)[href="?paginate=0&page=1"]');
- test_match ('#paginator', /\s\(paginate\)\s/m);
- test_count ('#texts_form :input', t.text_nb + 3);
- test_click ('#paginator a:eq(0)[href="?paginate=&page=1"]');
- test_count ('#texts_form :input', (t.text_nb < 10 ? t.text_nb : 10) + 3);
- test_match ('#paginator', new RegExp ('\\s1-10 of '+t.text_nb+'\\s','m'));
-
- // TOTEST : Bulk Actions -> Apply does enable
- // TOTEST : unitary delete
- test_page_loading ('/text/', 'Texts\n - '+c['#id_workspace_name']);
- test_text ('select#bulk_actions option:eq(0)[selected][value="-1"]', 'Bulk Actions', non_visible);
- test_text ('select#bulk_actions option:eq(1)[value="delete"]', 'Delete', non_visible);
- test_val ('form#texts_form input#apply[type=button][disabled]', 'Apply');
- test_count ('table.large_table:eq(1) th', 6);
- test_val ('table.large_table:eq(1) th:eq(0) input#all_check[type="checkbox"]', 'on');
- test_text ('table.large_table:eq(1) th:eq(1) a[href="?order=title"]', 'Text');
- test_text ('table.large_table:eq(1) th:eq(2)', 'Author');
- test_text ('table.large_table:eq(1) th:eq(3) a[href="?order=-modified"]', 'Modified');
- test_text ('table.large_table:eq(1) th:eq(4)', '# comments');
- test_text ('table.large_table:eq(1) th:eq(5)', 'Last week activity');
- test_unlogged_footer ();
- });
-
- suite ('edit profile page conformity', function () {
- test_page_loading ('/profile/', 'Your profile [(]'+w.USER_ADMIN+'[)]\n - '+c['#id_workspace_name']);
- test_logged_header (w.USER_ADMIN, no_tagline);
- test_count ('#content ul.sub_list:eq(0) a', 1);
- test_text ('#content ul.sub_list:eq(0) a:eq(0)[href="/profile-pw/"]', 'Password');
- test_count ('form#profile[action="."]:eq(0) :input', 5);
- test_field ('profile', 'id_email', 'text', 0, 'E-mail address', true);
- test_field ('profile', 'id_first_name','text', 1, 'First name');
- test_field ('profile', 'id_last_name', 'text', 2, 'Last name');
- test_field ('profile', 'id_tags', 'text', 3, 'Tags');
- test_val ('#profile :input:eq(4)[type=submit]', 'Save');
- test_unlogged_footer ();
- });
-
- suite ('edit password page conformity', function () {
- test_page_loading ('/profile-pw/', 'Your profile [(]'+w.USER_ADMIN+'[)]\n - '+c['#id_workspace_name']);
- test_logged_header (w.USER_ADMIN, no_tagline);
- test_count ('#content ul.sub_list:eq(0) a', 1);
- test_text ('#content ul.sub_list:eq(0) a:eq(0)[href="/profile/"]', 'Profile');
- test_count ('form#profile[action="."]:eq(0) :input', 4);
- test_field ('profile', 'id_old_password', 'password', 0, 'Old password', true);
- test_field ('profile', 'id_new_password1', 'password', 1, 'New password', true);
- test_field ('profile', 'id_new_password2', 'password', 2, 'New password confirmation', true);
- test_val ('#profile :input:eq(3)[type=submit]', 'Save');
- test_unlogged_footer ();
- });
-
- suite ('people list page conformity', function () {
- test_page_loading ('/user/', 'People\' list\n - '+c['#id_workspace_name']);
- test_logged_header (w.USER_ADMIN);
- test_default_tabs (t.text_nb, t.user_nb);
- test_count ('#user ul.sub_list:eq(0) a', 2);
- test_text ('#user ul.sub_list:eq(0) a:eq(0)[href="/user/add/"]', 'Add a new user');
- test_text ('#user ul.sub_list:eq(0) a:eq(1)[href="/user/mass-add/"]', 'Add users in bulk');
- // TOTEST : filter by tag -> commentator user should be tagged commentator (to change in fixture)
- test_count ('form#filter_form[action="."] :input', 1);
- test_text ('#filter_form a[href="?display=1"]', 'Display suspended users');
- test_text ('select#tag_selected option:eq(0)[selected][value="0"]', '- All -', non_visible);
- // TOTEST : pagination
- // TOTEST : Bulk Actions -> Apply does enable
- // TOTEST display suspended users
- test_text ('select#bulk_actions option:eq(0)[selected][value="-1"]', '- Bulk Actions -', non_visible);
- test_text ('select#bulk_actions option:eq(1)[value="disable"]', 'Suspend access', non_visible);
- test_text ('select#bulk_actions option:eq(2)[value="enable"]', 'Enable access', non_visible);
- test_text ('select#bulk_actions option:eq(3)[value="role_1"]', 'Change role to Manager', non_visible);
- test_text ('select#bulk_actions option:eq(4)[value="role_2"]', 'Change role to Editor', non_visible);
- test_text ('select#bulk_actions option:eq(5)[value="role_3"]', 'Change role to Moderator', non_visible);
- test_text ('select#bulk_actions option:eq(6)[value="role_4"]', 'Change role to Commentator', non_visible);
- test_text ('select#bulk_actions option:eq(7)[value="role_5"]', 'Change role to Observer', non_visible);
- test_val ('form#user_form input#apply[type=button][disabled]', 'Apply');
- test_count ('table.large_table:eq(1) th', 6);
- test_val ('table.large_table:eq(1) th:eq(0) input#all_check[type="checkbox"]', 'on');
- test_text ('table.large_table:eq(1) th:eq(1) a[href="?order=user__username"]', 'User');
- test_text ('table.large_table:eq(1) th:eq(2) a[href="?order=user__email"]', 'Email');
- test_text ('table.large_table:eq(1) th:eq(3) a[href="?order=-user__date_joined"]', 'Date joined');
- test_text ('table.large_table:eq(1) th:eq(4) a[href="?order=role__name"]', 'Role');
- test_text ('table.large_table:eq(1) th:eq(5)', 'Last week activity');
- test_text ('table.large_table:eq(1) tr:last a[href="/user/-/edit/"]', 'Anonymous users');
- test_text ('table.large_table:eq(1) a.main_object_title[href="/profile/"]', w.USER_ADMIN);
- test_text ('table.large_table:eq(1) div.hidden-user-actions a[href="/profile/"]', 'Your profile');
- // TOTEST roles of users
- test_unlogged_footer ();
- });
-
- suite ('check user number', function () {
- test_page_loading ('/user/?display=1', 'People\' list\n - '+c['#id_workspace_name']);
- test_count ('#user_form :input', 6 + (t.user_nb % 10) * 2);
- test_match ('#paginator', new RegExp ('\\s\\d+-\\d+ of '+t.user_nb+'\\s','m'));
- });
-
- suite ('add a user page conformity', function () {
- test_page_loading ('/user/add/', 'Add a new user\n - '+c['#id_workspace_name']);
- test_logged_header (w.USER_ADMIN);
- test_default_tabs (t.text_nb, t.user_nb);
- test_count ('#user ul.sub_list:eq(0) a', 2);
- test_text ('#user ul.sub_list:eq(0) a:eq(0)[href="/user/"]', 'Users\' list');
- test_text ('#user ul.sub_list:eq(0) a:eq(1)[href="/user/mass-add/"]', 'Add users in bulk');
- test_count ('#user form[action="."]:eq(0) :input', 8);
- test_field ('user', 'id_email', 'text', 0, 'E-mail address', true);
- test_field ('user', 'id_first_name', 'text', 1, 'First name');
- test_field ('user', 'id_last_name', 'text', 2, 'Last name');
- test_field ('user', 'id_tags', 'text', 3, 'Tags');
- test_field ('user', 'id_role', 'select', 4, 'Workspace level role');
- test_field ('user', 'id_note', 'textarea', 5, 'Note');
- test_count ('select#id_role option', 6);
- test_text ('select#id_role option:eq(0)[value][selected]', '---------', non_visible);
- test_text ('select#id_role option:eq(1)[value="1"]', 'Manager', non_visible);
- test_text ('select#id_role option:eq(2)[value="2"]', 'Editor', non_visible);
- test_text ('select#id_role option:eq(3)[value="3"]', 'Moderator', non_visible);
- test_text ('select#id_role option:eq(4)[value="4"]', 'Commentator', non_visible);
- test_text ('select#id_role option:eq(5)[value="5"]', 'Observer', non_visible);
- test_val ('#user :input:eq(6)[type=submit]', 'Add user');
- test_val ('#user :input:eq(7)#cancel_button[type=button]', 'Cancel');
- test_unlogged_footer ();
- test_submit('#user input[type="submit"]');
- test_count ('div.help_text span.error-text', 1);
- test_field ('user div.error', 'id_email', 'text', 0, 'E-mail address', true);
- test_match ('#user div.help_text:eq(0) span.error-text:eq(0)', /This field is required/m);
- // X TOTEST add user (pending)
- });
-
- suite ('add-users-in-bulk page conformity', function () {
- test_page_loading ('/user/mass-add/', 'Add users in bulk\n - '+c['#id_workspace_name']);
- test_logged_header (w.USER_ADMIN);
- test_default_tabs (t.text_nb, t.user_nb);
- test_count ('#user ul.sub_list:eq(0) a', 2);
- test_text ('#user ul.sub_list:eq(0) a:eq(0)[href="/user/"]', 'Users\' list');
- test_text ('#user ul.sub_list:eq(0) a:eq(1)[href="/user/add/"]', 'Add a new user');
- test_count ('#user form[action="."]:eq(0) :input', 6);
- test_field ('user', 'id_email', 'textarea', 0, 'Emails', true);
- test_field ('user', 'id_tags', 'text', 1, 'Tags');
- test_field ('user', 'id_role', 'select', 2, 'Workspace level role');
- test_field ('user', 'id_note', 'textarea', 3, 'Note');
- test_count ('select#id_role option', 6);
- test_text ('select#id_role option:eq(0)[value][selected]', '---------', non_visible);
- test_text ('select#id_role option:eq(1)[value="1"]', 'Manager', non_visible);
- test_text ('select#id_role option:eq(2)[value="2"]', 'Editor', non_visible);
- test_text ('select#id_role option:eq(3)[value="3"]', 'Moderator', non_visible);
- test_text ('select#id_role option:eq(4)[value="4"]', 'Commentator', non_visible);
- test_text ('select#id_role option:eq(5)[value="5"]', 'Observer', non_visible);
- test_val ('#user :input:eq(4)[type=submit]', 'Add users');
- test_val ('#user :input:eq(5)#cancel_button[type=button]', 'Cancel');
- // X TOTEST add users (pending) -> can't be deleted
- test_unlogged_footer ();
- test_submit('#user input[type="submit"]');
- test_count ('div.help_text span.error-text', 1);
- test_field ('user div.error', 'id_email', 'textarea', 0, 'Emails', true);
- test_match ('#user div.help_text:eq(0) span.error-text:eq(0)', /This field is required/m);
- });
-
- suite ('settings page conformity', function () {
- test_page_loading ('/settings/', 'Settings - '+c['#id_workspace_name']);
- test_logged_header (w.USER_ADMIN);
- test_default_tabs (t.text_nb, t.user_nb);
- test_count ('#settings ul.sub_list:eq(0) a', 1);
- test_text ('#settings ul.sub_list:eq(0) a:eq(0)[href="/settings/design/"]', 'Appearance');
- test_count ('#settings form[action="."]:eq(0) :input', 12);
- test_field ('settings', 'id_workspace_name', 'text', 0, 'Workspace name');
- test_field ('settings', 'id_workspace_tagline', 'text', 1, 'Workspace tagline');
- test_field ('settings', 'id_workspace_registration', 'checkbox', 2, 'Workspace registration');
- test_field ('settings', 'id_workspace_registration_moderation', 'checkbox', 3, 'Workspace registration moderation');
- test_field ('settings', 'id_workspace_role_model', 'select', 4, 'Role model');
- test_text ('select#id_workspace_role_model option:eq(0)[selected][value="generic"]', 'Generic', non_visible);
- test_text ('select#id_workspace_role_model option:eq(1)[value="teacher"]', 'Class (education)', non_visible);
- test_field ('settings', 'id_workspace_category_1', 'text', 5, 'Label for the first category of comments');
- test_field ('settings', 'id_workspace_category_2', 'text', 6, 'Label for the second category of comments');
- test_field ('settings', 'id_workspace_category_3', 'text', 7, 'Label for the third category of comments');
- test_field ('settings', 'id_workspace_category_4', 'text', 8, 'Label for the fourth category of comments');
- test_field ('settings', 'id_workspace_category_5', 'text', 9, 'Label for the fifth category of comments');
- test_val ('#settings :input:eq(10)[type=submit]', 'Save');
- test_val ('#settings :input:eq(11)#cancel_button[type=button]', 'Cancel');
- // TOTEST Workspace registration feature (with newly accessible page)
- test_unlogged_footer ();
- });
-
- suite ('settings design page conformity', function () {
- test_page_loading ('/settings/design/', 'Settings - '+c['#id_workspace_name']);
- test_logged_header (w.USER_ADMIN);
- test_default_tabs (t.text_nb, t.user_nb);
- test_count ('#settings ul.sub_list:eq(0) a', 1);
- test_text ('#settings ul.sub_list:eq(0) a:eq(0)[href="/settings/"]', 'General');
- test_count ('#settings form[action="."]:eq(0) :input', 7);
- test_field ('settings', 'id_workspace_logo_file', 'file', 0, 'Workspace logo');
- test_field ('settings', 'id_custom_css', 'textarea', 1, 'Custom CSS rules');
- test_field ('settings', 'id_custom_font', 'text', 2, 'Custom font');
- test_field ('settings', 'id_custom_titles_font', 'text', 3, 'Custom font for titles');
- test_val ('#settings :input:eq(4)[type=submit]', 'Save');
- test_val ('#settings :input:eq(5)#cancel_button[type=button]', 'Cancel');
- test_val ('#settings :input:eq(6)#delete_logo_button[type=submit]', 'Delete logo');
- test_unlogged_footer ();
- });
-
- suite ('followup page conformity', function () {
- test_page_loading ('/followup/', 'Followup\n - '+c['#id_workspace_name']);
- test_logged_header (w.USER_ADMIN);
- test_default_tabs (t.text_nb, t.user_nb);
- test_text ('#followup a:eq(0)[href="/help/#public_private_feed"]', '?');
- test_match ('#followup a:eq(1)[href$="/feed/"]', new RegExp (w.WORKSPACE_URL+'feed/', 'm'));
- test_text ('#followup a:eq(2)[href="/help/#public_private_feed"]', '?');
- test_count ('form#followup_form[action="."] :input', 3);
- test_val ('form#followup_form input[type=submit]', '(Activate private feed|Reset private feed url)');
- test_val ('form#followup_form input#workspace_notify_check[type=checkbox]', 'on');
- test_val ('form#followup_form input#own_notify_check[type=checkbox]', 'on');
-
- // X TOTEST qu'une fois cliqué, le bouton a le nvo label, et qu'une adresse est disponible
- // X TOTEST que si on reclique l'adresse est changée
-
- test_unlogged_footer ();
- });
-
-});
-
-function test_default_tabs (text_nb, user_nb) {
- test_count ('#main-tabs a', 5);
- test_text ('#main-tabs li:nth-of-type(1) a[href="/"]', 'Dashboard');
- test_match ('#main-tabs li:nth-of-type(2) a[href="/text/"]', /^Texts \(\d+\) $/);
- test_match ('#main-tabs li:nth-of-type(3) a[href="/user/"]', /^People \(\d+\)$/);
- test_text ('#main-tabs li:nth-of-type(4) a[href="/settings/"]', 'Settings');
- test_text ('#main-tabs li:nth-of-type(5) a[href="/followup/"]', 'Followup');
- test_match ('#main-tabs a[href="/text/"]', new RegExp ('^Texts\\s*\\('+text_nb+'\\)\\s*$'));
- test_match ('#main-tabs a[href="/user/"]', new RegExp ('^People\\s*\\('+user_nb+'\\)\\s*$'));
-}
-
-function test_logged_header (username, is_tagline) {
- is_tagline = typeof is_tagline == 'undefined' ? true : is_tagline;
-
- test_text ('#header_controls b', username)
- test_count ('#header_controls a', 6);
- test_text ('#header_controls a:nth-of-type(1)[href="/"]', 'Home');
- test_text ('#header_controls a:nth-of-type(2)[href="/create/content/"]', 'Create a text');
- test_text ('#header_controls a:nth-of-type(3)[href="/create/upload/"]', 'Upload a text');
- test_text ('#header_controls a:nth-of-type(4)[href="/create/import/"]', 'Import a co-mented text');
- test_text ('#header_controls a:nth-of-type(5)[href="/profile/"]', 'Profile');
- test_text ('#header_controls a:nth-of-type(6)[href="/logout/"]', 'Logout');
- test_text ('#content h1.main_title a[href="/"]', c['#id_workspace_name']);
-
- if (is_tagline) {
- test_match ('#content h1.main_title + div', new RegExp (c['#id_workspace_tagline'], 'm'));
- }
-}
-
-function test_fill_settings (s) {
- test_fill_field ('#id_workspace_name', s);
- test_fill_field ('#id_workspace_tagline', s);
- test_fill_field ('#id_workspace_registration', s);
- test_fill_field ('#id_workspace_registration_moderation', s);
- test_fill_field ('#id_workspace_role_model', s);
- test_fill_field ('#id_workspace_category_1', s);
- test_fill_field ('#id_workspace_category_2', s);
- test_fill_field ('#id_workspace_category_3', s);
- test_fill_field ('#id_workspace_category_4', s);
- test_fill_field ('#id_workspace_category_5', s);
-}
-
-function test_fill_design (s) {
- test_fill_field ('#id_custom_css', s);
- test_fill_field ('#id_custom_font', s);
- test_fill_field ('#id_custom_titles_font', s);
-}
-
-function create_text (i) {
- test_page_loading ('/create/content/', 'Create a text - '+c['#id_workspace_name']);
- test ('test creation', dsl(function () {
- dropdownlist ('#id_format').option (c['texts'][i]['#id_format']);
- }));
-
- test_fill_field ('#id_title', c['texts'][i]);
- test ('fill content', dsl(function (){
- elt ('#id_content').val (c['texts'][i]['#id_content']);
- }));
-
- test_fill_field ('#id_tags', c['texts'][i]);
- test_submit ('#save_button');
- t.text_nb++;
-}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/010_comt-unlogged-prelude.js Sat Apr 19 17:00:40 2014 +0200
@@ -0,0 +1,110 @@
+
+// " Vim settings
+// set tabstop=4 " number of spaces in a tab
+// set softtabstop=4 " as above
+// set shiftwidth=4 " as above
+
+suite ('comt unlogged prelude', function () {
+
+ this.timeout(20000);
+
+ suite ('contact page conformity', function () {
+ test_page_loading ('/contact/', 'Contact');
+ test_comt_unlogged_header ();
+ test_exist ('form#profile[action="."]'); // the form exists
+ test_count ('form#profile :input', 7); // it has no more than 5 labels (may be no more fields)
+ test_field ('profile', 'id_name', 'text', 0, 'Your name', true); // the field id_name is…
+ test_field ('profile', 'id_email', 'text', 1, 'Your email address', true);
+ test_field ('profile', 'id_title', 'text', 2, 'Subject of the message', true);
+ test_field ('profile', 'id_body', 'textarea', 3, 'Body of the message', true);
+ test_field ('profile', 'id_copy', 'checkbox', 4, 'Send me a copy of the email', false);
+ test_val ('#profile input[type=submit]','Send'); // test that a the .val() of the element is
+ test_val ('input#cancel_button[type=button]', 'Cancel');
+ test_comt_unlogged_footer ();
+ test ('to check that toBeDefined test still works', dsl(function () {
+ expect (elt ('#header_controls a[href="/xxx/"]').val ()).not ().toBeDefined ();
+ }));
+ test ('get back to / to avoid bugging next page load', dsl(function () { browser.navigateTo ('/'); }));
+ });
+
+ suite ('help page conformity', function () {
+ test_page_loading ('/help/', 'Help');
+ test_comt_unlogged_header ();
+ test_comt_unlogged_footer ();
+ });
+
+ suite ('can change lang', function () {
+ test ('get back to / to avoid bugging next page load', dsl(function () { browser.navigateTo ('/'); }));
+ test_comt_i18n ('fr', 'Aide');
+ test_comt_i18n ('en', 'Help');
+ test_comt_i18n ('es', 'Ayuda');
+ test_comt_i18n ('it', 'Aiuto');
+ test_comt_i18n ('de', 'Hilfe');
+ test_comt_i18n ('pt_BR', 'Ajuda');
+ test_comt_i18n ('nb', 'Hjelp');
+ test_comt_i18n ('bg', 'Помощ');
+ test_comt_i18n ('en', 'Help');
+ });
+
+ suite ('contact page mandatory field test', function () {
+ test_page_loading ('/contact/', 'Contact');
+ test_click ('#profile input[type="submit"]', C.WAIT_PAGE_LOAD);
+ test_count ('div.help_text span.error-text', 4);
+ test_field ('profile div.error', 'id_name', 'text', 0, 'Your name', true); // the field id_name is…
+ test_field ('profile div.error', 'id_email', 'text', 1, 'Your email address', true);
+ test_field ('profile div.error', 'id_title', 'text', 2, 'Subject of the message', true);
+ test_field ('profile div.error', 'id_body', 'textarea', 3, 'Body of the message', true);
+ test_field ('profile', 'id_copy', 'checkbox', 4, 'Send me a copy of the email', false);
+ });
+
+ suite ('reset password page conformity', function () {
+ test_page_loading ('/password_reset/', 'Reset my password');
+ test_comt_unlogged_header ();
+ test_count ('form#profile :input', 3);
+ test_field ('profile', 'id_email', 'text', 1, 'E-mail', true);
+ test_val ('#profile input[type=submit]', 'Reset my password');
+ test_comt_unlogged_footer ();
+ test_click ('#profile input[type="submit"]', C.WAIT_PAGE_LOAD);
+ test_count ('div.help_text span.error-text', 1);
+ test_field ('profile div.error', 'id_email', 'text', 0, 'E-mail', true);
+ });
+
+ suite ('login page conformity', function () {
+ test_page_loading ('/', 'Home');
+ test_comt_unlogged_header ();
+ test_count ('form#login[action="/login/"] :input', 3);
+ test_field ('login', 'id_username', 'text', 0, 'Username', true);
+ test_field ('login', 'id_password', 'password', 1, 'Password', true);
+ test_val ('form#login input[type=submit]', 'Login');
+ test_text ('form#login a[href="/password_reset/"]', 'Forgot password?');
+ test_comt_unlogged_footer ();
+ test ('get back to / to avoid bugging next page load', dsl(function () {
+ browser.navigateTo ('/');
+ }));
+ test_page_loading ('/login/', 'Login');
+ test_click ('#login input[type="submit"]', C.WAIT_PAGE_LOAD);
+ test_field ('login div.error', 'id_username', 'text', 0, 'Username', true);
+ test_field ('login div.error', 'id_password', 'password', 1, 'Password', true);
+ });
+});
+
+function test_comt_unlogged_header () {
+ test_count ('#header_controls a', 2);
+ test_text ('#header_controls a[href="/"]', 'Home');
+ test_text ('#header_controls a[href="/login/"]', 'Login');
+}
+
+function test_comt_unlogged_footer (url) {
+ test_count ('#footer a', 10);
+ test_text ('#footer a:nth-of-type(1)[href="/contact/"]', 'Contact');
+ test_match ('#footer #comentlink[href="http://www.co-ment.com"]', /Powered by/m);
+ test_text ('#footer a:nth-of-type(3)[href="/help/"]', 'Help');
+ test_text ('#footer a:nth-of-type(4)[href="/i18n/setlang/fr/"]', 'Français');
+ test_text ('#footer a:nth-of-type(5)[href="/i18n/setlang/es/"]', 'Español');
+ test_text ('#footer a:nth-of-type(6)[href="/i18n/setlang/it/"]', 'Italiano');
+ test_text ('#footer a:nth-of-type(7)[href="/i18n/setlang/de/"]', 'Deutsch');
+ test_text ('#footer a:nth-of-type(8)[href="/i18n/setlang/pt_BR/"]', 'Português Brasileiro');
+ test_text ('#footer a:nth-of-type(9)[href="/i18n/setlang/nb/"]', 'Norsk');
+ test_text ('#footer a:nth-of-type(10)[href="/i18n/setlang/bg/"]', 'Български');
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/011_comt-logged-admin.js Sat Apr 19 17:00:40 2014 +0200
@@ -0,0 +1,316 @@
+
+// " Vim settings
+// set tabstop=4 " number of spaces in a tab
+// set softtabstop=4 " as above
+// set shiftwidth=4 " as above
+
+suite ('comt logged admin', function () {
+
+ this.timeout(20000);
+
+ suite ('logs as an admin', function () {
+ test_comt_login (C.W.USER_ADMIN, C.W.PASS_ADMIN);
+ });
+
+ suite ('setting settings to test-values', function () {
+ test_page_loading ('/settings/', 'Settings');
+ test_comt_fill_settings (C);
+ test_val ('#id_workspace_name', C['#id_workspace_name']);
+ test_click ('#settings input[type="submit"]', C.WAIT_PAGE_LOAD);
+ test_page_loading ('/settings/', 'Settings');
+ test_text ('#content h1.main_title a[href="/"]', C['#id_workspace_name']);
+ test_page_loading ('/settings/design/', 'Settings');
+ test_comt_fill_design (C);
+ test_click ('#settings input[type="submit"]', C.WAIT_PAGE_LOAD);
+ });
+
+ suite ('admin dashboard page conformity', function () {
+ test_page_loading ('/', 'Dashboard\n - '+C['#id_workspace_name']);
+ test_comt_logged_header (C.W.USER_ADMIN);
+ test_comt_default_tabs (test_comt.text_nb, test_comt.user_nb);
+ test_count ('table.dash_table', 5);
+ test_text ('table.dash_table th:eq(0)', 'Actions');
+ test_match ('table.dash_table:eq(0) a:eq(0)[href="/create/content/"]', /\sCreate a text/);
+ test_text ('table.dash_table:eq(0) a:eq(1).tip[href="#"]', '\xa0');
+ test_match ('table.dash_table:eq(0) a:eq(2)[href="/create/upload/"]', /\sUpload a text/);
+ test_text ('table.dash_table:eq(0) a:eq(3).tip[href="#"]', '\xa0');
+ test_match ('table.dash_table:eq(0) a:eq(4)[href="/create/import/"]', /\sImport a co-mented text/);
+ test_text ('table.dash_table:eq(0) a:eq(5).tip[href="#"]', '\xa0');
+ test_match ('table.dash_table:eq(0) a:eq(6)[href="/user/add/"]', /\sInvite user/);
+ test_match ('table.dash_table:eq(0) a:eq(7)[href="/profile/"]', /\sEdit your profile/);
+ test_match ('table.dash_table:eq(0) a:eq(8)[href="/text/"]', /\sView text list/);
+ test_match ('table.dash_table:eq(0) a:eq(9)[href="/settings/"]', /\sConfigure workspace/);
+ test_text ('table.dash_table th:eq(1)', 'Recent texts (all)');
+ test_text ('table.dash_table:eq(1) a:eq(0)[href="/text/"]', 'all');
+ test_text ('table.dash_table th:eq(2)', 'Recent comments');
+ test_match ('table.dash_table th:eq(3)', /^Workspace activity\n\s+\(month\/week\/24 hours\)$/m);
+ test_text ('table.dash_table:eq(3) a:eq(0)[href="?span=month"]', 'month');
+ test_text ('table.dash_table:eq(3) a:eq(1)[href="?span=day"]', '24 hours');
+ test_text ('table.dash_table th:eq(4) span.em', 'Activities');
+ test_comt_unlogged_footer ();
+ });
+
+ suite ('create a text page conformity', function () {
+ test_page_loading ('/create/content/', 'Create a text - '+C['#id_workspace_name']);
+ test_comt_logged_header (C.W.USER_ADMIN);
+ test_comt_default_tabs (test_comt.text_nb, test_comt.user_nb);
+ test_count ('#text ul.sub_list:eq(0) a', 3);
+ test_text ('#text ul.sub_list:eq(0) a:eq(0)[href="/text/"]', 'Text list');
+ test_text ('#text ul.sub_list:eq(0) a:eq(1)[href="/create/upload/"]', 'Upload a text');
+ test_text ('#text ul.sub_list:eq(0) a:eq(2)[href="/create/import/"]', 'Import a co-mented text');
+ test_count ('#text form[action="."]:eq(0) :input', 6);
+ test_field ('text', 'id_title', 'text', 0, 'Title', true);
+ test_field ('text', 'id_format', 'select', 1, 'Format', true);
+ test_field ('text', 'id_content', 'textarea', 2, 'Content', true);
+ test_field ('text', 'id_tags', 'text', 3, 'Tags');
+ test_val ('#text :input:eq(4)[type=submit]', 'Save');
+ test_val ('#text :input:eq(5)#cancel_button[type=button]', 'Cancel');
+ test_count ('select#id_format option', 3);
+ test_text ('select#id_format option:eq(0)[value="markdown"][selected]', 'markdown', C.HIDDEN);
+ test_text ('select#id_format option:eq(1)[value="rst"]', 'rst', C.HIDDEN);
+ test_text ('select#id_format option:eq(2)[value="html"]', 'html', C.HIDDEN);
+ test_count ('.markdown #markItUpId_content li', 20); // How many buttons in the WYSIWYG editor toolbar ?
+ test_comt_unlogged_footer ();
+ test_click ('#text input[type="submit"]', C.WAIT_PAGE_LOAD);
+ test_count ('div.help_text span.error-text', 2);
+ test_field ('text div.error', 'id_title', 'text', 0, 'Title', true);
+ test_field ('text div.error', 'id_content', 'textarea', 1, 'Content', true);
+ });
+
+ suite ('upload text page conformity', function () {
+ test_page_loading ('/create/upload/', 'Upload a text - '+C['#id_workspace_name']);
+ test_comt_logged_header (C.W.USER_ADMIN);
+ test_comt_default_tabs (test_comt.text_nb, test_comt.user_nb);
+ test_count ('#text ul.sub_list:eq(0) a', 3);
+ test_text ('#text ul.sub_list:eq(0) a:eq(0)[href="/text/"]', 'Text list');
+ test_text ('#text ul.sub_list:eq(0) a:eq(1)[href="/create/content/"]', 'Create a text');
+ test_text ('#text ul.sub_list:eq(0) a:eq(2)[href="/create/import/"]', 'Import a co-mented text');
+ test_count ('#text form[action="."]:eq(0) :input', 6);
+ test_field ('text', 'id_title', 'text', 0, 'Title');
+ test_field ('text', 'id_format', 'select', 1, 'Format', true);
+ test_field ('text', 'id_tags', 'text', 2, 'Tags');
+ test_field ('text', 'id_file', 'file', 3, 'Upload file');
+ test_val ('#text :input:eq(4)[type=submit]', 'Save');
+ test_val ('#text :input:eq(5)#cancel_button[type=button]', 'Cancel');
+ test_count ('select#id_format option', 3);
+ test_text ('select#id_format option:eq(0)[value="markdown"][selected]', 'markdown', C.HIDDEN);
+ test_text ('select#id_format option:eq(1)[value="rst"]', 'rst', C.HIDDEN);
+ test_text ('select#id_format option:eq(2)[value="html"]', 'html', C.HIDDEN);
+ test_comt_unlogged_footer ();
+ test_click ('#text input[type="submit"]', C.WAIT_PAGE_LOAD);
+ test_count ('div.help_text span.error-text', 1);
+ test_field ('text div.error', 'id_file', 'file', 0, 'Upload file');
+ test_match ('#text div.help_text:eq(3) span.error-text:eq(0)', /You should specify a file to upload/m);
+ });
+
+ suite ('import a co-mented text page conformity', function () {
+ test_page_loading ('/create/import/', 'Import a co-mented text - '+C['#id_workspace_name']);
+ test_comt_logged_header (C.W.USER_ADMIN);
+ test_comt_default_tabs (test_comt.text_nb, test_comt.user_nb);
+ test_count ('#text ul.sub_list:eq(0) a', 3);
+ test_text ('#text ul.sub_list:eq(0) a:eq(0)[href="/text/"]', 'Text list');
+ test_text ('#text ul.sub_list:eq(0) a:eq(1)[href="/create/content/"]', 'Create a text');
+ test_text ('#text ul.sub_list:eq(0) a:eq(2)[href="/create/upload/"]', 'Upload a text');
+ test_count ('#text form[action="."]:eq(0) :input', 3);
+ test_field ('text', 'id_file', 'file', 0, 'Upload XML file', true);
+ test_val ('#text :input:eq(1)[type=submit]', 'Save');
+ test_val ('#text :input:eq(2)#cancel_button[type=button]', 'Cancel');
+ test_comt_unlogged_footer ();
+ test_click ('#text input[type="submit"]', C.WAIT_PAGE_LOAD);
+ test_count ('div.help_text span.error-text', 1);
+ test_field ('text div.error', 'id_file', 'file', 0, 'Upload XML file', true);
+ test_match ('#text div.help_text:eq(0) span.error-text:eq(0)', /You should specify a file to upload/m);
+ });
+
+ suite ('edit profile page conformity', function () {
+ test_page_loading ('/profile/', 'Your profile \\('+C.W.USER_ADMIN+'\\)\n - '+C['#id_workspace_name']);
+ test_comt_logged_header (C.W.USER_ADMIN, C.NO_TAGLINE);
+ test_count ('#content ul.sub_list:eq(0) a', 1);
+ test_text ('#content ul.sub_list:eq(0) a:eq(0)[href="/profile-pw/"]', 'Password');
+ test_count ('form#profile[action="."]:eq(0) :input', 5);
+ test_field ('profile', 'id_email', 'text', 0, 'E-mail address', true);
+ test_field ('profile', 'id_first_name','text', 1, 'First name');
+ test_field ('profile', 'id_last_name', 'text', 2, 'Last name');
+ test_field ('profile', 'id_tags', 'text', 3, 'Tags');
+ test_val ('#profile :input:eq(4)[type=submit]', 'Save');
+ test_comt_unlogged_footer ();
+ });
+
+ suite ('edit password page conformity', function () {
+ test_page_loading ('/profile-pw/', 'Your profile [(]'+C.W.USER_ADMIN+'[)]\n - '+C['#id_workspace_name']);
+ test_comt_logged_header (C.W.USER_ADMIN, C.NO_TAGLINE);
+ test_count ('#content ul.sub_list:eq(0) a', 1);
+ test_text ('#content ul.sub_list:eq(0) a:eq(0)[href="/profile/"]', 'Profile');
+ test_count ('form#profile[action="."]:eq(0) :input', 4);
+ test_field ('profile', 'id_old_password', 'password', 0, 'Old password', true);
+ test_field ('profile', 'id_new_password1', 'password', 1, 'New password', true);
+ test_field ('profile', 'id_new_password2', 'password', 2, 'New password confirmation', true);
+ test_val ('#profile :input:eq(3)[type=submit]', 'Save');
+ test_comt_unlogged_footer ();
+ });
+
+ suite ('people list page conformity', function () {
+ test_page_loading ('/user/', 'People\' list\n - '+C['#id_workspace_name']);
+ test_comt_logged_header (C.W.USER_ADMIN);
+ test_comt_default_tabs (test_comt.text_nb, test_comt.user_nb);
+ test_count ('#user ul.sub_list:eq(0) a', 2);
+ test_text ('#user ul.sub_list:eq(0) a:eq(0)[href="/user/add/"]', 'Add a new user');
+ test_text ('#user ul.sub_list:eq(0) a:eq(1)[href="/user/mass-add/"]', 'Add users in bulk');
+ // TOTEST : filter by tag -> commentator user should be tagged commentator (to change in fixture)
+ test_count ('form#filter_form[action="."] :input', 1);
+ test_text ('#filter_form a[href="?display=1"]', 'Display suspended users');
+ test_text ('select#tag_selected option:eq(0)[selected][value="0"]', '- All -', C.HIDDEN);
+ // TOTEST : pagination
+ // TOTEST : Bulk Actions -> Apply does enable
+ // TOTEST display suspended users
+ test_text ('select#bulk_actions option:eq(0)[selected][value="-1"]', '- Bulk Actions -', C.HIDDEN);
+ test_text ('select#bulk_actions option:eq(1)[value="disable"]', 'Suspend access', C.HIDDEN);
+ test_text ('select#bulk_actions option:eq(2)[value="enable"]', 'Enable access', C.HIDDEN);
+ test_text ('select#bulk_actions option:eq(3)[value="role_1"]', 'Change role to Manager', C.HIDDEN);
+ test_text ('select#bulk_actions option:eq(4)[value="role_2"]', 'Change role to Editor', C.HIDDEN);
+ test_text ('select#bulk_actions option:eq(5)[value="role_3"]', 'Change role to Moderator', C.HIDDEN);
+ test_text ('select#bulk_actions option:eq(6)[value="role_4"]', 'Change role to Commentator', C.HIDDEN);
+ test_text ('select#bulk_actions option:eq(7)[value="role_5"]', 'Change role to Observer', C.HIDDEN);
+ test_val ('form#user_form input#apply[type=button][disabled]', 'Apply');
+ test_count ('table.large_table:eq(1) th', 6);
+ test_val ('table.large_table:eq(1) th:eq(0) input#all_check[type="checkbox"]', 'on');
+ test_text ('table.large_table:eq(1) th:eq(1) a[href="?order=user__username"]', 'User');
+ test_text ('table.large_table:eq(1) th:eq(2) a[href="?order=user__email"]', 'Email');
+ test_text ('table.large_table:eq(1) th:eq(3) a[href="?order=-user__date_joined"]', 'Date joined');
+ test_text ('table.large_table:eq(1) th:eq(4) a[href="?order=role__name"]', 'Role');
+ test_text ('table.large_table:eq(1) th:eq(5)', 'Last week activity');
+ test_text ('table.large_table:eq(1) tr:last a[href="/user/-/edit/"]', 'Anonymous users');
+ test_text ('table.large_table:eq(1) a.main_object_title[href="/profile/"]', C.W.USER_ADMIN);
+ test_text ('table.large_table:eq(1) div.hidden-user-actions a[href="/profile/"]', 'Your profile');
+ // TOTEST roles of users
+ test_comt_unlogged_footer ();
+ });
+
+ suite ('check user number', function () {
+ test_page_loading ('/user/?display=1', 'People\' list\n - '+C['#id_workspace_name']);
+ test_count ('#user_form :input', 6 + (test_comt.user_nb % 10) * 2);
+ test_match ('#paginator', new RegExp ('\\s\\d+-\\d+ of '+test_comt.user_nb+'\\s','m'));
+ });
+
+ suite ('add a user page conformity', function () {
+ test_page_loading ('/user/add/', 'Add a new user\n - '+C['#id_workspace_name']);
+ test_comt_logged_header (C.W.USER_ADMIN);
+ test_comt_default_tabs (test_comt.text_nb, test_comt.user_nb);
+ test_count ('#user ul.sub_list:eq(0) a', 2);
+ test_text ('#user ul.sub_list:eq(0) a:eq(0)[href="/user/"]', 'Users\' list');
+ test_text ('#user ul.sub_list:eq(0) a:eq(1)[href="/user/mass-add/"]', 'Add users in bulk');
+ test_count ('#user form[action="."]:eq(0) :input', 8);
+ test_field ('user', 'id_email', 'text', 0, 'E-mail address', true);
+ test_field ('user', 'id_first_name', 'text', 1, 'First name');
+ test_field ('user', 'id_last_name', 'text', 2, 'Last name');
+ test_field ('user', 'id_tags', 'text', 3, 'Tags');
+ test_field ('user', 'id_role', 'select', 4, 'Workspace level role');
+ test_field ('user', 'id_note', 'textarea', 5, 'Note');
+ test_count ('select#id_role option', 6);
+ test_text ('select#id_role option:eq(0)[value][selected]', '---------', C.HIDDEN);
+ test_text ('select#id_role option:eq(1)[value="1"]', 'Manager', C.HIDDEN);
+ test_text ('select#id_role option:eq(2)[value="2"]', 'Editor', C.HIDDEN);
+ test_text ('select#id_role option:eq(3)[value="3"]', 'Moderator', C.HIDDEN);
+ test_text ('select#id_role option:eq(4)[value="4"]', 'Commentator', C.HIDDEN);
+ test_text ('select#id_role option:eq(5)[value="5"]', 'Observer', C.HIDDEN);
+ test_val ('#user :input:eq(6)[type=submit]', 'Add user');
+ test_val ('#user :input:eq(7)#cancel_button[type=button]', 'Cancel');
+ test_comt_unlogged_footer ();
+ test_click ('#user input[type="submit"]', C.WAIT_PAGE_LOAD);
+ test_count ('div.help_text span.error-text', 1);
+ test_field ('user div.error', 'id_email', 'text', 0, 'E-mail address', true);
+ test_match ('#user div.help_text:eq(0) span.error-text:eq(0)', /This field is required/m);
+ // X TOTEST add user (pending)
+ });
+
+ suite ('add-users-in-bulk page conformity', function () {
+ test_page_loading ('/user/mass-add/', 'Add users in bulk\n - '+C['#id_workspace_name']);
+ test_comt_logged_header (C.W.USER_ADMIN);
+ test_comt_default_tabs (test_comt.text_nb, test_comt.user_nb);
+ test_count ('#user ul.sub_list:eq(0) a', 2);
+ test_text ('#user ul.sub_list:eq(0) a:eq(0)[href="/user/"]', 'Users\' list');
+ test_text ('#user ul.sub_list:eq(0) a:eq(1)[href="/user/add/"]', 'Add a new user');
+ test_count ('#user form[action="."]:eq(0) :input', 6);
+ test_field ('user', 'id_email', 'textarea', 0, 'Emails', true);
+ test_field ('user', 'id_tags', 'text', 1, 'Tags');
+ test_field ('user', 'id_role', 'select', 2, 'Workspace level role');
+ test_field ('user', 'id_note', 'textarea', 3, 'Note');
+ test_count ('select#id_role option', 6);
+ test_text ('select#id_role option:eq(0)[value][selected]', '---------', C.HIDDEN);
+ test_text ('select#id_role option:eq(1)[value="1"]', 'Manager', C.HIDDEN);
+ test_text ('select#id_role option:eq(2)[value="2"]', 'Editor', C.HIDDEN);
+ test_text ('select#id_role option:eq(3)[value="3"]', 'Moderator', C.HIDDEN);
+ test_text ('select#id_role option:eq(4)[value="4"]', 'Commentator', C.HIDDEN);
+ test_text ('select#id_role option:eq(5)[value="5"]', 'Observer', C.HIDDEN);
+ test_val ('#user :input:eq(4)[type=submit]', 'Add users');
+ test_val ('#user :input:eq(5)#cancel_button[type=button]', 'Cancel');
+ // X TOTEST add users (pending) -> can't be deleted
+ test_comt_unlogged_footer ();
+ test_click ('#user input[type="submit"]', C.WAIT_PAGE_LOAD);
+ test_count ('div.help_text span.error-text', 1);
+ test_field ('user div.error', 'id_email', 'textarea', 0, 'Emails', true);
+ test_match ('#user div.help_text:eq(0) span.error-text:eq(0)', /This field is required/m);
+ });
+
+ suite ('settings page conformity', function () {
+ test_page_loading ('/settings/', 'Settings - '+C['#id_workspace_name']);
+ test_comt_logged_header (C.W.USER_ADMIN);
+ test_comt_default_tabs (test_comt.text_nb, test_comt.user_nb);
+ test_count ('#settings ul.sub_list:eq(0) a', 1);
+ test_text ('#settings ul.sub_list:eq(0) a:eq(0)[href="/settings/design/"]', 'Appearance');
+ test_count ('#settings form[action="."]:eq(0) :input', 12);
+ test_field ('settings', 'id_workspace_name', 'text', 0, 'Workspace name');
+ test_field ('settings', 'id_workspace_tagline', 'text', 1, 'Workspace tagline');
+ test_field ('settings', 'id_workspace_registration', 'checkbox', 2, 'Workspace registration');
+ test_field ('settings', 'id_workspace_registration_moderation', 'checkbox', 3, 'Workspace registration moderation');
+ test_field ('settings', 'id_workspace_role_model', 'select', 4, 'Role model');
+ test_text ('select#id_workspace_role_model option:eq(0)[selected][value="generic"]', 'Generic', C.HIDDEN);
+ test_text ('select#id_workspace_role_model option:eq(1)[value="teacher"]', 'Class (education)', C.HIDDEN);
+ test_field ('settings', 'id_workspace_category_1', 'text', 5, 'Label for the first category of comments');
+ test_field ('settings', 'id_workspace_category_2', 'text', 6, 'Label for the second category of comments');
+ test_field ('settings', 'id_workspace_category_3', 'text', 7, 'Label for the third category of comments');
+ test_field ('settings', 'id_workspace_category_4', 'text', 8, 'Label for the fourth category of comments');
+ test_field ('settings', 'id_workspace_category_5', 'text', 9, 'Label for the fifth category of comments');
+ test_val ('#settings :input:eq(10)[type=submit]', 'Save');
+ test_val ('#settings :input:eq(11)#cancel_button[type=button]', 'Cancel');
+ // TOTEST Workspace registration feature (with newly accessible page)
+ test_comt_unlogged_footer ();
+ });
+
+ suite ('settings design page conformity', function () {
+ test_page_loading ('/settings/design/', 'Settings - '+C['#id_workspace_name']);
+ test_comt_logged_header (C.W.USER_ADMIN);
+ test_comt_default_tabs (test_comt.text_nb, test_comt.user_nb);
+ test_count ('#settings ul.sub_list:eq(0) a', 1);
+ test_text ('#settings ul.sub_list:eq(0) a:eq(0)[href="/settings/"]', 'General');
+ test_count ('#settings form[action="."]:eq(0) :input', 7);
+ test_field ('settings', 'id_workspace_logo_file', 'file', 0, 'Workspace logo');
+ test_field ('settings', 'id_custom_css', 'textarea', 1, 'Custom CSS rules');
+ test_field ('settings', 'id_custom_font', 'text', 2, 'Custom font');
+ test_field ('settings', 'id_custom_titles_font', 'text', 3, 'Custom font for titles');
+ test_val ('#settings :input:eq(4)[type=submit]', 'Save');
+ test_val ('#settings :input:eq(5)#cancel_button[type=button]', 'Cancel');
+ test_val ('#settings :input:eq(6)#delete_logo_button[type=submit]', 'Delete logo');
+ test_comt_unlogged_footer ();
+ });
+
+ suite ('followup page conformity', function () {
+ test_page_loading ('/followup/', 'Followup\n - '+C['#id_workspace_name']);
+ test_comt_logged_header (C.W.USER_ADMIN);
+ test_comt_default_tabs (test_comt.text_nb, test_comt.user_nb);
+ test_text ('#followup a:eq(0)[href="/help/#public_private_feed"]', '?');
+ test_match ('#followup a:eq(1)[href$="/feed/"]', new RegExp (C.W.WORKSPACE_URL+'feed/', 'm'));
+ test_text ('#followup a:eq(2)[href="/help/#public_private_feed"]', '?');
+ test_count ('form#followup_form[action="."] :input', 3);
+ test_val ('form#followup_form input[type=submit]', '(Activate private feed|Reset private feed url)');
+ test_val ('form#followup_form input#workspace_notify_check[type=checkbox]', 'on');
+ test_val ('form#followup_form input#own_notify_check[type=checkbox]', 'on');
+
+ // X TOTEST qu'une fois cliqué, le bouton a le nvo label, et qu'une adresse est disponible
+ // X TOTEST que si on reclique l'adresse est changée
+
+ test_comt_unlogged_footer ();
+ });
+
+});
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/test-suite/tests/012_comt-admin-text-list.js Sat Apr 19 17:00:40 2014 +0200
@@ -0,0 +1,145 @@
+
+// " Vim settings
+// set tabstop=4 " number of spaces in a tab
+// set softtabstop=4 " as above
+// set shiftwidth=4 " as above
+
+var long_text = '';
+
+for (var i = 20; i--;)
+ long_text += 'Contenu du troisième texte.<br/>Sur <b>plusieurs</b> lignes<br/>';
+
+const ctexts = [
+ {
+ '#id_title': 'Text One Sopinspace-Test éléguant',
+ '#id_format': 'markdown',
+ '#id_content': 'Contenu du premier texte.\nSur plusieurs lignes\nPour tester un cas réaliste',
+ '#id_tags': 'test_text, Text Premier'
+ },
+ {
+ '#id_title': 'Text Two Sopinspace-Test éléguant',
+ '#id_format': 'rst',
+ '#id_content': 'Contenu du deuxième texte.\nSur plusieurs lignes aussi\nPour tester un cas réaliste',
+ '#id_tags': 'test_text, Text Second'
+ },
+ {
+ '#id_title': 'Text Three Sopinspace-Test éléguant',
+ '#id_format': 'html',
+ '#id_content': long_text,
+ '#id_tags': 'test_text, Text Troisième'
+ }
+];
+
+suite ('comt admin text list', function () {
+
+ this.timeout(200000);
+
+ suite ('empty texts list page conformity', function () {
+ test_page_loading ('/text/', 'Texts\n - '+C['#id_workspace_name']);
+ test_comt_logged_header (C.W.USER_ADMIN);
+ test_comt_default_tabs (test_comt.text_nb, test_comt.user_nb);
+ test_count ('#text ul.sub_list:eq(0) a', 3);
+ test_text ('#text ul.sub_list:eq(0) a:eq(0)[href="/create/content/"]', 'Create a text');
+ test_text ('#text ul.sub_list:eq(0) a:eq(1)[href="/create/upload/"]', 'Upload a text');
+ test_text ('#text ul.sub_list:eq(0) a:eq(2)[href="/create/import/"]', 'Import a co-mented text');
+ test_match ('#text', /No texts yet/m);
+ test_count ('#texts_form :input', 0);
+ });
+
+ suite ('create texts', function () {
+ for (var j=4; j--;)
+ for (var i=3; i--;)
+ test_comt_create_text (ctexts[i]);
+ });
+
+ suite ('texts list page conformity', function () {
+ test_page_loading ('/text/', 'Texts\n - '+C['#id_workspace_name']);
+ test_comt_logged_header (C.W.USER_ADMIN);
+ test_comt_default_tabs (test_comt.text_nb, test_comt.user_nb);
+ test_count ('#text ul.sub_list:eq(0) a', 3);
+ test_text ('#text ul.sub_list:eq(0) a:eq(0)[href="/create/content/"]', 'Create a text');
+ test_text ('#text ul.sub_list:eq(0) a:eq(1)[href="/create/upload/"]', 'Upload a text');
+ test_text ('#text ul.sub_list:eq(0) a:eq(2)[href="/create/import/"]', 'Import a co-mented text');
+ test_count ('form#filter_form[action="."] :input', 1);
+ test_text ('select#tag_selected option:eq(0)[selected][value="0"]', '- All -', C.HIDDEN);
+ test_text ('select#bulk_actions option:eq(0)[selected][value="-1"]', 'Bulk Actions', C.HIDDEN);
+ test_text ('select#bulk_actions option:eq(1)[value="delete"]', 'Delete', C.HIDDEN);
+ test_val ('form#texts_form input#apply[type=button][disabled]', 'Apply');
+ test_count ('table.large_table:eq(1) th', 6);
+ test_val ('table.large_table:eq(1) th:eq(0) input#all_check[type="checkbox"]', 'on');
+ test_text ('table.large_table:eq(1) th:eq(1) a[href="?order=title"]', 'Text');
+ test_text ('table.large_table:eq(1) th:eq(2)', 'Author');
+ test_text ('table.large_table:eq(1) th:eq(3) a[href="?order=-modified"]', 'Modified');
+ test_text ('table.large_table:eq(1) th:eq(4)', '# comments');
+ test_text ('table.large_table:eq(1) th:eq(5)', 'Last week activity');
+ test_comt_unlogged_footer ();
+ });
+
+ suite ('texts list filter', function () {
+ test_page_loading ('/text/?tag_selected=Text+Troisième', 'Texts\n - '+C['#id_workspace_name']);
+ test_count ('#texts_form :input', 4 + 3);
+ test_match ('#paginator', /\s1-4 of 4\s/m);
+
+ for (var i=4; i--;) {
+ test_text ('a.main_object_title:eq('+i+')', ctexts[2]['#id_title']);
+ test_match ('.tag_list:eq('+i+')', /tags: test_text Text Troisième /);
+ test_text ('.tag_list:eq('+i+') a:eq(0)[href="?tag_selected=test_text"]', 'test_text');
+ test_text ('.tag_list:eq('+i+') a:eq(1)[href="?tag_selected=Text+Troisi%C3%A8me"]','Text Troisième');
+ test_text ('#text .hidden-text-actions:eq('+i+') a:eq(0)[href^="/text/"][href$="/view/"]', 'View');
+ test_text ('#text .hidden-text-actions:eq('+i+') a:eq(1)[href^="/text/"][href$="/edit/"]', 'Edit');
+ test_text ('#text .hidden-text-actions:eq('+i+') a:eq(2)[href="#"][id*="text-delete-"]', 'Delete');
+ test_text ('#text .hidden-text-actions:eq('+i+') a:eq(3)[href^="/text/"][href$="/share/"]', 'Users');
+ test_text ('#text .hidden-text-actions:eq('+i+') a:eq(4)[href^="/text/"][href$="/settings/"]', 'Settings');
+ test_text ('#text a[title="Edit user"][href^="/user/"][href$="/edit/"]:eq('+i+')', 'admin');
+ test_text ('#text table[summary="text list"] tr:eq('+(i+1)+') td:eq(4)', '0');
+ }
+ });
+
+ suite ('texts list pagination conformity', function () {
+ test_page_loading ('/text/', 'Texts\n - '+C['#id_workspace_name']);
+ test_count ('#texts_form :input', (test_comt.text_nb < 10 ? test_comt.text_nb : 10) + 3);
+ test_match ('#paginator', new RegExp ('\\s1-10 of '+test_comt.text_nb+'\\s','m'));
+ test_text ('#paginator a:eq(0)[href="?page=2"]', '»');
+ test_text ('#paginator a:eq(1)[href="?paginate=0"]', 'all');
+ test_click ('#paginator a:eq(0)[href="?page=2"]');
+ test_match ('#paginator', new RegExp ('\\s11-12 of '+test_comt.text_nb+'\\s','m'));
+ test_count ('#texts_form :input', test_comt.text_nb % 10 + 3);
+ test_click ('#paginator a:eq(0)[href="?page=1"]');
+ test_match ('#paginator', new RegExp ('\\s1-10 of '+test_comt.text_nb+'\\s','m'));
+ test_count ('#texts_form :input', (test_comt.text_nb < 10 ? test_comt.text_nb : 10) + 3);
+ test_click ('#paginator a:eq(1)[href="?paginate=0&page=1"]');
+ test_match ('#paginator', /\s\(paginate\)\s/m);
+ test_count ('#texts_form :input', test_comt.text_nb + 3);
+ test_click ('#paginator a:eq(0)[href="?paginate=&page=1"]');
+ test_count ('#texts_form :input', (test_comt.text_nb < 10 ? test_comt.text_nb : 10) + 3);
+ test_match ('#paginator', new RegExp ('\\s1-10 of '+test_comt.text_nb+'\\s','m'));
+ });
+
+ suite ('texts list bulk deletion', function () {
+ test_page_loading ('/text/?page=2', 'Texts\n - '+C['#id_workspace_name']);
+ test ('choose bulk action Delete', dsl(function () { input('#bulk_actions').option('delete'); }));
+ test_click ('#all_check');
+ test_count ('form#texts_form input:checked', test_comt.text_nb % 10 + 1);
+ test_val ('form#texts_form input#apply[type=button]:not([disabled])', 'Apply');
+ /* test_click ('#texts_form #apply'); // can't click on the confirm dialog */
+ test_submit ('#texts_form');
+ test_page_loading ('/text/', 'Texts\n - '+C['#id_workspace_name']);
+ test_comt.text_nb -= 2;
+ test_count ('form#texts_form :input', test_comt.text_nb + 3);
+ test_match ('#paginator', new RegExp ('\\s1-'+test_comt.text_nb+' of '+test_comt.text_nb+'\\s','m'));
+ });
+
+ suite ('texts list single deletion', function () {
+ test ('choose bulk action Delete', dsl(function () { input('#bulk_actions').option('delete'); }));
+ test_click ('.text_check:eq(0)');
+ test_count ('form#texts_form input:checked', 1);
+ test_val ('form#texts_form input#apply[type=button]:not([disabled])', 'Apply');
+ test_submit ('#texts_form');
+ test_page_loading ('/text/', 'Texts\n - '+C['#id_workspace_name']);
+ test_comt.text_nb -= 1;
+ test_count ('form#texts_form :input', test_comt.text_nb + 3);
+ test_match ('#paginator', new RegExp ('\\s1-'+test_comt.text_nb+' of '+test_comt.text_nb+'\\s','m'));
+ });
+
+});
+
--- a/test-suite/workspace.info.js.example Sat Apr 19 13:10:09 2014 +0200
+++ b/test-suite/workspace.info.js.example Sat Apr 19 17:00:40 2014 +0200
@@ -1,7 +1,5 @@
-define ("DEBUG", false); // in DEBUG mode tests stop at first fail to let you check what happen
define ("BROWSERS", ['Chrome']);
-
define ("WORKSPACE_URL", '<workspace-url>'); // In http://IP_ADDRESS:PORT_NUM/ format
define ("USER_ADMIN", '<admin-login>');
define ("PASS_ADMIN", '<admin-password>');