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

Test ability for room members to override displayname on a per-room basis #337

Merged
merged 4 commits into from
Jan 25, 2017
Merged
Show file tree
Hide file tree
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
60 changes: 60 additions & 0 deletions tests/30rooms/14override-per-room.pl
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
test "Room members can override their displayname on a room-specific basis",
requires => [ local_user_and_room_fixtures() ],

do => sub {
my ( $user, $room_id ) = @_;

matrix_put_room_state( $user, $room_id,
type => "m.room.member",
state_key => $user->user_id,
content => {
membership => "join",
displayname => "Overridden",
},
)->then( sub {
matrix_get_room_state( $user, $room_id,
type => "m.room.member",
state_key => $user->user_id,
);
})->then( sub {
my ( $state ) = @_;

log_if_fail "State", $state;

assert_eq( $state->{displayname}, "Overridden",
'displayname in my m.room.member event' );

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

test "Room members can join a room with an overridden displayname",
requires => [ local_user_and_room_fixtures(), local_user_fixture() ],

do => sub {
my ( $creator, $room_id, $joiner ) = @_;

# PUT'ing my membership state should join me
matrix_put_room_state( $joiner, $room_id,
type => "m.room.member",
state_key => $joiner->user_id,
content => {
membership => "join",
displayname => "Overridden",
},
)->then( sub {
matrix_get_room_state( $creator, $room_id,
type => "m.room.member",
state_key => $joiner->user_id,
);
})->then( sub {
my ( $state ) = @_;

log_if_fail "State", $state;

assert_eq( $state->{displayname}, "Overridden",
'displayname in my m.room.member event at join time' );

Future->done(1);
});
};
9 changes: 4 additions & 5 deletions tests/31sync/06state.pl
Original file line number Diff line number Diff line change
Expand Up @@ -567,8 +567,6 @@ sub wait_for_event_in_room {
requires => [ local_user_fixture( with_events => 0 ),
qw( can_sync ) ],

bug => "SYN-707",

check => sub {
my ( $user ) = @_;

Expand All @@ -591,7 +589,8 @@ sub wait_for_event_in_room {
state_key => $user->user_id,
);
})->then( sub {
( $event_id_1 ) = @_;
my ( $result ) = @_;
$event_id_1 = $result->{event_id};

matrix_send_room_text_message_synced( $user, $room_id,
body => "A message to wait on because the m.room.member might not come down /sync"
Expand All @@ -609,8 +608,8 @@ sub wait_for_event_in_room {
log_if_fail "Room", $room;

assert_eq( scalar @{ $timeline }, 2, "Expected 2 events");
assert_eq( $timeline->[0]{event_id}, $event_id_1 );
assert_eq( $timeline->[1]{event_id}, $event_id_2 );
assert_eq( $timeline->[0]{event_id}, $event_id_1, "First event ID" );
assert_eq( $timeline->[1]{event_id}, $event_id_2, "Second event ID" );

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