summaryrefslogtreecommitdiff
path: root/rt/t/web/dashboard_with_deleted_saved_search.t
blob: 328095aaf2870be8950a388bbf8fbb2b75f0b9c3 (plain)
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
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
#!/usr/bin/env perl
use strict;
use warnings;

use RT::Test tests => 18;
my ( $url, $m ) = RT::Test->started_ok;
ok( $m->login, 'logged in' );

# create a saved search
$m->get_ok( $url . "/Search/Build.html?Query=" . 'id=1' );

$m->submit_form(
    form_name => 'BuildQuery',
    fields    => { SavedSearchDescription => 'foo', },
    button    => 'SavedSearchSave',
);

my ( $search_uri, $user_id, $search_id ) =
  $m->content =~ /value="(RT::User-(\d+)-SavedSearch-(\d+))"/;
$m->submit_form(
    form_name => 'BuildQuery',
    fields    => { SavedSearchLoad => $search_uri },
    button    => 'SavedSearchSave',
);

$m->content_like( qr/name="SavedSearchDelete"\s+value="Delete"/,
    'found Delete button' );
$m->content_like(
    qr/name="SavedSearchDescription"\s+value="foo"/,
    'found Description input with the value filled'
);

# create a dashboard with the created search

$m->get_ok( $url . "/Dashboards/Modify.html?Create=1" );
$m->submit_form(
    form_name => 'ModifyDashboard',
    fields    => { Name => 'bar' },
);

$m->content_like( qr/Saved dashboard bar/i, 'dashboard saved' );
my $dashboard_queries_link = $m->find_link( text_regex => qr/Queries/ );
my ( $dashboard_id ) = $dashboard_queries_link->url =~ /id=(\d+)/;

$m->get_ok( $url . "/Dashboards/Queries.html?id=$dashboard_id" );

$m->content_lacks( 'value="Update"', 'no update button' );

$m->submit_form(
    form_name => 'Dashboard-Searches-body',
    fields =>
      { 'Searches-body-Available' => "search-$search_id-RT::User-$user_id" },
    button => 'add',
);

$m->content_like( qr/Dashboard updated/i, 'added search foo to dashboard bar' );

# delete the created search

$m->get_ok( $url . "/Search/Build.html?Query=" . 'id=1' );
$m->submit_form(
    form_name => 'BuildQuery',
    fields    => { SavedSearchLoad => $search_uri },
);
$m->submit_form(
    form_name => 'BuildQuery',
    button    => 'SavedSearchDelete',
);

$m->content_lacks( $search_uri, 'deleted search foo' );

# here is what we really want to test

$m->get_ok( $url . "/Dashboards/Queries.html?id=$dashboard_id" );
$m->content_like( qr/Deleted queries/i, 'found deleted message' );

# Update button shows so we can update the deleted search easily
$m->content_contains( 'value="Update"', 'found update button' );

$m->submit_form(
    form_name => 'Dashboard-Searches-body',
    button    => 'update',
);

$m->content_unlike( qr/Deleted queries/i, 'deleted message is gone' );
$m->content_lacks( 'value="Update"', 'update button is gone too' );

$m->get_warnings; # we'll get a lot of warnings because the deleted search