Skip to content

Commit e48ccc4

Browse files
committed
Test @MakeClickyContentTypes config
1 parent 10eee74 commit e48ccc4

File tree

1 file changed

+140
-0
lines changed

1 file changed

+140
-0
lines changed

t/ticket/clicky.t

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,9 @@ the rt-users\@lists.bestpractical.com.
1414
1515
to test anchor:
1616
https://wiki.bestpractical.com/test#anchor
17+
18+
to test raw html link:
19+
<a href="https://requesttracker.com">RT</a>
1720
--
1821
Best regards. BestPractical Team.
1922
END
@@ -139,4 +142,141 @@ diag 'test httpurl_overwrite';
139142
ok( scalar @links, 'found clicky link with anchor' );
140143
}
141144

145+
diag 'test MakeClickyContentTypes';
146+
{
147+
RT::Test->stop_server;
148+
RT->Config->Set( 'MakeClickyContentTypes' => 'text/plain' );
149+
my ( $baseurl, $m ) = RT::Test->started_ok;
150+
ok $m->login, 'logged in';
151+
ok $m->goto_ticket($plain_id), 'opened diplay page of the ticket';
152+
153+
my @links = $m->find_link(
154+
tag => 'a',
155+
url => 'http://wiki.bestpractical.com',
156+
text => 'http://wiki.bestpractical.com',
157+
);
158+
ok( scalar @links, 'found clicky link' );
159+
@links = $m->find_link(
160+
tag => 'a',
161+
url => 'https://wiki.bestpractical.com/test#anchor',
162+
text => 'https://wiki.bestpractical.com/test#anchor',
163+
);
164+
ok( scalar @links, 'found clicky link with anchor' );
165+
166+
@links = $m->find_link(
167+
tag => 'a',
168+
url => 'https://requesttracker.com',
169+
);
170+
ok( @links == 0, 'not make raw html links clicky' );
171+
172+
$m->goto_ticket($html_id);
173+
@links = $m->find_link(
174+
tag => 'a',
175+
url => 'http://wiki.bestpractical.com',
176+
text => 'wiki',
177+
);
178+
ok( @links == 1, 'existing links still work' );
179+
180+
@links = $m->find_link(
181+
tag => 'a',
182+
url => 'http://rt3.fsck.com',
183+
);
184+
ok( @links == 0, 'not make clicky links clicky' );
185+
186+
@links = $m->find_link(
187+
tag => 'a',
188+
url => 'https://wiki.bestpractical.com/test#anchor',
189+
);
190+
ok( @links == 0, 'not make clicky links clicky' );
191+
192+
RT::Test->stop_server;
193+
RT->Config->Set( 'MakeClickyContentTypes' => 'text/html' );
194+
( $baseurl, $m ) = RT::Test->started_ok;
195+
ok $m->login, 'logged in';
196+
ok $m->goto_ticket($plain_id), 'opened diplay page of the ticket';
197+
198+
@links = $m->find_link(
199+
tag => 'a',
200+
url => 'http://wiki.bestpractical.com',
201+
);
202+
ok( @links == 0, 'not make clicky links clicky' );
203+
204+
@links = $m->find_link(
205+
tag => 'a',
206+
url => 'https://wiki.bestpractical.com/test#anchor',
207+
);
208+
ok( @links == 0, 'not make clicky links clicky' );
209+
210+
@links = $m->find_link(
211+
tag => 'a',
212+
url => 'https://requesttracker.com',
213+
);
214+
ok( @links == 0, 'not make raw html links clicky' );
215+
216+
$m->goto_ticket($html_id);
217+
@links = $m->find_link(
218+
tag => 'a',
219+
url => 'http://wiki.bestpractical.com',
220+
text => 'wiki',
221+
);
222+
ok( scalar @links, 'existing links still work' );
223+
224+
@links = $m->find_link(
225+
tag => 'a',
226+
url => 'http://rt3.fsck.com',
227+
);
228+
ok( scalar @links, 'found clicky link' );
229+
230+
@links = $m->find_link(
231+
tag => 'a',
232+
url => 'https://wiki.bestpractical.com/test#anchor',
233+
);
234+
ok( scalar @links, 'found clicky link with anchor' );
235+
236+
RT::Test->stop_server;
237+
RT->Config->Set( 'MakeClickyContentTypes' => () );
238+
( $baseurl, $m ) = RT::Test->started_ok;
239+
ok $m->login, 'logged in';
240+
ok $m->goto_ticket($plain_id), 'opened diplay page of the ticket';
241+
242+
@links = $m->find_link(
243+
tag => 'a',
244+
url => 'http://wiki.bestpractical.com',
245+
);
246+
ok( @links == 0, 'not make clicky links clicky' );
247+
248+
@links = $m->find_link(
249+
tag => 'a',
250+
url => 'https://wiki.bestpractical.com/test#anchor',
251+
);
252+
ok( @links == 0, 'not make clicky links clicky' );
253+
254+
@links = $m->find_link(
255+
tag => 'a',
256+
url => 'https://requesttracker.com',
257+
);
258+
ok( @links == 0, 'not make raw html links clicky' );
259+
260+
$m->goto_ticket($html_id);
261+
@links = $m->find_link(
262+
tag => 'a',
263+
url => 'http://wiki.bestpractical.com',
264+
text => 'wiki',
265+
);
266+
ok( scalar @links, 'existing links still work' );
267+
268+
@links = $m->find_link(
269+
tag => 'a',
270+
url => 'http://rt3.fsck.com',
271+
);
272+
ok( @links == 0, 'not make clicky links clicky' );
273+
274+
@links = $m->find_link(
275+
tag => 'a',
276+
url => 'https://wiki.bestpractical.com/test#anchor',
277+
);
278+
ok( @links == 0, 'not make clicky links clicky' );
279+
280+
}
281+
142282
done_testing;

0 commit comments

Comments
 (0)