2021-07-06 14:13:18 +02:00
|
|
|
<?php
|
|
|
|
|
|
|
|
namespace Tests\Browser\ClientPortal;
|
|
|
|
|
2021-07-06 14:31:14 +02:00
|
|
|
use Faker\Factory;
|
|
|
|
use Faker\Generator;
|
2021-07-06 14:13:18 +02:00
|
|
|
use Laravel\Dusk\Browser;
|
|
|
|
use Tests\Browser\Pages\ClientPortal\Login;
|
|
|
|
use Tests\DuskTestCase;
|
|
|
|
|
|
|
|
class ProfileSettingsTest extends DuskTestCase
|
|
|
|
{
|
2021-07-06 14:31:14 +02:00
|
|
|
/** @var Generator */
|
|
|
|
public $faker;
|
|
|
|
|
2021-07-06 14:13:18 +02:00
|
|
|
protected function setUp(): void
|
|
|
|
{
|
|
|
|
parent::setUp();
|
|
|
|
|
2021-07-06 14:31:14 +02:00
|
|
|
$this->faker = Factory::create();
|
|
|
|
|
2021-07-06 14:13:18 +02:00
|
|
|
foreach (static::$browsers as $browser) {
|
|
|
|
$browser->driver->manage()->deleteAllCookies();
|
|
|
|
}
|
|
|
|
|
|
|
|
$this->browse(function (Browser $browser) {
|
|
|
|
$browser
|
|
|
|
->visit(new Login())
|
|
|
|
->auth();
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
public function testPageLoads()
|
|
|
|
{
|
|
|
|
$this->browse(function (Browser $browser) {
|
|
|
|
$browser
|
|
|
|
->visitRoute('client.invoices.index')
|
|
|
|
->click('button[data-ref="client-profile-dropdown"]')
|
|
|
|
->click('a[data-ref="client-profile-dropdown-settings"]')
|
|
|
|
->waitForText('Client Information')
|
|
|
|
->assertSeeIn('span[data-ref="meta-title"]', 'Client Information')
|
|
|
|
->visitRoute('client.logout');
|
|
|
|
});
|
|
|
|
}
|
2021-07-06 14:31:14 +02:00
|
|
|
|
|
|
|
public function testClientDetailsUpdate()
|
|
|
|
{
|
|
|
|
$original = [
|
|
|
|
'name' => $this->faker->name,
|
|
|
|
'vat_number' => $this->faker->randomNumber(6),
|
|
|
|
'phone' => $this->faker->phoneNumber,
|
|
|
|
'website' => $this->faker->url,
|
|
|
|
];
|
|
|
|
|
|
|
|
$this->browse(function (Browser $browser) use ($original) {
|
|
|
|
$browser
|
|
|
|
->visitRoute('client.invoices.index')
|
|
|
|
->click('button[data-ref="client-profile-dropdown"]')
|
|
|
|
->click('a[data-ref="client-profile-dropdown-settings"]')
|
|
|
|
->waitForText('Client Information');
|
|
|
|
|
|
|
|
$browser
|
|
|
|
->type('name', $original['name'])
|
|
|
|
->type('vat_number', $original['vat_number'])
|
|
|
|
->type('phone', $original['phone'])
|
|
|
|
->type('website', $original['website'])
|
|
|
|
->press('Save')
|
|
|
|
->refresh();
|
|
|
|
|
|
|
|
$updated = [
|
|
|
|
'name' => $browser->inputValue('name'),
|
|
|
|
'vat_number' => $browser->inputValue('vat_number'),
|
|
|
|
'phone' => $browser->inputValue('phone'),
|
|
|
|
'website' => $browser->inputValue('website')
|
|
|
|
];
|
|
|
|
|
|
|
|
$this->assertNotSame($original, $updated);
|
|
|
|
});
|
|
|
|
}
|
2021-07-06 14:13:18 +02:00
|
|
|
}
|