test-suite/tests/001_comt_test_utils.js
author Yves-Marie Haussonne <ymh.work+github@gmail.com>
Fri, 09 May 2014 18:35:26 +0200
changeset 656 a84519031134
parent 646 24067001082c
permissions -rw-r--r--
add link to "privacy policy" in the header test
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
627
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
     1
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
     2
// " Vim settings
638
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
     3
// set tabstop=4          " number of spaces in a tab
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
     4
// set softtabstop=4      " as above
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
     5
// set shiftwidth=4       " as above
627
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
     6
638
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
     7
/**
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
     8
 * Constants and variables
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
     9
 */
627
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
    10
646
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
    11
var test_comt = { text_nb: 0, user_nb: 4, long_text: '' };
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
    12
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
    13
for (var i = 20; i--;)
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
    14
    test_comt.long_text += 'Contenu du troisième texte.<br/>Sur <b>plusieurs</b> lignes<br/>';
638
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
    15
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
    16
const C = { 'HIDDEN': false,
641
8f7dafe42d15 Refine user list tests
Simon Descarpentries <sid@sopinspace.com>
parents: 638
diff changeset
    17
	'H': false,
638
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
    18
	'NO_TAGLINE': false,
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
    19
	'WAIT_PAGE_LOAD': true,
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
    20
	'W': __karma__.config.W,
627
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
    21
	'#id_workspace_name':	'Test workspace name',
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
    22
	'#id_workspace_tagline':	'Test workspace tagline',
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
    23
	'#id_workspace_registration':			'on',	// registration
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
    24
	'#id_workspace_registration_moderation':'on',	// registration moderation
638
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
    25
	'#id_workspace_role_model': 'generic',
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
    26
	'#id_workspace_category_1': 'ws_cat_1',
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
    27
	'#id_workspace_category_2': 'ws_cat_2',
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
    28
	'#id_workspace_category_3': 'ws_cat_3',
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
    29
	'#id_workspace_category_4': 'ws_cat_4',
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
    30
	'#id_workspace_category_5': 'ws_cat_5',
627
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
    31
	'#id_custom_css': "h2 {  font-family: Test_Sopinspace !important; }",
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
    32
	'#id_custom_font': 'Test_Sopinspace_custom_font',
646
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
    33
	'#id_custom_titles_font': 'Test_Sopinspace_custom_titles_font',
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
    34
	'TEXTS': [
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
    35
	    {
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
    36
	        '#id_title':    'Text One Sopinspace-Test éléguant',
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
    37
	        '#id_format':   'markdown',
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
    38
	        '#id_content':  'Contenu du premier texte.\nSur plusieurs lignes\nPour tester un cas réaliste',
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
    39
	        '#id_tags':     'test_text, Text Premier'
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
    40
	    },
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
    41
	    {
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
    42
	        '#id_title':    'Text Two Sopinspace-Test éléguant',
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
    43
	        '#id_format':   'rst',
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
    44
	        '#id_content':  'Contenu du deuxième texte.\nSur plusieurs lignes aussi\nPour tester un cas réaliste',
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
    45
	        '#id_tags':     'test_text, Text Second'
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
    46
	    },
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
    47
	    {
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
    48
	        '#id_title':    'Text Three Sopinspace-Test éléguant',
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
    49
    	    '#id_format':   'html',
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
    50
	        '#id_content':  test_comt.long_text,
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
    51
	        '#id_tags':     'test_text, Text Troisième'
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
    52
	    }
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
    53
	],
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
    54
	'USERS': [
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
    55
	    {}, // to start counting at one
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
    56
		// SID roles should be : '', 4, 2, 5 ; but we're facing a bug here 
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
    57
	    { name: 'admin',        email: 'admin@mail.com',            date:'March 8, 2014 at 3:12 p.m.', role:'' },
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
    58
	    { name: 'user-com',     email: 'user-com@example.com',      date:'March 9, 2014 at 2:40 p.m.', role:'5'},
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
    59
    	{ name: 'user-edit',    email: 'user-edit@example.com',     date:'March 9, 2014 at 2:40 p.m.', role:'5'},
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
    60
	    { name: 'user-observ',  email: 'user-observ@example.com',   date:'March 9, 2014 at 2:40 p.m.', role:'5'},
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
    61
	    { '#id_tags': 'user-created-1',   '#id_email': 'uc1@example.com',   '#id_role':'2'},
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
    62
	    { '#id_tags': 'user-created-2',   '#id_email': 'uc2@example.com',   '#id_role':'4'}
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
    63
	]
627
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
    64
};
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
    65
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
    66
638
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
    67
/**
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
    68
 * COMT test API
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
    69
 */
627
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
    70
638
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
    71
function test_comt_login (user, pass) {
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
    72
	test ('with '+user+' - '+pass, dsl(function () {
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
    73
		browser.navigateTo ('/');
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
    74
		input ('#id_username').enter (user);
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
    75
		input ('#id_password').enter (pass);
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
    76
		elt ('#login input[type=submit]').click ();
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
    77
		browser.waitForPageLoad (); // Must be done here in this test() block
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
    78
		browser.navigateTo ('/');
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
    79
		expect (element ('title').text ()).toMatch (/Dashboard/m);
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
    80
	}));
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
    81
}
627
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
    82
638
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
    83
function test_comt_logout () {
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
    84
	test_page_loading ('/logout/', 'Home - '+C['#id_workspace_name']);
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
    85
};
627
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
    86
638
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
    87
function test_comt_create_text (t) {
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
    88
	test_page_loading	('/create/content/', 'Create a text - '+C['#id_workspace_name']);
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
    89
	test ('test creation', dsl(function () {
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
    90
		dropdownlist ('#id_format').option (t['#id_format']);
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
    91
	}));
627
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
    92
638
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
    93
	test_fill_field ('#id_title', t);
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
    94
	test ('fill content', dsl(function (){
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
    95
		elt ('#id_content').val (t['#id_content']);
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
    96
	}));
627
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
    97
638
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
    98
	test_fill_field ('#id_tags', t);
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
    99
	test_click	 ('#save_button', C.WAIT_PAGE_LOAD);
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
   100
	test_comt.text_nb++;
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
   101
}
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
   102
646
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
   103
function test_comt_create_user (u) {
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
   104
    test_page_loading   ('/user/add/', 'Add a new user\n - '+C['#id_workspace_name']);
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
   105
	test_fill_field ('#id_email', u);
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
   106
	test_fill_field ('#id_tags', u);
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
   107
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
   108
    test ('test creation', dsl(function () {
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
   109
        dropdownlist ('#id_role').option (u['#id_role']);
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
   110
    }));
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
   111
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
   112
    test_click   ('#user input[type="submit"]', C.WAIT_PAGE_LOAD);
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
   113
    test_comt.user_nb++;
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
   114
}
24067001082c Test user list, creation, filter, and in a separate file
Simon Descarpentries <sid@sopinspace.com>
parents: 641
diff changeset
   115
627
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
   116
638
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
   117
/**
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
   118
 * Other factorized tests
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
   119
 */
627
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
   120
638
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
   121
627
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
   122
638
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
   123
function test_comt_default_tabs (txt_nb, usr_nb) {
627
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
   124
	test_count	('#main-tabs a', 5);
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
   125
	test_text	('#main-tabs li:nth-of-type(1) a[href="/"]',			'Dashboard');
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
   126
	test_match	('#main-tabs li:nth-of-type(2) a[href="/text/"]',		/^Texts \(\d+\) $/);
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
   127
	test_match	('#main-tabs li:nth-of-type(3) a[href="/user/"]',		/^People  \(\d+\)$/);
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
   128
	test_text	('#main-tabs li:nth-of-type(4) a[href="/settings/"]',	'Settings');
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
   129
	test_text	('#main-tabs li:nth-of-type(5) a[href="/followup/"]',	'Followup');
638
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
   130
	test_match	('#main-tabs a[href="/text/"]', new RegExp ('^Texts\\s*\\('+txt_nb+'\\)\\s*$'));
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
   131
	test_match	('#main-tabs a[href="/user/"]', new RegExp ('^People\\s*\\('+usr_nb+'\\)\\s*$'));
627
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
   132
}
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
   133
638
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
   134
function test_comt_logged_header (username, is_tagline) {
627
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
   135
	is_tagline = typeof is_tagline == 'undefined' ? true : is_tagline;
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
   136
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
   137
	test_text	('#header_controls b', username)
656
a84519031134 add link to "privacy policy" in the header test
Yves-Marie Haussonne <ymh.work+github@gmail.com>
parents: 646
diff changeset
   138
	test_count	('#header_controls a', 7);
627
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
   139
	test_text	('#header_controls a:nth-of-type(1)[href="/"]',					'Home');
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
   140
	test_text	('#header_controls a:nth-of-type(2)[href="/create/content/"]',	'Create a text');
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
   141
	test_text	('#header_controls a:nth-of-type(3)[href="/create/upload/"]',	'Upload a text');
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
   142
	test_text	('#header_controls a:nth-of-type(4)[href="/create/import/"]',	'Import a co-mented text');
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
   143
	test_text	('#header_controls a:nth-of-type(5)[href="/profile/"]',			'Profile');
656
a84519031134 add link to "privacy policy" in the header test
Yves-Marie Haussonne <ymh.work+github@gmail.com>
parents: 646
diff changeset
   144
	test_text	('#header_controls a:nth-of-type(6)#hide-piwik-cookies-optout',	'Privacy policy ');
a84519031134 add link to "privacy policy" in the header test
Yves-Marie Haussonne <ymh.work+github@gmail.com>
parents: 646
diff changeset
   145
	test_text	('#header_controls a:nth-of-type(7)[href="/logout/"]',			'Logout');
638
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
   146
	test_text	('#content h1.main_title a[href="/"]',							C['#id_workspace_name']);
627
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
   147
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
   148
	if (is_tagline) {
638
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
   149
		test_match	('#content h1.main_title  + div', new RegExp (C['#id_workspace_tagline'], 'm'));
627
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
   150
	}
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
   151
}
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
   152
638
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
   153
function test_comt_fill_settings (s) {
627
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
   154
	test_fill_field ('#id_workspace_name', s);
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
   155
	test_fill_field ('#id_workspace_tagline', s);
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
   156
	test_fill_field ('#id_workspace_registration', s);
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
   157
	test_fill_field ('#id_workspace_registration_moderation', s);
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
   158
	test_fill_field ('#id_workspace_role_model', s);
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
   159
	test_fill_field ('#id_workspace_category_1', s);
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
   160
	test_fill_field ('#id_workspace_category_2', s);
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
   161
	test_fill_field ('#id_workspace_category_3', s);
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
   162
	test_fill_field ('#id_workspace_category_4', s);
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
   163
	test_fill_field ('#id_workspace_category_5', s);
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
   164
}
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
   165
638
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
   166
function test_comt_fill_design (s) {
627
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
   167
	test_fill_field ('#id_custom_css', s);
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
   168
	test_fill_field ('#id_custom_font', s);
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
   169
	test_fill_field ('#id_custom_titles_font', s);
7d93eccbb565 Move helpers somewhere less trickier, test pagination with 12 texts
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
   170
}
638
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
   171
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
   172
/** Test if it's possible to change lang to the specified :
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
   173
 *  c : lang code
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
   174
 *  l : help label
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
   175
 */
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
   176
function test_comt_i18n (c, l) {
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
   177
    test ('to '+c, dsl(function () {
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
   178
        element ('#footer a[href="/i18n/setlang/'+c+'/"]').click ();
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
   179
        browser.navigateTo ('/');
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
   180
        expect (elt ('#footer a[href="/help/"]').text ()).toMatch (new RegExp (l, 'm'));
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
   181
    }));
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
   182
}
61dc5370b351 start building a COMT test API, automate testserver starting and stopping
Simon Descarpentries <sid@sopinspace.com>
parents: 637
diff changeset
   183