-
Notifications
You must be signed in to change notification settings - Fork 38
/
tests.html
144 lines (128 loc) · 5.41 KB
/
tests.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
<!DOCTYPE html>
<html>
<head>
<title>jDrupal</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<link rel="stylesheet" type='text/css' href="http://code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.min.css" />
<link rel='stylesheet' type='text/css' href='http://code.jquery.com/qunit/qunit-1.12.0.css' />
<script src="http://code.jquery.com/jquery-1.9.1.min.js"></script>
<script src="http://code.jquery.com/mobile/1.4.0/jquery.mobile-1.4.0.min.js"></script>
<script type='text/javascript' src='http://code.jquery.com/qunit/qunit-1.12.0.js'></script>
<script src="jdrupal.min.js"></script>
<script type="text/javascript">
jDrupal.settings = {
sitePath: 'http://localhost/d8', // The path to your Drupal site, for example: http://www.example.com
basePath: '/'
};
</script>
<!-- include tests -->
<script src="tests/services.comment.test.js"></script>
<script src="tests/services.node.test.js"></script>
<script src="tests/services.system.test.js"></script>
<script src="tests/services.taxonomy_term.test.js"></script>
<script src="tests/services.taxonomy_vocabulary.test.js"></script>
<script src="tests/services.user.test.js"></script>
</head>
<body>
<div data-role="page" id="jdrupal">
<div data-role="header">
<h1>jDrupal</h1>
</div><!-- header -->
<div data-role="content" class='content'>
<div data-role="fieldcontain">
<label for="site_path">Drupal Path</label>
<input type="text" id="site_path" value="" />
</div>
<div data-role="fieldcontain" id="login_name_wrapper" style="display: none;">
<label for="login_name">Username</label>
<input type="text" id="login_name" value="" />
</div>
<div data-role="fieldcontain" id="login_pass_wrapper" style="display: none;">
<label for="login_pass">Password</label>
<input type="password" id="login_pass" />
</div>
<fieldset>
<div><button type="submit" id="go">Connect</button></div>
<div><button type="submit" id="login" style="display: none;">Login</button></div>
<div><button type="submit" id="logout" style="display: none;">Logout</button></div>
<div><button type="submit" id="run_tests" style="display: none;">Run Tests</button></div>
</fieldset>
<div id="qunit"></div>
<ol id="qunit-tests"></ol>
<div id="qunit-fixture"></div>
</div><!-- /content -->
</div><!-- /page -->
<script type="text/javascript">
$().ready(function() {
$('#site_path').val(jDrupal.sitePath());
$('#go').on('click', function(){
set_drupal_settings();
if (jDrupal.sitePath() == '') {
alert('Enter a site path!');
return false;
}
jDrupal.connect().then(function() {
var account = jDrupal.currentUser();
var uid = account.id();
$('#login_name_wrapper').show('slow');
$('#login_pass_wrapper').show('slow');
if (uid != '0') {
$('#login_name').val(account.getAccountName());
$('#logout').show();
$('#go').hide();
if (uid == '1') {
$('#run_tests').show('slow');
}
else {
alert('Only user #1 can perform tests, your are user # ' + uid + '!');
}
}
else {
$('#login').show('slow');
$('#go').hide();
}
});
return false;
});
$('#login').on('click', function(){
set_drupal_settings();
jDrupal.userLogin($('#login_name').val(), $('#login_pass').val()).then(function() {
$('#login').hide();
$('#logout').show('slow');
$('#run_tests').show('slow');
});
return false;
});
$('#logout').on('click', function(){
jDrupal.userLogout().then(function() {
$('#login').show('slow');
$('#run_tests').hide();
$('#logout').hide();
$('#login_pass').val('');
});
return false;
});
function set_drupal_settings() {
jDrupal.settings.sitePath = $('#site_path').val();
}
$('#run_tests').on('click', function(){
var account = jDrupal.currentUser();
if (account.id() != 1) {
alert('Only user #1 can run tests!');
return;
}
if (jDrupal.isEmpty($('#login_pass').val())) {
alert('Enter password to run tests!');
return;
}
set_drupal_settings();
test_services_system();
// this call iterates through other tests
test_services_user($('#login_name').val(), $('#login_pass').val());
return false;
});
});
</script>
</body>
</html>