Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/UsersTest.php
Show All 21 Lines | |||||
use Illuminate\Foundation\Testing\DatabaseMigrations; | use Illuminate\Foundation\Testing\DatabaseMigrations; | ||||
class UsersTest extends TestCaseDusk | class UsersTest extends TestCaseDusk | ||||
{ | { | ||||
private $profile = [ | private $profile = [ | ||||
'first_name' => 'John', | 'first_name' => 'John', | ||||
'last_name' => 'Doe', | 'last_name' => 'Doe', | ||||
'organization' => 'Kolab Developers', | 'organization' => 'Kolab Developers', | ||||
'limit_geo' => null, | |||||
]; | ]; | ||||
/** | /** | ||||
* {@inheritDoc} | * {@inheritDoc} | ||||
*/ | */ | ||||
public function setUp(): void | public function setUp(): void | ||||
{ | { | ||||
parent::setUp(); | parent::setUp(); | ||||
▲ Show 20 Lines • Show All 319 Lines • ▼ Show 20 Lines | class UsersTest extends TestCaseDusk | ||||
* Test user settings tab | * Test user settings tab | ||||
* | * | ||||
* @depends testInfo | * @depends testInfo | ||||
*/ | */ | ||||
public function testUserSettings(): void | public function testUserSettings(): void | ||||
{ | { | ||||
$john = $this->getTestUser('john@kolab.org'); | $john = $this->getTestUser('john@kolab.org'); | ||||
$john->setSetting('greylist_enabled', null); | $john->setSetting('greylist_enabled', null); | ||||
$john->setSetting('guam_enabled', null); | |||||
$john->setSetting('limit_geo', null); | $john->setSetting('limit_geo', null); | ||||
$this->browse(function (Browser $browser) use ($john) { | $this->browse(function (Browser $browser) use ($john) { | ||||
$browser->visit('/user/' . $john->id) | $browser->visit('/user/' . $john->id) | ||||
->on(new UserInfo()) | ->on(new UserInfo()) | ||||
->assertElementsCount('@nav a', 2) | ->assertElementsCount('@nav a', 2) | ||||
->assertSeeIn('@nav #tab-general', 'General') | ->assertSeeIn('@nav #tab-general', 'General') | ||||
->assertSeeIn('@nav #tab-settings', 'Settings') | ->assertSeeIn('@nav #tab-settings', 'Settings') | ||||
->click('@nav #tab-settings') | ->click('@nav #tab-settings') | ||||
->with('#settings form', function (Browser $browser) { | ->with('#settings form', function (Browser $browser) { | ||||
$browser->assertSeeIn('div.row:nth-child(1) label', 'Greylisting') | $browser->assertSeeIn('div.row:nth-child(1) label', 'Greylisting') | ||||
->assertMissing('div.row:nth-child(2)') // geo-lockin setting is hidden | ->assertMissing('div.row:nth-child(2)') // guam and geo-lockin settings are hidden | ||||
->click('div.row:nth-child(1) input[type=checkbox]:checked') | ->click('div.row:nth-child(1) input[type=checkbox]:checked') | ||||
->click('button[type=submit]') | ->click('button[type=submit]') | ||||
->assertToast(Toast::TYPE_SUCCESS, 'User settings updated successfully.'); | ->assertToast(Toast::TYPE_SUCCESS, 'User settings updated successfully.'); | ||||
}); | }); | ||||
}); | }); | ||||
$this->assertSame('false', $john->getSetting('greylist_enabled')); | $this->assertSame('false', $john->getSetting('greylist_enabled')); | ||||
$this->addBetaEntitlement($john); | $this->addBetaEntitlement($john); | ||||
$this->browse(function (Browser $browser) use ($john) { | $this->browse(function (Browser $browser) use ($john) { | ||||
$browser->refresh() | $browser->refresh() | ||||
->on(new UserInfo()) | ->on(new UserInfo()) | ||||
->click('@nav #tab-settings') | ->click('@nav #tab-settings') | ||||
->with('#settings form', function (Browser $browser) use ($john) { | ->with('#settings form', function (Browser $browser) use ($john) { | ||||
$browser->assertSeeIn('div.row:nth-child(1) label', 'Greylisting') | $browser->assertSeeIn('div.row:nth-child(1) label', 'Greylisting') | ||||
->assertSeeIn('div.row:nth-child(2) label', 'Geo-lockin') | ->assertSeeIn('div.row:nth-child(2) label', 'IMAP proxy') | ||||
->assertNotChecked('div.row:nth-child(2) input') | |||||
->assertSeeIn('div.row:nth-child(3) label', 'Geo-lockin') | |||||
->with(new CountrySelect('#limit_geo'), function ($browser) { | ->with(new CountrySelect('#limit_geo'), function ($browser) { | ||||
$browser->assertCountries([]) | $browser->assertCountries([]) | ||||
->setCountries(['DE', 'PL']) | ->setCountries(['DE', 'PL']) | ||||
->assertCountries(['DE', 'PL']); | ->assertCountries(['DE', 'PL']); | ||||
}) | }) | ||||
->click('div.row:nth-child(2) input') | |||||
->click('button[type=submit]') | ->click('button[type=submit]') | ||||
->assertToast(Toast::TYPE_SUCCESS, 'User settings updated successfully.'); | ->assertToast(Toast::TYPE_SUCCESS, 'User settings updated successfully.'); | ||||
$this->assertSame('["DE","PL"]', $john->getSetting('limit_geo')); | $this->assertSame('["DE","PL"]', $john->getSetting('limit_geo')); | ||||
$this->assertSame('true', $john->getSetting('guam_enabled')); | |||||
$browser | $browser | ||||
->with(new CountrySelect('#limit_geo'), function ($browser) { | ->with(new CountrySelect('#limit_geo'), function ($browser) { | ||||
$browser->setCountries([]) | $browser->setCountries([]) | ||||
->assertCountries([]); | ->assertCountries([]); | ||||
}) | }) | ||||
->click('div.row:nth-child(2) input') | |||||
->click('button[type=submit]') | ->click('button[type=submit]') | ||||
->assertToast(Toast::TYPE_SUCCESS, 'User settings updated successfully.'); | ->assertToast(Toast::TYPE_SUCCESS, 'User settings updated successfully.'); | ||||
$this->assertSame(null, $john->getSetting('limit_geo')); | $this->assertSame(null, $john->getSetting('limit_geo')); | ||||
$this->assertSame(null, $john->getSetting('guam_enabled')); | |||||
}); | }); | ||||
}); | }); | ||||
} | } | ||||
/** | /** | ||||
* Test user adding page | * Test user adding page | ||||
* | * | ||||
* @depends testInfo | * @depends testInfo | ||||
▲ Show 20 Lines • Show All 383 Lines • Show Last 20 Lines |