fix ticketing system error on bootstrap of new install
[freeside.git] / rt / t / web / squish.t
1 use strict;
2 use warnings;
3 use RT;
4 use RT::Test tests => 26;
5
6 RT->Config->Set( DevelMode            => 0 );
7 RT->Config->Set( WebDefaultStylesheet => 'aileron' );
8 RT->Config->Set( LocalStaticPath => RT::Test::get_abs_relocatable_dir('static') );
9
10 my ( $url, $m ) = RT::Test->started_ok;
11 $m->login;
12
13 diag "test squished files with devel mode disabled";
14
15 $m->follow_link_ok( { url_regex => qr!aileron/squished-([a-f0-9]{32})\.css! },
16     'follow squished css' );
17 $m->content_like( qr!/\*\* End of .*?.css \*/!, 'squished css' );
18 $m->content_lacks( 'counteract the titlebox',
19     'no mobile.css by default' );
20
21 $m->back;
22 my ($js_link) =
23   $m->content =~ m!src="([^"]+?squished-([a-f0-9]{32})\.js)"!;
24 $m->get_ok( $url . $js_link, 'follow squished js' );
25 $m->content_lacks('function just_testing', "no not-by-default.js");
26 $m->content_contains('jQuery.noConflict', "found default js content");
27
28 RT::Test->stop_server;
29
30 diag "test squished files with customized files and devel mode disabled";
31 RT->AddJavaScript( 'not-by-default.js' );
32 RT->AddStyleSheets( 'mobile.css' );
33
34 ( $url, $m ) = RT::Test->started_ok;
35
36 $m->login;
37 $m->follow_link_ok( { url_regex => qr!aileron/squished-([a-f0-9]{32})\.css! },
38     'follow squished css' );
39 $m->content_like( qr!/\*\* End of .*?.css \*/!, 'squished css' );
40 $m->content_contains( 'counteract the titlebox',
41     'has mobile.css' );
42
43 $m->back;
44 ($js_link) =
45   $m->content =~ m!src="([^"]+?squished-([a-f0-9]{32})\.js)"!;
46 $m->get_ok( $url . $js_link, 'follow squished js' );
47 $m->content_contains( 'function just_testing', "has not-by-default.js" );
48 $m->content_contains('jQuery.noConflict', "found default js content");
49 RT::Test->stop_server;
50
51
52 diag "Test with a trivial jsmin which is a pass-through";
53 RT->Config->Set( 'JSMinPath' => RT::Test::get_abs_relocatable_dir("passthrough-jsmin"));
54 ( $url, $m ) = RT::Test->started_ok;
55 $m->login;
56 ($js_link) =
57   $m->content =~ m!src="([^"]+?squished-([a-f0-9]{32})\.js)"!;
58 $m->get_ok( $url . $js_link, 'follow squished js' );
59 $m->content_contains( 'passthrough-jsmin added this', "has passthrough-added content" );
60 $m->content_contains( 'function just_testing', "has not-by-default.js" );
61 $m->content_contains('jQuery.noConflict', "found default js content");
62 RT::Test->stop_server;
63
64
65 diag "test squished files with devel mode enabled";
66 RT->Config->Set( 'DevelMode' => 1 );
67 RT->AddJavaScript( 'not-by-default.js' );
68 RT->AddStyleSheets( 'nottherebutwedontcare.css' );
69
70 ( $url, $m ) = RT::Test->started_ok;
71 $m->login;
72 $m->content_unlike( qr!squished-.*?\.(js|css)!,
73     'no squished link with develmode' );
74
75 $m->content_contains('not-by-default.js', "found extra javascript resource");
76 $m->content_contains('nottherebutwedontcare.css', "found extra css resource");
77 $m->content_contains('jquery_noconflict.js', "found a default js resource");
78