@@ -18,7 +18,7 @@
{{ ctrans('texts.dashboard') }}
-
+
{{ ctrans('texts.quick_overview_statistics') }}
diff --git a/tests/Browser/ClientPortalTest.php b/tests/Browser/ClientPortalTest.php
index a0673ed37793..f06bf69237ef 100644
--- a/tests/Browser/ClientPortalTest.php
+++ b/tests/Browser/ClientPortalTest.php
@@ -2,15 +2,13 @@
namespace Tests\Browser;
-use App\DataMapper\CompanySettings;
-use App\DataMapper\DefaultSettings;
use App\Models\ClientContact;
+use App\Models\Credit;
+use App\Models\Invoice;
+use App\Models\Payment;
+use App\Models\RecurringInvoice;
use App\Utils\Traits\MakesHash;
-use Hash;
-use Illuminate\Foundation\Testing\DatabaseTransactions;
use Illuminate\Foundation\Testing\WithFaker;
-use Illuminate\Support\Facades\DB;
-use Laravel\Dusk\Browser;
use Tests\DuskTestCase;
class ClientPortalTest extends DuskTestCase
@@ -18,104 +16,38 @@ class ClientPortalTest extends DuskTestCase
use WithFaker;
use MakesHash;
+ public $contact;
+
+ public function tearDown(): void
+ {
+ parent::tearDown();
+
+ $this->browse(function ($browser) {
+ $browser->driver->manage()->deleteAllCookies();
+ });
+ }
+
public function testLoginPageDisplayed()
{
$this->browse(function ($browser) {
$browser->visit('/client/login')
- ->assertPathIs('/client/login');
+ ->assertPathIs('/client/login');
});
}
- /**
- * A valid user can be logged in.
- *
- * @return void
- */
public function testLoginAValidUser()
{
- \Eloquent::unguard();
-
- $faker = \Faker\Factory::create();
-
- $account = factory(\App\Models\Account::class)->create();
- $company = factory(\App\Models\Company::class)->create([
- 'account_id' => $account->id,
- ]);
-
- $account->default_company_id = $company->id;
- $account->save();
-
- $user = factory(\App\Models\User::class)->create([
- 'email' => $faker->email,
- 'account_id' => $account->id,
- 'confirmation_code' => $this->createDbHash(config('database.default'))
- ]);
-
- $company_token = \App\Models\CompanyToken::create([
- 'user_id' => $user->id,
- 'company_id' => $company->id,
- 'account_id' => $account->id,
- 'name' => 'test token',
- 'token' => \Illuminate\Support\Str::random(64),
- ]);
-
- $user->companies()->attach($company->id, [
- 'account_id' => $account->id,
- 'is_owner' => 1,
- 'is_admin' => 1,
- 'is_locked' => 0,
- 'notifications' => CompanySettings::notificationDefaults(),
- 'permissions' => '',
- 'settings' => null,
- ]);
-
- $client = factory(\App\Models\Client::class)->create([
- 'user_id' => $user->id,
- 'company_id' => $company->id
- ]);
-
-
- $contact = new ClientContact;
- $contact->first_name = $faker->firstName;
- $contact->last_name = $faker->lastName;
- $contact->email = $faker->email;
- $contact->company_id = $company->id;
- $contact->password = Hash::make(config('ninja.testvars.password'));
- $contact->email_verified_at = now();
- $contact->client_id = $client->id;
- $contact->save();
-
-
- $this->browse(function ($browser) use ($contact) {
+ $this->browse(function ($browser) {
$browser->visit('/client/login')
- ->type('email', $contact->email)
- ->type('password', config('ninja.testvars.password'))
- ->press('Login')
- ->assertPathIs('/client/dashboard');
-
- $browser->visit('client/invoices')
- ->assertSee('Invoice Number');
-
- $browser->with('.table', function ($table) {
- $table->assertSee('Invoice Date');
- });
-
- $browser->visit('client/payments')
- ->assertSee('Payment Date');
-
- $browser->visit('client/recurring_invoices')
- ->assertSee('Frequency');
-
- $browser->visit('client/logout')
- ->assertPathIs('/client/login');
+ ->type('email', 'user@example.com')
+ ->type('password', config('ninja.testvars.password'))
+ ->press('Login')
+ ->assertPathIs('/client/dashboard')
+ ->visit('client/logout')
+ ->assertPathIs('/client/login');
});
}
- /**
- * Testing sidebar pages availability.
- *
- * @return void
- */
public function testDashboardElements(): void
{
$this->browse(function ($browser) {
@@ -126,11 +58,7 @@ class ClientPortalTest extends DuskTestCase
->assertPathIs('/client/dashboard');
$browser->visit('/client/dashboard')
- ->assertSee(strtoupper(ctrans('texts.total_invoiced')))
- ->assertSee(strtoupper(ctrans('texts.paid_to_date')))
- ->assertSee(strtoupper(ctrans('texts.open_balance')))
- ->assertSee(ctrans('texts.client_information'))
- ->assertSee(\App\Models\Client::first()->name)
+ ->assertSee(ctrans('texts.quick_overview_statistics'))
->visit('client/logout')
->assertPathIs('/client/login');
});
@@ -150,40 +78,39 @@ class ClientPortalTest extends DuskTestCase
->press('Login')
->assertPathIs('/client/dashboard');
+ $invoice = Invoice::first();
+
$browser->visit('/client/invoices')
->assertSee(ctrans('texts.pay_now'))
- ->waitFor('.dataTable')
- ->waitFor('.page-item')
- ->assertVisible('.page-item')
- ->assertVisible('tr.odd')
- ->assertVisible('#datatable_info')
- ->assertMissing('.dataTables_empty')
+ ->assertSee($invoice->number)
+ ->clickLink(ctrans('texts.view'))
+ ->assertPathIs(route('client.invoice.show', $invoice->hashed_id, false))
+ ->assertSee(ctrans('texts.pay_now'));
+
+ $browser->visit('/client/invoices')
+ ->check('#paid')
+ ->assertSee(ctrans('texts.paid'))
->visit('client/logout')
->assertPathIs('/client/login');
});
}
- /**
- * Testing recurring invoices list.
- *
- * @return void
- */
public function testRecurringInvoicesElements(): void
{
$this->browse(function ($browser) {
$browser->visit('/client/login')
- ->assertPathIs('/client/login')
->type('email', 'user@example.com')
->type('password', config('ninja.testvars.password'))
->press('Login')
->assertPathIs('/client/dashboard');
+ $invoice = RecurringInvoice::first();
+
$browser->visit('/client/recurring_invoices')
- ->waitFor('.dataTable')
- ->waitFor('.page-link')
- ->assertVisible('.page-link')
- ->assertVisible('#datatable_info')
- ->visit('client/logout')
+ ->assertSee(ctrans('texts.recurring_invoices'))
+ ->clickLink(ctrans('texts.view'))
+ ->assertPathIs(route('client.recurring_invoices.show', $invoice->hashed_id, false))
+ ->visit('/client/logout')
->assertPathIs('/client/login');
});
}
@@ -196,17 +123,17 @@ class ClientPortalTest extends DuskTestCase
public function testPaymentsElements(): void
{
$this->browse(function ($browser) {
- $browser
- ->visit('/client/logout')
- ->visit('/client/login')
+ $browser->visit('/client/login')
->type('email', 'user@example.com')
->type('password', config('ninja.testvars.password'))
->press('Login')
->assertPathIs('/client/dashboard');
+ $payment = Payment::first();
+
$browser->visit('/client/payments')
- ->waitFor('.dataTable')
- ->assertVisible('#datatable_info')
+ ->clickLink(ctrans('texts.view'))
+ ->assertPathIs(route('client.payments.show', $payment->hashed_id, false))
->visit('/client/logout')
->assertPathIs('/client/login');
});
@@ -220,17 +147,49 @@ class ClientPortalTest extends DuskTestCase
public function testPaymentMethodsElements(): void
{
$this->browse(function ($browser) {
- $browser->visit('/client/logout')
- ->visit('/client/login')
+ $browser->visit('/client/login')
->type('email', 'user@example.com')
->type('password', config('ninja.testvars.password'))
->press('Login')
->assertPathIs('/client/dashboard');
$browser->visit('/client/payment_methods')
- ->waitFor('.dataTable')
- ->assertVisible('#datatable_info')
- // ->assertVisible('.dataTables_empty');
+ ->assertSee('No results found.')
+ ->visit('client/logout')
+ ->assertPathIs('/client/login');
+ });
+ }
+
+ public function testQuotesElements(): void
+ {
+ $this->browse(function ($browser) {
+ $browser->visit('/client/login')
+ ->type('email', 'user@example.com')
+ ->type('password', config('ninja.testvars.password'))
+ ->press('Login')
+ ->assertPathIs('/client/dashboard');
+
+ $credit = Credit::first();
+
+ $browser->visit('/client/quotes')
+ ->clickLink(ctrans('texts.view'))
+ ->assertPathIs(route('client.credits.show', $credit->hashed_id, false))
+ ->visit('client/logout')
+ ->assertPathIs('/client/login');
+ });
+ }
+
+ public function testCreditsElements(): void
+ {
+ $this->browse(function ($browser) {
+ $browser->visit('/client/login')
+ ->type('email', 'user@example.com')
+ ->type('password', config('ninja.testvars.password'))
+ ->press('Login')
+ ->assertPathIs('/client/dashboard');
+
+ $browser->visit('/client/credits')
+ ->assertSee('No results found.')
->visit('client/logout')
->assertPathIs('/client/login');
});
@@ -252,10 +211,10 @@ class ClientPortalTest extends DuskTestCase
$browser->maximize();
$browser->visit(sprintf('/client/profile/%s/edit', $client_contact->client->user->hashed_id))
- ->assertSee(ctrans('texts.details'));
+ ->assertSee(ctrans('texts.profile'));
$first_name = $browser->value('#first_name');
-
+
$browser->value('#first_name', $faker->firstName);
$browser->assertSee(ctrans('texts.save'))
@@ -267,48 +226,4 @@ class ClientPortalTest extends DuskTestCase
->assertPathIs('/client/login');
});
}
-
- /**
- * Test 'profile page' updating functions.
- *
- * @return void
- */
- public function testProfilePageClientUpdate(): void
- {
- $faker = \Faker\Factory::create();
-
- $this->browse(function ($browser) use ($faker) {
- $browser->visit('/client/login')
- ->type('email', 'user@example.com')
- ->type('password', config('ninja.testvars.password'))
- ->press('Login')
- ->assertPathIs('/client/dashboard');
-
- $client_contact = ClientContact::where('email', 'user@example.com')->first();
-
- $browser->visit(sprintf('/client/profile/%s/edit', $client_contact->client->user->hashed_id))
- ->assertSee(ctrans('texts.client_information'));
-
- $browser->driver->executeScript('window.scrollTo(0, document.body.scrollHeight)');
-
- $browser->value('#name', '')
- ->assertVisible('#update_settings > .card > .card-body > button')
- ->click('#update_settings > .card > .card-body > button')
- ->assertVisible('.invalid-feedback');
-
-
- $name = $browser->value('#name');
-
- $browser->maximize();
- $browser->driver->executeScript('window.scrollTo(0, document.body.scrollHeight)');
-
- $browser->value('#name', $faker->name)
- ->assertVisible('#update_settings > .card > .card-body > button')
- ->click('#update_settings > .card > .card-body > button');
-
- $this->assertNotEquals($name, $browser->value('#name'));
-
- $browser->driver->executeScript('window.scrollTo(0, document.body.scrollHeight)');
- });
- }
}
diff --git a/tests/DuskTestCase.php b/tests/DuskTestCase.php
index 3f7998b4eca0..494cc8d72ab5 100644
--- a/tests/DuskTestCase.php
+++ b/tests/DuskTestCase.php
@@ -31,7 +31,6 @@ abstract class DuskTestCase extends BaseTestCase
{
$options = (new ChromeOptions)->addArguments([
'--disable-gpu',
- '--headless'
]);
return RemoteWebDriver::create(