root/tags/rel0_59/t/42_edit_conflict.t

Revision 956, 4.4 kB (checked in by earle, 22 months ago)

Complete transition to using skip_all (remove old SKIP blocks).
More verbose reporting for error "require"ing DBD::SQLite.

Line 
1use strict;
2use OpenGuides;
3use OpenGuides::Test;
4use Test::More;
5use Wiki::Toolkit::Setup::SQLite;
6
7eval { require DBD::SQLite; };
8if ( $@ ) {
9    my ($error) = $@ =~ /^(.*?)\n/;
10    plan skip_all => "DBD::SQLite could not be used - no database to test with ($error)";
11}
12
13eval { require Test::HTML::Content; };
14if ( $@ ) {
15    plan skip_all => "Test::HTML::Content not installed";
16}
17
18plan tests => 16;
19
20Wiki::Toolkit::Setup::SQLite::setup( { dbname => "t/node.db" } );
21
22# Make a guide that works on latitude/longitude, and allows node images.
23my $config = OpenGuides::Test->make_basic_config;
24$config->geo_handler( 3 );
25$config->ellipsoid( "WGS-84" );
26$config->enable_node_image( 1 );
27my $guide = OpenGuides->new( config => $config );
28my $wiki = $guide->wiki;
29
30# Clear out the database from any previous runs.
31foreach my $del_node ( $wiki->list_all_nodes ) {
32    print "# Deleting node $del_node\n";
33    $wiki->delete_node( $del_node ) or die "Can't delete $del_node";
34}
35
36
37# Write some data.
38OpenGuides::Test->write_data(
39                              guide         => $guide,
40                              node          => "Crabtree Tavern",
41                              content       => "A pub.",
42                              locales       => "W6",
43                              categories    => "Pubs\r\nPub Food",
44                              latitude      => 51.5,
45                              longitude     => -0.05,
46                            );
47
48# Make sure the normal edit form doesn't think there's a conflict.
49my $output = $guide->display_edit_form(
50                                        id => "Crabtree Tavern",
51                                        return_output => 1,
52                                      );
53                                       
54# Strip Content-Type header to stop Test::HTML::Content getting confused.
55$output =~ s/^Content-Type.*[\r\n]+//m;
56
57Test::HTML::Content::no_tag( $output, "div", { class => "warning_text" },
58                             "Normal edit form doesn't contain warning_text" );
59
60# Now try to commit some edits without giving the checksum.
61$output = OpenGuides::Test->write_data(
62                                        guide         => $guide,
63                                        node          => "Crabtree Tavern",
64                                        content       => "Still a pub.",
65                                        locales       => "Hammersmith",
66                                        categories    => "Beer Garden",
67                                        latitude      => 41.5,
68                                        longitude     => -0.04,
69                                        omit_checksum => 1,
70                                        return_output => 1,
71                                      );
72
73# Strip Content-Type header to stop Test::HTML::Content getting confused.
74$output =~ s/^Content-Type.*[\r\n]+//m;
75
76Test::HTML::Content::tag_ok( $output, "div", { class => "warning_text" },
77                             "Edit conflict form contains warning_text" );
78
79like( $output, qr/A pub./s, "...and old content" );
80like( $output, qr/Still a pub./s, "...and new content" );
81like( $output, qr/W6/s, "...and old locales" );
82like( $output, qr/Hammersmith/s, "...and new locales" );
83like( $output, qr/Pubs/s, "...and old categories" );
84like( $output, qr/Pub Food/s, "...both of them" );
85like( $output, qr/Beer Garden/s, "...and new categories" );
86
87# Bug #173 (edit conflict form doesn't let you edit everything).
88Test::HTML::Content::tag_ok( $output, "input", { name => "node_image" },
89                             "...and 'node_image' input box too" );
90
91# Bug #48 (Edit conflict page erroneously converts lat/lon to os_x, os_y).
92Test::HTML::Content::tag_ok( $output, "input", { name => "latitude" },
93                             "UTM guide has 'latitude' input box in edit "
94                             . "conflict" );
95Test::HTML::Content::tag_ok( $output, "input", { name  => "latitude",
96                                                 value => 51.5 },
97                             "...with correct value" );
98Test::HTML::Content::tag_ok( $output, "input", { name => "longitude" },
99                             "...and 'longitude' input box too" );
100Test::HTML::Content::tag_ok( $output, "input", { name  => "longitude",
101                                                 value => -0.05 },
102                             "...with correct value" );
103like( $output, qr/41\.5/, "...new latitude is there too" );
104like( $output, qr/-0\.04/, "...and new longitude" );
Note: See TracBrowser for help on using the browser.