|
1 |
|
2 // " Vim settings |
|
3 // set tabstop=4 " number of spaces in a tab |
|
4 // set softtabstop=4 " as above |
|
5 // set shiftwidth=4 " as above |
|
6 |
|
7 var long_text = ''; |
|
8 |
|
9 for (var i = 20; i--;) |
|
10 long_text += 'Contenu du troisième texte.<br/>Sur <b>plusieurs</b> lignes<br/>'; |
|
11 |
|
12 const ctexts = [ |
|
13 { |
|
14 '#id_title': 'Text One Sopinspace-Test éléguant', |
|
15 '#id_format': 'markdown', |
|
16 '#id_content': 'Contenu du premier texte.\nSur plusieurs lignes\nPour tester un cas réaliste', |
|
17 '#id_tags': 'test_text, Text Premier' |
|
18 }, |
|
19 { |
|
20 '#id_title': 'Text Two Sopinspace-Test éléguant', |
|
21 '#id_format': 'rst', |
|
22 '#id_content': 'Contenu du deuxième texte.\nSur plusieurs lignes aussi\nPour tester un cas réaliste', |
|
23 '#id_tags': 'test_text, Text Second' |
|
24 }, |
|
25 { |
|
26 '#id_title': 'Text Three Sopinspace-Test éléguant', |
|
27 '#id_format': 'html', |
|
28 '#id_content': long_text, |
|
29 '#id_tags': 'test_text, Text Troisième' |
|
30 } |
|
31 ]; |
|
32 |
|
33 suite ('comt admin text list', function () { |
|
34 |
|
35 this.timeout(200000); |
|
36 |
|
37 suite ('empty texts list page conformity', function () { |
|
38 test_page_loading ('/text/', 'Texts\n - '+c['#id_workspace_name']); |
|
39 test_logged_header (w.USER_ADMIN); |
|
40 test_default_tabs (t.text_nb, t.user_nb); |
|
41 test_count ('#text ul.sub_list:eq(0) a', 3); |
|
42 test_text ('#text ul.sub_list:eq(0) a:eq(0)[href="/create/content/"]', 'Create a text'); |
|
43 test_text ('#text ul.sub_list:eq(0) a:eq(1)[href="/create/upload/"]', 'Upload a text'); |
|
44 test_text ('#text ul.sub_list:eq(0) a:eq(2)[href="/create/import/"]', 'Import a co-mented text'); |
|
45 test_match ('#text', /No texts yet/m); |
|
46 test_count ('#texts_form :input', 0); |
|
47 }); |
|
48 |
|
49 suite ('create texts', function () { |
|
50 for (var j=4; j--;) |
|
51 for (var i=3; i--;) |
|
52 create_text (i); |
|
53 }); |
|
54 |
|
55 suite ('texts list page conformity', function () { |
|
56 test_page_loading ('/text/', 'Texts\n - '+c['#id_workspace_name']); |
|
57 test_logged_header (w.USER_ADMIN); |
|
58 test_default_tabs (t.text_nb, t.user_nb); |
|
59 test_count ('#text ul.sub_list:eq(0) a', 3); |
|
60 test_text ('#text ul.sub_list:eq(0) a:eq(0)[href="/create/content/"]', 'Create a text'); |
|
61 test_text ('#text ul.sub_list:eq(0) a:eq(1)[href="/create/upload/"]', 'Upload a text'); |
|
62 test_text ('#text ul.sub_list:eq(0) a:eq(2)[href="/create/import/"]', 'Import a co-mented text'); |
|
63 test_count ('form#filter_form[action="."] :input', 1); |
|
64 test_text ('select#tag_selected option:eq(0)[selected][value="0"]', '- All -', hidden); |
|
65 test_text ('select#bulk_actions option:eq(0)[selected][value="-1"]', 'Bulk Actions', hidden); |
|
66 test_text ('select#bulk_actions option:eq(1)[value="delete"]', 'Delete', hidden); |
|
67 test_val ('form#texts_form input#apply[type=button][disabled]', 'Apply'); |
|
68 test_count ('table.large_table:eq(1) th', 6); |
|
69 test_val ('table.large_table:eq(1) th:eq(0) input#all_check[type="checkbox"]', 'on'); |
|
70 test_text ('table.large_table:eq(1) th:eq(1) a[href="?order=title"]', 'Text'); |
|
71 test_text ('table.large_table:eq(1) th:eq(2)', 'Author'); |
|
72 test_text ('table.large_table:eq(1) th:eq(3) a[href="?order=-modified"]', 'Modified'); |
|
73 test_text ('table.large_table:eq(1) th:eq(4)', '# comments'); |
|
74 test_text ('table.large_table:eq(1) th:eq(5)', 'Last week activity'); |
|
75 test_unlogged_footer (); |
|
76 }); |
|
77 |
|
78 suite ('texts list filter', function () { |
|
79 test_page_loading ('/text/?tag_selected=Text+Troisième', 'Texts\n - '+c['#id_workspace_name']); |
|
80 test_count ('#texts_form :input', 4 + 3); |
|
81 test_match ('#paginator', /\s1-4 of 4\s/m); |
|
82 |
|
83 for (var i=4; i--;) { |
|
84 test_text ('a.main_object_title:eq('+i+')', ctexts[2]['#id_title']); |
|
85 test_match ('.tag_list:eq('+i+')', /tags: test_text Text Troisième /); |
|
86 test_text ('.tag_list:eq('+i+') a:eq(0)[href="?tag_selected=test_text"]', 'test_text'); |
|
87 test_text ('.tag_list:eq('+i+') a:eq(1)[href="?tag_selected=Text+Troisi%C3%A8me"]','Text Troisième'); |
|
88 test_text ('#text .hidden-text-actions:eq('+i+') a:eq(0)[href^="/text/"][href$="/view/"]', 'View'); |
|
89 test_text ('#text .hidden-text-actions:eq('+i+') a:eq(1)[href^="/text/"][href$="/edit/"]', 'Edit'); |
|
90 test_text ('#text .hidden-text-actions:eq('+i+') a:eq(2)[href="#"][id*="text-delete-"]', 'Delete'); |
|
91 test_text ('#text .hidden-text-actions:eq('+i+') a:eq(3)[href^="/text/"][href$="/share/"]', 'Users'); |
|
92 test_text ('#text .hidden-text-actions:eq('+i+') a:eq(4)[href^="/text/"][href$="/settings/"]', 'Settings'); |
|
93 test_text ('#text a[title="Edit user"][href^="/user/"][href$="/edit/"]:eq('+i+')', 'admin'); |
|
94 test_text ('#text table[summary="text list"] tr:eq('+(i+1)+') td:eq(4)', '0'); |
|
95 } |
|
96 }); |
|
97 |
|
98 suite ('texts list pagination conformity', function () { |
|
99 test_page_loading ('/text/', 'Texts\n - '+c['#id_workspace_name']); |
|
100 test_count ('#texts_form :input', (t.text_nb < 10 ? t.text_nb : 10) + 3); |
|
101 test_match ('#paginator', new RegExp ('\\s1-10 of '+t.text_nb+'\\s','m')); |
|
102 test_text ('#paginator a:eq(0)[href="?page=2"]', '»'); |
|
103 test_text ('#paginator a:eq(1)[href="?paginate=0"]', 'all'); |
|
104 test_click ('#paginator a:eq(0)[href="?page=2"]'); |
|
105 test_match ('#paginator', new RegExp ('\\s11-12 of '+t.text_nb+'\\s','m')); |
|
106 test_count ('#texts_form :input', t.text_nb % 10 + 3); |
|
107 test_click ('#paginator a:eq(0)[href="?page=1"]'); |
|
108 test_match ('#paginator', new RegExp ('\\s1-10 of '+t.text_nb+'\\s','m')); |
|
109 test_count ('#texts_form :input', (t.text_nb < 10 ? t.text_nb : 10) + 3); |
|
110 test_click ('#paginator a:eq(1)[href="?paginate=0&page=1"]'); |
|
111 test_match ('#paginator', /\s\(paginate\)\s/m); |
|
112 test_count ('#texts_form :input', t.text_nb + 3); |
|
113 test_click ('#paginator a:eq(0)[href="?paginate=&page=1"]'); |
|
114 test_count ('#texts_form :input', (t.text_nb < 10 ? t.text_nb : 10) + 3); |
|
115 test_match ('#paginator', new RegExp ('\\s1-10 of '+t.text_nb+'\\s','m')); |
|
116 }); |
|
117 |
|
118 suite ('texts list bulk deletion', function () { |
|
119 test_page_loading ('/text/?page=2', 'Texts\n - '+c['#id_workspace_name']); |
|
120 test ('choose bulk action Delete', dsl(function () { input('#bulk_actions').option('delete'); })); |
|
121 test_click ('#all_check'); |
|
122 test_count ('form#texts_form input:checked', t.text_nb % 10 + 1); |
|
123 test_val ('form#texts_form input#apply[type=button]:not([disabled])', 'Apply'); |
|
124 /* test_click ('#texts_form #apply'); // can't click on the confirm dialog */ |
|
125 test_submit ('#texts_form'); |
|
126 test_page_loading ('/text/', 'Texts\n - '+c['#id_workspace_name']); |
|
127 t.text_nb -= 2; |
|
128 test_count ('form#texts_form :input', t.text_nb + 3); |
|
129 test_match ('#paginator', new RegExp ('\\s1-'+t.text_nb+' of '+t.text_nb+'\\s','m')); |
|
130 }); |
|
131 |
|
132 suite ('texts list single deletion', function () { |
|
133 test ('choose bulk action Delete', dsl(function () { input('#bulk_actions').option('delete'); })); |
|
134 test_click ('.text_check:eq(0)'); |
|
135 test_count ('form#texts_form input:checked', 1); |
|
136 test_val ('form#texts_form input#apply[type=button]:not([disabled])', 'Apply'); |
|
137 test_submit ('#texts_form'); |
|
138 test_page_loading ('/text/', 'Texts\n - '+c['#id_workspace_name']); |
|
139 t.text_nb -= 1; |
|
140 test_count ('form#texts_form :input', t.text_nb + 3); |
|
141 test_match ('#paginator', new RegExp ('\\s1-'+t.text_nb+' of '+t.text_nb+'\\s','m')); |
|
142 }); |
|
143 |
|
144 }); |
|
145 |
|
146 function create_text (i) { |
|
147 test_page_loading ('/create/content/', 'Create a text - '+c['#id_workspace_name']); |
|
148 test ('test creation', dsl(function () { |
|
149 dropdownlist ('#id_format').option (ctexts[i]['#id_format']); |
|
150 })); |
|
151 |
|
152 test_fill_field ('#id_title', ctexts[i]); |
|
153 test ('fill content', dsl(function (){ |
|
154 elt ('#id_content').val (ctexts[i]['#id_content']); |
|
155 })); |
|
156 |
|
157 test_fill_field ('#id_tags', ctexts[i]); |
|
158 test_click ('#save_button', wait_page_load); |
|
159 t.text_nb++; |
|
160 } |
|
161 |