added commit page test
|
1 |
use Test::More 'no_plan'; |
2 | ||
3 |
use FindBin; |
|
cleanup blob and raw page an...
|
4 |
use utf8; |
added commit page test
|
5 |
use lib "$FindBin::Bin/../lib"; |
6 |
use lib "$FindBin::Bin/../extlib/lib/perl5"; |
|
cleanup blob and raw page an...
|
7 |
use Encode qw/encode decode/; |
added commit page test
|
8 | |
9 |
use Test::Mojo; |
|
added test
|
10 | |
11 |
# Test DB |
|
12 |
$ENV{GITPREP_DB_FILE} = "$FindBin::Bin/basic.db"; |
|
13 | ||
14 |
# Test Repository home |
|
15 |
$ENV{GITPREP_REP_HOME} = "$FindBin::Bin/../../gitprep_t_rep_home"; |
|
16 | ||
add need_login_always_option
|
17 |
$ENV{GITPREP_NO_MYCONFIG} = 1; |
18 | ||
added commit page test
|
19 |
use Gitprep; |
20 | ||
21 |
my $app = Gitprep->new; |
|
22 |
my $t = Test::Mojo->new($app); |
|
23 | ||
24 |
my $user = 'kimoto'; |
|
25 |
my $project = 'gitprep_t'; |
|
26 | ||
added test
|
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 |
|
58 |
$t->content_like(qr/gitprep test repository/); |
|
59 |
|
|
added commit datetime to pro...
|
60 |
# Commit datetime |
61 |
$t->content_like(qr/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/); |
|
62 |
|
|
added test
|
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...
|
73 |
note 'Commit page'; |
improved commit page design
|
74 |
{ |
add diff status bar to commi...
|
75 |
note 'first commit'; |
added branch long name featu...
|
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
|
87 |
$t->content_like(qr/<span>0 parent/); |
added branch long name featu...
|
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
|
103 |
$t->content_like(qr/class="file-add"/); |
added branch long name featu...
|
104 |
} |
add diff status bar to commi...
|
105 |
|
improve rename commit
|
106 |
note 'rename'; |
107 |
{ |
|
108 |
$t->get_ok("/$user/$project/commit/15ea9d711617abda5eed7b4173a3349d30bca959"); |
|
improve commit page design
|
109 |
$t->content_like(qr#<span>1 parent</span>.*1b59896#s); |
improve rename commit
|
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
|
115 |
note 'add text'; |
116 |
{ |
|
117 |
$t->get_ok("/$user/$project/commit/da5b854b760351adc58d24d121070e729e80534d"); |
|
fixed blob diff line number ...
|
118 |
$t->content_like(qr/\@\@/); |
add test
|
119 |
$t->content_like(qr/\+aaa/); |
120 |
} |
|
improve rename commit
|
121 |
|
fixed blob diff line number ...
|
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
|
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...
|
147 |
note 'Branch name'; |
added branch long name featu...
|
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...
|
152 | |
added branch long name featu...
|
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...
|
158 |
|
improved tag and branch refe...
|
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...
|
166 |
|
added commits page tests and...
|
167 |
} |
added commit page test
|
168 | |
added test
|
169 |
note 'Commits page'; |
added commits page tests and...
|
170 |
{ |
added branch long name featu...
|
171 |
{ |
172 |
# Page access |
|
173 |
$t->get_ok("/$user/$project/commits/master"); |
|
fixed commits page title bug
|
174 |
$t->content_like(qr/Commit History/); |
added branch long name featu...
|
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...
|
184 |
|
185 |
# Commits page - atom feed |
|
186 |
{ |
|
187 |
# Page access(branch name long) |
|
188 |
$t->get_ok("/$user/$project/commits/master.atom"); |
|
fix test
|
189 |
$t->content_like(qr/\Q<?xml version="1.0" encoding="UTF-8" ?>/); |
support atom feed of commits...
|
190 |
$t->content_like(qr/<entry>/); |
191 |
} |
|
added branch long name featu...
|
192 |
} |
193 | ||
194 |
note 'History page'; |
|
195 |
{ |
|
196 |
{ |
|
197 |
# Page access |
|
198 |
$t->get_ok("/$user/$project/commits/b1/README"); |
|
simplify branch select
|
199 |
$t->content_like(qr/Commits on/); |
added branch long name featu...
|
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...
|
211 |
} |
added tests
|
212 | |
213 |
note 'Tags page'; |
|
214 |
{ |
|
215 |
# Page access |
|
improve tags page design
|
216 |
$t->get_ok("/$user/$project/tags?page=2"); |
added tests
|
217 |
|
added commit datetime to man...
|
218 |
# Commit datetime |
219 |
$t->content_like(qr/\d{4}-\d{2}-\d{2} \d{2}:\d{2}:\d{2}/); |
|
improved tags page design
|
220 |
|
added tests
|
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...
|
233 | |
added commit datetime to man...
|
234 |
note 'Tree page'; |
235 |
{ |
|
added branch long name featu...
|
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...
|
248 | |
added branch long name featu...
|
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
|
264 |
$t->content_like(qr/dir\/b\.txt/s); |
added branch long name featu...
|
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...
|
274 |
} |
275 | ||
276 |
note 'Blob page'; |
|
cleanup blob and raw page an...
|
277 |
{ |
added branch long name featu...
|
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
|
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...
|
317 | |
318 |
note 'raw page'; |
|
319 |
{ |
|
added branch long name featu...
|
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...
|
350 |
} |
added merged branches to bra...
|
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...
|
362 | |
363 |
note 'Compare page'; |
|
364 |
{ |
|
365 |
# Page access (branch name) |
|
366 |
$t->get_ok("/$user/$project/compare/b1...master"); |
|
367 |
$t->content_like(qr#renamed dir/a\.txt to dir/b\.txt and added text#); |
|
368 | ||
369 |
# Page access (branch name long) |
|
370 |
$t->get_ok("/$user/$project/compare/refs/heads/b1...refs/heads/master"); |
|
371 |
$t->content_like(qr#renamed dir/a\.txt to dir/b\.txt and added text#); |
|
372 | ||
fixed bug that fork return e...
|
373 |
} |
374 | ||
375 |
note 'API References'; |
|
376 |
{ |
|
377 |
# Page access (branch name) |
|
378 |
$t->get_ok("/$user/$project/api/revs"); |
|
379 |
my $content = $t->tx->res->body; |
|
380 |
like($content, qr/branch_names/); |
|
381 |
like($content, qr/tag_names/); |
|
improved network graph page ...
|
382 |
} |
383 | ||
384 |
note 'Network page'; |
|
385 |
{ |
|
386 |
# Page access |
|
387 |
$t->get_ok("/$user/$project/network"); |
|
388 |
$t->content_like(qr/Network/); |
|
389 |
} |
|
add README link test
|
390 | |
391 |
note 'README'; |
|
392 |
{ |
|
393 |
# Links |
|
394 |
$t->get_ok("/$user/$project/tree/84199670c2f8e51f87b05b336020bde968975498"); |
|
395 |
$t->content_like(qr#<a href="http://foo1">http://foo1</a>#); |
|
396 |
$t->content_like(qr#<a href="https://foo2">https://foo2</a>#); |
|
397 |
$t->content_like(qr#<a href="http://foo3">http://foo3</a>#); |
|
398 |
$t->content_like(qr#<a href="http://foo4">http://foo4</a>#); |
|
399 |
$t->content_like(qr#<a href="http://foo5">http://foo5</a>#); |
|
fix no merged branch not sho...
|
400 |
} |
401 | ||
402 |
note 'Branches'; |
|
403 |
{ |
|
404 |
# Page access |
|
405 |
$t->get_ok("/$user/$project/branches"); |
|
406 |
$t->content_like(qr/Branches/); |
|
407 |
|
|
add compare page test and ad...
|
408 |
} |
409 | ||
410 |
note 'Compare'; |
|
411 |
{ |
|
412 |
# Page access |
|
413 |
$t->get_ok("/$user/$project/compare/master...no_merged"); |
|
414 |
$t->content_like(qr/branch change/); |
|
415 |
$t->content_like(qr#http://foo5branch change#); |
|
416 |
} |
|
fix blame page desing bug an...
|
417 | |
418 |
note 'blame'; |
|
419 |
{ |
|
420 |
# Page access |
|
421 |
$t->get_ok("/$user/$project/blame/3c617100f8e6d8ffe11d6c14ddf7b3646a198269/README"); |
|
422 |
$t->content_like(qr/Blame page/); |
|
423 |
|
|
424 |
# Commit link |
|
425 |
$t->content_like(qr#/commit/0929b1a4ee79d0f104fd9ef7d6d410d501a273cf#); |
|
426 |
|
|
427 |
# Lines |
|
428 |
$t->content_like(qr#http://foo1#); |
|
429 |
} |
|
add support normal file mark...
|
430 | |
431 |
note 'Markdown normal file'; |
|
432 |
{ |
|
433 |
# Page access |
|
434 |
$t->get_ok("/$user/$project/blob/12e44f2e4ecf55c5d3a307889829b47c05e216d3/dir/markdown.md"); |
|
add changes
|
435 |
$t->content_like(qr#<h1 .*?>Head</h1>#); |
add support normal file mark...
|
436 |
} |
add encoding_suspects test
|
437 | |
438 |
note 'encoding_suspects option'; |
|
439 |
{ |
|
440 |
my $app = Gitprep->new; |
|
441 |
$app->git->encoding_suspects(['EUC-jp', 'UTF-8']); |
|
442 |
my $t = Test::Mojo->new($app); |
|
443 |
$t->get_ok("/$user/$project/blob/3cf14ade5e28ee0cd83b9a3b1e1c332aed66df53/euc-jp.txt"); |
|
444 |
$t->content_like(qr/あああ/); |
|
445 |
} |