src/cm/scripts/test-suite/tests/tests.js
author Simon Descarpentries <sid@sopinspace.com>
Thu, 06 Mar 2014 19:04:47 +0100
changeset 594 daf4516b022d
parent 583 084934fe912e
child 598 fd0507590413
permissions -rw-r--r--
Set and restore settings during test suite
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
575
8ce80860c3fe Add the skeleton of the future comt test-suite
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
     1
577
65fab7b5ce5e Add 1st tests of login page congruency
Simon Descarpentries <sid@sopinspace.com>
parents: 575
diff changeset
     2
// try to login
65fab7b5ce5e Add 1st tests of login page congruency
Simon Descarpentries <sid@sopinspace.com>
parents: 575
diff changeset
     3
65fab7b5ce5e Add 1st tests of login page congruency
Simon Descarpentries <sid@sopinspace.com>
parents: 575
diff changeset
     4
// create texts and co-ments
65fab7b5ce5e Add 1st tests of login page congruency
Simon Descarpentries <sid@sopinspace.com>
parents: 575
diff changeset
     5
// collect newly created URLs
65fab7b5ce5e Add 1st tests of login page congruency
Simon Descarpentries <sid@sopinspace.com>
parents: 575
diff changeset
     6
578
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
     7
// Get workspace name, public texts…
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
     8
577
65fab7b5ce5e Add 1st tests of login page congruency
Simon Descarpentries <sid@sopinspace.com>
parents: 575
diff changeset
     9
// unlog
65fab7b5ce5e Add 1st tests of login page congruency
Simon Descarpentries <sid@sopinspace.com>
parents: 575
diff changeset
    10
65fab7b5ce5e Add 1st tests of login page congruency
Simon Descarpentries <sid@sopinspace.com>
parents: 575
diff changeset
    11
// check that public texts still work while unlogged
578
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
    12
// check that non public texts are unavailable
577
65fab7b5ce5e Add 1st tests of login page congruency
Simon Descarpentries <sid@sopinspace.com>
parents: 575
diff changeset
    13
578
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
    14
// Is the workspace name correctly displayed ? 
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
    15
// Are the public texts displayed in the login page ?
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
    16
594
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
    17
var w = __karma__.config.w,
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
    18
	z = {};
583
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
    19
const non_visible = false;
594
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
    20
const t = {
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
    21
	'#id_workspace_name':	'Test workspace name',
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
    22
	'#id_workspace_tagline':	'Test workspace tagline',
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
    23
	'#id_workspace_registration':		'on',		// registration
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
    24
	'#id_workspace_registration_moderation':	'on',		// registration moderation
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
    25
	'#id_workspace_role_model':	'generic',
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
    26
	'#id_workspace_category_1':	'ws_cat_1',
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
    27
	'#id_workspace_category_2':	'ws_cat_2',
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
    28
	'#id_workspace_category_3':	'ws_cat_3',
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
    29
	'#id_workspace_category_4':	'ws_cat_4',
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
    30
	'#id_workspace_category_5':	'ws_cat_5'
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
    31
};
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
    32
578
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
    33
579
869f02c75687 daily progress : suite/test style, config from single config file, attempt to test i18n in footer
Simon Descarpentries <sid@sopinspace.com>
parents: 578
diff changeset
    34
suite ('comt', function () {
575
8ce80860c3fe Add the skeleton of the future comt test-suite
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
    35
8ce80860c3fe Add the skeleton of the future comt test-suite
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
    36
	this.timeout(150000);
8ce80860c3fe Add the skeleton of the future comt test-suite
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
    37
579
869f02c75687 daily progress : suite/test style, config from single config file, attempt to test i18n in footer
Simon Descarpentries <sid@sopinspace.com>
parents: 578
diff changeset
    38
	suite ('contact page', function () {
869f02c75687 daily progress : suite/test style, config from single config file, attempt to test i18n in footer
Simon Descarpentries <sid@sopinspace.com>
parents: 578
diff changeset
    39
		test_page_loading ('/contact/', 'Contact');
869f02c75687 daily progress : suite/test style, config from single config file, attempt to test i18n in footer
Simon Descarpentries <sid@sopinspace.com>
parents: 578
diff changeset
    40
		test_unlogged_header ();
583
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
    41
		test_val	('form#profile[action="."]'); // the form exists
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
    42
		test_count	('form#profile :input', 7); // it has no more than 5 labels (may be no more fields)
582
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
    43
		test_form_field ('profile', 'id_name', 'text', 0, 'Your name', true); // the field id_name is…
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
    44
		test_form_field ('profile', 'id_email', 'text', 1, 'Your email address', true);
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
    45
		test_form_field ('profile', 'id_title', 'text', 2, 'Subject of the message', true);
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
    46
		test_form_field ('profile', 'id_body', 'textarea', 3, 'Body of the message', true);
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
    47
		test_form_field ('profile', 'id_copy', 'checkbox', 4, 'Send me a copy of the email', false);
583
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
    48
		test_val	('#profile input[type=submit]','Send'); // test that a the .val() of the element is
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
    49
		test_val	('input#cancel_button[type=button]', 'Cancel');
581
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
    50
		test_unlogged_footer ();
583
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
    51
		test		('to check that toBeDefined test still works', dsl(function () {
581
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
    52
			expect (elt ('#header_controls a[href="/xxx/"]').val ()).not ().toBeDefined ();
577
65fab7b5ce5e Add 1st tests of login page congruency
Simon Descarpentries <sid@sopinspace.com>
parents: 575
diff changeset
    53
		}));
583
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
    54
		test		('get back to / to avoid bugging next page load', dsl(function () {
579
869f02c75687 daily progress : suite/test style, config from single config file, attempt to test i18n in footer
Simon Descarpentries <sid@sopinspace.com>
parents: 578
diff changeset
    55
			browser.navigateTo ('/');
869f02c75687 daily progress : suite/test style, config from single config file, attempt to test i18n in footer
Simon Descarpentries <sid@sopinspace.com>
parents: 578
diff changeset
    56
		}));
578
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
    57
	});
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
    58
579
869f02c75687 daily progress : suite/test style, config from single config file, attempt to test i18n in footer
Simon Descarpentries <sid@sopinspace.com>
parents: 578
diff changeset
    59
	suite ('help page', function () {
869f02c75687 daily progress : suite/test style, config from single config file, attempt to test i18n in footer
Simon Descarpentries <sid@sopinspace.com>
parents: 578
diff changeset
    60
		test_page_loading ('/help/', 'Help');
869f02c75687 daily progress : suite/test style, config from single config file, attempt to test i18n in footer
Simon Descarpentries <sid@sopinspace.com>
parents: 578
diff changeset
    61
		test_unlogged_header ();
869f02c75687 daily progress : suite/test style, config from single config file, attempt to test i18n in footer
Simon Descarpentries <sid@sopinspace.com>
parents: 578
diff changeset
    62
		test_unlogged_footer ();
869f02c75687 daily progress : suite/test style, config from single config file, attempt to test i18n in footer
Simon Descarpentries <sid@sopinspace.com>
parents: 578
diff changeset
    63
	});
578
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
    64
579
869f02c75687 daily progress : suite/test style, config from single config file, attempt to test i18n in footer
Simon Descarpentries <sid@sopinspace.com>
parents: 578
diff changeset
    65
	suite ('reset password page', function () {
869f02c75687 daily progress : suite/test style, config from single config file, attempt to test i18n in footer
Simon Descarpentries <sid@sopinspace.com>
parents: 578
diff changeset
    66
		test_page_loading ('/password_reset/', 'Reset my password');
869f02c75687 daily progress : suite/test style, config from single config file, attempt to test i18n in footer
Simon Descarpentries <sid@sopinspace.com>
parents: 578
diff changeset
    67
		test_unlogged_header ();
583
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
    68
		test_val	('form#profile[action="."]');
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
    69
		test_count	('form#profile :input', 3);
582
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
    70
		test_form_field ('profile', 'id_email', 'text', 1, 'E-mail', true);
583
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
    71
		test_val	('#profile input[type=submit]', 'Reset my password');
579
869f02c75687 daily progress : suite/test style, config from single config file, attempt to test i18n in footer
Simon Descarpentries <sid@sopinspace.com>
parents: 578
diff changeset
    72
		test_unlogged_footer ();
578
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
    73
	});
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
    74
579
869f02c75687 daily progress : suite/test style, config from single config file, attempt to test i18n in footer
Simon Descarpentries <sid@sopinspace.com>
parents: 578
diff changeset
    75
	suite ('login page', function () {
869f02c75687 daily progress : suite/test style, config from single config file, attempt to test i18n in footer
Simon Descarpentries <sid@sopinspace.com>
parents: 578
diff changeset
    76
		test_page_loading ('/', 'Home');
869f02c75687 daily progress : suite/test style, config from single config file, attempt to test i18n in footer
Simon Descarpentries <sid@sopinspace.com>
parents: 578
diff changeset
    77
		test_unlogged_header ();
583
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
    78
		test_val	('form#login[action="/login/"]');
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
    79
		test_count	('form#login[action="/login/"] :input', 3);
582
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
    80
		test_form_field ('login', 'id_username', 'text', 0, 'Username', true);
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
    81
		test_form_field ('login', 'id_password', 'password', 1, 'Password', true);
581
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
    82
		test_val ('form#login input[type=submit]', 'Login');
583
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
    83
		test_text	('form#login a[href="/password_reset/"]', 'Forgot password?');
579
869f02c75687 daily progress : suite/test style, config from single config file, attempt to test i18n in footer
Simon Descarpentries <sid@sopinspace.com>
parents: 578
diff changeset
    84
		test_unlogged_footer ();
581
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
    85
		// test_i18n ();
583
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
    86
		test		('logs an admin in', dsl(function () {
579
869f02c75687 daily progress : suite/test style, config from single config file, attempt to test i18n in footer
Simon Descarpentries <sid@sopinspace.com>
parents: 578
diff changeset
    87
			input ('#id_username').enter (w.USER_ADMIN);
869f02c75687 daily progress : suite/test style, config from single config file, attempt to test i18n in footer
Simon Descarpentries <sid@sopinspace.com>
parents: 578
diff changeset
    88
			input ('#id_password').enter (w.PASS_ADMIN);
578
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
    89
			elt ('#login input[type=submit]').click ();
579
869f02c75687 daily progress : suite/test style, config from single config file, attempt to test i18n in footer
Simon Descarpentries <sid@sopinspace.com>
parents: 578
diff changeset
    90
			// Must be done here in this test() block
578
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
    91
			browser.waitForPageLoad ();
575
8ce80860c3fe Add the skeleton of the future comt test-suite
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
    92
			browser.navigateTo ('/');
577
65fab7b5ce5e Add 1st tests of login page congruency
Simon Descarpentries <sid@sopinspace.com>
parents: 575
diff changeset
    93
			expect (element ('title').text ()).toMatch (/Dashboard/m);
575
8ce80860c3fe Add the skeleton of the future comt test-suite
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
    94
		}));
8ce80860c3fe Add the skeleton of the future comt test-suite
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
    95
	});
578
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
    96
579
869f02c75687 daily progress : suite/test style, config from single config file, attempt to test i18n in footer
Simon Descarpentries <sid@sopinspace.com>
parents: 578
diff changeset
    97
	suite ('admin dashboard', function () {
869f02c75687 daily progress : suite/test style, config from single config file, attempt to test i18n in footer
Simon Descarpentries <sid@sopinspace.com>
parents: 578
diff changeset
    98
		// Should starts with :
581
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
    99
		// test_page_loading ('/', 'Dashboard');
579
869f02c75687 daily progress : suite/test style, config from single config file, attempt to test i18n in footer
Simon Descarpentries <sid@sopinspace.com>
parents: 578
diff changeset
   100
		// But its the last thing we did in the previous test
869f02c75687 daily progress : suite/test style, config from single config file, attempt to test i18n in footer
Simon Descarpentries <sid@sopinspace.com>
parents: 578
diff changeset
   101
		test_logged_header (w.USER_ADMIN);
583
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   102
		test ('get text and user nb', dsl(function () {
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   103
			element ('span.metadata:eq(0)').text (function (metadata) {
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   104
				var r = metadata.match (/(\d+) texts, (\d+) users/);
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   105
				if (r.length != 3) throw 'expected 3 matches got '+r.length;
594
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   106
				z.text_nb = r[1];
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   107
				z.user_nb = r[2];
583
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   108
			});
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   109
		}));
581
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   110
		test_default_tabs ();
582
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
   111
		test_count	('table.dash_table', 5);
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
   112
		test_text	('table.dash_table th:eq(0)', 'Actions');
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
   113
		test_match	('table.dash_table:eq(0) a:eq(0)[href="/create/content/"]', /\sCreate a text/);
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
   114
		test_text	('table.dash_table:eq(0) a:eq(1).tip[href="#"]', ' ');
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
   115
		test_match	('table.dash_table:eq(0) a:eq(2)[href="/create/upload/"]', /\sUpload a text/);
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
   116
		test_text	('table.dash_table:eq(0) a:eq(3).tip[href="#"]', ' ');
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
   117
		test_match	('table.dash_table:eq(0) a:eq(4)[href="/create/import/"]', /\sImport a co-mented text/);
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
   118
		test_text	('table.dash_table:eq(0) a:eq(5).tip[href="#"]', ' ');
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
   119
		test_match	('table.dash_table:eq(0) a:eq(6)[href="/user/add/"]', /\sInvite user/);
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
   120
		test_match	('table.dash_table:eq(0) a:eq(7)[href="/profile/"]', /\sEdit your profile/);
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
   121
		test_match	('table.dash_table:eq(0) a:eq(8)[href="/text/"]', /\sView text list/);
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
   122
		test_match	('table.dash_table:eq(0) a:eq(9)[href="/settings/"]', /\sConfigure workspace/);
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
   123
		test_text	('table.dash_table th:eq(1)', 'Recent texts (all)');
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
   124
		test_text	('table.dash_table:eq(1) a:eq(0)[href="/text/"]', 'all');
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
   125
		test_text	('table.dash_table th:eq(2)', 'Recent comments');
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
   126
		test_match	('table.dash_table th:eq(3)', /^Workspace activity\n\s+\(month\/week\/24 hours\)$/m);
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
   127
		test_text	('table.dash_table:eq(3) a:eq(0)[href="?span=month"]', 'month');
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
   128
		test_text	('table.dash_table:eq(3) a:eq(1)[href="?span=day"]', '24 hours');
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
   129
		test_text	('table.dash_table th:eq(4) span.em', 'Activities');
579
869f02c75687 daily progress : suite/test style, config from single config file, attempt to test i18n in footer
Simon Descarpentries <sid@sopinspace.com>
parents: 578
diff changeset
   130
		test_unlogged_footer ();
578
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
   131
	});
582
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
   132
583
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   133
	suite ('texts list', function () {
594
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   134
		test_page_loading	('/text/', 'Texts');
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   135
		test_logged_header	(w.USER_ADMIN);
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   136
		test_default_tabs	();
583
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   137
		test_count	('#text ul.sub_list:eq(0) a', 3);
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   138
		test_text	('#text ul.sub_list:eq(0) a:eq(0)[href="/create/content/"]', 'Create a text');
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   139
		test_text	('#text ul.sub_list:eq(0) a:eq(1)[href="/create/upload/"]', 'Upload a text');
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   140
		test_text	('#text ul.sub_list:eq(0) a:eq(2)[href="/create/import/"]', 'Import a co-mented text');
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   141
		// TOTEST : filter by tag
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   142
		test_count	('form#filter_form[action="."] :input', 1);
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   143
		test_text	('select#tag_selected option:eq(0)[selected][value="0"]', '- All -', non_visible);
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   144
		test		('#texts_form input count', dsl (function () {
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   145
			elt ('form#texts_form[action="."] :input').count (function (c) {
594
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   146
				var n = 3 + z.text_nb % 10;
583
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   147
				if (c != n) throw 'expected computed '+n+' to equal got '+c;
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   148
			});
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   149
		}));
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   150
		test		('#paginator "of #" value', dsl (function () {
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   151
			elt ('span#paginator').text (function (t) {
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   152
				var r = t.match (/\s\d+-\d+ of (\d+)\s/m);
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   153
				if (r.length != 2) throw 'expected 2 matches got '+r.length;
594
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   154
				if (r[1] != z.text_nb) throw 'expected paginator total ('+r[1]+') to be '+z.text_nb;
583
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   155
			});
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   156
		}));
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   157
		// TOTEST : pagination
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   158
		// TOTEST : Bulk Actions -> Apply does enable
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   159
		test_text	('select#bulk_actions option:eq(0)[selected][value="-1"]', 'Bulk Actions', non_visible);
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   160
		test_text	('select#bulk_actions option:eq(1)[value="delete"]', 'Delete', non_visible);
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   161
		test_val	('form#texts_form input#apply[type=button][disabled]', 'Apply');
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   162
		test_count	('table.large_table:eq(1) th', 6);
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   163
		test_val	('table.large_table:eq(1) th:eq(0) input#all_check[type="checkbox"]', 'on');
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   164
		test_text	('table.large_table:eq(1) th:eq(1) a[href="?order=title"]', 'Text');
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   165
		test_text	('table.large_table:eq(1) th:eq(2)', 'Author');
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   166
		test_text	('table.large_table:eq(1) th:eq(3) a[href="?order=-modified"]', 'Modified');
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   167
		test_text	('table.large_table:eq(1) th:eq(4)', '# comments');
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   168
		test_text	('table.large_table:eq(1) th:eq(5)', 'Last week activity');
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   169
		test_unlogged_footer ();
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   170
	});
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   171
594
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   172
    suite ('people list', function () {
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   173
        test_page_loading	('/user/', 'People');
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   174
        test_logged_header	(w.USER_ADMIN);
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   175
        test_default_tabs	();
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   176
        test_count  ('#user ul.sub_list:eq(0) a', 2);
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   177
        test_text   ('#user ul.sub_list:eq(0) a:eq(0)[href="/user/add/"]', 'Add a new user');
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   178
        test_text   ('#user ul.sub_list:eq(0) a:eq(1)[href="/user/mass-add/"]', 'Add users in bulk');
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   179
        // TOTEST : filter by tag
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   180
        test_count  ('form#filter_form[action="."] :input', 1);
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   181
		test_text	('#filter_form a[href="?display=1"]', 'Display suspended users');
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   182
        test_text   ('select#tag_selected option:eq(0)[selected][value="0"]', '- All -', non_visible);
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   183
        test        ('#user_form input count', dsl (function () {
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   184
            elt ('form#user_form[action="."] :input').count (function (c) {
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   185
                var n = 6 + (z.user_nb % 10) * 2;
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   186
                if (c != n) throw 'expected computed '+n+' to equal got '+c;
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   187
            });
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   188
        }));
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   189
        test        ('#paginator "of #" value', dsl (function () {
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   190
            elt ('span#paginator').text (function (t) {
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   191
                var r = t.match (/\s\d+-\d+ of (\d+)\s/m);
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   192
                if (r.length != 2) throw 'expected 2 matches got '+r.length;
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   193
                if (r[1] != z.user_nb) throw 'expected paginator total ('+r[1]+') to be '+z.user_nb;
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   194
            });
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   195
        }));
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   196
        // TOTEST : pagination
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   197
        // TOTEST : Bulk Actions -> Apply does enable
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   198
        test_text   ('select#bulk_actions option:eq(0)[selected][value="-1"]', '- Bulk Actions -', non_visible);
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   199
        test_text   ('select#bulk_actions option:eq(1)[value="disable"]', 'Suspend access', non_visible);
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   200
        test_text   ('select#bulk_actions option:eq(2)[value="enable"]', 'Enable access', non_visible);
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   201
        test_text   ('select#bulk_actions option:eq(3)[value="role_1"]', 'Change role to Manager', non_visible);
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   202
        test_text   ('select#bulk_actions option:eq(4)[value="role_2"]', 'Change role to Editor', non_visible);
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   203
        test_text   ('select#bulk_actions option:eq(5)[value="role_3"]', 'Change role to Moderator', non_visible);
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   204
        test_text   ('select#bulk_actions option:eq(6)[value="role_4"]', 'Change role to Commentator', non_visible);
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   205
        test_text   ('select#bulk_actions option:eq(7)[value="role_5"]', 'Change role to Observer', non_visible);
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   206
        test_val    ('form#user_form input#apply[type=button][disabled]', 'Apply');
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   207
        test_count  ('table.large_table:eq(1) th', 6);
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   208
        test_val    ('table.large_table:eq(1) th:eq(0) input#all_check[type="checkbox"]', 'on');
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   209
        test_text   ('table.large_table:eq(1) th:eq(1) a[href="?order=user__username"]', 'User');
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   210
        test_text   ('table.large_table:eq(1) th:eq(2) a[href="?order=user__email"]', 'Email');
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   211
        test_text   ('table.large_table:eq(1) th:eq(3) a[href="?order=-user__date_joined"]', 'Date joined');
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   212
        test_text   ('table.large_table:eq(1) th:eq(4) a[href="?order=role__name"]', 'Role');
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   213
        test_text   ('table.large_table:eq(1) th:eq(5)', 'Last week activity');
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   214
		test_text	('table.large_table:eq(1) tr:last a[href="/user/-/edit/"]', 'Anonymous users');
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   215
		test_text	('table.large_table:eq(1) a.main_object_title[href="/profile/"]', w.USER_ADMIN);
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   216
		test_text	('table.large_table:eq(1) div.hidden-user-actions a[href="/profile/"]', 'Your profile');
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   217
        test_unlogged_footer ();
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   218
    });
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   219
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   220
	suite ('settings conformity', function () {
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   221
        test_page_loading	('/settings/', 'Settings');
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   222
		test_logged_header	(w.USER_ADMIN);
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   223
		test_default_tabs	();
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   224
        test_count  ('#settings ul.sub_list:eq(0) a', 1);
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   225
        test_text   ('#settings ul.sub_list:eq(0) a:eq(0)[href="/settings/design/"]', 'Appearance');
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   226
        test_count  ('#settings form[action="."]:eq(0) :input', 12);
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   227
		test_form_field ('settings', 'id_workspace_name', 'text', 0, 'Workspace name');
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   228
		test_form_field ('settings', 'id_workspace_tagline', 'text', 1, 'Workspace tagline');
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   229
		test_form_field ('settings', 'id_workspace_registration', 'checkbox', 2, 'Workspace registration');
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   230
		test_form_field ('settings', 'id_workspace_registration_moderation', 'checkbox', 3, 'Workspace registration moderation');
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   231
		test_form_field ('settings', 'id_workspace_role_model', 'select', 4, 'Role model');
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   232
        test_text   ('select#id_workspace_role_model option:eq(0)[selected][value="generic"]', 'Generic', non_visible);
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   233
        test_text   ('select#id_workspace_role_model option:eq(1)[value="teacher"]', 'Class (education)', non_visible);
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   234
		test_form_field ('settings', 'id_workspace_category_1', 'text', 5, 'Label for the first category of comments');
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   235
		test_form_field ('settings', 'id_workspace_category_2', 'text', 6, 'Label for the second category of comments');
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   236
		test_form_field ('settings', 'id_workspace_category_3', 'text', 7, 'Label for the third category of comments');
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   237
		test_form_field ('settings', 'id_workspace_category_4', 'text', 8, 'Label for the fourth category of comments');
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   238
		test_form_field ('settings', 'id_workspace_category_5', 'text', 9, 'Label for the fifth category of comments');
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   239
		test_val	('#settings :input:eq(10)[type=submit]', 'Save');
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   240
		test_val	('#settings :input:eq(11)#cancel_button[type=button]', 'Cancel');
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   241
		test_unlogged_footer ();
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   242
    });
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   243
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   244
	suite ('settings reading', function () {
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   245
		test_readz_field ('#id_workspace_name');
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   246
		test_readz_field ('#id_workspace_tagline');
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   247
		test_readz_field ('#id_workspace_registration');
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   248
		test_readz_field ('#id_workspace_registration_moderation');
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   249
		test_readz_field ('#id_workspace_role_model');
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   250
		test_readz_field ('#id_workspace_category_1');
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   251
		test_readz_field ('#id_workspace_category_2');
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   252
		test_readz_field ('#id_workspace_category_3');
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   253
		test_readz_field ('#id_workspace_category_4');
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   254
		test_readz_field ('#id_workspace_category_5');
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   255
/*		test ('display z', dsl(function () {
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   256
			elt ('#main-tabs').text (function (t) {
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   257
				console.log ('z '+JSON.stringify(z));
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   258
			});
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   259
		}));*/
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   260
    });
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   261
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   262
	suite ('settings restoration', function () {
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   263
		test_fill_settings (t);
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   264
		test_val ('#id_workspace_name', t['#id_workspace_name']);
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   265
		test ('Save test settings ', dsl (function () {
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   266
			elt ('#settings input[type="submit"]').click ();
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   267
			browser.waitForPageLoad ();
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   268
		}));
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   269
        test_page_loading	('/settings/', 'Settings');
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   270
		test_text ('#content h1.main_title a[href="/"]', t['#id_workspace_name']);
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   271
    });
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   272
582
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
   273
	suite ('followup', function () {
594
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   274
		test_page_loading	('/followup/', 'Followup');
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   275
		test_logged_header	(w.USER_ADMIN);
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   276
		test_default_tabs	();
582
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
   277
		test_text	('#followup a:eq(0)[href="/help/#public_private_feed"]', '?');
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
   278
		test_match	('#followup a:eq(1)[href$="/feed/"]', new RegExp (w.WORKSPACE_URL+'feed/', 'm'));
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
   279
		test_text	('#followup a:eq(2)[href="/help/#public_private_feed"]', '?');
583
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   280
		test_count	('form#followup_form[action="."] :input', 3);
582
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
   281
		test_val	('form#followup_form input[type=submit]', '(Activate private feed|Reset private feed url)');
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
   282
		test_val	('form#followup_form input#workspace_notify_check[type=checkbox]', 'on');
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
   283
		test_val	('form#followup_form input#own_notify_check[type=checkbox]', 'on');
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
   284
	
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
   285
		// tester qu'une fois cliqué, le bouton à le nvo label, et qu'une adresse est disponible
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
   286
		// tester que si on reclique l'adresse est changée
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
   287
583
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   288
		test_unlogged_footer ();
582
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
   289
	});
594
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   290
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   291
	suite ('settings restoration', function () {
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   292
        test_page_loading	('/settings/', 'Settings');
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   293
		test_fill_settings (z);
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   294
		test ('Restore settings ', dsl (function () {
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   295
			elt ('#settings input[type="submit"]').click ();
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   296
			browser.waitForPageLoad ();
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   297
		}));
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   298
		// next instruction must be a page loading
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   299
    });
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   300
575
8ce80860c3fe Add the skeleton of the future comt test-suite
Simon Descarpentries <sid@sopinspace.com>
parents:
diff changeset
   301
});
578
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
   302
581
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   303
function test_default_tabs () {
582
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
   304
	test_count	('#main-tabs a', 5);
583
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   305
	test_text	('#main-tabs li:nth-of-type(1) a[href="/"]',			'Dashboard');
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   306
	test_match	('#main-tabs li:nth-of-type(2) a[href="/text/"]',		/^Texts \(\d+\) $/);
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   307
	test_match	('#main-tabs li:nth-of-type(3) a[href="/user/"]',		/^People  \(\d+\)$/);
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   308
	test_text	('#main-tabs li:nth-of-type(4) a[href="/settings/"]',	'Settings');
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   309
	test_text	('#main-tabs li:nth-of-type(5) a[href="/followup/"]',	'Followup');
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   310
	test ('right tab nb', dsl(function () {
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   311
		elt ('#main-tabs a[href="/text/"]').text (function (t) {
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   312
			var r = t.match (/^Texts \((\d+)\) $/);
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   313
			if (r.length != 2) throw 'for Texts expected 2 matches got '+r.length;
594
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   314
			if (z.text_nb != r[1]) throw 'expected tab text nb ('+r[1]+') to be '+z.text_nb;
583
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   315
		});
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   316
		elt ('#main-tabs a[href="/user/"]').text (function (t) {
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   317
			var r = t.match (/^People  \((\d+)\)$/);
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   318
			if (r.length != 2) throw 'for People expected 2 matches got '+r.length;
594
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   319
			if (z.user_nb != r[1]) throw 'expected tab people nb ('+r[1]+') to be '+z.user_nb;
583
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   320
		});
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   321
	}));
581
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   322
}
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   323
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   324
function test_logged_header (username) {
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   325
	test_text	('#header_controls b', username)
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   326
	test_count	('#header_controls a', 6);
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   327
	test_text	('#header_controls a:nth-of-type(1)[href="/"]',					'Home');
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   328
	test_text	('#header_controls a:nth-of-type(2)[href="/create/content/"]',	'Create a text');
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   329
	test_text	('#header_controls a:nth-of-type(3)[href="/create/upload/"]',	'Upload a text');
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   330
	test_text	('#header_controls a:nth-of-type(4)[href="/create/import/"]',	'Import a co-mented text');
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   331
	test_text	('#header_controls a:nth-of-type(5)[href="/profile/"]',			'Profile');
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   332
	test_text	('#header_controls a:nth-of-type(6)[href="/logout/"]',			'Logout');
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   333
}
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   334
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   335
function test_unlogged_header () {
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   336
	test_count	('#header_controls a', 2);
583
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   337
	test_text	('#header_controls a[href="/"]',		'Home');
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   338
	test_text	('#header_controls a[href="/login/"]',	'Login');
581
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   339
}
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   340
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   341
function test_unlogged_footer (url) {
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   342
	test_count	('#footer a', 9);
583
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   343
	test_text	('#footer a:nth-of-type(1)[href="/contact/"]',				'Contact');
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   344
	test_match	('#footer #comentlink[href="http://www.co-ment.com"]',		/Powered by/m);
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   345
	test_text	('#footer a:nth-of-type(3)[href="/help/"]',					'Help');
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   346
	test_text	('#footer a:nth-of-type(4)[href="/i18n/setlang/fr/"]',		'Français');
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   347
	test_text	('#footer a:nth-of-type(5)[href="/i18n/setlang/no/"]',		'Norsk');
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   348
	test_text	('#footer a:nth-of-type(6)[href="/i18n/setlang/pt_BR/"]',	'Português Brasileiro');
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   349
	test_text	('#footer a:nth-of-type(7)[href="/i18n/setlang/es/"]',		'Español');
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   350
	test_text	('#footer a:nth-of-type(8)[href="/i18n/setlang/bg/"]',		'Български');
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   351
	test_text	('#footer a:nth-of-type(9)[href="/i18n/setlang/it/"]',		'Italiano');
581
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   352
}
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   353
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   354
function test_i18n () {
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   355
	test ('can change lang to french', dsl(function () {
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   356
		element ('#footer a[href="/i18n/setlang/fr/"]').click ();
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   357
//		browser.waitForPageLoad ();
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   358
//		browser.navigateTo ('/');
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   359
//		browser.reload ();
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   360
		expect (elt ('#footer a[href="/help/"]').text ()).toBe ('Aide');
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   361
		element ('#footer a[href="/i18n/setlang/en/"]').click ();
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   362
//		browser.waitForPageLoad ();
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   363
//		browser.navigateTo ('/');
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   364
	}));
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   365
}
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   366
579
869f02c75687 daily progress : suite/test style, config from single config file, attempt to test i18n in footer
Simon Descarpentries <sid@sopinspace.com>
parents: 578
diff changeset
   367
function test_page_loading (url, title) {
583
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   368
	test (url+' loads', dsl(function () {
578
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
   369
		// here we are in Karma page
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
   370
		browser.navigateTo (url);
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
   371
		expect (element ('title').text ()).toMatch (new RegExp (title,'m'));
581
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   372
		// The same test agin vaniller javascript
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   373
		element ('title').text (function (page_title) {
578
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
   374
			// here we got a value from the test iframe
581
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   375
			// to display the tested value : console.log (page_title);
578
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
   376
			if (!(new RegExp (title, 'm').test (page_title))) throw 'got page '+page_title+' instead';
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
   377
		});
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
   378
	}));
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
   379
}
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
   380
581
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   381
/** Test if the selected DOM element is defined or has a given value : .val()
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   382
 *  s : CSS selector
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   383
 *  e : expected value, if omited, test existence
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   384
 */
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   385
function test_val (s, e) {
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   386
	e = typeof e == 'undefined' ? '' : e; // .val() returns defined ? '' : undefined; // if no value
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   387
	test (s+' is '+e, dsl(function () {
582
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
   388
		expect (elt (s).val ()).toMatch (new RegExp (e, 'm'));
578
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
   389
	}));
581
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   390
}
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   391
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   392
/** Test if the selected DOM element has the given text : .text()
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   393
 *  s : CSS selector
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   394
 *  e : expected value
583
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   395
 *  v : should we test a visible value ?
581
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   396
 */
583
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   397
function test_text (s, e, v) {
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   398
	v = typeof v == 'undefined' ? true : v;
581
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   399
	test (s+' has text '+e, dsl(function () {
583
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   400
		expect (elt (s, v).text ()).toBe (e);
578
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
   401
	}));
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
   402
}
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
   403
581
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   404
/** Test if the selected DOM element .text() value match the given regexp
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   405
 *  s : CSS selector
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   406
 *  r : regexp to match
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   407
 */
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   408
function test_match (s, r) {
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   409
	test (s+' text match '+r, dsl(function () {
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   410
		expect (elt (s).text ()).toMatch (r);
578
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
   411
	}));
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
   412
}
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
   413
581
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   414
/** Count selector occurences
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   415
 *  s : CSS selector
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   416
 *  e : expected count
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   417
 */
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   418
function test_count (s, e) {
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   419
	test (s+' count is '+e, dsl(function () {
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   420
		expect (elt (s).count ()).toBe (e);
578
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
   421
	}));
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
   422
}
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
   423
581
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   424
/** Test Django form field presence
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   425
 */
582
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
   426
function test_form_field (form_id, field_id, type, position, label, mandatory) {
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
   427
	test ('has a '+label+' form field', dsl(function () {
594
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   428
		var s = '';
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   429
		switch (type) {
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   430
			case 'textarea':s = 'textarea#'+field_id; break;
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   431
			case 'select':	s = 'select#'+field_id; break;
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   432
			default:		s = 'input#'+field_id+'[type="'+type+'"]';
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   433
		}
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   434
//		var s = type == 'textarea' ? 'textarea#'+field_id : 'input#'+field_id+'[type='+type+']';
578
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
   435
		expect (elt (s).val ()).toBeDefined ();
582
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
   436
		expect (elt ('#'+form_id+' :input:eq('+position+')#'+field_id).val ()).toBeDefined ();
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
   437
		expect (elt ('label[for='+field_id+']').text ()).toBe (label);
578
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
   438
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
   439
		if (mandatory)
582
63b489ad02a3 rewritting and new tests
Simon Descarpentries <sid@sopinspace.com>
parents: 581
diff changeset
   440
			expect (elt ('label[for='+field_id+'] + span.required_star').val ()).toBeDefined ();
578
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
   441
	}));
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
   442
}
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
   443
594
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   444
function test_readz_field (field_id) {
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   445
	test ('get '+field_id, dsl(function () {
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   446
		element (field_id).val (function (v) {
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   447
			z[field_id] = v;
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   448
		});
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   449
	}));
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   450
}
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   451
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   452
function test_fill_field (field_id, stored) {
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   453
	test ('set '+field_id, dsl(function () {
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   454
		input (field_id).enter (stored[field_id]);
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   455
	}));
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   456
}
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   457
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   458
function test_fill_settings (s) {
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   459
	test_fill_field ('#id_workspace_name', s);
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   460
	test_fill_field ('#id_workspace_tagline', s);
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   461
	test_fill_field ('#id_workspace_registration', s);
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   462
	test_fill_field ('#id_workspace_registration_moderation', s);
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   463
	test_fill_field ('#id_workspace_role_model', s);
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   464
	test_fill_field ('#id_workspace_category_1', s);
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   465
	test_fill_field ('#id_workspace_category_2', s);
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   466
	test_fill_field ('#id_workspace_category_3', s);
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   467
	test_fill_field ('#id_workspace_category_4', s);
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   468
	test_fill_field ('#id_workspace_category_5', s);
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   469
}
daf4516b022d Set and restore settings during test suite
Simon Descarpentries <sid@sopinspace.com>
parents: 583
diff changeset
   470
581
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   471
/** Ensure the given element is visible
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   472
 *  s : CSS selector of the DOM element to check
583
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   473
 *  v : should the element being visible
581
d50d457e7e39 rewritting of up to 102 tests, admin dashboard conformity
Simon Descarpentries <sid@sopinspace.com>
parents: 579
diff changeset
   474
 */
583
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   475
function elt (s, v) {
084934fe912e construction de la suite de test, pages followup et Texts
Simon Descarpentries <sid@sopinspace.com>
parents: 582
diff changeset
   476
	return element (s + (v ? ':visible' : ''));
578
1793daa8df8a Add tests for other unloggedely accessible webpages
Simon Descarpentries <sid@sopinspace.com>
parents: 577
diff changeset
   477
}