Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/Meet/RoomSecurityTest.php
Show First 20 Lines • Show All 109 Lines • ▼ Show 20 Lines | public function testRoomPassword(): void | ||||
// Test removing the password | // Test removing the password | ||||
$owner->click('@menu button.link-security') | $owner->click('@menu button.link-security') | ||||
->with(new Dialog('#security-options-dialog'), function (Browser $browser) use ($room) { | ->with(new Dialog('#security-options-dialog'), function (Browser $browser) use ($room) { | ||||
$browser->assertSeeIn('@title', 'Security options') | $browser->assertSeeIn('@title', 'Security options') | ||||
->assertSeeIn('#password-input-text:not(.text-muted)', 'pass') | ->assertSeeIn('#password-input-text:not(.text-muted)', 'pass') | ||||
->assertSeeIn('#password-clear-btn.btn-outline-danger', 'Clear password') | ->assertSeeIn('#password-clear-btn.btn-outline-danger', 'Clear password') | ||||
->assertElementsCount('#password-input button', 1) | ->assertElementsCount('#password-input button', 1) | ||||
->click('#password-clear-btn') | ->click('#password-clear-btn') | ||||
->assertToast(Toast::TYPE_SUCCESS, 'Room configuration updated successfully.') | ->assertToast(Toast::TYPE_SUCCESS, "Room configuration updated successfully.") | ||||
->assertMissing('#password-input input') | ->assertMissing('#password-input input') | ||||
->assertSeeIn('#password-input-text.text-muted', 'none') | ->assertSeeIn('#password-input-text.text-muted', 'none') | ||||
->assertSeeIn('#password-set-btn', 'Set password') | ->assertSeeIn('#password-set-btn', 'Set password') | ||||
->assertElementsCount('#password-input button', 1) | ->assertElementsCount('#password-input button', 1) | ||||
->click('@button-action'); | ->click('@button-action'); | ||||
$this->assertSame(null, $room->fresh()->getSetting('password')); | $this->assertSame(null, $room->fresh()->getSetting('password')); | ||||
}); | }); | ||||
}); | }); | ||||
} | } | ||||
/** | |||||
* Test locked room | |||||
* | |||||
* @group openvidu | |||||
*/ | |||||
public function testLockedRoom(): void | |||||
{ | |||||
$this->browse(function (Browser $owner, Browser $guest) { | |||||
// Make sure there's no session yet | |||||
$room = Room::where('name', 'john')->first(); | |||||
if ($room->session_id) { | |||||
$room->session_id = null; | |||||
$room->save(); | |||||
} | |||||
// Join the room as an owner (authenticate) | |||||
$owner->visit(new RoomPage('john')) | |||||
// ->click('@setup-button') | |||||
// ->submitLogon('john@kolab.org', 'simple123') | |||||
->waitFor('@setup-form') | |||||
->waitUntilMissing('@setup-status-message.loading') | |||||
->click('@setup-button') | |||||
->waitFor('@session') | |||||
// Enter Security option dialog | |||||
->click('@menu button.link-security') | |||||
->with(new Dialog('#security-options-dialog'), function (Browser $browser) use ($room) { | |||||
$browser->assertSeeIn('@title', 'Security options') | |||||
->assertSeeIn('#room-lock label', 'Locked room:') | |||||
->assertVisible('#room-lock input[type=checkbox]:not(:checked)') | |||||
->assertVisible('#room-lock + small') | |||||
// Test setting the lock | |||||
->click('#room-lock input') | |||||
->assertToast(Toast::TYPE_SUCCESS, "Room configuration updated successfully.") | |||||
->click('@button-action'); | |||||
$this->assertSame('true', $room->fresh()->getSetting('locked')); | |||||
}); | |||||
// In another browser act as a guest | |||||
$guest->visit(new RoomPage('john')) | |||||
->waitFor('@setup-form') | |||||
->waitUntilMissing('@setup-status-message.loading') | |||||
->assertSeeIn('@setup-button:not([disabled]).btn-success', 'JOIN NOW') | |||||
// try without the nickname | |||||
->click('@setup-button') | |||||
->waitFor('@setup-nickname-input.is-invalid') | |||||
->assertSeeIn( | |||||
'@setup-status-message.text-danger', | |||||
"The room is locked. Please, enter your name and try again." | |||||
) | |||||
->assertMissing('@setup-password-input') | |||||
->assertSeeIn('@setup-button:not([disabled]).btn-success', 'JOIN NOW') | |||||
->type('@setup-nickname-input', 'Guest<p>') | |||||
->click('@setup-button') | |||||
->assertMissing('@setup-nickname-input.is-invalid') | |||||
->waitFor('@setup-button[disabled]') | |||||
->assertSeeIn('@setup-status-message.text-danger', "Waiting for permission to join the room."); | |||||
// Test denying the request (this will also test custom toasts) | |||||
$owner | |||||
->whenAvailable(new Toast(Toast::TYPE_CUSTOM), function ($browser) { | |||||
$browser->assertToastTitle('Join request') | |||||
->assertVisible('.toast-header svg.fa-user') | |||||
->assertSeeIn('@message', 'Guest<p> requested to join.') | |||||
->assertAttributeRegExp('@message img', 'src', '|^data:image|') | |||||
->assertSeeIn('@message button.accept.btn-success', 'Accept') | |||||
->assertSeeIn('@message button.deny.btn-danger', 'Deny') | |||||
->click('@message button.deny'); | |||||
}) | |||||
->waitUntilMissing('.toast') | |||||
// wait 10 seconds to make sure the request message does not show up again | |||||
->pause(10 * 1000) | |||||
->assertMissing('.toast'); | |||||
// Test accepting the request | |||||
$guest->refresh() | |||||
->waitFor('@setup-form') | |||||
->waitUntilMissing('@setup-status-message.loading') | |||||
->type('@setup-nickname-input', 'guest') | |||||
->click('@setup-button') | |||||
->waitFor('@setup-button[disabled]') | |||||
->assertSeeIn('@setup-status-message.text-danger', "Waiting for permission to join the room."); | |||||
$owner | |||||
->whenAvailable(new Toast(Toast::TYPE_CUSTOM), function ($browser) { | |||||
$browser->assertToastTitle('Join request') | |||||
->assertSeeIn('@message', 'guest requested to join.') | |||||
->click('@message button.accept'); | |||||
}); | |||||
$guest->waitFor('@session', 12); | |||||
}); | |||||
} | |||||
} | } |