gitprep / xt / basic.t /
Newer Older
430 lines | 10.148kb
added commit page test
Yuki Kimoto authored on 2013-04-27
1
use Test::More 'no_plan';
2

            
3
use FindBin;
cleanup blob and raw page an...
Yuki Kimoto authored on 2013-05-02
4
use utf8;
added commit page test
Yuki Kimoto authored on 2013-04-27
5
use lib "$FindBin::Bin/../lib";
6
use lib "$FindBin::Bin/../extlib/lib/perl5";
cleanup blob and raw page an...
Yuki Kimoto authored on 2013-05-02
7
use Encode qw/encode decode/;
added commit page test
Yuki Kimoto authored on 2013-04-27
8

            
9
use Test::Mojo;
added test
Yuki Kimoto authored on 2013-04-30
10

            
cleanup tests
Yuki Kimoto authored on 2016-04-14
11
# Data directory
fix tests
Yuki Kimoto authored on 2016-04-14
12
my $data_dir =  $ENV{GITPREP_DATA_DIR} = "$FindBin::Bin/basic";
cleanup tests
Yuki Kimoto authored on 2016-04-14
13

            
fix test and anyone can exec...
Yuki Kimoto authored on 2016-04-14
14
# You must clone "gitprep_t"
15
# cd basic/rep/kimoto
16
# git clone --bare https://github.com/yuki-kimoto/gitprep_t.git
added test
Yuki Kimoto authored on 2013-04-30
17

            
add need_login_always_option
Yuki Kimoto authored on 2013-08-21
18
$ENV{GITPREP_NO_MYCONFIG} = 1;
19

            
cleanup
Yuki Kimoto authored on 2016-04-22
20
my $app = Mojo::Server->new->load_app("$FindBin::Bin/../script/gitprep");
cleanup tests
Yuki Kimoto authored on 2016-04-14
21

            
added commit page test
Yuki Kimoto authored on 2013-04-27
22
my $t = Test::Mojo->new($app);
23

            
24
my $user = 'kimoto';
25
my $project = 'gitprep_t';
26

            
added test
Yuki Kimoto authored on 2013-04-30
27
note 'Home page';
28
{
29
  # Page access
30
  $t->get_ok('/');
31
  
32
  # Title
33
  $t->content_like(qr/GitPrep/);
34
  $t->content_like(qr/Users/);
35
  
36
  # User link
37
  $t->content_like(qr#/$user#);
38
}
39

            
40
note 'Projects page';
41
{
42
  # Page access
43
  $t->get_ok("/$user");
44
  
45
  # Title
46
  $t->content_like(qr/Repositories/);
47
  
48
  # project link
49
  $t->content_like(qr#/$user/$project#);
50
}
51

            
52
note 'Project page';
53
{
54
  # Page access
55
  $t->get_ok("/$user/$project");
56
  
57
  # Description
fix test and anyone can exec...
Yuki Kimoto authored on 2016-04-14
58
  $t->content_like(qr/Unnamed repository/);
added test
Yuki Kimoto authored on 2013-04-30
59
  
added commit datetime to pro...
Yuki Kimoto authored on 2013-05-03
60
  # Commit datetime
61
  $t->content_like(qr/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/);
62
  
added test
Yuki Kimoto authored on 2013-04-30
63
  # README
64
  $t->content_like(qr/README/);
65
  
66
  # tree directory link
67
  $t->content_like(qr#/$user/$project/tree/master/dir#);
68

            
69
  # tree file link
70
  $t->content_like(qr#/$user/$project/blob/master/README#);
71
}
72

            
added branch long name featu...
Yuki Kimoto authored on 2013-05-12
73
note 'Commit page';
improved commit page design
Yuki Kimoto authored on 2013-04-27
74
{
add diff status bar to commi...
Yuki Kimoto authored on 2013-05-30
75
  note 'first commit';
added branch long name featu...
Yuki Kimoto authored on 2013-05-12
76
  {
77
    # Page access
78
    $t->get_ok("/$user/$project/commit/4b0e81c462088b16fefbe545e00b993fd7e6f884");
79
    
80
    # Commit message
81
    $t->content_like(qr/first commit/);
82
    
83
    # Commit datetime
84
    $t->content_like(qr/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/);
85
    
86
    # Parent not eixsts
improve commit page design
Yuki Kimoto authored on 2016-02-02
87
    $t->content_like(qr/<span>0 parent/);
added branch long name featu...
Yuki Kimoto authored on 2013-05-12
88
    
89
    # Commit id
90
    $t->content_like(qr/4b0e81c462088b16fefbe545e00b993fd7e6f884/);
91
    
92
    # Author
93
    $t->content_like(qr/Yuki Kimoto/);
94
    
95
    # File change count
96
    $t->content_like(qr/1 changed files/);
97
    
98
    # Added README
99
    $t->content_like(qr/class="file-add".*?README/s);
100
    
101
    # Empty file is added
102
    $t->content_like(qr/No changes/);
improve rename commit
Yuki Kimoto authored on 2013-06-01
103
    $t->content_like(qr/class="file-add"/);
added branch long name featu...
Yuki Kimoto authored on 2013-05-12
104
  }
add diff status bar to commi...
Yuki Kimoto authored on 2013-05-30
105
  
improve rename commit
Yuki Kimoto authored on 2013-06-01
106
  note 'rename';
107
  {
108
    $t->get_ok("/$user/$project/commit/15ea9d711617abda5eed7b4173a3349d30bca959");
improve commit page design
Yuki Kimoto authored on 2016-02-02
109
    $t->content_like(qr#<span>1 parent</span>.*1b59896#s);
improve rename commit
Yuki Kimoto authored on 2013-06-01
110
    $t->content_like(qr/File renamed without changes/);
111
    $t->content_like(qr/a.txt → a_renamed.txt/);
112
    $t->content_like(qr/class="file-renamed"/);
113
  }
114
  
add test
Yuki Kimoto authored on 2013-06-01
115
  note 'add text';
116
  {
117
    $t->get_ok("/$user/$project/commit/da5b854b760351adc58d24d121070e729e80534d");
fixed blob diff line number ...
Yuki Kimoto authored on 2013-06-01
118
    $t->content_like(qr/\@\@/);
add test
Yuki Kimoto authored on 2013-06-01
119
    $t->content_like(qr/\+aaa/);
120
  }
improve rename commit
Yuki Kimoto authored on 2013-06-01
121
  
fixed blob diff line number ...
Yuki Kimoto authored on 2013-06-01
122
  note 'added aaa to a_renamed.txt for merge commit';
123
  {
124
    $t->get_ok("/$user/$project/commit/da5b854b760351adc58d24d121070e729e80534d");
125
    $t->content_like(qr/\@\@/);
126
  }
127
  
128
  note 'add image data';
129
  {
130
    $t->get_ok("/$user/$project/commit/0b6eca6a28538b1226961ca7655d2662f3522652");
131
    $t->content_like(qr/BIN/);
132
    $t->content_like(qr#/raw/0b6eca6a28538b1226961ca7655d2662f3522652/sample.png#);
133
  }
134
  
binary data not shown
Yuki Kimoto authored on 2013-06-02
135
  note 'binary data';
136
  {
137
    $t->get_ok("/$user/$project/commit/ed7b91659762fa612563f0595f3faca6aecfcfa0");
138
    $t->content_like(qr/Binary file not shown/);
139
  }
140
  
141
  note 'binary data rename';
142
  {
143
    $t->get_ok("/$user/$project/commit/3c617100f8e6d8ffe11d6c14ddf7b3646a198269");
144
    $t->content_like(qr/File renamed without changes/);
145
  }
146
  
add diff status bar to commi...
Yuki Kimoto authored on 2013-05-30
147
  note 'Branch name';
added branch long name featu...
Yuki Kimoto authored on 2013-05-12
148
  {
149
    # Page access (branch name)
150
    $t->get_ok("/$user/$project/commit/b1");
151
    $t->content_like(qr/\+bbb/);
add diff status bar to commi...
Yuki Kimoto authored on 2013-05-30
152

            
added branch long name featu...
Yuki Kimoto authored on 2013-05-12
153
    # Page access (branch name long)
154
    $t->get_ok("/$user/$project/commit/refs/heads/b1");
155
    $t->content_like(qr/\+bbb/);
156
    $t->content_like(qr#refs/heads/b1#);
157
  }
add diff status bar to commi...
Yuki Kimoto authored on 2013-05-30
158
  
improved tag and branch refe...
Yuki Kimoto authored on 2013-06-03
159
  note 'Branch and tag refernce';
160
  {
161
    $t->get_ok("/$user/$project/commit/6d71d9bc1ee3bd1c96a559109244c1fe745045de");
162
    $t->content_like(qr/b2/);
163
    $t->content_like(qr/t21/);
164
    $t->content_unlike(qr/t21\^\{\}/);
165
  }
add diff status bar to commi...
Yuki Kimoto authored on 2013-05-30
166
  
added commits page tests and...
Yuki Kimoto authored on 2013-04-29
167
}
added commit page test
Yuki Kimoto authored on 2013-04-27
168

            
added test
Yuki Kimoto authored on 2013-04-30
169
note 'Commits page';
added commits page tests and...
Yuki Kimoto authored on 2013-04-29
170
{
added branch long name featu...
Yuki Kimoto authored on 2013-05-12
171
  {
172
    # Page access
173
    $t->get_ok("/$user/$project/commits/master");
fixed commits page title bug
Yuki Kimoto authored on 2013-05-13
174
    $t->content_like(qr/Commit History/);
added branch long name featu...
Yuki Kimoto authored on 2013-05-12
175
    
176
    # Commit date time
177
    $t->content_like(qr/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/);
178
  }
179
  {
180
    # Page access(branch name long)
181
    $t->get_ok("/$user/$project/commits/refs/heads/master");
182
    $t->content_like(qr#refs/heads/master#);
183
  }
support atom feed of commits...
Yuki Kimoto authored on 2014-10-03
184
  
185
  # Commits page - atom feed
186
  {
187
    # Page access(branch name long)
188
    $t->get_ok("/$user/$project/commits/master.atom");
fix test
Yuki Kimoto authored on 2014-11-17
189
    $t->content_like(qr/\Q<?xml version="1.0" encoding="UTF-8" ?>/);
support atom feed of commits...
Yuki Kimoto authored on 2014-10-03
190
    $t->content_like(qr/<entry>/);
191
  }
added branch long name featu...
Yuki Kimoto authored on 2013-05-12
192
}
193

            
194
note 'History page';
195
{
196
  {
197
    # Page access
198
    $t->get_ok("/$user/$project/commits/b1/README");
simplify branch select
Yuki Kimoto authored on 2015-12-18
199
    $t->content_like(qr/Commits on/);
added branch long name featu...
Yuki Kimoto authored on 2013-05-12
200
    
201
    # Content
202
    $t->content_like(qr/first commit/);
203
  }
204
  {
205
    # Page access (branch name long)
206
    $t->get_ok("/$user/$project/commits/refs/heads/b1/README");
207
    
208
    # Content
209
    $t->content_like(qr/first commit/);
210
  }
added commits page tests and...
Yuki Kimoto authored on 2013-04-29
211
}
added tests
Yuki Kimoto authored on 2013-05-01
212

            
213
note 'Tags page';
214
{
215
  # Page access
improve tags page design
Yuki Kimoto authored on 2016-02-01
216
  $t->get_ok("/$user/$project/tags?page=2");
added tests
Yuki Kimoto authored on 2013-05-01
217
  
added commit datetime to man...
Yuki Kimoto authored on 2013-05-03
218
  # Commit datetime
219
  $t->content_like(qr/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/);
improved tags page design
Yuki Kimoto authored on 2013-05-01
220
  
added tests
Yuki Kimoto authored on 2013-05-01
221
  # Tree link
222
  $t->content_like(qr#/$user/$project/tree/t1#);
223
  
224
  # Commit link
225
  $t->content_like(qr#/$user/$project/commit/15ea9d711617abda5eed7b4173a3349d30bca959#);
226

            
227
  # Zip link
228
  $t->content_like(qr#/$user/$project/archive/t1.zip#);
229
  
230
  # Tar.gz link
231
  $t->content_like(qr#/$user/$project/archive/t1.tar.gz#);
232
}
cleanup blob and raw page an...
Yuki Kimoto authored on 2013-05-02
233

            
added commit datetime to man...
Yuki Kimoto authored on 2013-05-03
234
note 'Tree page';
235
{
added branch long name featu...
Yuki Kimoto authored on 2013-05-12
236
  {
237
    # Page access (hash)
238
    $t->get_ok("/$user/$project/tree/e891266d8aeab864c8eb36b7115416710b2cdc2e");
239
    
240
    # Commit datetime
241
    $t->content_like(qr/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/);
242
    
243
    # README
244
    $t->content_like(qr/README.*bbb/s);
245
    
246
    # tree directory link
247
    $t->content_like(qr#/$user/$project/tree/e891266d8aeab864c8eb36b7115416710b2cdc2e/dir#);
added commit datetime to man...
Yuki Kimoto authored on 2013-05-03
248

            
added branch long name featu...
Yuki Kimoto authored on 2013-05-12
249
    # tree file link
250
    $t->content_like(qr#/$user/$project/blob/e891266d8aeab864c8eb36b7115416710b2cdc2e/README#);
251
  }
252
  {
253
    # Page access (branch name)
254
    $t->get_ok("/$user/$project/tree/b21/dir");
255
    
256
    # File
257
    $t->content_like(qr/b\.txt/s);
258
  }
259
  {
260
    # Page access (branch name middle)
261
    $t->get_ok("/$user/$project/tree/heads/b21/dir");
262
    
263
    # File
fix tree page link bug
Yuki Kimoto authored on 2015-12-19
264
    $t->content_like(qr/dir\/b\.txt/s);
added branch long name featu...
Yuki Kimoto authored on 2013-05-12
265
  }
266
  {
267
    # Page access (branch name long)
268
    $t->get_ok("/$user/$project/tree/refs/heads/b21/dir");
269
    $t->content_like(qr#refs/heads/b21#);
270
    
271
    # File
272
    $t->content_like(qr/b\.txt/s);
273
  }
added commit datetime to man...
Yuki Kimoto authored on 2013-05-03
274
}
275

            
276
note 'Blob page';
cleanup blob and raw page an...
Yuki Kimoto authored on 2013-05-02
277
{
added branch long name featu...
Yuki Kimoto authored on 2013-05-12
278
  {
279
    # Page access (hash)
280
    $t->get_ok("/$user/$project/blob/b9f0f107672b910a44d22d4623ce7445d40565aa/a_renamed.txt");
281
    
282
    # Commit datetime
283
    $t->content_like(qr/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/);
284
    
285
    # Content
286
    $t->content_like(qr/あああ/);
287
  }
288
  {
289
    # Page access (branch name)
290
    $t->get_ok("/$user/$project/blob/b1/README");
291
    
292
    # Content
293
    $t->content_like(qr/bbb/);
294
  }
295
  {
296
    # Page access (branch name middle)
297
    $t->get_ok("/$user/$project/blob/heads/b1/README");
298
    
299
    # Content
300
    $t->content_like(qr/bbb/);
301
  }
302
  {
303
    # Page access (branch name long)
304
    $t->get_ok("/$user/$project/blob/refs/heads/b1/README");
305
    $t->content_like(qr#refs/heads/b1#);
306
    
307
    # Content
308
    $t->content_like(qr/bbb/);
not show binary file
Yuki Kimoto authored on 2013-06-02
309
  }
310
  
311
  note 'blob binary';
312
  {
313
    $t->get_ok("/$user/$project/blob/ed7b91659762fa612563f0595f3faca6aecfcfa0/sample.bin");
314
    $t->content_like(qr/View raw/);
315
  }
316
}
cleanup blob and raw page an...
Yuki Kimoto authored on 2013-05-02
317

            
318
note 'raw page';
319
{
added branch long name featu...
Yuki Kimoto authored on 2013-05-12
320
  {
321
    # Page access (hash)
322
    $t->get_ok("/$user/$project/raw/b9f0f107672b910a44d22d4623ce7445d40565aa/a_renamed.txt");
323
    
324
    # Content
325
    my $content_binary = $t->tx->res->body;
326
    my $content = decode('UTF-8', $content_binary);
327
    like($content, qr/あああ/);
328
  }
329
  {
330
    # Page access (branch name)
331
    $t->get_ok("/$user/$project/raw/b21/dir/b.txt");
332
    
333
    my $content = $t->tx->res->body;
334
    like($content, qr/aaaa/);
335
  }
336
  {
337
    # Page access (branch name middle)
338
    $t->get_ok("/$user/$project/raw/heads/b21/dir/b.txt");
339
    
340
    my $content = $t->tx->res->body;
341
    like($content, qr/aaaa/);
342
  }
343
  {
344
    # Page access (branch name long)
345
    $t->get_ok("/$user/$project/raw/refs/heads/b21/dir/b.txt");
346
    
347
    my $content = $t->tx->res->body;
348
    like($content, qr/aaaa/);
349
  }
cleanup blob and raw page an...
Yuki Kimoto authored on 2013-05-02
350
}
added merged branches to bra...
Yuki Kimoto authored on 2013-05-03
351

            
352
note 'Aarchive';
353
{
354
  # Archive zip
355
  $t->get_ok("/$user/$project/archive/t1.zip");
356
  $t->content_type_is('application/zip');
357
  
358
  # Archice tar.gz
359
  $t->get_ok("/$user/$project/archive/t1.tar.gz");
360
  $t->content_type_is('application/x-tar');
361
}
added branch long name featu...
Yuki Kimoto authored on 2013-05-12
362

            
fixed bug that fork return e...
Yuki Kimoto authored on 2013-05-13
363
note 'API References';
364
{
365
  # Page access (branch name)
366
  $t->get_ok("/$user/$project/api/revs");
367
  my $content = $t->tx->res->body;
368
  like($content, qr/branch_names/);
369
  like($content, qr/tag_names/);
improved network graph page ...
Yuki Kimoto authored on 2013-05-13
370
}
371

            
372
note 'Network page';
373
{
374
  # Page access
375
  $t->get_ok("/$user/$project/network");
376
  $t->content_like(qr/Network/);
377
}
add README link test
Yuki Kimoto authored on 2013-05-24
378

            
379
note 'README';
380
{
381
  # Links
382
  $t->get_ok("/$user/$project/tree/84199670c2f8e51f87b05b336020bde968975498");
383
  $t->content_like(qr#<a href="http://foo1">http://foo1</a>#);
384
  $t->content_like(qr#<a href="https://foo2">https://foo2</a>#);
385
  $t->content_like(qr#<a href="http://foo3">http://foo3</a>#);
386
  $t->content_like(qr#<a href="http://foo4">http://foo4</a>#);
387
  $t->content_like(qr#<a href="http://foo5">http://foo5</a>#);
fix no merged branch not sho...
Yuki Kimoto authored on 2013-05-27
388
}
389

            
390
note 'Branches';
391
{
392
  # Page access
393
  $t->get_ok("/$user/$project/branches");
394
  $t->content_like(qr/Branches/);
add compare page test and ad...
Yuki Kimoto authored on 2013-05-29
395
}
396

            
fix blame page desing bug an...
Yuki Kimoto authored on 2013-08-10
397
note 'blame';
398
{
399
  # Page access
400
  $t->get_ok("/$user/$project/blame/3c617100f8e6d8ffe11d6c14ddf7b3646a198269/README");
401
  $t->content_like(qr/Blame page/);
402
  
403
  # Commit link
404
  $t->content_like(qr#/commit/0929b1a4ee79d0f104fd9ef7d6d410d501a273cf#);
405
  
406
  # Lines
407
  $t->content_like(qr#http://foo1#);
408
}
add support normal file mark...
Yuki Kimoto authored on 2013-10-08
409

            
410
note 'Markdown normal file';
411
{
412
  # Page access
413
  $t->get_ok("/$user/$project/blob/12e44f2e4ecf55c5d3a307889829b47c05e216d3/dir/markdown.md");
add changes
Yuki Kimoto authored on 2014-03-14
414
  $t->content_like(qr#<h1 .*?>Head</h1>#);
add support normal file mark...
Yuki Kimoto authored on 2013-10-08
415
}
add empty password to _start...
Yuki Kimoto authored on 2016-04-29
416

            
fix search page error bug
Yuki Kimoto authored on 2016-06-11
417
note 'Search page';
418
{
419
  # Page access (branch name)
420
  $t->get_ok("/_search");
421
  $t->content_like(qr/Search/);
422

            
423
  # Page access (branch name)
424
  $t->get_ok("/_search?q=foo&type=repositories");
425
  $t->content_like(qr/Search/);
426

            
427
  # Page access (branch name)
428
  $t->get_ok("/_search?q=foo&type=users");
429
  $t->content_like(qr/Search/);
430
}