# Copyright (c) 2005-2010 bivio Software, Inc. All Rights Reserved. # $Id: calendar.btest,v 1.10 2011/04/11 22:52:15 schellj Exp $ test_setup('PetShop', 'groupware'); home_page(); do_test_backdoor(TestData => 'reset_calendar_btest'); login_as('calendar_btest_user'); follow_menu_link(qw(calendar_btest_main calendar)); follow_link('[change]'); submit_form({ qr{time zone}i => 'UTC' }); verify_text(qr{Show in UTC time}i); follow_menu_link('add_event'); my($r) = random_string(); submit_form({ title => $r, start_time => '11:00', end_time => '12:00', }); follow_menu_link("11:00 $r", 'modify'); verify_form({ title => $r, start_time => '11:00', end_time => '12:00', }); my($r2) = random_string(); submit_form({ title => $r2, start_time => '10:00', }); verify_no_text($r); follow_menu_link("10:00 $r2", 'delete'); submit_form('delete'); verify_no_text($r2); # Show in UTC and View event list... submit_form({ list => 1, }); verify_text(qr{\bno events}i); submit_form({ list => 0, }); verify_no_text(qr{\bno events}i); follow_menu_link('add_event'); submit_form({ title => 'mst_event', zone => 'MST', start_date => '2/3/2010', end_date => '2/3/2010', start_time => '11:00', end_time => '12:00', }); # Test that showing the calendar in the user's time zone # still renders a calendar (q586) submit_form({ show => 1, list => 0, }); verify_text(qr{Show in UTC time}i); verify_text(qr{sunday}i); follow_link('[change]'); submit_form({ qr{time zone}i => 'Asia/Seoul' }); verify_text(qr{Show in Asia/Seoul time}i); verify_text(qr{sunday}i); follow_link('[change]'); submit_form({ qr{time zone}i => 'America/Denver' }); verify_text(qr{Show in America/Denver time}i); verify_text(qr{sunday}i); follow_link('[change]'); submit_form({ qr{time zone}i => 'UTC' }); verify_text(qr{Show in UTC time}i); verify_text(qr{sunday}i); submit_form({ show => 1, list => 1, }); #TODO: Test that the events appear on the right day # with changing the time zone case_tag('tz'); verify_table(start => [ [qw(start zone title)], ['02/03/2010 18:00', 'UTC', 'mst_event'], ]); submit_form({ show => 0, }); verify_table(start => [ [qw(start zone title)], ['02/03/2010 11:00', 'MST', 'mst_event'], ]); follow_link_in_table(qw(start title mst_event actions delete)); submit_form('delete'); verify_no_text('mst_event'); my($start_date) = Type_Date('1/1/2010'); date_time_now($start_date); follow_menu_link(qw(calendar_btest_main calendar add_event_8)); verify_form({ start_date => '01/03/2010', end_date => '01/03/2010', }); go_back(); # add repeated events and check number of occurances... my($repeat_end) = Type_Date()->set_end_of_month($start_date); # repeats interval values are the recurrence counts # within the start_date to repeat_ends period #TODO: this is testing business logic which is for bunits # test stuff that has to do with workflow in btests #TODO: test feb 2009, no other months (only links for 1-28) # test that we return the month for the starting event, not the subsequent #TODO: A hash is in appropriate here, because order matters when debugging my($repeats) = { every_week => 5, every_two_weeks => 3, every_four_weeks => 2, }; foreach my $interval (sort(keys(%{$repeats}))) { follow_menu_link('add_event'); my($title) = random_string(); submit_form({ title => $title, start_date => $start_date, start_time => '12pm', end_date => $start_date, end_time => '1 pm', repeats => $interval, repeat_ends => Type_Date()->to_string($repeat_end), }); my($count) = $repeats->{$interval}; my($pat) = qr(@{[join('.*', map($title, 1 .. $count))]})s; verify_text($pat); verify_no_text(qr{$pat.*$title}); foreach my $i (reverse(0 .. $count - 1)) { follow_link( $title . ($i ? '_' . $i : ''), 'delete', ); submit_form('delete'); } verify_no_text($title); }; # add daily events and traverse using back/next links.. my($d1) = Type_Date()->add_days(Type_Date()->now, -2); my($d2) = Type_Date()->now; my($d3) = Type_Date()->add_days($d2, 2); my($daysevents) = { $d1 => [['1','2']], $d2 => [['8:30', '9:00'], ['12pm','2pm'], ['16:00','17:00']], $d3 => [['8am', '9am']], }; my($titles) = []; foreach my $devk (sort(keys(%{$daysevents}))) { foreach my $d (@{$daysevents->{$devk}}) { my($title) = random_string(); push(@$titles, $title); my($st, $et) = @$d; follow_menu_link('add_event'); submit_form({ title => $title, start_date => $devk, start_time => $st, end_date => $devk, end_time => $et, }); }; }; # note that back is actually going to newer event -- DEPENDS ON SORTING #TODO: Fix the code to say Older & Newer #TODO: Does this iterate through all events in the calendars? foreach my $dir (qw(next back)) { my($not_first) = 0; follow_menu_link('calendar'); foreach my $title ($dir eq 'next' ? reverse(@$titles) : @$titles) { follow_link($not_first++ ? qr{^$dir$}i : $title); verify_text($title); } return; } foreach my $title (@$titles) { follow_link('calendar$'); #TODO: Need to test navigating through months submit_form(refresh => { _anon => 'Feb 2010', }) unless text_exists($title); follow_link($title); follow_menu_link('delete'); submit_form('delete'); } #TODO: Test modify, create from All Forums view #TODO: Test return to date of event after create/modify #TODO: Test today is highlighted #TODO: Test create links on empty space in calendar days