Skip to content

Commit

Permalink
Delete 10apidoc/36room-levels as it was migrated to Complement (#1316)
Browse files Browse the repository at this point in the history
  • Loading branch information
reivilibre authored Jul 23, 2024
1 parent e0ef8d8 commit 91a3ab3
Showing 1 changed file with 2 additions and 128 deletions.
130 changes: 2 additions & 128 deletions tests/10apidoc/36room-levels.pl
Original file line number Diff line number Diff line change
@@ -1,131 +1,5 @@
my ( $user_fixture, $room_fixture ) = local_user_and_room_fixtures();

test "GET /rooms/:room_id/state/m.room.power_levels can fetch levels",
requires => [ $user_fixture, $room_fixture ],

proves => [qw( can_get_power_levels )],

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

do_request_json_for( $user,
method => "GET",
uri => "/v3/rooms/$room_id/state/m.room.power_levels",
)->then( sub {
my ( $body ) = @_;

# Simple level keys
assert_json_keys( $body, qw( ban kick redact state_default events_default users_default ));
assert_json_number( $body->{$_} ) for qw( ban kick redact state_default events_default users_default );

assert_json_object( $body->{events} );

# Don't care what they keys are
assert_json_number( $_ ) for values %{ $body->{events} };

assert_json_number( $_ ) for values %{ $body->{users} };

exists $body->{users}{ $user->user_id } or
die "Expected room creator to exist in user powerlevel list";

$body->{users}{ $user->user_id } > $body->{users_default} or
die "Expected room creator to have a higher-than-default powerlevel";

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

test "PUT /rooms/:room_id/state/m.room.power_levels can set levels",
requires => [ $user_fixture, $room_fixture,
qw( can_get_power_levels )],

proves => [qw( can_set_power_levels )],

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

matrix_get_room_state( $user, $room_id, type => "m.room.power_levels" )
->then( sub {
my ( $levels ) = @_;

$levels->{users}{'@random-other-user:their.home'} = 20;

do_request_json_for( $user,
method => "PUT",
uri => "/v3/rooms/$room_id/state/m.room.power_levels",
content => $levels,
)
})->then( sub {
retry_until_success {
matrix_get_room_state(
$user, $room_id, type => "m.room.power_levels"
)->then( sub {
my ( $levels ) = @_;

$levels->{users}{'@random-other-user:their.home'} == 20 or
die "Expected to have set other user's level to 20";

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

test "PUT power_levels should not explode if the old power levels were empty",
requires => [ $user_fixture, $room_fixture,
qw( can_get_power_levels )],

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

# absence of an 'events' key
matrix_put_room_state(
$user,
$room_id,
type => "m.room.power_levels",
state_key => "",
content => {
users => {
$user->user_id => 100,
},
},
)->then( sub {
# absence of a 'users' key
matrix_put_room_state(
$user,
$room_id,
type => "m.room.power_levels",
state_key => "",
content => {
},
);
})->then( sub {
# this should now give a 403 (not a 500)
matrix_put_room_state(
$user,
$room_id,
type => "m.room.power_levels",
state_key => "",
content => {
users => {},
},
) -> main::expect_http_403;
})->then( sub {
matrix_get_room_state( $user, $room_id, type => "m.room.power_levels" )
});
};


test "Both GET and PUT work",
requires => [qw( can_get_power_levels can_set_power_levels )],

proves => [qw( can_change_power_levels )],

check => sub {
# Nothing to be done

Future->done(1);
};
# Tests migrated to Complement as of https://github.com/matrix-org/complement/pull/545
# However this helper function is used in other tests.

push our @EXPORT, qw( matrix_change_room_power_levels );

Expand Down

0 comments on commit 91a3ab3

Please sign in to comment.