Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/Admin/DomainTest.php
Show All 14 Lines | |||||
class DomainTest extends TestCaseDusk | class DomainTest extends TestCaseDusk | ||||
{ | { | ||||
/** | /** | ||||
* {@inheritDoc} | * {@inheritDoc} | ||||
*/ | */ | ||||
public function setUp(): void | public function setUp(): void | ||||
{ | { | ||||
parent::setUp(); | parent::setUp(); | ||||
$this->deleteTestUser('test1@domainscontroller.com'); | |||||
$this->deleteTestDomain('domainscontroller.com'); | |||||
self::useAdminUrl(); | self::useAdminUrl(); | ||||
} | } | ||||
/** | /** | ||||
* {@inheritDoc} | * {@inheritDoc} | ||||
*/ | */ | ||||
public function tearDown(): void | public function tearDown(): void | ||||
{ | { | ||||
$domain = $this->getTestDomain('kolab.org'); | $domain = $this->getTestDomain('kolab.org'); | ||||
$domain->setSetting('spf_whitelist', null); | $domain->setSetting('spf_whitelist', null); | ||||
$this->deleteTestUser('test1@domainscontroller.com'); | |||||
$this->deleteTestDomain('domainscontroller.com'); | |||||
parent::tearDown(); | parent::tearDown(); | ||||
} | } | ||||
/** | /** | ||||
* Test domain info page (unauthenticated) | * Test domain info page (unauthenticated) | ||||
*/ | */ | ||||
public function testDomainUnauth(): void | public function testDomainUnauth(): void | ||||
{ | { | ||||
▲ Show 20 Lines • Show All 72 Lines • ▼ Show 20 Lines | class DomainTest extends TestCaseDusk | ||||
/** | /** | ||||
* Test suspending/unsuspending a domain | * Test suspending/unsuspending a domain | ||||
* | * | ||||
* @depends testDomainInfo | * @depends testDomainInfo | ||||
*/ | */ | ||||
public function testSuspendAndUnsuspend(): void | public function testSuspendAndUnsuspend(): void | ||||
{ | { | ||||
$this->browse(function (Browser $browser) { | $this->browse(function (Browser $browser) { | ||||
$sku_domain = \App\Sku::withEnvTenantContext()->where('title', 'domain-hosting')->first(); | |||||
$user = $this->getTestUser('test1@domainscontroller.com'); | |||||
$domain = $this->getTestDomain('domainscontroller.com', [ | $domain = $this->getTestDomain('domainscontroller.com', [ | ||||
'status' => Domain::STATUS_NEW | Domain::STATUS_ACTIVE | 'status' => Domain::STATUS_NEW | Domain::STATUS_ACTIVE | ||||
| Domain::STATUS_LDAP_READY | Domain::STATUS_CONFIRMED | | Domain::STATUS_LDAP_READY | Domain::STATUS_CONFIRMED | ||||
| Domain::STATUS_VERIFIED, | | Domain::STATUS_VERIFIED, | ||||
'type' => Domain::TYPE_EXTERNAL, | 'type' => Domain::TYPE_EXTERNAL, | ||||
]); | ]); | ||||
\App\Entitlement::create([ | |||||
'wallet_id' => $user->wallets()->first()->id, | |||||
'sku_id' => $sku_domain->id, | |||||
'entitleable_id' => $domain->id, | |||||
'entitleable_type' => Domain::class | |||||
]); | |||||
$browser->visit(new DomainPage($domain->id)) | $browser->visit(new DomainPage($domain->id)) | ||||
->assertVisible('@domain-info #button-suspend') | ->assertVisible('@domain-info #button-suspend') | ||||
->assertMissing('@domain-info #button-unsuspend') | ->assertMissing('@domain-info #button-unsuspend') | ||||
->click('@domain-info #button-suspend') | ->click('@domain-info #button-suspend') | ||||
->assertToast(Toast::TYPE_SUCCESS, 'Domain suspended successfully.') | ->assertToast(Toast::TYPE_SUCCESS, 'Domain suspended successfully.') | ||||
->assertSeeIn('@domain-info #status span.text-warning', 'Suspended') | ->assertSeeIn('@domain-info #status span.text-warning', 'Suspended') | ||||
->assertMissing('@domain-info #button-suspend') | ->assertMissing('@domain-info #button-suspend') | ||||
->click('@domain-info #button-unsuspend') | ->click('@domain-info #button-unsuspend') | ||||
->assertToast(Toast::TYPE_SUCCESS, 'Domain unsuspended successfully.') | ->assertToast(Toast::TYPE_SUCCESS, 'Domain unsuspended successfully.') | ||||
->assertSeeIn('@domain-info #status span.text-success', 'Active') | ->assertSeeIn('@domain-info #status span.text-success', 'Active') | ||||
->assertVisible('@domain-info #button-suspend') | ->assertVisible('@domain-info #button-suspend') | ||||
->assertMissing('@domain-info #button-unsuspend'); | ->assertMissing('@domain-info #button-unsuspend'); | ||||
}); | }); | ||||
} | } | ||||
} | } |