From ed55940d4f32d870f629f9a431dcf6315935d108 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 2 Jul 2021 15:37:49 +0200 Subject: [PATCH 01/88] Install laravel/dusk --- composer.json | 1 + composer.lock | 141 +++++++++++++++++++++++++++++++++++++++++++++++++- 2 files changed, 141 insertions(+), 1 deletion(-) diff --git a/composer.json b/composer.json index aac5045c9a80..060b616e649e 100644 --- a/composer.json +++ b/composer.json @@ -85,6 +85,7 @@ "fakerphp/faker": "^1.14", "filp/whoops": "^2.7", "friendsofphp/php-cs-fixer": "^2.16", + "laravel/dusk": "^6.15", "mockery/mockery": "^1.3.1", "nunomaduro/collision": "^5.0", "phpunit/phpunit": "^9.0", diff --git a/composer.lock b/composer.lock index 8f7e0b5d340e..514bdeb65287 100644 --- a/composer.lock +++ b/composer.lock @@ -4,7 +4,7 @@ "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", "This file is @generated automatically" ], - "content-hash": "013b0357f14c1782315168bc42234b34", + "content-hash": "fd79af6e4cc28ff40894070b09b431a3", "packages": [ { "name": "asm/php-ansible", @@ -11774,6 +11774,79 @@ }, "time": "2020-07-09T08:09:16+00:00" }, + { + "name": "laravel/dusk", + "version": "v6.15.0", + "source": { + "type": "git", + "url": "https://github.com/laravel/dusk.git", + "reference": "45b55fa20321086c4f8cc4e712cbe54db644e21c" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/laravel/dusk/zipball/45b55fa20321086c4f8cc4e712cbe54db644e21c", + "reference": "45b55fa20321086c4f8cc4e712cbe54db644e21c", + "shasum": "" + }, + "require": { + "ext-json": "*", + "ext-zip": "*", + "illuminate/console": "^6.0|^7.0|^8.0", + "illuminate/support": "^6.0|^7.0|^8.0", + "nesbot/carbon": "^2.0", + "php": "^7.2|^8.0", + "php-webdriver/webdriver": "^1.9.0", + "symfony/console": "^4.3|^5.0", + "symfony/finder": "^4.3|^5.0", + "symfony/process": "^4.3|^5.0", + "vlucas/phpdotenv": "^3.0|^4.0|^5.0" + }, + "require-dev": { + "mockery/mockery": "^1.0", + "orchestra/testbench": "^4.16|^5.17.1|^6.12.1", + "phpunit/phpunit": "^7.5.15|^8.4|^9.0" + }, + "suggest": { + "ext-pcntl": "Used to gracefully terminate Dusk when tests are running." + }, + "type": "library", + "extra": { + "branch-alias": { + "dev-master": "6.x-dev" + }, + "laravel": { + "providers": [ + "Laravel\\Dusk\\DuskServiceProvider" + ] + } + }, + "autoload": { + "psr-4": { + "Laravel\\Dusk\\": "src/" + } + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "authors": [ + { + "name": "Taylor Otwell", + "email": "taylor@laravel.com" + } + ], + "description": "Laravel Dusk provides simple end-to-end testing and browser automation.", + "keywords": [ + "laravel", + "testing", + "webdriver" + ], + "support": { + "issues": "https://github.com/laravel/dusk/issues", + "source": "https://github.com/laravel/dusk/tree/v6.15.0" + }, + "time": "2021-04-06T14:14:57+00:00" + }, { "name": "maximebf/debugbar", "version": "v1.16.5", @@ -12327,6 +12400,72 @@ }, "time": "2020-10-14T08:39:05+00:00" }, + { + "name": "php-webdriver/webdriver", + "version": "1.11.1", + "source": { + "type": "git", + "url": "https://github.com/php-webdriver/php-webdriver.git", + "reference": "da16e39968f8dd5cfb7d07eef91dc2b731c69880" + }, + "dist": { + "type": "zip", + "url": "https://api.github.com/repos/php-webdriver/php-webdriver/zipball/da16e39968f8dd5cfb7d07eef91dc2b731c69880", + "reference": "da16e39968f8dd5cfb7d07eef91dc2b731c69880", + "shasum": "" + }, + "require": { + "ext-curl": "*", + "ext-json": "*", + "ext-zip": "*", + "php": "^5.6 || ~7.0 || ^8.0", + "symfony/polyfill-mbstring": "^1.12", + "symfony/process": "^2.8 || ^3.1 || ^4.0 || ^5.0" + }, + "replace": { + "facebook/webdriver": "*" + }, + "require-dev": { + "friendsofphp/php-cs-fixer": "^2.0", + "ondram/ci-detector": "^2.1 || ^3.5 || ^4.0", + "php-coveralls/php-coveralls": "^2.4", + "php-mock/php-mock-phpunit": "^1.1 || ^2.0", + "php-parallel-lint/php-parallel-lint": "^1.2", + "phpunit/phpunit": "^5.7 || ^7 || ^8 || ^9", + "squizlabs/php_codesniffer": "^3.5", + "symfony/var-dumper": "^3.3 || ^4.0 || ^5.0" + }, + "suggest": { + "ext-SimpleXML": "For Firefox profile creation" + }, + "type": "library", + "autoload": { + "psr-4": { + "Facebook\\WebDriver\\": "lib/" + }, + "files": [ + "lib/Exception/TimeoutException.php" + ] + }, + "notification-url": "https://packagist.org/downloads/", + "license": [ + "MIT" + ], + "description": "A PHP client for Selenium WebDriver. Previously facebook/webdriver.", + "homepage": "https://github.com/php-webdriver/php-webdriver", + "keywords": [ + "Chromedriver", + "geckodriver", + "php", + "selenium", + "webdriver" + ], + "support": { + "issues": "https://github.com/php-webdriver/php-webdriver/issues", + "source": "https://github.com/php-webdriver/php-webdriver/tree/1.11.1" + }, + "time": "2021-05-21T15:12:49+00:00" + }, { "name": "phpdocumentor/reflection-common", "version": "2.2.0", From d7a4bc711c15f5eb9daeb9c0580e10e1a1e42879 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 2 Jul 2021 15:40:29 +0200 Subject: [PATCH 02/88] Post-installation of laravel/dusk --- tests/Browser/ExampleTest.php | 23 +++++++++++ tests/Browser/Pages/HomePage.php | 41 +++++++++++++++++++ tests/Browser/Pages/Page.php | 20 +++++++++ tests/Browser/console/.gitignore | 2 + tests/Browser/screenshots/.gitignore | 2 + tests/DuskTestCase.php | 61 ++++++++++++++++++++++++++++ 6 files changed, 149 insertions(+) create mode 100644 tests/Browser/ExampleTest.php create mode 100644 tests/Browser/Pages/HomePage.php create mode 100644 tests/Browser/Pages/Page.php create mode 100644 tests/Browser/console/.gitignore create mode 100644 tests/Browser/screenshots/.gitignore create mode 100644 tests/DuskTestCase.php diff --git a/tests/Browser/ExampleTest.php b/tests/Browser/ExampleTest.php new file mode 100644 index 000000000000..9d8968b2f00c --- /dev/null +++ b/tests/Browser/ExampleTest.php @@ -0,0 +1,23 @@ +browse(function (Browser $browser) { + $browser->visit('/') + ->assertSee('Laravel'); + }); + } +} diff --git a/tests/Browser/Pages/HomePage.php b/tests/Browser/Pages/HomePage.php new file mode 100644 index 000000000000..e01f999980d5 --- /dev/null +++ b/tests/Browser/Pages/HomePage.php @@ -0,0 +1,41 @@ + '#selector', + ]; + } +} diff --git a/tests/Browser/Pages/Page.php b/tests/Browser/Pages/Page.php new file mode 100644 index 000000000000..f8d76222c01b --- /dev/null +++ b/tests/Browser/Pages/Page.php @@ -0,0 +1,20 @@ + '#selector', + ]; + } +} diff --git a/tests/Browser/console/.gitignore b/tests/Browser/console/.gitignore new file mode 100644 index 000000000000..d6b7ef32c847 --- /dev/null +++ b/tests/Browser/console/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/tests/Browser/screenshots/.gitignore b/tests/Browser/screenshots/.gitignore new file mode 100644 index 000000000000..d6b7ef32c847 --- /dev/null +++ b/tests/Browser/screenshots/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore diff --git a/tests/DuskTestCase.php b/tests/DuskTestCase.php new file mode 100644 index 000000000000..b4394174318d --- /dev/null +++ b/tests/DuskTestCase.php @@ -0,0 +1,61 @@ +addArguments(collect([ + '--window-size=1920,1080', + ])->unless($this->hasHeadlessDisabled(), function ($items) { + return $items->merge([ + '--disable-gpu', + '--headless', + ]); + })->all()); + + return RemoteWebDriver::create( + $_ENV['DUSK_DRIVER_URL'] ?? 'http://localhost:9515', + DesiredCapabilities::chrome()->setCapability( + ChromeOptions::CAPABILITY, $options + ) + ); + } + + /** + * Determine whether the Dusk command has disabled headless mode. + * + * @return bool + */ + protected function hasHeadlessDisabled() + { + return isset($_SERVER['DUSK_HEADLESS_DISABLED']) || + isset($_ENV['DUSK_HEADLESS_DISABLED']); + } +} From d7d966cd56732f5cabda1e432ab5270aa3a383cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 2 Jul 2021 16:19:32 +0200 Subject: [PATCH 03/88] Login test: Login page, login validation, forgot password link --- tests/Browser/ClientPortal/LoginTest.php | 55 ++++++++++++++++++++++++ 1 file changed, 55 insertions(+) create mode 100644 tests/Browser/ClientPortal/LoginTest.php diff --git a/tests/Browser/ClientPortal/LoginTest.php b/tests/Browser/ClientPortal/LoginTest.php new file mode 100644 index 000000000000..a2ed80073d82 --- /dev/null +++ b/tests/Browser/ClientPortal/LoginTest.php @@ -0,0 +1,55 @@ +driver->manage()->deleteAllCookies(); + } + } + + public function testLoginPage() + { + $this->browse(function (Browser $browser) { + $browser + ->visit(route('client.login')) + ->assertSee('Client Portal') + ->type('email', 'user@example.com') + ->type('password', 'password') + ->press('Login'); + + $browser->assertPathIs('/client/invoices'); + }); + } + + public function testLoginFormValidation() + { + $this->browse(function (Browser $browser) { + $browser + ->visit(route('client.login')) + ->press('Login') + ->assertSee('The email field is required.') + ->assertSee('The password field is required.'); + }); + } + + public function testForgotPasswordLink() + { + $this->browse(function (Browser $browser) { + $browser + ->visit(route('client.login')) + ->assertSeeLink('Forgot your password?') + ->clickLink('Forgot your password?') + ->assertPathIs('/client/password/reset'); + }); + } +} From 817de978e315df7ab4325bde7e974b526f5e57cd Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 2 Jul 2021 16:20:23 +0200 Subject: [PATCH 04/88] Remove Laravel Dusk scaffold files --- tests/Browser/ExampleTest.php | 23 ---------------- tests/Browser/Pages/HomePage.php | 41 ---------------------------- tests/Browser/Pages/Page.php | 20 -------------- tests/Browser/console/.gitignore | 2 -- tests/Browser/screenshots/.gitignore | 2 -- tests/DuskTestCase.php | 1 - 6 files changed, 89 deletions(-) delete mode 100644 tests/Browser/ExampleTest.php delete mode 100644 tests/Browser/Pages/HomePage.php delete mode 100644 tests/Browser/Pages/Page.php delete mode 100644 tests/Browser/console/.gitignore delete mode 100644 tests/Browser/screenshots/.gitignore diff --git a/tests/Browser/ExampleTest.php b/tests/Browser/ExampleTest.php deleted file mode 100644 index 9d8968b2f00c..000000000000 --- a/tests/Browser/ExampleTest.php +++ /dev/null @@ -1,23 +0,0 @@ -browse(function (Browser $browser) { - $browser->visit('/') - ->assertSee('Laravel'); - }); - } -} diff --git a/tests/Browser/Pages/HomePage.php b/tests/Browser/Pages/HomePage.php deleted file mode 100644 index e01f999980d5..000000000000 --- a/tests/Browser/Pages/HomePage.php +++ /dev/null @@ -1,41 +0,0 @@ - '#selector', - ]; - } -} diff --git a/tests/Browser/Pages/Page.php b/tests/Browser/Pages/Page.php deleted file mode 100644 index f8d76222c01b..000000000000 --- a/tests/Browser/Pages/Page.php +++ /dev/null @@ -1,20 +0,0 @@ - '#selector', - ]; - } -} diff --git a/tests/Browser/console/.gitignore b/tests/Browser/console/.gitignore deleted file mode 100644 index d6b7ef32c847..000000000000 --- a/tests/Browser/console/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/tests/Browser/screenshots/.gitignore b/tests/Browser/screenshots/.gitignore deleted file mode 100644 index d6b7ef32c847..000000000000 --- a/tests/Browser/screenshots/.gitignore +++ /dev/null @@ -1,2 +0,0 @@ -* -!.gitignore diff --git a/tests/DuskTestCase.php b/tests/DuskTestCase.php index b4394174318d..74a0a3871dac 100644 --- a/tests/DuskTestCase.php +++ b/tests/DuskTestCase.php @@ -36,7 +36,6 @@ abstract class DuskTestCase extends BaseTestCase ])->unless($this->hasHeadlessDisabled(), function ($items) { return $items->merge([ '--disable-gpu', - '--headless', ]); })->all()); From 16e9cd37a6909d782499d9d8e5643bd6e97c7d09 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 2 Jul 2021 16:21:42 +0200 Subject: [PATCH 05/88] Update copyright on LoginTest.php --- tests/Browser/ClientPortal/LoginTest.php | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/tests/Browser/ClientPortal/LoginTest.php b/tests/Browser/ClientPortal/LoginTest.php index a2ed80073d82..407e2f3c2999 100644 --- a/tests/Browser/ClientPortal/LoginTest.php +++ b/tests/Browser/ClientPortal/LoginTest.php @@ -1,5 +1,15 @@ Date: Fri, 2 Jul 2021 16:36:29 +0200 Subject: [PATCH 06/88] Add .gitignore to screenshots/ folder --- tests/Browser/screenshots/.gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 tests/Browser/screenshots/.gitignore diff --git a/tests/Browser/screenshots/.gitignore b/tests/Browser/screenshots/.gitignore new file mode 100644 index 000000000000..d6b7ef32c847 --- /dev/null +++ b/tests/Browser/screenshots/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore From 4cf049b9fa8b2a75be8a7baeed60470d9185d23d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 2 Jul 2021 16:36:45 +0200 Subject: [PATCH 07/88] Extract login/authentication in Login.php --- tests/Browser/Pages/ClientPortal/Login.php | 51 ++++++++++++++++++++++ 1 file changed, 51 insertions(+) create mode 100644 tests/Browser/Pages/ClientPortal/Login.php diff --git a/tests/Browser/Pages/ClientPortal/Login.php b/tests/Browser/Pages/ClientPortal/Login.php new file mode 100644 index 000000000000..11125eba444a --- /dev/null +++ b/tests/Browser/Pages/ClientPortal/Login.php @@ -0,0 +1,51 @@ +assertPathIs($this->url()); + } + + /** + * Get the element shortcuts for the page. + * + * @return array + */ + public function elements() + { + return [ + '@element' => '#selector', + ]; + } + + public function auth(Browser $browser) + { + $browser + ->visitRoute('client.login') + ->type('email', 'user@example.com') + ->type('password', 'password') + ->press('Login'); + } +} From 7aa7fc5e297325c9d7ab49dba9e04f50e837af4d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 2 Jul 2021 16:36:53 +0200 Subject: [PATCH 08/88] Invoices: Assert page loads --- tests/Browser/ClientPortal/InvoicesTest.php | 32 +++++++++++++++++++++ 1 file changed, 32 insertions(+) create mode 100644 tests/Browser/ClientPortal/InvoicesTest.php diff --git a/tests/Browser/ClientPortal/InvoicesTest.php b/tests/Browser/ClientPortal/InvoicesTest.php new file mode 100644 index 000000000000..3d027a9ea88c --- /dev/null +++ b/tests/Browser/ClientPortal/InvoicesTest.php @@ -0,0 +1,32 @@ +driver->manage()->deleteAllCookies(); + } + } + + public function testPageLoads() + { + $this->browse(function (Browser $browser) { + $browser + ->visit(new Login()) + ->auth() + ->visitRoute('client.invoices.index') + ->assertSee('Invoices'); + }); + } +} From f55276c429d5d9b9522f884f4c2f8d546b28ff78 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 2 Jul 2021 16:51:13 +0200 Subject: [PATCH 09/88] Recurring invoices: Assert page loads --- tests/Browser/ClientPortal/InvoicesTest.php | 2 -- .../ClientPortal/RecurringInvoices.php | 30 +++++++++++++++++++ 2 files changed, 30 insertions(+), 2 deletions(-) create mode 100644 tests/Browser/ClientPortal/RecurringInvoices.php diff --git a/tests/Browser/ClientPortal/InvoicesTest.php b/tests/Browser/ClientPortal/InvoicesTest.php index 3d027a9ea88c..6ad5bb004c69 100644 --- a/tests/Browser/ClientPortal/InvoicesTest.php +++ b/tests/Browser/ClientPortal/InvoicesTest.php @@ -2,8 +2,6 @@ namespace Tests\Browser\ClientPortal; -use App\Models\ClientContact; -use Illuminate\Foundation\Testing\DatabaseMigrations; use Laravel\Dusk\Browser; use Tests\Browser\Pages\ClientPortal\Login; use Tests\DuskTestCase; diff --git a/tests/Browser/ClientPortal/RecurringInvoices.php b/tests/Browser/ClientPortal/RecurringInvoices.php new file mode 100644 index 000000000000..47bc1b858c65 --- /dev/null +++ b/tests/Browser/ClientPortal/RecurringInvoices.php @@ -0,0 +1,30 @@ +driver->manage()->deleteAllCookies(); + } + } + + public function testPageLoads() + { + $this->browse(function (Browser $browser) { + $browser + ->visit(new Login()) + ->auth() + ->visitRoute('client.recurring_invoices.index') + ->assertSee('Recurring Invoices'); + }); + } +} From 553ce88af04ee6807e3891c285bf92b8d7d59770 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 2 Jul 2021 16:51:24 +0200 Subject: [PATCH 10/88] Revert 'headless' mode in Dusk --- tests/DuskTestCase.php | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/DuskTestCase.php b/tests/DuskTestCase.php index 74a0a3871dac..b4394174318d 100644 --- a/tests/DuskTestCase.php +++ b/tests/DuskTestCase.php @@ -36,6 +36,7 @@ abstract class DuskTestCase extends BaseTestCase ])->unless($this->hasHeadlessDisabled(), function ($items) { return $items->merge([ '--disable-gpu', + '--headless', ]); })->all()); From 213e1ab957bafed26dc00cddf78a6af2acbbfbe3 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 2 Jul 2021 16:52:16 +0200 Subject: [PATCH 11/88] Payments: Assert page loads --- tests/Browser/ClientPortal/PaymentsTest.php | 30 +++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tests/Browser/ClientPortal/PaymentsTest.php diff --git a/tests/Browser/ClientPortal/PaymentsTest.php b/tests/Browser/ClientPortal/PaymentsTest.php new file mode 100644 index 000000000000..cb9bd2bdc43c --- /dev/null +++ b/tests/Browser/ClientPortal/PaymentsTest.php @@ -0,0 +1,30 @@ +driver->manage()->deleteAllCookies(); + } + } + + public function testPageLoads() + { + $this->browse(function (Browser $browser) { + $browser + ->visit(new Login()) + ->auth() + ->visitRoute('client.payments.index') + ->assertSee('Recurring Invoices'); + }); + } +} From 40a4e3f3ea4ae80b3f9c9c41d35df70599856f0b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 2 Jul 2021 16:53:21 +0200 Subject: [PATCH 12/88] Quotes: Assert page loads --- tests/Browser/ClientPortal/QuotesTest.php | 30 +++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tests/Browser/ClientPortal/QuotesTest.php diff --git a/tests/Browser/ClientPortal/QuotesTest.php b/tests/Browser/ClientPortal/QuotesTest.php new file mode 100644 index 000000000000..84ccb9dbe13c --- /dev/null +++ b/tests/Browser/ClientPortal/QuotesTest.php @@ -0,0 +1,30 @@ +driver->manage()->deleteAllCookies(); + } + } + + public function testPageLoads() + { + $this->browse(function (Browser $browser) { + $browser + ->visit(new Login()) + ->auth() + ->visitRoute('client.quotes.index') + ->assertSee('Quotes'); + }); + } +} From 7e6663ac0b3385528f40bd247ecd3ce8645393b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 2 Jul 2021 16:53:57 +0200 Subject: [PATCH 13/88] Credits: Assert page loads --- tests/Browser/ClientPortal/CreditsTest.php | 30 ++++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tests/Browser/ClientPortal/CreditsTest.php diff --git a/tests/Browser/ClientPortal/CreditsTest.php b/tests/Browser/ClientPortal/CreditsTest.php new file mode 100644 index 000000000000..5a8e530b5334 --- /dev/null +++ b/tests/Browser/ClientPortal/CreditsTest.php @@ -0,0 +1,30 @@ +driver->manage()->deleteAllCookies(); + } + } + + public function testPageLoads() + { + $this->browse(function (Browser $browser) { + $browser + ->visit(new Login()) + ->auth() + ->visitRoute('client.credits.index') + ->assertSee('Credits'); + }); + } +} From ccf64f6a3dfce9b242f625a354591f07ba687cc6 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 2 Jul 2021 16:58:30 +0200 Subject: [PATCH 14/88] Payment Methods: Assert page loads --- .../ClientPortal/PaymentMethodsTest.php | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tests/Browser/ClientPortal/PaymentMethodsTest.php diff --git a/tests/Browser/ClientPortal/PaymentMethodsTest.php b/tests/Browser/ClientPortal/PaymentMethodsTest.php new file mode 100644 index 000000000000..ba9df0280f02 --- /dev/null +++ b/tests/Browser/ClientPortal/PaymentMethodsTest.php @@ -0,0 +1,30 @@ +driver->manage()->deleteAllCookies(); + } + } + + public function testPageLoads() + { + $this->browse(function (Browser $browser) { + $browser + ->visit(new Login()) + ->auth() + ->visitRoute('client.payment_methods.index') + ->assertSee('Payment Methods'); + }); + } +} From a2e25de6abdc2d81bf2600417d09d01b8da23053 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 2 Jul 2021 16:59:03 +0200 Subject: [PATCH 15/88] Documents: Assert page loads --- tests/Browser/ClientPortal/DocumentsTest.php | 30 ++++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tests/Browser/ClientPortal/DocumentsTest.php diff --git a/tests/Browser/ClientPortal/DocumentsTest.php b/tests/Browser/ClientPortal/DocumentsTest.php new file mode 100644 index 000000000000..1fa976d39289 --- /dev/null +++ b/tests/Browser/ClientPortal/DocumentsTest.php @@ -0,0 +1,30 @@ +driver->manage()->deleteAllCookies(); + } + } + + public function testPageLoads() + { + $this->browse(function (Browser $browser) { + $browser + ->visit(new Login()) + ->auth() + ->visitRoute('client.documents.index') + ->assertSee('Invoices'); + }); + } +} From 90e0d0cbabed7b56168e89dd1f21724a01fc2a37 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Fri, 2 Jul 2021 16:59:40 +0200 Subject: [PATCH 16/88] Subscriptions: Assert page loads --- .../ClientPortal/SubscriptionsTest.php | 30 +++++++++++++++++++ 1 file changed, 30 insertions(+) create mode 100644 tests/Browser/ClientPortal/SubscriptionsTest.php diff --git a/tests/Browser/ClientPortal/SubscriptionsTest.php b/tests/Browser/ClientPortal/SubscriptionsTest.php new file mode 100644 index 000000000000..d8c1d9fc2581 --- /dev/null +++ b/tests/Browser/ClientPortal/SubscriptionsTest.php @@ -0,0 +1,30 @@ +driver->manage()->deleteAllCookies(); + } + } + + public function testPageLoads() + { + $this->browse(function (Browser $browser) { + $browser + ->visit(new Login()) + ->auth() + ->visitRoute('client.subscriptions.index') + ->assertSee('Invoices'); + }); + } +} From 7b41f2dbd0fe8aa9566eb1d48751e675f7817b30 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Mon, 5 Jul 2021 10:04:11 +0200 Subject: [PATCH 17/88] Invoices: Test clicking "Pay Now" without selecting any invoices --- tests/Browser/ClientPortal/InvoicesTest.php | 22 ++++++++++++++++----- 1 file changed, 17 insertions(+), 5 deletions(-) diff --git a/tests/Browser/ClientPortal/InvoicesTest.php b/tests/Browser/ClientPortal/InvoicesTest.php index 6ad5bb004c69..c909ff9e2850 100644 --- a/tests/Browser/ClientPortal/InvoicesTest.php +++ b/tests/Browser/ClientPortal/InvoicesTest.php @@ -20,11 +20,23 @@ class InvoicesTest extends DuskTestCase public function testPageLoads() { $this->browse(function (Browser $browser) { - $browser - ->visit(new Login()) - ->auth() - ->visitRoute('client.invoices.index') - ->assertSee('Invoices'); + $browser + ->visit(new Login()) + ->auth() + ->visitRoute('client.invoices.index') + ->assertSee('Invoices'); + }); + } + + public function testClickingPayNowWithoutInvoices() + { + $this->browse(function (Browser $browser) { + $browser + ->visit(new Login()) + ->auth() + ->visitRoute('client.invoices.index') + ->press('Pay Now') + ->assertSee('No payable invoices selected. Make sure you are not trying to pay draft invoice or invoice with zero balance due.'); }); } } From dde0af3fd2397bc1dc6bd7f810be5f4a6087bee4 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Mon, 5 Jul 2021 10:05:03 +0200 Subject: [PATCH 18/88] Invoices: Test clicking "Download" without any invoices --- tests/Browser/ClientPortal/InvoicesTest.php | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/tests/Browser/ClientPortal/InvoicesTest.php b/tests/Browser/ClientPortal/InvoicesTest.php index c909ff9e2850..20c25adeb929 100644 --- a/tests/Browser/ClientPortal/InvoicesTest.php +++ b/tests/Browser/ClientPortal/InvoicesTest.php @@ -39,4 +39,16 @@ class InvoicesTest extends DuskTestCase ->assertSee('No payable invoices selected. Make sure you are not trying to pay draft invoice or invoice with zero balance due.'); }); } + + public function testClickingDownloadWithoutInvoices() + { + $this->browse(function (Browser $browser) { + $browser + ->visit(new Login()) + ->auth() + ->visitRoute('client.invoices.index') + ->press('Download') + ->assertSee('No items selected.'); + }); + } } From 1d1d04ccd1b1b6cfec6831e1aefde063e29b9be1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Mon, 5 Jul 2021 10:17:01 +0200 Subject: [PATCH 19/88] Invoices: Test clicking on "Pay Now" with selected invoice --- tests/Browser/ClientPortal/InvoicesTest.php | 33 +++++++++++++++------ 1 file changed, 24 insertions(+), 9 deletions(-) diff --git a/tests/Browser/ClientPortal/InvoicesTest.php b/tests/Browser/ClientPortal/InvoicesTest.php index 20c25adeb929..59afe4231a25 100644 --- a/tests/Browser/ClientPortal/InvoicesTest.php +++ b/tests/Browser/ClientPortal/InvoicesTest.php @@ -15,16 +15,21 @@ class InvoicesTest extends DuskTestCase 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 - ->visit(new Login()) - ->auth() ->visitRoute('client.invoices.index') - ->assertSee('Invoices'); + ->assertSee('Invoices') + ->visitRoute('client.logout'); }); } @@ -32,11 +37,10 @@ class InvoicesTest extends DuskTestCase { $this->browse(function (Browser $browser) { $browser - ->visit(new Login()) - ->auth() ->visitRoute('client.invoices.index') ->press('Pay Now') - ->assertSee('No payable invoices selected. Make sure you are not trying to pay draft invoice or invoice with zero balance due.'); + ->assertSee('No payable invoices selected. Make sure you are not trying to pay draft invoice or invoice with zero balance due.') + ->visitRoute('client.logout'); }); } @@ -44,11 +48,22 @@ class InvoicesTest extends DuskTestCase { $this->browse(function (Browser $browser) { $browser - ->visit(new Login()) - ->auth() ->visitRoute('client.invoices.index') ->press('Download') - ->assertSee('No items selected.'); + ->assertSee('No items selected.') + ->visitRoute('client.logout'); + }); + } + + public function testCheckingInvoiceAndClickingPayNow() + { + $this->browse(function (Browser $browser) { + $browser + ->visitRoute('client.invoices.index') + ->check('.form-check.form-check-child') + ->press('Pay Now') + ->assertPathIs('/client/invoices/payment') + ->visitRoute('client.logout'); }); } } From 53b4bd8d576269a161fb61034a0493fbca231e24 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Mon, 5 Jul 2021 10:29:52 +0200 Subject: [PATCH 20/88] Update authentication process --- tests/Browser/ClientPortal/CreditsTest.php | 11 ++++++++--- tests/Browser/ClientPortal/DocumentsTest.php | 11 ++++++++--- tests/Browser/ClientPortal/PaymentMethodsTest.php | 11 ++++++++--- tests/Browser/ClientPortal/PaymentsTest.php | 11 ++++++++--- tests/Browser/ClientPortal/QuotesTest.php | 11 ++++++++--- tests/Browser/ClientPortal/RecurringInvoices.php | 11 ++++++++--- tests/Browser/ClientPortal/SubscriptionsTest.php | 11 ++++++++--- 7 files changed, 56 insertions(+), 21 deletions(-) diff --git a/tests/Browser/ClientPortal/CreditsTest.php b/tests/Browser/ClientPortal/CreditsTest.php index 5a8e530b5334..30d8547e92d4 100644 --- a/tests/Browser/ClientPortal/CreditsTest.php +++ b/tests/Browser/ClientPortal/CreditsTest.php @@ -15,16 +15,21 @@ class CreditsTest extends DuskTestCase 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 - ->visit(new Login()) - ->auth() ->visitRoute('client.credits.index') - ->assertSee('Credits'); + ->assertSee('Credits') + ->visitRoute('client.logout'); }); } } diff --git a/tests/Browser/ClientPortal/DocumentsTest.php b/tests/Browser/ClientPortal/DocumentsTest.php index 1fa976d39289..d394f5f16b5d 100644 --- a/tests/Browser/ClientPortal/DocumentsTest.php +++ b/tests/Browser/ClientPortal/DocumentsTest.php @@ -15,16 +15,21 @@ class DocumentsTest extends DuskTestCase 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 - ->visit(new Login()) - ->auth() ->visitRoute('client.documents.index') - ->assertSee('Invoices'); + ->assertSee('Invoices') + ->visitRoute('client.logout'); }); } } diff --git a/tests/Browser/ClientPortal/PaymentMethodsTest.php b/tests/Browser/ClientPortal/PaymentMethodsTest.php index ba9df0280f02..190b1ca2cec4 100644 --- a/tests/Browser/ClientPortal/PaymentMethodsTest.php +++ b/tests/Browser/ClientPortal/PaymentMethodsTest.php @@ -15,16 +15,21 @@ class PaymentMethodsTest extends DuskTestCase 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 - ->visit(new Login()) - ->auth() ->visitRoute('client.payment_methods.index') - ->assertSee('Payment Methods'); + ->assertSee('Payment Methods') + ->visitRoute('client.logout'); }); } } diff --git a/tests/Browser/ClientPortal/PaymentsTest.php b/tests/Browser/ClientPortal/PaymentsTest.php index cb9bd2bdc43c..4ffe599ed933 100644 --- a/tests/Browser/ClientPortal/PaymentsTest.php +++ b/tests/Browser/ClientPortal/PaymentsTest.php @@ -15,16 +15,21 @@ class PaymentsTest extends DuskTestCase 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 - ->visit(new Login()) - ->auth() ->visitRoute('client.payments.index') - ->assertSee('Recurring Invoices'); + ->assertSee('Recurring Invoices') + ->visitRoute('client.logout'); }); } } diff --git a/tests/Browser/ClientPortal/QuotesTest.php b/tests/Browser/ClientPortal/QuotesTest.php index 84ccb9dbe13c..47ea8a881a18 100644 --- a/tests/Browser/ClientPortal/QuotesTest.php +++ b/tests/Browser/ClientPortal/QuotesTest.php @@ -15,16 +15,21 @@ class QuotesTest extends DuskTestCase 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 - ->visit(new Login()) - ->auth() ->visitRoute('client.quotes.index') - ->assertSee('Quotes'); + ->assertSee('Quotes') + ->visitRoute('client.logout'); }); } } diff --git a/tests/Browser/ClientPortal/RecurringInvoices.php b/tests/Browser/ClientPortal/RecurringInvoices.php index 47bc1b858c65..31748987f8a0 100644 --- a/tests/Browser/ClientPortal/RecurringInvoices.php +++ b/tests/Browser/ClientPortal/RecurringInvoices.php @@ -15,16 +15,21 @@ class RecurringInvoices extends DuskTestCase 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 - ->visit(new Login()) - ->auth() ->visitRoute('client.recurring_invoices.index') - ->assertSee('Recurring Invoices'); + ->assertSee('Recurring Invoices') + ->visitRoute('client.logout'); }); } } diff --git a/tests/Browser/ClientPortal/SubscriptionsTest.php b/tests/Browser/ClientPortal/SubscriptionsTest.php index d8c1d9fc2581..4372d4795c74 100644 --- a/tests/Browser/ClientPortal/SubscriptionsTest.php +++ b/tests/Browser/ClientPortal/SubscriptionsTest.php @@ -15,16 +15,21 @@ class SubscriptionsTest extends DuskTestCase 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 - ->visit(new Login()) - ->auth() ->visitRoute('client.subscriptions.index') - ->assertSee('Invoices'); + ->assertSee('Invoices') + ->visitRoute('client.logout'); }); } } From 9274b3e0cd46c1e086e4a4793c36ab637145a681 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Mon, 5 Jul 2021 10:38:16 +0200 Subject: [PATCH 21/88] Move CreditsTest.php into Feature/ClientPortal --- tests/{ => Feature}/ClientPortal/CreditsTest.php | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) rename tests/{ => Feature}/ClientPortal/CreditsTest.php (98%) diff --git a/tests/ClientPortal/CreditsTest.php b/tests/Feature/ClientPortal/CreditsTest.php similarity index 98% rename from tests/ClientPortal/CreditsTest.php rename to tests/Feature/ClientPortal/CreditsTest.php index 129c811bc34c..dc61ad687b6f 100644 --- a/tests/ClientPortal/CreditsTest.php +++ b/tests/Feature/ClientPortal/CreditsTest.php @@ -10,7 +10,7 @@ * @license https://www.elastic.co/licensing/elastic-license */ -namespace Tests\ClientPortal; +namespace Tests\Feature\ClientPortal; use App\Http\Livewire\CreditsTable; use App\Models\Account; @@ -23,6 +23,7 @@ use Faker\Factory; use Illuminate\Foundation\Testing\DatabaseTransactions; use Livewire\Livewire; use Tests\TestCase; +use function now; class CreditsTest extends TestCase { From 9ec4051f49e0adfc97afd7593b8013f19d48e23f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Mon, 5 Jul 2021 11:15:03 +0200 Subject: [PATCH 22/88] Invoices: Paid, unpaid, past due filters --- tests/Feature/ClientPortal/InvoicesTest.php | 90 +++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 tests/Feature/ClientPortal/InvoicesTest.php diff --git a/tests/Feature/ClientPortal/InvoicesTest.php b/tests/Feature/ClientPortal/InvoicesTest.php new file mode 100644 index 000000000000..2ec29de8ca01 --- /dev/null +++ b/tests/Feature/ClientPortal/InvoicesTest.php @@ -0,0 +1,90 @@ +faker = Factory::create(); + } + + public function testInvoiceTableFilters() + { + $account = Account::factory()->create(); + + $user = User::factory()->create( + ['account_id' => $account->id, 'email' => $this->faker->safeEmail] + ); + + $company = Company::factory()->create(['account_id' => $account->id]); + + $client = Client::factory()->create(['company_id' => $company->id, 'user_id' => $user->id]); + + ClientContact::factory()->count(2)->create([ + 'user_id' => $user->id, + 'client_id' => $client->id, + 'company_id' => $company->id, + ]); + + $sent = Invoice::factory()->create([ + 'user_id' => $user->id, + 'company_id' => $company->id, + 'client_id' => $client->id, + 'status_id' => Invoice::STATUS_SENT, + ]); + + $paid = Invoice::factory()->create([ + 'user_id' => $user->id, + 'company_id' => $company->id, + 'client_id' => $client->id, + 'status_id' => Invoice::STATUS_PAID, + ]); + + $unpaid = Invoice::factory()->create([ + 'user_id' => $user->id, + 'company_id' => $company->id, + 'client_id' => $client->id, + 'status_id' => Invoice::STATUS_UNPAID, + ]); + + $this->actingAs($client->contacts->first(), 'contact'); + + Livewire::test(InvoicesTable::class, ['company' => $company]) + ->assertSee($sent->number) + ->assertSee($paid->number) + ->assertSee($unpaid->number); + + Livewire::test(InvoicesTable::class, ['company' => $company]) + ->set('status', ['paid']) + ->assertSee($paid->number) + ->assertDontSee($unpaid->number); + } +} From 22acc8f14c48affbe9b48e2666b8f04407e446fa Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Mon, 5 Jul 2021 11:17:50 +0200 Subject: [PATCH 23/88] Update update licence/copyright on tests --- tests/Browser/ClientPortal/CreditsTest.php | 10 ++++++++++ tests/Browser/ClientPortal/DocumentsTest.php | 10 ++++++++++ tests/Browser/ClientPortal/InvoicesTest.php | 10 ++++++++++ tests/Browser/ClientPortal/PaymentMethodsTest.php | 10 ++++++++++ tests/Browser/ClientPortal/PaymentsTest.php | 10 ++++++++++ tests/Browser/ClientPortal/QuotesTest.php | 10 ++++++++++ tests/Browser/ClientPortal/RecurringInvoices.php | 10 ++++++++++ tests/Browser/ClientPortal/SubscriptionsTest.php | 10 ++++++++++ 8 files changed, 80 insertions(+) diff --git a/tests/Browser/ClientPortal/CreditsTest.php b/tests/Browser/ClientPortal/CreditsTest.php index 30d8547e92d4..c3b46c8e3ea7 100644 --- a/tests/Browser/ClientPortal/CreditsTest.php +++ b/tests/Browser/ClientPortal/CreditsTest.php @@ -1,5 +1,15 @@ Date: Mon, 5 Jul 2021 11:49:01 +0200 Subject: [PATCH 24/88] Add createRecurringInvoice($client) in CreateSingleAccount.php --- app/Console/Commands/CreateSingleAccount.php | 117 +++++++++++++------ 1 file changed, 83 insertions(+), 34 deletions(-) diff --git a/app/Console/Commands/CreateSingleAccount.php b/app/Console/Commands/CreateSingleAccount.php index 82d738b16b35..4fb8d08e567e 100644 --- a/app/Console/Commands/CreateSingleAccount.php +++ b/app/Console/Commands/CreateSingleAccount.php @@ -14,9 +14,11 @@ namespace App\Console\Commands; use App\DataMapper\CompanySettings; use App\DataMapper\FeesAndLimits; use App\Events\Invoice\InvoiceWasCreated; +use App\Events\RecurringInvoice\RecurringInvoiceWasCreated; use App\Factory\GroupSettingFactory; use App\Factory\InvoiceFactory; use App\Factory\InvoiceItemFactory; +use App\Factory\RecurringInvoiceFactory; use App\Factory\SubscriptionFactory; use App\Helpers\Invoice\InvoiceSum; use App\Jobs\Company\CreateCompanyTaskStatuses; @@ -48,6 +50,7 @@ use Illuminate\Console\Command; use Illuminate\Support\Facades\Cache; use Illuminate\Support\Facades\Schema; use Illuminate\Support\Str; +use stdClass; class CreateSingleAccount extends Command { @@ -117,7 +120,7 @@ class CreateSingleAccount extends Command $company->settings = $settings; $company->save(); - + $account->default_company_id = $company->id; $account->save(); @@ -165,7 +168,7 @@ class CreateSingleAccount extends Command TaxRate::factory()->create([ 'user_id' => $user->id, - 'company_id' => $company->id, + 'company_id' => $company->id, 'name' => 'VAT', 'rate' => 17.5 ]); @@ -176,7 +179,7 @@ class CreateSingleAccount extends Command 'name' => 'CA Sales Tax', 'rate' => 5 ]); - + $this->info('Creating '.$this->count.' clients'); @@ -225,16 +228,19 @@ class CreateSingleAccount extends Command $client = $company->clients->random(); - $this->info('creating task for client #'.$client->id); + $this->info('creating task for client #' . $client->id); $this->createTask($client); $client = $company->clients->random(); - $this->info('creating project for client #'.$client->id); + $this->info('creating project for client #' . $client->id); $this->createProject($client); - $this->info('creating credit for client #'.$client->id); + $this->info('creating credit for client #' . $client->id); $this->createCredit($client); + + $this->info('creating recurring invoice for client # ' . $client->id); + $this->createRecurringInvoice($client); } $this->createGateways($company, $user); @@ -249,34 +255,34 @@ class CreateSingleAccount extends Command $gs->save(); $p1 = Product::factory()->create([ - 'user_id' => $user->id, - 'company_id' => $company->id, - 'product_key' => 'pro_plan', - 'notes' => 'The Pro Plan', - 'cost' => 10, - 'price' => 10, - 'quantity' => 1, - ]); + 'user_id' => $user->id, + 'company_id' => $company->id, + 'product_key' => 'pro_plan', + 'notes' => 'The Pro Plan', + 'cost' => 10, + 'price' => 10, + 'quantity' => 1, + ]); $p2 = Product::factory()->create([ - 'user_id' => $user->id, - 'company_id' => $company->id, - 'product_key' => 'enterprise_plan', - 'notes' => 'The Enterprise Plan', - 'cost' => 14, - 'price' => 14, - 'quantity' => 1, - ]); + 'user_id' => $user->id, + 'company_id' => $company->id, + 'product_key' => 'enterprise_plan', + 'notes' => 'The Enterprise Plan', + 'cost' => 14, + 'price' => 14, + 'quantity' => 1, + ]); $p3 = Product::factory()->create([ - 'user_id' => $user->id, - 'company_id' => $company->id, - 'product_key' => 'free_plan', - 'notes' => 'The Free Plan', - 'cost' => 0, - 'price' => 0, - 'quantity' => 1, - ]); + 'user_id' => $user->id, + 'company_id' => $company->id, + 'product_key' => 'free_plan', + 'notes' => 'The Free Plan', + 'cost' => 0, + 'price' => 0, + 'quantity' => 1, + ]); $webhook_config = [ 'post_purchase_url' => 'http://ninja.test:8000/api/admin/plan', @@ -619,7 +625,7 @@ class CreateSingleAccount extends Command $gateway_types = $cg->driver(new Client)->gatewayTypes(); - $fees_and_limits = new \stdClass; + $fees_and_limits = new stdClass; $fees_and_limits->{$gateway_types[0]} = new FeesAndLimits; $cg->fees_and_limits = $fees_and_limits; @@ -642,7 +648,7 @@ class CreateSingleAccount extends Command $gateway_types = $cg->driver(new Client)->gatewayTypes(); - $fees_and_limits = new \stdClass; + $fees_and_limits = new stdClass; $fees_and_limits->{$gateway_types[0]} = new FeesAndLimits; $cg->fees_and_limits = $fees_and_limits; @@ -663,7 +669,7 @@ class CreateSingleAccount extends Command $gateway_types = $cg->driver(new Client)->gatewayTypes(); - $fees_and_limits = new \stdClass; + $fees_and_limits = new stdClass; $fees_and_limits->{$gateway_types[0]} = new FeesAndLimits; $cg->fees_and_limits = $fees_and_limits; @@ -684,11 +690,54 @@ class CreateSingleAccount extends Command $gateway_types = $cg->driver(new Client)->gatewayTypes(); - $fees_and_limits = new \stdClass; + $fees_and_limits = new stdClass; $fees_and_limits->{$gateway_types[0]} = new FeesAndLimits; $cg->fees_and_limits = $fees_and_limits; $cg->save(); } } + + private function createRecurringInvoice($client) + { + $faker = Factory::create(); + + $invoice = RecurringInvoiceFactory::create($client->company->id, $client->user->id); //stub the company and user_id + $invoice->client_id = $client->id; + $dateable = Carbon::now()->subDays(rand(0, 90)); + $invoice->date = $dateable; + + $invoice->line_items = $this->buildLineItems(rand(1, 10)); + $invoice->uses_inclusive_taxes = false; + + if (rand(0, 1)) { + $invoice->tax_name1 = 'GST'; + $invoice->tax_rate1 = 10.00; + } + + if (rand(0, 1)) { + $invoice->tax_name2 = 'VAT'; + $invoice->tax_rate2 = 17.50; + } + + if (rand(0, 1)) { + $invoice->tax_name3 = 'CA Sales Tax'; + $invoice->tax_rate3 = 5; + } + + $invoice->custom_value1 = $faker->date; + $invoice->custom_value2 = rand(0, 1) ? 'yes' : 'no'; + + $invoice->status_id = RecurringInvoice::STATUS_ACTIVE; + $invoice->save(); + + $invoice_calc = new InvoiceSum($invoice); + $invoice_calc->build(); + + $invoice = $invoice_calc->getInvoice(); + + $invoice->save(); + + event(new RecurringInvoiceWasCreated($invoice, $invoice->company, Ninja::eventVars())); + } } From a82e3f57c378b64fbbd7221d0ca5c70eebbe86b5 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Mon, 5 Jul 2021 11:49:17 +0200 Subject: [PATCH 25/88] Recurring invoices: Test the cancellation feature --- .../ClientPortal/RecurringInvoices.php | 20 +++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/tests/Browser/ClientPortal/RecurringInvoices.php b/tests/Browser/ClientPortal/RecurringInvoices.php index 6f069d4911ff..62fbc0b6577e 100644 --- a/tests/Browser/ClientPortal/RecurringInvoices.php +++ b/tests/Browser/ClientPortal/RecurringInvoices.php @@ -12,6 +12,7 @@ namespace Tests\Browser\ClientPortal; +use App\Models\RecurringInvoice; use Laravel\Dusk\Browser; use Tests\Browser\Pages\ClientPortal\Login; use Tests\DuskTestCase; @@ -42,4 +43,23 @@ class RecurringInvoices extends DuskTestCase ->visitRoute('client.logout'); }); } + + public function testRequestingCancellation() + { + $this->browse(function (Browser $browser) { + $browser + ->visitRoute('client.recurring_invoices.index') + ->clickLink('View') + ->assertSee('Cancellation') + ->press('Request Cancellation') + ->pause(1000) + ->waitForText('Request cancellation') + ->press('Confirm') + ->pause(5000) + ->assertPathIs( + route('client.recurring_invoices.request_cancellation', RecurringInvoice::first()->hashed_id, false) + ) + ->visitRoute('client.logout'); + }); + } } From f35ed86299e790c999102a3570cb5a75a734c712 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Mon, 5 Jul 2021 13:32:41 +0200 Subject: [PATCH 26/88] Quotes: Clicking "Approve" button without quotes --- tests/Browser/ClientPortal/QuotesTest.php | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/tests/Browser/ClientPortal/QuotesTest.php b/tests/Browser/ClientPortal/QuotesTest.php index 15c19a51cc71..a6495be0b015 100644 --- a/tests/Browser/ClientPortal/QuotesTest.php +++ b/tests/Browser/ClientPortal/QuotesTest.php @@ -12,6 +12,7 @@ namespace Tests\Browser\ClientPortal; +use App\Models\Quote; use Laravel\Dusk\Browser; use Tests\Browser\Pages\ClientPortal\Login; use Tests\DuskTestCase; @@ -42,4 +43,14 @@ class QuotesTest extends DuskTestCase ->visitRoute('client.logout'); }); } + + public function testClickingApproveWithoutQuotes() + { + $this->browse(function (Browser $browser) { + $browser + ->visitRoute('client.quotes.index') + ->press('Approve') + ->assertPathIs('/client/quotes'); + }); + } } From 1a5c40d02e0471ca3bf4eca4c23287f315294a9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Mon, 5 Jul 2021 13:57:11 +0200 Subject: [PATCH 27/88] QuotesController: Allow approving only quotes with STATUS_SENT --- app/Http/Controllers/ClientPortal/QuoteController.php | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/Http/Controllers/ClientPortal/QuoteController.php b/app/Http/Controllers/ClientPortal/QuoteController.php index f26b2cefa46b..253631fc5b3f 100644 --- a/app/Http/Controllers/ClientPortal/QuoteController.php +++ b/app/Http/Controllers/ClientPortal/QuoteController.php @@ -24,6 +24,7 @@ use App\Utils\TempFile; use App\Utils\Traits\MakesHash; use Illuminate\Contracts\View\Factory; use Illuminate\View\View; +use Symfony\Component\HttpFoundation\BinaryFileResponse; use ZipStream\Option\Archive; use ZipStream\ZipStream; @@ -46,7 +47,7 @@ class QuoteController extends Controller * * @param ShowQuoteRequest $request * @param Quote $quote - * @return Factory|View|\Symfony\Component\HttpFoundation\BinaryFileResponse + * @return Factory|View|BinaryFileResponse */ public function show(ShowQuoteRequest $request, Quote $quote) { @@ -110,10 +111,12 @@ class QuoteController extends Controller protected function approve(array $ids, $process = false) { $quotes = Quote::whereIn('id', $ids) - ->whereClientId(auth()->user()->client->id) + ->where('client_id', auth('contact')->user()->client->id) + ->where('company_id', auth('contact')->user()->client->company_id) + ->where('status_id', Quote::STATUS_SENT) ->get(); - if (! $quotes || $quotes->count() == 0) { + if (!$quotes || $quotes->count() == 0) { return redirect()->route('client.quotes.index'); } From c81044994b19711196306d3b91c7b6ffd7c05a23 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Mon, 5 Jul 2021 13:57:28 +0200 Subject: [PATCH 28/88] Quotes: Test approving process --- tests/Browser/ClientPortal/QuotesTest.php | 30 ++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/tests/Browser/ClientPortal/QuotesTest.php b/tests/Browser/ClientPortal/QuotesTest.php index a6495be0b015..0a1164f7116f 100644 --- a/tests/Browser/ClientPortal/QuotesTest.php +++ b/tests/Browser/ClientPortal/QuotesTest.php @@ -44,7 +44,7 @@ class QuotesTest extends DuskTestCase }); } - public function testClickingApproveWithoutQuotes() + public function testClickingApproveWithoutQuotesDoesntWork() { $this->browse(function (Browser $browser) { $browser @@ -53,4 +53,32 @@ class QuotesTest extends DuskTestCase ->assertPathIs('/client/quotes'); }); } + + public function testApprovingQuotes() + { + $this->browse(function (Browser $browser) { + $browser + ->visitRoute('client.quotes.index') + ->check('.form-check.form-check-child') + ->press('Approve') + ->assertPathIs('/client/quotes/approve') + ->press('Approve') + ->assertPathIs('/client/quotes') + ->assertSee('Quote(s) approved successfully.') + ->visitRoute('client.logout'); + }); + } + + public function testQuotesWithSentStatusCanOnlyBeApproved() + { + $this->browse(function (Browser $browser) { + $browser + ->visitRoute('client.quotes.index') + ->check('.form-check.form-check-child') + ->press('Approve') + ->assertPathIs('/client/quotes') + ->assertDontSee('Quote(s) approved successfully.') + ->visitRoute('client.logout'); + }); + } } From 410ea21f3d0a4de23206f3d6c4af60ba0b99d47f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Mon, 5 Jul 2021 14:25:24 +0200 Subject: [PATCH 29/88] Update testPageLoads() --- tests/Browser/ClientPortal/CreditsTest.php | 2 +- tests/Browser/ClientPortal/DocumentsTest.php | 2 +- tests/Browser/ClientPortal/InvoicesTest.php | 2 +- tests/Browser/ClientPortal/PaymentMethodsTest.php | 2 +- tests/Browser/ClientPortal/PaymentsTest.php | 2 +- tests/Browser/ClientPortal/QuotesTest.php | 2 +- .../{RecurringInvoices.php => RecurringInvoicesTest.php} | 4 ++-- tests/Browser/ClientPortal/SubscriptionsTest.php | 2 +- 8 files changed, 9 insertions(+), 9 deletions(-) rename tests/Browser/ClientPortal/{RecurringInvoices.php => RecurringInvoicesTest.php} (92%) diff --git a/tests/Browser/ClientPortal/CreditsTest.php b/tests/Browser/ClientPortal/CreditsTest.php index c3b46c8e3ea7..c5c274b44461 100644 --- a/tests/Browser/ClientPortal/CreditsTest.php +++ b/tests/Browser/ClientPortal/CreditsTest.php @@ -38,7 +38,7 @@ class CreditsTest extends DuskTestCase $this->browse(function (Browser $browser) { $browser ->visitRoute('client.credits.index') - ->assertSee('Credits') + ->assertSeeIn('span[data-ref="meta-title"]', 'Credits') ->visitRoute('client.logout'); }); } diff --git a/tests/Browser/ClientPortal/DocumentsTest.php b/tests/Browser/ClientPortal/DocumentsTest.php index f6573c5a6c80..454acd856b59 100644 --- a/tests/Browser/ClientPortal/DocumentsTest.php +++ b/tests/Browser/ClientPortal/DocumentsTest.php @@ -38,7 +38,7 @@ class DocumentsTest extends DuskTestCase $this->browse(function (Browser $browser) { $browser ->visitRoute('client.documents.index') - ->assertSee('Invoices') + ->assertSee('Documents') ->visitRoute('client.logout'); }); } diff --git a/tests/Browser/ClientPortal/InvoicesTest.php b/tests/Browser/ClientPortal/InvoicesTest.php index 8d9831f00f83..838ae1bc6671 100644 --- a/tests/Browser/ClientPortal/InvoicesTest.php +++ b/tests/Browser/ClientPortal/InvoicesTest.php @@ -38,7 +38,7 @@ class InvoicesTest extends DuskTestCase $this->browse(function (Browser $browser) { $browser ->visitRoute('client.invoices.index') - ->assertSee('Invoices') + ->assertSeeIn('span[data-ref="meta-title"]', 'Invoices') ->visitRoute('client.logout'); }); } diff --git a/tests/Browser/ClientPortal/PaymentMethodsTest.php b/tests/Browser/ClientPortal/PaymentMethodsTest.php index 4b04e1da1680..56feb97f80c2 100644 --- a/tests/Browser/ClientPortal/PaymentMethodsTest.php +++ b/tests/Browser/ClientPortal/PaymentMethodsTest.php @@ -38,7 +38,7 @@ class PaymentMethodsTest extends DuskTestCase $this->browse(function (Browser $browser) { $browser ->visitRoute('client.payment_methods.index') - ->assertSee('Payment Methods') + ->assertSeeIn('span[data-ref="meta-title"]', 'Payment Methods') ->visitRoute('client.logout'); }); } diff --git a/tests/Browser/ClientPortal/PaymentsTest.php b/tests/Browser/ClientPortal/PaymentsTest.php index dc50254b4d58..835389d16506 100644 --- a/tests/Browser/ClientPortal/PaymentsTest.php +++ b/tests/Browser/ClientPortal/PaymentsTest.php @@ -38,7 +38,7 @@ class PaymentsTest extends DuskTestCase $this->browse(function (Browser $browser) { $browser ->visitRoute('client.payments.index') - ->assertSee('Recurring Invoices') + ->assertSeeIn('span[data-ref="meta-title"]', 'Payments') ->visitRoute('client.logout'); }); } diff --git a/tests/Browser/ClientPortal/QuotesTest.php b/tests/Browser/ClientPortal/QuotesTest.php index 0a1164f7116f..2a294eca2ed2 100644 --- a/tests/Browser/ClientPortal/QuotesTest.php +++ b/tests/Browser/ClientPortal/QuotesTest.php @@ -39,7 +39,7 @@ class QuotesTest extends DuskTestCase $this->browse(function (Browser $browser) { $browser ->visitRoute('client.quotes.index') - ->assertSee('Quotes') + ->assertSeeIn('span[data-ref="meta-title"]', 'Quotes') ->visitRoute('client.logout'); }); } diff --git a/tests/Browser/ClientPortal/RecurringInvoices.php b/tests/Browser/ClientPortal/RecurringInvoicesTest.php similarity index 92% rename from tests/Browser/ClientPortal/RecurringInvoices.php rename to tests/Browser/ClientPortal/RecurringInvoicesTest.php index 62fbc0b6577e..d5d9b711ef6b 100644 --- a/tests/Browser/ClientPortal/RecurringInvoices.php +++ b/tests/Browser/ClientPortal/RecurringInvoicesTest.php @@ -17,7 +17,7 @@ use Laravel\Dusk\Browser; use Tests\Browser\Pages\ClientPortal\Login; use Tests\DuskTestCase; -class RecurringInvoices extends DuskTestCase +class RecurringInvoicesTest extends DuskTestCase { protected function setUp(): void { @@ -39,7 +39,7 @@ class RecurringInvoices extends DuskTestCase $this->browse(function (Browser $browser) { $browser ->visitRoute('client.recurring_invoices.index') - ->assertSee('Recurring Invoices') + ->assertSeeIn('span[data-ref="meta-title"]', 'Recurring Invoices') ->visitRoute('client.logout'); }); } diff --git a/tests/Browser/ClientPortal/SubscriptionsTest.php b/tests/Browser/ClientPortal/SubscriptionsTest.php index 4d193da3f74a..b0962cc3e333 100644 --- a/tests/Browser/ClientPortal/SubscriptionsTest.php +++ b/tests/Browser/ClientPortal/SubscriptionsTest.php @@ -38,7 +38,7 @@ class SubscriptionsTest extends DuskTestCase $this->browse(function (Browser $browser) { $browser ->visitRoute('client.subscriptions.index') - ->assertSee('Invoices') + ->assertSeeIn('span[data-ref="meta-title"]', 'Subscriptions') ->visitRoute('client.logout'); }); } From ecc08d5d56759869b881eed9a98cb44735c89534 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Tue, 6 Jul 2021 14:13:05 +0200 Subject: [PATCH 30/88] Create console/ for logs --- tests/Browser/console/.gitignore | 2 ++ 1 file changed, 2 insertions(+) create mode 100644 tests/Browser/console/.gitignore diff --git a/tests/Browser/console/.gitignore b/tests/Browser/console/.gitignore new file mode 100644 index 000000000000..d6b7ef32c847 --- /dev/null +++ b/tests/Browser/console/.gitignore @@ -0,0 +1,2 @@ +* +!.gitignore From 6e5a08578716aa2704b403e3c88dcd3deaba5c94 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Tue, 6 Jul 2021 14:13:18 +0200 Subject: [PATCH 31/88] Profile settings: Page loads --- .../general/sidebar/header.blade.php | 25 +++++++++--- .../ClientPortal/ProfileSettingsTest.php | 39 +++++++++++++++++++ 2 files changed, 58 insertions(+), 6 deletions(-) create mode 100644 tests/Browser/ClientPortal/ProfileSettingsTest.php diff --git a/resources/views/portal/ninja2020/components/general/sidebar/header.blade.php b/resources/views/portal/ninja2020/components/general/sidebar/header.blade.php index ee232d1952c8..e829b120f9f3 100644 --- a/resources/views/portal/ninja2020/components/general/sidebar/header.blade.php +++ b/resources/views/portal/ninja2020/components/general/sidebar/header.blade.php @@ -23,7 +23,10 @@ @@ -32,18 +35,28 @@ @endif
-
-