#!perl
use Cassandane::Tiny;

sub test_calendarevent_get_duplicate_recurrence_ids
    :min_version_3_7 :needs_component_jmap
{
    my ($self) = @_;
    my $jmap = $self->{jmap};
    my $caldav = $self->{caldav};

    my $ical = <<'EOF';
BEGIN:VCALENDAR
VERSION:2.0
PRODID:-//Apple Inc.//Mac OS X 10.9.5//EN
CALSCALE:GREGORIAN
BEGIN:VEVENT
RECURRENCE-ID;TZID=America/New_York:20210101T060000
DTSTART;TZID=Europe/Berlin:20210101T120000
DURATION:PT1H
UID:2a358cee-6489-4f14-a57f-c104db4dc357
DTSTAMP:20150928T132434Z
CREATED:20150928T125212Z
SUMMARY:instance1
SEQUENCE:0
LAST-MODIFIED:20150928T132434Z
END:VEVENT
BEGIN:VEVENT
RECURRENCE-ID;TZID=America/New_York:20210101T060000
DTSTART;TZID=Europe/Berlin:20210101T120000
DURATION:PT1H
UID:2a358cee-6489-4f14-a57f-c104db4dc357
DTSTAMP:20150928T132434Z
CREATED:20150928T125212Z
SUMMARY:instance2
SEQUENCE:0
LAST-MODIFIED:20150928T132434Z
END:VEVENT
END:VCALENDAR
EOF
    $caldav->Request('PUT', 'Default/test.ics', $ical,
        'Content-Type' => 'text/calendar');

    my $res = $jmap->CallMethods([
        ['CalendarEvent/get', {
            properties => ['title', 'recurrenceId']
        }, 'R1'],
    ]);
    $self->assert_num_equals(1, scalar @{$res->[0][1]{list}});
    $self->assert_str_equals('instance1', $res->[0][1]{list}[0]{title});
    $self->assert_str_equals('2021-01-01T06:00:00',
        $res->[0][1]{list}[0]{recurrenceId});
}
