-
Notifications
You must be signed in to change notification settings - Fork 38
/
locations.t
56 lines (43 loc) · 1.6 KB
/
locations.t
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
use Mojo::Base -strict;
use Mojo::JSON 'j';
use File::Spec;
use Galileo::DB::Deploy;
use Test::More;
use Test::Mojo;
my $home = $ENV{GALILEO_HOME} = File::Spec->rel2abs(File::Spec->catdir( qw/ t locations / ));
my $t = Galileo::DB::Deploy->create_test_object({ test => 1 });
my $app = $t->app;
is( $app->home, $home, 'home dir detected from GALILEO_HOME' );
$t->get_ok('/test.html')
->status_is(200)
->text_is('body' => 'test text')
->or( sub { diag "'static' should be in @{ $app->static->paths }" } );
TODO: {
local $TODO = 'Not sure why this fails sometimes';
# login
$t->post_ok( '/login' => form => {from => '/page/home', username => 'admin', password => 'pass' } );
# this hack fixes windows tests, but not the underlying problem that I don't want these found files reslashed!
my $image2 = File::Spec->catfile( qw/ img image2.jpg / );
$t->websocket_ok('/files/list')
->send_ok({ text => j({limit => 0}) })
->message_ok
->json_message_is( '/' => { files => [sort 'image1.jpg', $image2], finished => 1 })
->finish_ok;
# test limited number of files found. note order is not guaranteed
$t->websocket_ok('/files/list')
->send_ok({ text => j({limit => 1}) })
->message_ok
->json_message_has( '/files/0' )
->json_message_hasnt( '/files/1' )
->json_message_is( '/finished' => 0 )
->send_ok({ text => j({limit => 1}) })
->message_ok
->json_message_has( '/files/0' )
->json_message_hasnt( '/files/1' )
->json_message_is( '/finished' => 0 )
->send_ok({ text => j({limit => 1}) })
->message_ok
->json_message_is( '/' => { files => [], finished => 1 } )
->finish_ok;
}
done_testing();