-
Notifications
You must be signed in to change notification settings - Fork 9
Add basic Calendar support/tests to JMAP::TestSuite #27
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,47 @@ | ||
package JMAP::TestSuite::Comparator::Calendar; | ||
use Moose; | ||
|
||
use Test::Deep ':v1'; | ||
use Test::Deep::JType; | ||
use Test::Deep::HashRec; | ||
|
||
use Sub::Exporter -setup => [ qw(calendar) ]; | ||
|
||
sub calendar { | ||
my ($overrides) = @_; | ||
|
||
$overrides ||= {}; | ||
|
||
my %required = ( | ||
id => jstr, | ||
name => jstr, | ||
color => jstr, | ||
sortOrder => jnum, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. sortOrder isn't strictly required, it has a default value ( |
||
isVisible => jbool, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The following non-null, non-default properties are missing:
|
||
mayReadFreeBusy => jbool, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The See the definition of the CalendarRights object type in https://www.ietf.org/archive/id/draft-ietf-jmap-calendars-22.html#section-4 |
||
mayReadItems => jbool, | ||
mayAddItems => jbool, | ||
mayModifyItems => jbool, | ||
mayRemoveItems => jbool, | ||
mayRename => jbool, | ||
mayDelete => jbool, | ||
); | ||
|
||
my %optional; | ||
|
||
for my $k (keys %$overrides) { | ||
if (exists $required{$k}) { | ||
$required{$k} = $overrides->{$k}; | ||
} else { | ||
$optional{$k} = $overrides->{$k}; | ||
} | ||
} | ||
|
||
return hashrec({ | ||
required => \%required, | ||
optional => \%optional, | ||
}); | ||
} | ||
|
||
no Moose; | ||
__PACKAGE__->meta->make_immutable; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
package JMAP::TestSuite::Entity::Calendar; | ||
use Moose; | ||
use Carp (); | ||
with 'JMAP::TestSuite::Entity' => { | ||
singular_noun => 'calendar', | ||
properties => [ qw( | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as in Comparator/Calendar.pm. |
||
id | ||
name | ||
color | ||
sortOrder | ||
isVisible | ||
mayReadFreeBusy | ||
mayReadItems | ||
mayAddItems | ||
mayModifyItems | ||
mayRemoveItems | ||
mayRename | ||
mayDelete | ||
) ], | ||
}; | ||
|
||
no Moose; | ||
__PACKAGE__->meta->make_immutable; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
use jmaptest; | ||
|
||
use JMAP::TestSuite::Util qw(calendar); | ||
|
||
test { | ||
my ($self) = @_; | ||
|
||
my $account = $self->any_account; | ||
my $tester = $account->tester; | ||
|
||
my $calendar1 = $account->create_calendar; | ||
|
||
# Sanity, I guess | ||
ok($calendar1->id, 'calendar has an id'); | ||
ok($calendar1->name, 'calendar has a name'); | ||
ok($calendar1->color, 'calendar has a color'); | ||
|
||
my $res = $tester->request([[ | ||
"Calendar/get" => { ids => [ $calendar1->id ], }, | ||
]]); | ||
ok($res->is_success, "Calendar/get") | ||
or diag explain $res->response_payload; | ||
|
||
jcmp_deeply( | ||
$res->single_sentence("Calendar/get")->arguments, | ||
superhashof({ | ||
accountId => jstr($account->accountId), | ||
state => jstr(), | ||
notFound => [], | ||
list => [ | ||
calendar({ | ||
id => $calendar1->id, | ||
name => $calendar1->name, | ||
color => $calendar1->color, | ||
sortOrder => 0, | ||
isVisible => jtrue, | ||
}), | ||
], | ||
}), | ||
"Base response looks good", | ||
) or diag explain $res->as_stripped_triples; | ||
}; |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
use jmaptest; | ||
|
||
test { | ||
my ($self) = @_; | ||
|
||
my $account = $self->any_account; | ||
my $tester = $account->tester; | ||
|
||
# Add a calendar to make sure we don't get it | ||
$account->create_calendar; | ||
|
||
my $res = $tester->request_ok( | ||
[ "Calendar/get" => { ids => [] } ], | ||
superhashof({ | ||
accountId => jstr($account->accountId), | ||
state => jstr(), | ||
list => [], | ||
}), | ||
"Response for ids => [] looks good" | ||
); | ||
}; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
color is optional