1 package SL::Controller::JSTests;
 
   5 use parent qw(SL::Controller::Base);
 
   9 use List::UtilsBy qw(sort_by);
 
  11 use SL::System::Process;
 
  13 use Rose::Object::MakeMethods::Generic
 
  15   'scalar --get_set_init' => [ qw(all_scripts scripts_to_run) ],
 
  25   $::request->layout->use_stylesheet("css/qunit.css");
 
  26   $self->render('js_tests/run', title => $::locale->text('Run JavaScript unit tests'));
 
  33 sub init_all_scripts {
 
  36   my $exe_dir = SL::System::Process->exe_dir;
 
  40     return if ( ! -f $File::Find::name ) || ($File::Find::name !~ m{\.js$});
 
  41     push @scripts, File::Spec->abs2rel($File::Find::name, $exe_dir);
 
  44   File::Find::find($wanted, $exe_dir . '/js/t');
 
  46   return [ sort_by { lc } @scripts ];
 
  49 sub init_scripts_to_run {
 
  51   my $filter = $::form->{file_filter} || '.';
 
  52   return [ grep { m{$filter} } @{ $self->all_scripts } ];