Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/Meet/RoomOptionsTest.php
- This file was moved from src/tests/Browser/Meet/RoomSecurityTest.php.
<?php | <?php | ||||
namespace Tests\Browser\Meet; | namespace Tests\Browser\Meet; | ||||
use App\OpenVidu\Room; | use App\OpenVidu\Room; | ||||
use Tests\Browser; | use Tests\Browser; | ||||
use Tests\Browser\Components\Dialog; | use Tests\Browser\Components\Dialog; | ||||
use Tests\Browser\Components\Toast; | use Tests\Browser\Components\Toast; | ||||
use Tests\Browser\Pages\Meet\Room as RoomPage; | use Tests\Browser\Pages\Meet\Room as RoomPage; | ||||
use Tests\TestCaseDusk; | use Tests\TestCaseDusk; | ||||
class RoomSecurityTest extends TestCaseDusk | class RoomOptionsTest extends TestCaseDusk | ||||
{ | { | ||||
/** | /** | ||||
* {@inheritDoc} | * {@inheritDoc} | ||||
*/ | */ | ||||
public function setUp(): void | public function setUp(): void | ||||
{ | { | ||||
parent::setUp(); | parent::setUp(); | ||||
$this->setupTestRoom(); | $this->setupTestRoom(); | ||||
Show All 19 Lines | public function testRoomPassword(): void | ||||
$owner->visit(new RoomPage('john')) | $owner->visit(new RoomPage('john')) | ||||
->click('@setup-button') | ->click('@setup-button') | ||||
->submitLogon('john@kolab.org', 'simple123') | ->submitLogon('john@kolab.org', 'simple123') | ||||
->waitFor('@setup-form') | ->waitFor('@setup-form') | ||||
->waitUntilMissing('@setup-status-message.loading') | ->waitUntilMissing('@setup-status-message.loading') | ||||
->assertMissing('@setup-password-input') | ->assertMissing('@setup-password-input') | ||||
->clickWhenEnabled('@setup-button') | ->clickWhenEnabled('@setup-button') | ||||
->waitFor('@session') | ->waitFor('@session') | ||||
// Enter Security option dialog | // Enter room option dialog | ||||
->click('@menu button.link-security') | ->click('@menu button.link-options') | ||||
->with(new Dialog('#security-options-dialog'), function (Browser $browser) use ($room) { | ->with(new Dialog('#room-options-dialog'), function (Browser $browser) use ($room) { | ||||
$browser->assertSeeIn('@title', 'Security options') | $browser->assertSeeIn('@title', 'Room options') | ||||
->assertSeeIn('@button-action', 'Close') | ->assertSeeIn('@button-action', 'Close') | ||||
->assertElementsCount('.modal-footer button', 1) | ->assertElementsCount('.modal-footer button', 1) | ||||
->assertSeeIn('#password-input .label', 'Password:') | ->assertSeeIn('#password-input .label', 'Password:') | ||||
->assertSeeIn('#password-input-text.text-muted', 'none') | ->assertSeeIn('#password-input-text.text-muted', 'none') | ||||
->assertVisible('#password-input + small') | ->assertVisible('#password-input + small') | ||||
->assertSeeIn('#password-set-btn', 'Set password') | ->assertSeeIn('#password-set-btn', 'Set password') | ||||
->assertElementsCount('#password-input button', 1) | ->assertElementsCount('#password-input button', 1) | ||||
->assertMissing('#password-input input') | ->assertMissing('#password-input input') | ||||
Show All 30 Lines | public function testRoomPassword(): void | ||||
->clickWhenEnabled('@setup-button') | ->clickWhenEnabled('@setup-button') | ||||
->waitFor('#setup-password.is-invalid') | ->waitFor('#setup-password.is-invalid') | ||||
// Try to join with a valid password | // Try to join with a valid password | ||||
->type('#setup-password', 'pass') | ->type('#setup-password', 'pass') | ||||
->clickWhenEnabled('@setup-button') | ->clickWhenEnabled('@setup-button') | ||||
->waitFor('@session'); | ->waitFor('@session'); | ||||
// Test removing the password | // Test removing the password | ||||
$owner->click('@menu button.link-security') | $owner->click('@menu button.link-options') | ||||
->with(new Dialog('#security-options-dialog'), function (Browser $browser) use ($room) { | ->with(new Dialog('#room-options-dialog'), function (Browser $browser) use ($room) { | ||||
$browser->assertSeeIn('@title', 'Security options') | $browser->assertSeeIn('@title', 'Room 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 (denying the join request) | * Test locked room (denying the join request) | ||||
* | * | ||||
* @group openvidu | * @group openvidu | ||||
*/ | */ | ||||
public function testLockedRoomDeny(): void | public function testLockedRoomDeny(): void | ||||
{ | { | ||||
$this->browse(function (Browser $owner, Browser $guest) { | $this->browse(function (Browser $owner, Browser $guest) { | ||||
// Make sure there's no session yet | |||||
$room = Room::where('name', 'john')->first(); | $room = Room::where('name', 'john')->first(); | ||||
// Join the room as an owner (authenticate) | // Join the room as an owner (authenticate) | ||||
$owner->visit(new RoomPage('john')) | $owner->visit(new RoomPage('john')) | ||||
// ->click('@setup-button') | // ->click('@setup-button') | ||||
// ->submitLogon('john@kolab.org', 'simple123') | // ->submitLogon('john@kolab.org', 'simple123') | ||||
->waitFor('@setup-form') | ->waitFor('@setup-form') | ||||
->waitUntilMissing('@setup-status-message.loading') | ->waitUntilMissing('@setup-status-message.loading') | ||||
->type('@setup-nickname-input', 'John') | ->type('@setup-nickname-input', 'John') | ||||
->clickWhenEnabled('@setup-button') | ->clickWhenEnabled('@setup-button') | ||||
->waitFor('@session') | ->waitFor('@session') | ||||
// Enter Security option dialog | // Enter room option dialog | ||||
->click('@menu button.link-security') | ->click('@menu button.link-options') | ||||
->with(new Dialog('#security-options-dialog'), function (Browser $browser) use ($room) { | ->with(new Dialog('#room-options-dialog'), function (Browser $browser) use ($room) { | ||||
$browser->assertSeeIn('@title', 'Security options') | $browser->assertSeeIn('@title', 'Room options') | ||||
->assertSeeIn('#room-lock label', 'Locked room:') | ->assertSeeIn('#room-lock label', 'Locked room:') | ||||
->assertVisible('#room-lock input[type=checkbox]:not(:checked)') | ->assertVisible('#room-lock input[type=checkbox]:not(:checked)') | ||||
->assertVisible('#room-lock + small') | ->assertVisible('#room-lock + small') | ||||
// Test setting the lock | // Test setting the lock | ||||
->click('#room-lock input') | ->click('#room-lock input') | ||||
->assertToast(Toast::TYPE_SUCCESS, "Room configuration updated successfully.") | ->assertToast(Toast::TYPE_SUCCESS, "Room configuration updated successfully.") | ||||
->click('@button-action'); | ->click('@button-action'); | ||||
▲ Show 20 Lines • Show All 43 Lines • ▼ Show 20 Lines | class RoomOptionsTest extends TestCaseDusk | ||||
/** | /** | ||||
* Test locked room (accepting the join request, and dismissing a user) | * Test locked room (accepting the join request, and dismissing a user) | ||||
* | * | ||||
* @group openvidu | * @group openvidu | ||||
*/ | */ | ||||
public function testLockedRoomAcceptAndDismiss(): void | public function testLockedRoomAcceptAndDismiss(): void | ||||
{ | { | ||||
$this->browse(function (Browser $owner, Browser $guest) { | $this->browse(function (Browser $owner, Browser $guest) { | ||||
// Make sure there's no session yet | |||||
$room = Room::where('name', 'john')->first(); | $room = Room::where('name', 'john')->first(); | ||||
// Join the room as an owner (authenticate) | // Join the room as an owner (authenticate) | ||||
$owner->visit(new RoomPage('john')) | $owner->visit(new RoomPage('john')) | ||||
// ->click('@setup-button') | // ->click('@setup-button') | ||||
// ->submitLogon('john@kolab.org', 'simple123') | // ->submitLogon('john@kolab.org', 'simple123') | ||||
->waitFor('@setup-form') | ->waitFor('@setup-form') | ||||
->waitUntilMissing('@setup-status-message.loading') | ->waitUntilMissing('@setup-status-message.loading') | ||||
->type('@setup-nickname-input', 'John') | ->type('@setup-nickname-input', 'John') | ||||
->clickWhenEnabled('@setup-button') | ->clickWhenEnabled('@setup-button') | ||||
->waitFor('@session') | ->waitFor('@session') | ||||
// Enter Security option dialog | // Enter room option dialog | ||||
->click('@menu button.link-security') | ->click('@menu button.link-options') | ||||
->with(new Dialog('#security-options-dialog'), function (Browser $browser) use ($room) { | ->with(new Dialog('#room-options-dialog'), function (Browser $browser) use ($room) { | ||||
$browser->assertSeeIn('@title', 'Security options') | $browser->assertSeeIn('@title', 'Room options') | ||||
->assertSeeIn('#room-lock label', 'Locked room:') | ->assertSeeIn('#room-lock label', 'Locked room:') | ||||
->assertVisible('#room-lock input[type=checkbox]:not(:checked)') | ->assertVisible('#room-lock input[type=checkbox]:not(:checked)') | ||||
->assertVisible('#room-lock + small') | ->assertVisible('#room-lock + small') | ||||
// Test setting the lock | // Test setting the lock | ||||
->click('#room-lock input') | ->click('#room-lock input') | ||||
->assertToast(Toast::TYPE_SUCCESS, "Room configuration updated successfully.") | ->assertToast(Toast::TYPE_SUCCESS, "Room configuration updated successfully.") | ||||
->click('@button-action'); | ->click('@button-action'); | ||||
Show All 38 Lines | public function testLockedRoomAcceptAndDismiss(): void | ||||
$guest->with(new Dialog('#leave-dialog'), function (Browser $browser) { | $guest->with(new Dialog('#leave-dialog'), function (Browser $browser) { | ||||
$browser->assertSeeIn('@title', 'Room closed') | $browser->assertSeeIn('@title', 'Room closed') | ||||
->assertSeeIn('@body', "The session has been closed by the room owner.") | ->assertSeeIn('@body', "The session has been closed by the room owner.") | ||||
->assertMissing('@button-cancel') | ->assertMissing('@button-cancel') | ||||
->assertSeeIn('@button-action', 'Close'); | ->assertSeeIn('@button-action', 'Close'); | ||||
}); | }); | ||||
}); | }); | ||||
} | } | ||||
/** | |||||
* Test nomedia (subscribers only) feature | |||||
* | |||||
* @group openvidu | |||||
*/ | |||||
public function testSubscribersOnly(): void | |||||
{ | |||||
$this->browse(function (Browser $owner, Browser $guest) { | |||||
$room = Room::where('name', 'john')->first(); | |||||
// 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') | |||||
->type('@setup-nickname-input', 'John') | |||||
->clickWhenEnabled('@setup-button') | |||||
->waitFor('@session') | |||||
// Enter room option dialog | |||||
->click('@menu button.link-options') | |||||
->with(new Dialog('#room-options-dialog'), function (Browser $browser) use ($room) { | |||||
$browser->assertSeeIn('@title', 'Room options') | |||||
->assertSeeIn('#room-nomedia label', 'Subscribers only:') | |||||
->assertVisible('#room-nomedia input[type=checkbox]:not(:checked)') | |||||
->assertVisible('#room-nomedia + small') | |||||
// Test enabling the option | |||||
->click('#room-nomedia input') | |||||
->assertToast(Toast::TYPE_SUCCESS, "Room configuration updated successfully.") | |||||
->click('@button-action'); | |||||
$this->assertSame('true', $room->fresh()->getSetting('nomedia')); | |||||
}); | |||||
// In another browser act as a guest | |||||
$guest->visit(new RoomPage('john')) | |||||
->waitFor('@setup-form') | |||||
->waitUntilMissing('@setup-status-message.loading') | |||||
->type('@setup-nickname-input', 'John') | |||||
->clickWhenEnabled('@setup-button') | |||||
// expect the owner to have a video, but the guest to have none | |||||
->waitFor('@session .meet-video') | |||||
->waitFor('@session .meet-subscriber.self'); | |||||
// Unset the option back | |||||
$owner->click('@menu button.link-options') | |||||
->with(new Dialog('#room-options-dialog'), function (Browser $browser) use ($room) { | |||||
$browser->assertVisible('#room-nomedia input[type=checkbox]:checked') | |||||
// Test enabling the option | |||||
->click('#room-nomedia input') | |||||
->assertToast(Toast::TYPE_SUCCESS, "Room configuration updated successfully.") | |||||
->click('@button-action'); | |||||
$this->assertSame(null, $room->fresh()->getSetting('nomedia')); | |||||
}); | |||||
}); | |||||
} | |||||
} | } |