# HG changeset patch # User ymh # Date 1394809143 -3600 # Node ID 61408993f361773c2ac19b4f461d6d76931cd53e # Parent fa66f4bb15635e4b5866544bcfcbe3c089ea4ee0# Parent a0b695aace0a093a4f8355dd5cd94b44bd96ffbf merge a0b695aace0a + 2bed79bde721 diff -r fa66f4bb1563 -r 61408993f361 src/cm/scripts/test-suite/README.txt --- a/src/cm/scripts/test-suite/README.txt Fri Mar 14 13:16:10 2014 +0100 +++ b/src/cm/scripts/test-suite/README.txt Fri Mar 14 15:59:03 2014 +0100 @@ -26,9 +26,7 @@ Starting the test-suite : ------------------------- cd comt/src/cm/scripts +cp workspace.info.js.example workspace.info.js vi workspace.info.js # Customize tested workspace settings -./test-suite.sh +./start-test-suite.sh -So you can run the test-suite multiple times using only `karma start` after the -first run. - diff -r fa66f4bb1563 -r 61408993f361 src/cm/scripts/test-suite/start-test-suite.sh --- a/src/cm/scripts/test-suite/start-test-suite.sh Fri Mar 14 13:16:10 2014 +0100 +++ b/src/cm/scripts/test-suite/start-test-suite.sh Fri Mar 14 15:59:03 2014 +0100 @@ -1,6 +1,7 @@ #!/bin/bash -export CHROME_BIN= `which chromium` +export CHROME_BIN=`which chromium` + if [ -z "$CHROME_BIN" ]; then export CHROME_BIN=`which chrome` fi diff -r fa66f4bb1563 -r 61408993f361 src/cm/scripts/test-suite/tests/tests.js --- a/src/cm/scripts/test-suite/tests/tests.js Fri Mar 14 13:16:10 2014 +0100 +++ b/src/cm/scripts/test-suite/tests/tests.js Fri Mar 14 15:59:03 2014 +0100 @@ -23,9 +23,9 @@ '#id_workspace_category_3': 'ws_cat_3', '#id_workspace_category_4': 'ws_cat_4', '#id_workspace_category_5': 'ws_cat_5', - '#id_custom_css': ".voted {\n color: #008000;\n}\n\n.rejected, .fallen, .withdrawn {\n color: #ff0000;\n}\n\ndiv.frame {\n border: 1px solid #000;\n padding: 5px;\n}\n\ndiv.frame .title {\n font-weight: bold;\n text-align: center; font-color:purple; \n}", - '#id_custom_font': 'Ubuntu', - '#id_custom_titles_font': 'Ubuntu Monospaced', + '#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', }; @@ -60,6 +60,21 @@ test_unlogged_footer (); }); + suite ('contact page mandatory field test', function () { + test_page_loading ('/contact/', 'Contact'); + + test ('submit empty fields', dsl(function () { + elt ('#profile input[type="submit"]').click (); + browser.waitForPageLoad (); + })); + test_count ('div.help_text span.error-text', 4); + test_form_field ('profile div.error', 'id_name', 'text', 0, 'Your name', true); // the field id_name is… + test_form_field ('profile div.error', 'id_email', 'text', 1, 'Your email address', true); + test_form_field ('profile div.error', 'id_title', 'text', 2, 'Subject of the message', true); + test_form_field ('profile div.error', 'id_body', 'textarea', 3, 'Body of the message', true); + test_form_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 (); @@ -68,6 +83,14 @@ test_form_field ('profile', 'id_email', 'text', 1, 'E-mail', true); test_val ('#profile input[type=submit]', 'Reset my password'); test_unlogged_footer (); + + test ('submit empty fields', dsl(function () { + elt ('#profile input[type="submit"]').click (); + browser.waitForPageLoad (); + })); + + test_count ('div.help_text span.error-text', 1); + test_form_field ('profile div.error', 'id_email', 'text', 0, 'E-mail', true); }); suite ('login page conformity', function () { @@ -77,11 +100,22 @@ test_count ('form#login[action="/login/"] :input', 3); test_form_field ('login', 'id_username', 'text', 0, 'Username', true); test_form_field ('login', 'id_password', 'password', 1, 'Password', true); - test_val ('form#login input[type=submit]', 'Login'); + test_val ('form#login input[type=submit]', 'Login'); test_text ('form#login a[href="/password_reset/"]', 'Forgot password?'); test_unlogged_footer (); // test_i18n (); - test ('logs an admin in', dsl(function () { + + test ('get back to / to avoid bugging next page load', dsl(function () { + browser.navigateTo ('/'); + })); + test_page_loading ('/login/', 'Login'); + test ('submit empty fields', dsl(function () { + elt ('#login input[type="submit"]').click (); + browser.waitForPageLoad (); + })); + test_form_field ('login div.error', 'id_username', 'text', 0, 'Username', true); + test_form_field ('login div.error', 'id_password', 'password', 1, 'Password', true); + test ('logs an admin in', dsl(function () { input ('#id_username').enter (w.USER_ADMIN); input ('#id_password').enter (w.PASS_ADMIN); elt ('#login input[type=submit]').click (); @@ -115,7 +149,7 @@ }));*/ }); - suite ('setting settings to test values', function () { + suite ('setting settings to test-values', function () { test_page_loading ('/settings/', 'Settings'); test_fill_settings (t); test_val ('#id_workspace_name', t['#id_workspace_name']); @@ -215,18 +249,26 @@ 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_form_field ('text', 'id_title', 'text', 0, 'Title', true); - test_form_field ('text', 'id_format', 'select', 1, 'Format', true); - test_form_field ('text', 'id_content', 'textarea', 2, 'Content', true); - test_form_field ('text', 'id_tags', 'text', 3, 'Tags'); + test_form_field ('text', 'id_title', 'text', 0, 'Title', true); + test_form_field ('text', 'id_format', 'select', 1, 'Format', true); + test_form_field ('text', 'id_content', 'textarea', 2, 'Content', true); + test_form_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 ('#markItUpId_content li', 20); + test_count ('#markItUpId_content li', 20); // How many buttons are in the WYSIWYG editor toolbar ? test_unlogged_footer (); + + test ('submit empty fields', dsl(function () { + elt ('#text input[type="submit"]').click (); + browser.waitForPageLoad (); + })); + test_count ('div.help_text span.error-text', 2); + test_form_field ('text div.error', 'id_title', 'text', 0, 'Title', true); + test_form_field ('text div.error', 'id_content', 'textarea', 1, 'Content', true); }); suite ('upload text page conformity', function () { @@ -238,10 +280,10 @@ 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_form_field ('text', 'id_title', 'text', 0, 'Title'); - test_form_field ('text', 'id_format', 'select', 1, 'Format', true); - test_form_field ('text', 'id_tags', 'text', 2, 'Tags'); - test_form_field ('text', 'id_file', 'file', 3, 'Upload file (optional)'); + test_form_field ('text', 'id_title', 'text', 0, 'Title'); + test_form_field ('text', 'id_format', 'select', 1, 'Format', true); + test_form_field ('text', 'id_tags', 'text', 2, 'Tags'); + test_form_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); @@ -249,6 +291,14 @@ 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 empty fields', dsl(function () { + elt ('#text input[type="submit"]').click (); + browser.waitForPageLoad (); + })); + test_count ('div.help_text span.error-text', 1); + test_form_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 () { @@ -264,6 +314,14 @@ 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 empty fields', dsl(function () { + elt ('#text input[type="submit"]').click (); + browser.waitForPageLoad (); + })); + test_count ('div.help_text span.error-text', 1); + test_form_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 () { @@ -300,7 +358,7 @@ 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 + // TOTEST : filter by tag -> commentator user should be tagged commentator 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); @@ -325,6 +383,7 @@ 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 presence of commentator and editor user test_unlogged_footer (); }); @@ -369,7 +428,15 @@ test_val ('#user :input:eq(6)[type=submit]', 'Add user'); test_val ('#user :input:eq(7)#cancel_button[type=button]', 'Cancel'); test_unlogged_footer (); - // TOTEST add user (pending) + + test ('submit empty fields', dsl(function () { + elt ('#user input[type="submit"]').click (); + browser.waitForPageLoad (); + })); + test_count ('div.help_text span.error-text', 1); + test_form_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 () { @@ -395,6 +462,14 @@ 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 empty fields', dsl(function () { + elt ('#user input[type="submit"]').click (); + browser.waitForPageLoad (); + })); + test_count ('div.help_text span.error-text', 1); + test_form_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 () { @@ -418,7 +493,7 @@ test_form_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 + // TOTEST Workspace registration feature (with newly accessible page) test_unlogged_footer (); }); @@ -436,7 +511,6 @@ 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'); - // TOTEST custom CSS, font, font for titles like the rest of the settings test_unlogged_footer (); }); @@ -452,12 +526,24 @@ test_val ('form#followup_form input#workspace_notify_check[type=checkbox]', 'on'); test_val ('form#followup_form input#own_notify_check[type=checkbox]', 'on'); - // tester qu'une fois cliqué, le bouton à le nvo label, et qu'une adresse est disponible - // tester que si on reclique l'adresse est changée + // 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 (); }); + // vérifier les valeurs de settings sauvées + // Tester les champs obligatoires + // Tester les créations de textes + // 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 ('settings restoration', function () { test_page_loading ('/settings/', 'Settings'); test_fill_settings (z); @@ -535,6 +621,39 @@ test_text ('#footer a:nth-of-type(9)[href="/i18n/setlang/it/"]', 'Italiano'); } +function test_readz_field (field_id) { + test ('get '+field_id, dsl(function () { + element (field_id).val (function (v) { + z[field_id] = v; + }); + })); +} + +function test_fill_field (field_id, stored) { + test ('set '+field_id, dsl(function () { + input (field_id).enter (stored[field_id]); + })); +} + +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 test_i18n () { test ('can change lang to french', dsl(function () { element ('#footer a[href="/i18n/setlang/fr/"]').click (); @@ -610,12 +729,13 @@ function test_form_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+'"]'; } -// var s = type == 'textarea' ? 'textarea#'+field_id : '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); @@ -625,39 +745,6 @@ })); } -function test_readz_field (field_id) { - test ('get '+field_id, dsl(function () { - element (field_id).val (function (v) { - z[field_id] = v; - }); - })); -} - -function test_fill_field (field_id, stored) { - test ('set '+field_id, dsl(function () { - input (field_id).enter (stored[field_id]); - })); -} - -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); -} - /** Ensure the given element is visible * s : CSS selector of the DOM element to check * v : should the element being visible diff -r fa66f4bb1563 -r 61408993f361 src/cm/scripts/test-suite/workspace.info.js.example --- a/src/cm/scripts/test-suite/workspace.info.js.example Fri Mar 14 13:16:10 2014 +0100 +++ b/src/cm/scripts/test-suite/workspace.info.js.example Fri Mar 14 15:59:03 2014 +0100 @@ -1,7 +1,9 @@ -define ("WORKSPACE_URL", 'http://192.168.2.61:8000/'); -define ("USER_ADMIN", ''); -define ("PASS_ADMIN", ''); +define ("BROWSERS", ['Chrome']); + +define ("WORKSPACE_URL", ''); // Under http://IP_ADDRESS:PORT_NUM/ format +define ("USER_ADMIN", ''); +define ("PASS_ADMIN", ''); define ("USER_EDIT", ''); define ("PASS_EDIT", ''); @@ -9,6 +11,9 @@ define ("USER_COM", ''); define ("PASS_COM", ''); +define ("USER_OBSERV", ''); +define ("PASS_OBSERV", ''); + function define (name, value) { Object.defineProperty (exports, name, { value: value, diff -r fa66f4bb1563 -r 61408993f361 src/cm/views/create.py --- a/src/cm/views/create.py Fri Mar 14 13:16:10 2014 +0100 +++ b/src/cm/views/create.py Fri Mar 14 15:59:03 2014 +0100 @@ -26,8 +26,8 @@ from base64 import b64decode class CreateTextUploadForm(ModelForm): - file = forms.FileField(required=False, - label=ugettext_lazy("Upload file (optional)"), + file = forms.FileField(required=True, + label=ugettext_lazy("Upload file"), help_text=ugettext_lazy("Upload a file from your computer instead of using the direct input above"),) title = forms.CharField(required=False,