Skip to content
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

Check that current state events are in timeline #385

Merged
merged 3 commits into from
Sep 19, 2017
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
156 changes: 156 additions & 0 deletions tests/31sync/06state.pl
Original file line number Diff line number Diff line change
Expand Up @@ -745,3 +745,159 @@ sub wait_for_event_in_room {
Future->done(1);
})
};

# Test to check that current state events appear in the timeline,
# even if they were set during a period the user couldn't see.
# See bug https://github.com/matrix-org/matrix-ios-sdk/issues/341
test "Current state appears in timeline in private history",
requires => [ local_user_fixtures( 3, with_events => 0 ),
qw( can_sync ) ],

check => sub {
my ( $creator, $syncer, $invitee ) = @_;

my ( $room_id );

matrix_create_room( $creator )
->then( sub {
( $room_id ) = @_;

matrix_join_room( $syncer, $room_id )
})->then( sub {
matrix_set_room_history_visibility( $creator, $room_id, "joined" )
})->then( sub {
matrix_invite_user_to_room( $creator, $invitee, $room_id )
})->then( sub {
matrix_sync( $syncer )
})->then( sub {
matrix_leave_room( $syncer, $room_id )
})->then( sub {
matrix_join_room( $invitee, $room_id )
})->then( sub {
matrix_join_room_synced( $syncer, $room_id )
})->then( sub {
matrix_sync_again( $syncer )
})->then( sub {
my ( $body ) = @_;

my $room = $body->{rooms}{join}{$room_id};

# Check that we see invitee join event
any {
$_->{type} eq "m.room.member"
&& $_->{state_key} eq $invitee->user_id
&& $_->{content}{membership} eq "join"
} @{ $room->{timeline}{events} }
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

not sure I'd expect this to appear in the timeline, but ymmv

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It can't really be put in the "state" part, as that specifically is for state at the start of the timeline, which would rightly have the "invite" in. It does feel quite icky though :/

or die "No join for joined user";

Future->done( 1 );
})
};

test "Current state appears in timeline in private history with many messages before",
requires => [ local_user_fixtures( 3, with_events => 0 ),
qw( can_sync ) ],

check => sub {
my ( $creator, $syncer, $invitee ) = @_;

my ( $room_id );

matrix_create_room( $creator )
->then( sub {
( $room_id ) = @_;

matrix_join_room( $syncer, $room_id )
})->then( sub {
matrix_set_room_history_visibility( $creator, $room_id, "joined" )
})->then( sub {
matrix_invite_user_to_room( $creator, $invitee, $room_id )
})->then( sub {
matrix_sync( $syncer )
})->then( sub {
repeat( sub {
my $msgnum = $_[0];

matrix_send_room_text_message( $creator, $room_id,
body => "Message $msgnum",
)
}, foreach => [ 1 .. 50 ])
})->then( sub {
matrix_leave_room( $syncer, $room_id )
})->then( sub {
matrix_join_room( $invitee, $room_id )
})->then( sub {
matrix_join_room_synced( $syncer, $room_id )
})->then( sub {
matrix_sync_again( $syncer )
})->then( sub {
my ( $body ) = @_;

my $room = $body->{rooms}{join}{$room_id};

# Check that we see invitee join event
any {
$_->{type} eq "m.room.member"
&& $_->{state_key} eq $invitee->user_id
&& $_->{content}{membership} eq "join"
} @{ $room->{timeline}{events} }
or die "No join for joined user";

Future->done( 1 );
})
};



test "Current state appears in timeline in private history with many messages after",
requires => [ local_user_fixtures( 3, with_events => 0 ),
qw( can_sync ) ],

check => sub {
my ( $creator, $syncer, $invitee ) = @_;

my ( $room_id );

matrix_create_room( $creator )
->then( sub {
( $room_id ) = @_;

matrix_join_room( $syncer, $room_id )
})->then( sub {
matrix_set_room_history_visibility( $creator, $room_id, "joined" )
})->then( sub {
matrix_invite_user_to_room( $creator, $invitee, $room_id )
})->then( sub {
matrix_sync( $syncer )
})->then( sub {
matrix_leave_room( $syncer, $room_id )
})->then( sub {
matrix_join_room( $invitee, $room_id )
})->then( sub {
repeat( sub {
my $msgnum = $_[0];

matrix_send_room_text_message( $creator, $room_id,
body => "Message $msgnum",
)
}, foreach => [ 1 .. 50 ])
})->then( sub {
matrix_join_room_synced( $syncer, $room_id )
})->then( sub {
matrix_sync_again( $syncer )
})->then( sub {
my ( $body ) = @_;

my $room = $body->{rooms}{join}{$room_id};

# Check that we see invitee join event
any {
$_->{type} eq "m.room.member"
&& $_->{state_key} eq $invitee->user_id
&& $_->{content}{membership} eq "join"
} @{ $room->{timeline}{events} }
or die "No join for joined user";

Future->done( 1 );
})
};