Changeset View
Changeset View
Standalone View
Standalone View
src/tests/Browser/DegradedAccountTest.php
- This file was added.
<?php | |||||
namespace Tests\Browser; | |||||
use App\User; | |||||
use Tests\Browser; | |||||
use Tests\Browser\Pages\Dashboard; | |||||
use Tests\Browser\Pages\Home; | |||||
use Tests\Browser\Pages\UserList; | |||||
use Tests\TestCaseDusk; | |||||
class DegradedAccountTest extends TestCaseDusk | |||||
{ | |||||
/** | |||||
* {@inheritDoc} | |||||
*/ | |||||
public function setUp(): void | |||||
{ | |||||
parent::setUp(); | |||||
$john = $this->getTestUser('john@kolab.org'); | |||||
if (!$john->isDegraded()) { | |||||
$john->status |= User::STATUS_DEGRADED; | |||||
User::where('id', $john->id)->update(['status' => $john->status]); | |||||
} | |||||
$this->clearBetaEntitlements(); | |||||
$this->clearMeetEntitlements(); | |||||
} | |||||
/** | |||||
* {@inheritDoc} | |||||
*/ | |||||
public function tearDown(): void | |||||
{ | |||||
$john = $this->getTestUser('john@kolab.org'); | |||||
if ($john->isDegraded()) { | |||||
$john->status ^= User::STATUS_DEGRADED; | |||||
User::where('id', $john->id)->update(['status' => $john->status]); | |||||
} | |||||
$this->clearBetaEntitlements(); | |||||
$this->clearMeetEntitlements(); | |||||
parent::tearDown(); | |||||
} | |||||
/** | |||||
* Test acting as an owner of a degraded account | |||||
*/ | |||||
public function testDegradedAccountOwner(): void | |||||
{ | |||||
$this->browse(function (Browser $browser) { | |||||
$browser->visit(new Home()) | |||||
->submitLogon('john@kolab.org', 'simple123', true) | |||||
->on(new Dashboard()) | |||||
->assertSeeIn('#status-degraded p.alert', 'The account is degraded') | |||||
->assertSeeIn('#status-degraded p.alert', 'Please, make a payment'); | |||||
// Goto /users and assert that the warning is also displayed there | |||||
$browser->visit(new UserList()) | |||||
->assertSeeIn('#status-degraded p.alert', 'The account is degraded') | |||||
->assertSeeIn('#status-degraded p.alert', 'Please, make a payment') | |||||
->whenAvailable('@table', function (Browser $browser) { | |||||
$browser->waitFor('tbody tr') | |||||
->assertVisible('tbody tr:nth-child(1) td:first-child svg.text-warning') // Jack | |||||
->assertText('tbody tr:nth-child(2) td:first-child svg.text-warning title', 'Degraded') | |||||
->assertVisible('tbody tr:nth-child(3) td:first-child svg.text-warning') // John | |||||
->assertText('tbody tr:nth-child(3) td:first-child svg.text-warning title', 'Degraded'); | |||||
}); | |||||
// Test that /rooms is not accessible | |||||
$browser->visit('/rooms') | |||||
->waitFor('#app > #error-page') | |||||
->assertSeeIn('#error-page .code', '403'); | |||||
}); | |||||
} | |||||
/** | |||||
* Test acting as non-owner of a degraded account | |||||
*/ | |||||
public function testDegradedAccountUser(): void | |||||
{ | |||||
$this->browse(function (Browser $browser) { | |||||
$browser->visit(new Home()) | |||||
->submitLogon('jack@kolab.org', 'simple123', true) | |||||
->on(new Dashboard()) | |||||
->assertSeeIn('#status-degraded p.alert', 'The account is degraded') | |||||
->assertDontSeeIn('#status-degraded p.alert', 'Please, make a payment'); | |||||
}); | |||||
} | |||||
} |