gitprep / xt / basic.t /
Newer Older
436 lines | 10.27kb
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/../mojo/lib";
6
use lib "$FindBin::Bin/../lib";
7
use lib "$FindBin::Bin/../extlib/lib/perl5";
cleanup blob and raw page an...
Yuki Kimoto authored on 2013-05-02
8
use Encode qw/encode decode/;
added commit page test
Yuki Kimoto authored on 2013-04-27
9

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

            
12
# Test DB
13
$ENV{GITPREP_DB_FILE} = "$FindBin::Bin/basic.db";
14

            
15
# Test Repository home
16
$ENV{GITPREP_REP_HOME} = "$FindBin::Bin/../../gitprep_t_rep_home";
17

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

            
added commit page test
Yuki Kimoto authored on 2013-04-27
20
use Gitprep;
21

            
22
my $app = Gitprep->new;
23
my $t = Test::Mojo->new($app);
24

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

            
perl test 5.8 compatible
Yuki Kimoto authored on 2013-05-27
28
# For perl 5.8
29
{
30
  no warnings 'redefine';
31
  sub note { print STDERR "# $_[0]\n" unless $ENV{HARNESS_ACTIVE} }
32
}
33

            
added test
Yuki Kimoto authored on 2013-04-30
34
note 'Home page';
35
{
36
  # Page access
37
  $t->get_ok('/');
38
  
39
  # Title
40
  $t->content_like(qr/GitPrep/);
41
  $t->content_like(qr/Users/);
42
  
43
  # User link
44
  $t->content_like(qr#/$user#);
45
}
46

            
47
note 'Projects page';
48
{
49
  # Page access
50
  $t->get_ok("/$user");
51
  
52
  # Title
53
  $t->content_like(qr/Repositories/);
54
  
55
  # project link
56
  $t->content_like(qr#/$user/$project#);
57
}
58

            
59
note 'Project page';
60
{
61
  # Page access
62
  $t->get_ok("/$user/$project");
63
  
64
  # Description
65
  $t->content_like(qr/gitprep test repository/);
66
  
added commit datetime to pro...
Yuki Kimoto authored on 2013-05-03
67
  # Commit datetime
68
  $t->content_like(qr/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/);
69
  
added test
Yuki Kimoto authored on 2013-04-30
70
  # README
71
  $t->content_like(qr/README/);
72
  
73
  # tree directory link
74
  $t->content_like(qr#/$user/$project/tree/master/dir#);
75

            
76
  # tree file link
77
  $t->content_like(qr#/$user/$project/blob/master/README#);
78
}
79

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

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

            
added test
Yuki Kimoto authored on 2013-04-30
176
note 'Commits page';
added commits page tests and...
Yuki Kimoto authored on 2013-04-29
177
{
added branch long name featu...
Yuki Kimoto authored on 2013-05-12
178
  {
179
    # Page access
180
    $t->get_ok("/$user/$project/commits/master");
fixed commits page title bug
Yuki Kimoto authored on 2013-05-13
181
    $t->content_like(qr/Commit History/);
added branch long name featu...
Yuki Kimoto authored on 2013-05-12
182
    
183
    # Commit date time
184
    $t->content_like(qr/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/);
185
  }
186
  {
187
    # Page access(branch name long)
188
    $t->get_ok("/$user/$project/commits/refs/heads/master");
189
    $t->content_like(qr#refs/heads/master#);
190
  }
191
}
192

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

            
212
note 'Tags page';
213
{
214
  # Page access
215
  $t->get_ok("/$user/$project/tags");
216
  
added commit datetime to man...
Yuki Kimoto authored on 2013-05-03
217
  # Commit datetime
218
  $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
219
  
added tests
Yuki Kimoto authored on 2013-05-01
220
  # Tree link
221
  $t->content_like(qr#/$user/$project/tree/t1#);
222
  
223
  # Commit link
224
  $t->content_like(qr#/$user/$project/commit/15ea9d711617abda5eed7b4173a3349d30bca959#);
225

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

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

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

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

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

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

            
362
note 'Compare page';
363
{
364
  # Page access (branch name)
365
  $t->get_ok("/$user/$project/compare/b1...master");
366
  $t->content_like(qr#renamed dir/a\.txt to dir/b\.txt and added text#);
367

            
368
  # Page access (branch name long)
369
  $t->get_ok("/$user/$project/compare/refs/heads/b1...refs/heads/master");
370
  $t->content_like(qr#renamed dir/a\.txt to dir/b\.txt and added text#);
371

            
fixed bug that fork return e...
Yuki Kimoto authored on 2013-05-13
372
}
373

            
374
note 'API References';
375
{
376
  # Page access (branch name)
377
  $t->get_ok("/$user/$project/api/revs");
378
  my $content = $t->tx->res->body;
379
  like($content, qr/branch_names/);
380
  like($content, qr/tag_names/);
improved network graph page ...
Yuki Kimoto authored on 2013-05-13
381
}
382

            
383
note 'Network page';
384
{
385
  # Page access
386
  $t->get_ok("/$user/$project/network");
387
  $t->content_like(qr/Network/);
388
}
add README link test
Yuki Kimoto authored on 2013-05-24
389

            
390
note 'README';
391
{
392
  # Links
393
  $t->get_ok("/$user/$project/tree/84199670c2f8e51f87b05b336020bde968975498");
394
  $t->content_like(qr#<a href="http://foo1">http://foo1</a>#);
395
  $t->content_like(qr#<a href="https://foo2">https://foo2</a>#);
396
  $t->content_like(qr#<a href="http://foo3">http://foo3</a>#);
397
  $t->content_like(qr#<a href="http://foo4">http://foo4</a>#);
398
  $t->content_like(qr#<a href="http://foo5">http://foo5</a>#);
fix no merged branch not sho...
Yuki Kimoto authored on 2013-05-27
399
}
400

            
401
note 'Branches';
402
{
403
  # Page access
404
  $t->get_ok("/$user/$project/branches");
405
  $t->content_like(qr/Branches/);
406
  
407
  # No merged branch
408
  $t->content_like(qr/no-merged-branch.*?no_merged/s);
409
  
410
  # Marged branch
411
  $t->content_like(qr/"merged-branch.*?b2/s);
add compare page test and ad...
Yuki Kimoto authored on 2013-05-29
412
}
413

            
414
note 'Compare';
415
{
416
  # Page access
417
  $t->get_ok("/$user/$project/compare/master...no_merged");
418
  $t->content_like(qr/branch change/);
419
  $t->content_like(qr#http://foo5branch change#);
420
}
fix blame page desing bug an...
Yuki Kimoto authored on 2013-08-10
421

            
422
note 'blame';
423
{
424
  # Page access
425
  $t->get_ok("/$user/$project/blame/3c617100f8e6d8ffe11d6c14ddf7b3646a198269/README");
426
  $t->content_like(qr/Blame page/);
427
  
428
  # Commit link
429
  $t->content_like(qr#/commit/0929b1a4ee79d0f104fd9ef7d6d410d501a273cf#);
430
  
431
  # Blame link
432
  $t->content_like(qr#/blame/0929b1a4ee79d0f104fd9ef7d6d410d501a273cf/README#);
433
  
434
  # Lines
435
  $t->content_like(qr#http://foo1#);
436
}