Merge pull request #8630 from turbo124/v5-develop

Fixes for client statements in client portal.
This commit is contained in:
David Bomba 2023-07-09 17:07:47 +10:00 committed by GitHub
commit 40c37703a6
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
53 changed files with 112 additions and 3771 deletions

View File

@ -223,9 +223,12 @@ class Rule extends BaseRule implements RuleInterface
public function calculateRates(): self public function calculateRates(): self
{ {
if ($this->client->is_tax_exempt) { if ($this->client->is_tax_exempt) {
// nlog("tax exempt");
$this->tax_rate = 0; $this->tax_rate = 0;
$this->reduced_tax_rate = 0; $this->reduced_tax_rate = 0;
return $this;
}
// } elseif($this->client_subregion != $this->client->company->tax_data->seller_subregion && in_array($this->client_subregion, $this->eu_country_codes) && $this->client->has_valid_vat_number && $this->eu_business_tax_exempt) { // } elseif($this->client_subregion != $this->client->company->tax_data->seller_subregion && in_array($this->client_subregion, $this->eu_country_codes) && $this->client->has_valid_vat_number && $this->eu_business_tax_exempt) {
// nlog("euro zone and tax exempt"); // nlog("euro zone and tax exempt");
// $this->tax_rate = 0; // $this->tax_rate = 0;
@ -246,10 +249,9 @@ class Rule extends BaseRule implements RuleInterface
// $this->tax_rate = $this->client->company->tax_data->regions->EU->subregions->{$this->client->company->country()->iso_3166_2}->tax_rate; // $this->tax_rate = $this->client->company->tax_data->regions->EU->subregions->{$this->client->company->country()->iso_3166_2}->tax_rate;
// $this->reduced_tax_rate = $this->client->company->tax_data->regions->EU->subregions->{$this->client->company->country()->iso_3166_2}->reduced_tax_rate; // $this->reduced_tax_rate = $this->client->company->tax_data->regions->EU->subregions->{$this->client->company->country()->iso_3166_2}->reduced_tax_rate;
// } // }
} else {
$this->tax_rate = $this->client->company->tax_data->regions->AU->subregions->{$this->client->company->country()->iso_3166_2}->tax_rate; $this->tax_rate = $this->client->company->tax_data->regions->AU->subregions->{$this->client->company->country()->iso_3166_2}->tax_rate;
$this->reduced_tax_rate = $this->client->company->tax_data->regions->AU->subregions->{$this->client->company->country()->iso_3166_2}->reduced_tax_rate; $this->reduced_tax_rate = $this->client->company->tax_data->regions->AU->subregions->{$this->client->company->country()->iso_3166_2}->reduced_tax_rate;
}
return $this; return $this;

View File

@ -25,6 +25,8 @@ class PdfSlot extends Component
public $pdf; public $pdf;
public $url;
public function mount() public function mount()
{ {
MultiDB::setDb($this->db); MultiDB::setDb($this->db);

View File

@ -42,6 +42,8 @@ trait MakesInvoiceHtml
{ {
$data['__env'] = app(Factory::class); $data['__env'] = app(Factory::class);
return Blade::render($string, $data); //potential fix for removing eval()
$php = Blade::compileString($string); $php = Blade::compileString($string);
$obLevel = ob_get_level(); $obLevel = ob_get_level();

View File

@ -106,7 +106,6 @@
"filp/whoops": "^2.7", "filp/whoops": "^2.7",
"friendsofphp/php-cs-fixer": "^3.14", "friendsofphp/php-cs-fixer": "^3.14",
"laracasts/cypress": "^3.0", "laracasts/cypress": "^3.0",
"laravel/dusk": "^6.15",
"mockery/mockery": "^1.4.4", "mockery/mockery": "^1.4.4",
"nunomaduro/collision": "^6.1", "nunomaduro/collision": "^6.1",
"nunomaduro/larastan": "^2.0", "nunomaduro/larastan": "^2.0",

View File

@ -15,8 +15,8 @@ return [
'require_https' => env('REQUIRE_HTTPS', true), 'require_https' => env('REQUIRE_HTTPS', true),
'app_url' => rtrim(env('APP_URL', ''), '/'), 'app_url' => rtrim(env('APP_URL', ''), '/'),
'app_domain' => env('APP_DOMAIN', 'invoicing.co'), 'app_domain' => env('APP_DOMAIN', 'invoicing.co'),
'app_version' => '5.6.16', 'app_version' => env('APP_VERSION','5.6.16'),
'app_tag' => '5.6.16', 'app_tag' => env('APP_TAG','5.6.16'),
'minimum_client_version' => '5.0.16', 'minimum_client_version' => '5.0.16',
'terms_version' => '1.0.1', 'terms_version' => '1.0.1',
'api_secret' => env('API_SECRET', ''), 'api_secret' => env('API_SECRET', ''),

64
dusk.sh
View File

@ -1,64 +0,0 @@
#!/bin/bash
n=1
TYPE=${!n}
if [ -z "$TYPE" ]; then
TYPE="all"
fi
echo "$ RUNNING: '$TYPE'"
echo "$ php artisan optimize"
php artisan optimize
echo "=========================================="
GENERIC_TESTS=`find tests/Browser/ClientPortal/ -maxdepth 1 -type f -name '*.php'`
if [ $TYPE == 'gateways' ]; then
GENERIC_TESTS=""
echo "$ Skippping generic tests."
echo "=========================================="
fi
for TEST_CLASS in $GENERIC_TESTS; do
echo "Test class: $TEST_CLASS"
echo "$ php artisan migrate:fresh --seed"
php artisan migrate:fresh --seed &> /dev/null
echo "$ php artisan ninja:create-single-account"
php artisan ninja:create-single-account &> /dev/null
echo "$ php artisan dusk $TEST_CLASS"
php -d memory_limit=1G artisan dusk ${@:2} --stop-on-error --stop-on-failure $TEST_CLASS || exit 1
echo "=========================================="
done || exit 1
GATEWAY_TESTS=`find tests/Browser/ClientPortal/Gateways/ -type f -name '*.php'`
if [ $TYPE == 'generic' ]; then
GATEWAY_TESTS=""
echo "$ Skippping gateway tests."
echo "=========================================="
fi
for TEST_CLASS in $GATEWAY_TESTS; do
echo "Test class: $TEST_CLASS"
echo "$ php artisan migrate:fresh --seed"
php artisan migrate:fresh --seed &> /dev/null
echo "$ php artisan ninja:create-single-account"
php artisan ninja:create-single-account &> /dev/null
echo "$ php artisan dusk $TEST_CLASS"
php -d memory_limit=1G artisan dusk ${@:2} --stop-on-error --stop-on-failure $TEST_CLASS || exit 1
echo "=========================================="
done || exit 1
echo 'All tests completed successfully.'

View File

@ -0,0 +1,98 @@
@php
//$mobile = stripos(request()->server('HTTP_USER_AGENT'), 'Android') || stripos(request()->server('HTTP_USER_AGENT'), 'iPhone') || stripos(request()->server('HTTP_USER_AGENT'), 'iPod') || stripos(request()->server('HTTP_USER_AGENT'), 'iPad');
$mobile = false;
@endphp
@push('head')
<meta name="pdf-url" content="{{ $url ?? $entity->pdf_file_path($invitation, 'url', true) }}?cache_buster={{time()}}">
<script src="{{ asset('js/vendor/pdf.js/pdf.min.js') }}"></script>
@endpush
<div class="flex items-center justify-between mt-4">
<section class="flex items-center">
<div class="items-center" style="{{ $mobile ? '' : 'display: none' }}" id="pagination-button-container">
<button class="input-label focus:outline-none hover:text-blue-600 transition ease-in-out duration-300"
id="previous-page-button" title="Previous page">
<svg class="w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M15 19l-7-7 7-7" />
</svg>
</button>
<button class="input-label focus:outline-none hover:text-blue-600 transition ease-in-out duration-300"
id="next-page-button" title="Next page">
<svg class="w-6" fill="none" viewBox="0 0 24 24" stroke="currentColor">
<path stroke-linecap="round" stroke-linejoin="round" stroke-width="2" d="M9 5l7 7-7 7" />
</svg>
</button>
</div>
<span class="text-sm text-gray-700 ml-2 {{ $mobile ? 'block' : 'hidden' }}">{{ ctrans('texts.page') }}:
<span id="current-page-container"></span>
<span>{{ strtolower(ctrans('texts.of')) }}</span>
<span id="total-page-container"></span>
</span>
</section>
<section class="flex items-center space-x-1">
<div class="flex items-center mr-4 space-x-1 {{ $mobile ? 'block' : 'hidden' }}">
<span class="text-gray-600 mr-2" id="zoom-level">100%</span>
<a href="#" id="zoom-in">
<svg class="text-gray-400 hover:text-gray-600 focus:outline-none focus:text-gray-600 cursor-pointer"
xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<circle cx="11" cy="11" r="8"></circle>
<line x1="21" y1="21" x2="16.65" y2="16.65"></line>
<line x1="11" y1="8" x2="11" y2="14"></line>
<line x1="8" y1="11" x2="14" y2="11"></line>
</svg>
</a>
<a href="#" id="zoom-out">
<svg class="text-gray-400 hover:text-gray-600 focus:outline-none focus:text-gray-600 cursor-pointer"
xmlns="http://www.w3.org/2000/svg" width="24" height="24" viewBox="0 0 24 24" fill="none"
stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">
<circle cx="11" cy="11" r="8"></circle>
<line x1="21" y1="21" x2="16.65" y2="16.65"></line>
<line x1="8" y1="11" x2="14" y2="11"></line>
</svg>
</a>
</div>
<div x-data="{ open: false }" @keydown.escape="open = false" @click.away="open = false"
class="relative inline-block text-left">
<div>
<button @click="open = !open"
class="flex items-center text-gray-400 hover:text-gray-600 focus:outline-none focus:text-gray-600">
<svg class="h-5 w-5" fill="currentColor" viewBox="0 0 20 20">
<path
d="M10 6a2 2 0 110-4 2 2 0 010 4zM10 12a2 2 0 110-4 2 2 0 010 4zM10 18a2 2 0 110-4 2 2 0 010 4z" />
</svg>
</button>
</div>
<div x-show="open" x-transition:enter="transition ease-out duration-100"
x-transition:enter-start="transform opacity-0 scale-95"
x-transition:enter-end="transform opacity-100 scale-100"
x-transition:leave="transition ease-in duration-75"
x-transition:leave-start="transform opacity-100 scale-100"
x-transition:leave-end="transform opacity-0 scale-95"
class="origin-top-right absolute right-0 mt-2 w-56 rounded-md shadow-lg">
<div class="rounded-md bg-white ring-1 ring-black ring-opacity-5">
<div class="py-1">
<a target="_blank" href="{{ $fullscreen_url ?? '?mode=fullscreen' }}"
class="block px-4 py-2 text-sm leading-5 text-gray-700 hover:bg-gray-100 hover:text-gray-900 focus:outline-none focus:bg-gray-100 focus:text-gray-900">{{ ctrans('texts.open_in_new_tab') }}</a>
</div>
</div>
</div>
</div>
</section>
</div>
@if($mobile)
<div class="w-full h-full overflow-auto mt-4">
<canvas id="pdf-placeholder" class="shadow rounded-lg bg-white"></canvas>
</div>
@else
<iframe id="pdf-iframe" src="{{ $url ?? $entity->pdf_file_path($invitation, 'url', true) }}?cache_buster={{time()}}" class="h-screen w-full border-0 mt-4"></iframe>
@endif
@if($mobile)
@push('footer')
<script src="{{ asset('js/clients/shared/pdf.js') }}" defer></script>
@endpush
@endif

View File

@ -44,7 +44,7 @@
<button onclick="setTimeout(() => this.disabled = true, 0); setTimeout(() => this.disabled = false, 5000); return true;" id="pdf-download" class="button button-primary bg-primary mt-4 md:mt-0">{{ ctrans('texts.download') }}</button> <button onclick="setTimeout(() => this.disabled = true, 0); setTimeout(() => this.disabled = false, 5000); return true;" id="pdf-download" class="button button-primary bg-primary mt-4 md:mt-0">{{ ctrans('texts.download') }}</button>
</div> </div>
@include('portal.ninja2020.components.pdf-viewer', ['url' => route('client.statement.raw')]) @include('portal.ninja2020.components.statement-pdf-viewer', ['url' => route('client.statement.raw')])
@endsection @endsection

View File

@ -1,45 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Tests\Browser\ClientPortal;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\ClientPortal\Login;
use Tests\DuskTestCase;
class CreditsTest extends DuskTestCase
{
protected function setUp(): void
{
parent::setUp();
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.credits.index')
->assertSeeIn('span[data-ref="meta-title"]', 'Credits')
->visitRoute('client.logout');
});
}
}

View File

@ -1,45 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Tests\Browser\ClientPortal;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\ClientPortal\Login;
use Tests\DuskTestCase;
class DocumentsTest extends DuskTestCase
{
protected function setUp(): void
{
parent::setUp();
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.documents.index')
->assertSee('Documents')
->visitRoute('client.logout');
});
}
}

View File

@ -1,127 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Tests\Browser\ClientPortal\Gateways\AuthorizeNet;
use App\Models\CompanyGateway;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\ClientPortal\Login;
use Tests\DuskTestCase;
class CreditCardTest extends DuskTestCase
{
protected function setUp(): void
{
parent::setUp();
if (getenv('GITHUB_ACTIONS')) {
$this->markTestSkipped('Skipping Authorize.net (GitHub Actions)');
}
foreach (static::$browsers as $browser) {
$browser->driver->manage()->deleteAllCookies();
}
$this->browse(function (Browser $browser) {
$browser
->visit(new Login())
->auth();
});
$this->disableCompanyGateways();
CompanyGateway::where('gateway_key', '3b6621f970ab18887c4f6dca78d3f8bb')->restore();
}
public function testPayWithNewCard()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('Credit Card')
->type('card-number', '4007000000027')
->type('card-holders-name', 'John Doe')
->type('.expiry', '12/28')
->type('cvc', '100')
->press('Pay Now')
->waitForText('Details of the payment', 60);
});
}
public function testPayWithNewCardAndSaveForFutureUse()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('Credit Card')
->radio('#proxy_is_default', true)
->type('card-number', '4007000000027')
->type('card-holders-name', 'John Doe')
->type('.expiry', '12/28')
->type('cvc', '100')
->press('Pay Now')
->waitForText('Details of the payment', 60)
->visitRoute('client.payment_methods.index')
->clickLink('View')
->assertSee('0027');
});
}
public function testPayWithSavedCard()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('Credit Card')
->click('.toggle-payment-with-token')
->press('Pay Now')
->waitForText('Details of the payment', 60);
});
}
public function testRemoveCard()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.payment_methods.index')
->clickLink('View')
->press('Remove Payment Method')
->waitForText('Confirmation')
->click('@confirm-payment-removal')
->assertSee('Payment method has been successfully removed.');
});
}
public function testAddingCreditCardStandalone()
{
$this->markTestIncomplete("E00117 OTS Service Error 'Field validation error.'");
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.payment_methods.index')
->press('Add Payment Method')
->clickLink('Credit Card')
->type('card-number', '4012888818888')
->type('card-holders-name', 'John Doe')
->type('.expiry', '12/28')
->type('cvc', '900')
->press('Add Payment Method')
->waitForText('0027', 60);
});
}
}

View File

@ -1,91 +0,0 @@
<?php
namespace Tests\Browser\ClientPortal\Gateways\Braintree;
use App\DataMapper\FeesAndLimits;
use App\Models\Company;
use App\Models\CompanyGateway;
use App\Models\GatewayType;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\ClientPortal\Login;
use Tests\DuskTestCase;
class ACHTest extends DuskTestCase
{
protected function setUp(): void
{
parent::setUp();
foreach (static::$browsers as $browser) {
$browser->driver->manage()->deleteAllCookies();
}
$this->browse(function (Browser $browser) {
$browser
->visit(new Login())
->auth();
});
$this->disableCompanyGateways();
CompanyGateway::where('gateway_key', 'f7ec488676d310683fb51802d076d713')->restore();
$cg = CompanyGateway::where('gateway_key', 'f7ec488676d310683fb51802d076d713')->firstOrFail();
$fees_and_limits = $cg->fees_and_limits;
$fees_and_limits->{GatewayType::BANK_TRANSFER} = new FeesAndLimits();
$cg->fees_and_limits = $fees_and_limits;
$cg->save();
$company = Company::first();
$settings = $company->settings;
$settings->client_portal_allow_under_payment = true;
$settings->client_portal_allow_over_payment = true;
$company->settings = $settings;
$company->save();
}
public function testAddingBankAccount()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.payment_methods.index')
->press('Add Payment Method')
->clickLink('Bank Account')
->type('#account-holder-name', 'John Doe')
->type('#account-number', '1000000000')
->type('#routing-number', '011000015')
->type('#billing-postal-code', '12345')
->press('Add Payment Method')
->waitForText('Added payment method.');
});
}
public function testPayingWithExistingACH()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('Bank Transfer')
->click('.toggle-payment-with-token')
->press('Pay Now')
->waitForText('Details of the payment', 60);
});
}
public function testRemoveACHAccount()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.payment_methods.index')
->clickLink('View')
->press('Remove Payment Method')
->waitForText('Confirmation')
->click('@confirm-payment-removal')
->assertSee('Payment method has been successfully removed.');
});
}
}

View File

@ -1,145 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Tests\Browser\ClientPortal\Gateways\Braintree;
use App\DataMapper\FeesAndLimits;
use App\Models\Company;
use App\Models\CompanyGateway;
use App\Models\GatewayType;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\ClientPortal\Login;
use Tests\DuskTestCase;
class CreditCardTest extends DuskTestCase
{
protected function setUp(): void
{
parent::setUp();
foreach (static::$browsers as $browser) {
$browser->driver->manage()->deleteAllCookies();
}
$this->browse(function (Browser $browser) {
$browser
->visit(new Login())
->auth();
});
$this->disableCompanyGateways();
CompanyGateway::where('gateway_key', 'f7ec488676d310683fb51802d076d713')->restore();
$cg = CompanyGateway::where('gateway_key', 'f7ec488676d310683fb51802d076d713')->firstOrFail();
$fees_and_limits = $cg->fees_and_limits;
$fees_and_limits->{GatewayType::CREDIT_CARD} = new FeesAndLimits();
$cg->fees_and_limits = $fees_and_limits;
$cg->save();
$company = Company::first();
$settings = $company->settings;
$settings->client_portal_allow_under_payment = true;
$settings->client_portal_allow_over_payment = true;
$company->settings = $settings;
$company->save();
}
public function testPayWithNewCard()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->type('@underpayment-input', '100')
->press('Pay Now')
->clickLink('Credit Card')
->waitFor('#braintree-hosted-field-number', 60)
->withinFrame('#braintree-hosted-field-number', function (Browser $browser) {
$browser->type('credit-card-number', '4111111111111111');
})
->withinFrame('#braintree-hosted-field-expirationDate', function (Browser $browser) {
$browser->type('expiration', '04/25');
})
->press('Pay Now')
->waitForText('Details of the payment', 60);
});
}
public function testPayWithNewCardAndSaveForFuture()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->type('@underpayment-input', '100')
->press('Pay Now')
->clickLink('Credit Card')
->waitFor('#braintree-hosted-field-number', 60)
->withinFrame('#braintree-hosted-field-number', function (Browser $browser) {
$browser->typeSlowly('credit-card-number', '4005519200000004');
})
->withinFrame('#braintree-hosted-field-expirationDate', function (Browser $browser) {
$browser->typeSlowly('expiration', '04/25');
})
->radio('#proxy_is_default', true)
->press('Pay Now')
->waitForText('Details of the payment', 60)
->visitRoute('client.payment_methods.index')
->clickLink('View')
->assertSee('0004');
});
}
public function testPayWithSavedCard()
{
$this->markTestSkipped('Works in "real" browser, otherwise giving error code 0.');
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->type('@underpayment-input', '100')
->press('Pay Now')
->clickLink('Credit Card')
->click('.toggle-payment-with-token')
->click('#pay-now-with-token')
->waitForText('Details of the payment', 60);
});
}
public function testRemoveCreditCard()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.payment_methods.index')
->clickLink('View')
->press('Remove Payment Method')
->waitForText('Confirmation')
->click('@confirm-payment-removal')
->assertSee('Payment method has been successfully removed.');
});
}
public function testAddingPaymentMethodShouldntBePossible()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.payment_methods.index')
->press('Add Payment Method')
->clickLink('Credit Card')
->assertSee('This payment method can be can saved for future use, once you complete your first transaction. Don\'t forget to check "Store credit card details" during payment process.');
});
}
}

View File

@ -1,45 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Tests\Browser\ClientPortal\Gateways\Braintree;
use App\Models\CompanyGateway;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\ClientPortal\Login;
use Tests\DuskTestCase;
class PayPalTest extends DuskTestCase
{
protected function setUp(): void
{
parent::setUp();
foreach (static::$browsers as $browser) {
$browser->driver->manage()->deleteAllCookies();
}
$this->browse(function (Browser $browser) {
$browser
->visit(new Login())
->auth();
});
$this->disableCompanyGateways();
CompanyGateway::where('gateway_key', 'f7ec488676d310683fb51802d076d713')->restore();
}
public function testOffsitePayment()
{
$this->markTestSkipped('Sometimes after redirect PayPal shows the register-like page with credit card, sometimes is login page.');
}
}

View File

@ -1,127 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Tests\Browser\ClientPortal\Gateways\CheckoutCom;
use App\Models\CompanyGateway;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\ClientPortal\Login;
use Tests\DuskTestCase;
class CreditCardTest extends DuskTestCase
{
protected function setUp(): void
{
parent::setUp();
foreach (static::$browsers as $browser) {
$browser->driver->manage()->deleteAllCookies();
}
$this->disableCompanyGateways();
CompanyGateway::where('gateway_key', '3758e7f7c6f4cecf0f4f348b9a00f456')->restore();
$this->browse(function (Browser $browser) {
$browser
->visit(new Login())
->auth();
});
}
public function testPayWithNewCard()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('Credit Card')
->withinFrame('iframe', function (Browser $browser) {
$browser
->type('cardnumber', '4242424242424242')
->type('exp-date', '04/22')
->type('cvc', '100');
})
->press('#pay-button')
->waitForText('Details of the payment', 60);
});
}
public function testPayWithNewCardAndSaveForFutureUse()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('Credit Card')
->withinFrame('iframe', function (Browser $browser) {
$browser
->type('cardnumber', '4242424242424242')
->type('exp-date', '04/22')
->type('cvc', '100');
})
->radio('#proxy_is_default', true)
->press('#pay-button')
->waitForText('Details of the payment', 60)
->visitRoute('client.payment_methods.index')
->clickLink('View')
->assertSee('4242');
});
}
public function testPayWithSavedCreditCard()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('Credit Card')
->click('.toggle-payment-with-token')
->click('#pay-now-with-token')
->waitForText('Details of the payment', 60);
});
}
public function testRemoveCreditCard()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.payment_methods.index')
->clickLink('View')
->press('Remove Payment Method')
->waitForText('Confirmation')
->click('@confirm-payment-removal')
->assertSee('Payment method has been successfully removed.');
});
}
public function testAddingCreditCardStandalone()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.payment_methods.index')
->press('Add Payment Method')
->clickLink('Credit Card')
->withinFrame('iframe', function (Browser $browser) {
$browser
->type('cardnumber', '4242424242424242')
->type('exp-date', '04/22')
->type('cvc', '100');
})
->press('#pay-button')
->waitForText('Details of payment method', 60);
});
}
}

View File

@ -1,125 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Tests\Browser\ClientPortal\Gateways\Eway;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\ClientPortal\Login;
use Tests\DuskTestCase;
class CreditCardTest extends DuskTestCase
{
protected function setUp(): void
{
parent::setUp();
foreach (static::$browsers as $browser) {
$browser->driver->manage()->deleteAllCookies();
}
$this->browse(function (Browser $browser) {
$browser
->visit(new Login())
->auth();
});
}
public function testPaymentWithNewCard()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->click('@pay-now-dropdown')
->clickLink('Credit Card')
->withinFrame('iframe', function (Browser $browser) {
$browser
->type('EWAY_CARDNAME', 'Invoice Ninja')
->type('EWAY_CARDNUMBER', '4111 1111 1111 1111')
->type('EWAY_CARDEXPIRY', '04/22')
->type('EWAY_CARDCVN', '100');
})
->click('#pay-now')
->waitForText('Details of the payment', 60);
});
}
public function testPayWithNewCardAndSaveForFutureUse()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->click('@pay-now-dropdown')
->clickLink('Credit Card')
->withinFrame('iframe', function (Browser $browser) {
$browser
->type('EWAY_CARDNAME', 'Invoice Ninja')
->type('EWAY_CARDNUMBER', '4111 1111 1111 1111')
->type('EWAY_CARDEXPIRY', '04/22')
->type('EWAY_CARDCVN', '100');
})
->radio('#proxy_is_default', true)
->click('#pay-now')
->waitForText('Details of the payment', 60)
->visitRoute('client.payment_methods.index')
->clickLink('View')
->assertSee('1111');
});
}
public function testPayWithSavedCreditCard()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->click('@pay-now-dropdown')
->clickLink('Credit Card')
->click('.toggle-payment-with-token')
->click('#pay-now')
->waitForText('Details of the payment', 60);
});
}
public function testRemoveCreditCard()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.payment_methods.index')
->clickLink('View')
->press('Remove Payment Method')
->waitForText('Confirmation')
->click('@confirm-payment-removal')
->assertSee('Payment method has been successfully removed.');
});
}
public function testAddingCreditCardStandalone()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.payment_methods.index')
->press('Add Payment Method')
->clickLink('Credit Card')
->withinFrame('iframe', function (Browser $browser) {
$browser
->type('EWAY_CARDNAME', 'Invoice Ninja')
->type('EWAY_CARDNUMBER', '4111 1111 1111 1111')
->type('EWAY_CARDEXPIRY', '04/22')
->type('EWAY_CARDCVN', '100');
})
->press('Add Payment Method')
->waitForText('**** 1111');
});
}
}

View File

@ -1,42 +0,0 @@
<?php
namespace Tests\Browser\ClientPortal\Gateways\GoCardless;
use App\Models\CompanyGateway;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\ClientPortal\Login;
use Tests\DuskTestCase;
class ACHTest extends DuskTestCase
{
protected function setUp(): void
{
parent::setUp();
foreach (static::$browsers as $browser) {
$browser->driver->manage()->deleteAllCookies();
}
$this->disableCompanyGateways();
CompanyGateway::where('gateway_key', 'b9886f9257f0c6ee7c302f1c74475f6c')->restore();
$this->browse(function (Browser $browser) {
$browser
->visit(new Login())
->auth();
});
}
public function testPayingWithNoPreauthorizedIsntPossible()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('Bank Transfer')
->assertSee('To pay with a bank account, first you have to add it as payment method.');
});
}
}

View File

@ -1,42 +0,0 @@
<?php
namespace Tests\Browser\ClientPortal\Gateways\GoCardless;
use App\Models\CompanyGateway;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\ClientPortal\Login;
use Tests\DuskTestCase;
class DirectDebitTest extends DuskTestCase
{
protected function setUp(): void
{
parent::setUp();
foreach (static::$browsers as $browser) {
$browser->driver->manage()->deleteAllCookies();
}
$this->disableCompanyGateways();
CompanyGateway::where('gateway_key', 'b9886f9257f0c6ee7c302f1c74475f6c')->restore();
$this->browse(function (Browser $browser) {
$browser
->visit(new Login())
->auth();
});
}
public function testPayingWithNoPreauthorizedIsntPossible()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('Direct Debit')
->assertSee('To pay with a bank account, first you have to add it as payment method.');
});
}
}

View File

@ -1,42 +0,0 @@
<?php
namespace Tests\Browser\ClientPortal\Gateways\GoCardless;
use App\Models\CompanyGateway;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\ClientPortal\Login;
use Tests\DuskTestCase;
class SEPATest extends DuskTestCase
{
protected function setUp(): void
{
parent::setUp();
foreach (static::$browsers as $browser) {
$browser->driver->manage()->deleteAllCookies();
}
$this->disableCompanyGateways();
CompanyGateway::where('gateway_key', 'b9886f9257f0c6ee7c302f1c74475f6c')->restore();
$this->browse(function (Browser $browser) {
$browser
->visit(new Login())
->auth();
});
}
public function testPayingWithNoPreauthorizedIsntPossible()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('SEPA Direct Debit')
->assertSee('To pay with a bank account, first you have to add it as payment method.');
});
}
}

View File

@ -1,102 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Tests\Browser\ClientPortal\Gateways\Mollie;
use App\Models\CompanyGateway;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\ClientPortal\Login;
use Tests\DuskTestCase;
class BancontactTest extends DuskTestCase
{
protected function setUp(): void
{
parent::setUp();
foreach (static::$browsers as $browser) {
$browser->driver->manage()->deleteAllCookies();
}
$this->disableCompanyGateways();
CompanyGateway::where('gateway_key', '1bd651fb213ca0c9d66ae3c336dc77e8')->restore();
$this->browse(function (Browser $browser) {
$browser
->visit(new Login())
->auth();
});
}
public function testSuccessfulPayment(): void
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('Bancontact')
->waitForText('Test profile')
->radio('final_state', 'paid')
->press('Continue')
->waitForText('Details of the payment')
->assertSee('Completed');
});
}
public function testOpenPayments(): void
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('Bancontact')
->waitForText('Test profile')
->radio('final_state', 'open')
->press('Continue')
->waitForText('Details of the payment')
->assertSee('Pending');
});
}
public function testFailedPayment(): void
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('Bancontact')
->waitForText('Test profile')
->radio('final_state', 'failed')
->press('Continue')
->waitForText('Failed.');
});
}
public function testCancelledTest(): void
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('Bancontact')
->waitForText('Test profile')
->radio('final_state', 'canceled')
->press('Continue')
->waitForText('Cancelled.');
});
}
}

View File

@ -1,72 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Tests\Browser\ClientPortal\Gateways\Mollie;
use App\Models\CompanyGateway;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\ClientPortal\Login;
use Tests\DuskTestCase;
class BankTransferTest extends DuskTestCase
{
protected function setUp(): void
{
parent::setUp();
foreach (static::$browsers as $browser) {
$browser->driver->manage()->deleteAllCookies();
}
$this->disableCompanyGateways();
CompanyGateway::where('gateway_key', '1bd651fb213ca0c9d66ae3c336dc77e8')->restore();
$this->browse(function (Browser $browser) {
$browser
->visit(new Login())
->auth();
});
}
public function testSuccessfulPayment(): void
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('Bank Transfer')
->waitForText('Test profile')
->radio('final_state', 'paid')
->press('Continue')
->waitForText('Details of the payment')
->assertSee('Completed');
});
}
public function testPendingPayment(): void
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('Bank Transfer')
->waitForText('Test profile')
->radio('final_state', 'open')
->press('Continue')
->waitForText('Details of the payment')
->assertSee('Pending');
});
}
}

View File

@ -1,134 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Tests\Browser\ClientPortal\Gateways\Mollie;
use App\Models\CompanyGateway;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\ClientPortal\Login;
use Tests\DuskTestCase;
class CreditCardTest extends DuskTestCase
{
protected function setUp(): void
{
parent::setUp();
foreach (static::$browsers as $browser) {
$browser->driver->manage()->deleteAllCookies();
}
$this->disableCompanyGateways();
CompanyGateway::where('gateway_key', '1bd651fb213ca0c9d66ae3c336dc77e8')->restore();
$this->browse(function (Browser $browser) {
$browser
->visit(new Login())
->auth();
});
}
public function testPayWithNewCreditCard()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('Credit Card')
->pause(5000)
->withinFrame('iframe[name=cardNumber-input]', function (Browser $browser) {
$browser->type('#cardNumber', '4242424242424242');
})
->withinFrame('iframe[name=cardHolder-input]', function (Browser $browser) {
$browser->type('#cardHolder', 'Invoice Ninja Test Suite');
})
->withinFrame('iframe[name=expiryDate-input]', function (Browser $browser) {
$browser->type('#expiryDate', '12/29');
})
->withinFrame('iframe[name=verificationCode-input]', function (Browser $browser) {
$browser->type('#verificationCode', '100');
})
->press('Pay Now')
->waitForText('Details of the payment', 60);
});
}
public function testPayWithNewCreditCardAndSaveForFutureUse()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('Credit Card')
->pause(5000)
->withinFrame('iframe[name=cardNumber-input]', function (Browser $browser) {
$browser->type('#cardNumber', '4242424242424242');
})
->withinFrame('iframe[name=cardHolder-input]', function (Browser $browser) {
$browser->type('#cardHolder', 'Invoice Ninja Test Suite');
})
->withinFrame('iframe[name=expiryDate-input]', function (Browser $browser) {
$browser->type('#expiryDate', '12/29');
})
->withinFrame('iframe[name=verificationCode-input]', function (Browser $browser) {
$browser->type('#verificationCode', '100');
})
->radio('#proxy_is_default', true)
->press('Pay Now')
->waitForText('Details of the payment', 60)
->visitRoute('client.payment_methods.index')
->clickLink('View')
->assertSee('4242');
});
}
public function testPayWithSavedCreditCard()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('Credit Card')
->click('.toggle-payment-with-token')
->press('Pay Now')
->waitForText('Details of the payment', 60);
});
}
public function testAddingPaymentMethodShouldntBePossible()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.payment_methods.index')
->press('Add Payment Method')
->clickLink('Credit Card')
->assertSee('This payment method can be can saved for future use, once you complete your first transaction. Don\'t forget to check "Store credit card details" during payment process.');
});
}
public function testRemoveCreditCard()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.payment_methods.index')
->clickLink('View')
->press('Remove Payment Method')
->waitForText('Confirmation')
->click('@confirm-payment-removal')
->assertSee('Payment method has been successfully removed.');
});
}
}

View File

@ -1,106 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Tests\Browser\ClientPortal\Gateways\Mollie;
use App\Models\CompanyGateway;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\ClientPortal\Login;
use Tests\DuskTestCase;
class IDEALTest extends DuskTestCase
{
protected function setUp(): void
{
parent::setUp();
foreach (static::$browsers as $browser) {
$browser->driver->manage()->deleteAllCookies();
}
$this->disableCompanyGateways();
CompanyGateway::where('gateway_key', '1bd651fb213ca0c9d66ae3c336dc77e8')->restore();
$this->browse(function (Browser $browser) {
$browser
->visit(new Login())
->auth();
});
}
public function testSuccessfulPayment(): void
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('iDEAL')
->waitForText('Test profile')
->press('ABN AMRO')
->radio('final_state', 'paid')
->press('Continue')
->waitForText('Details of the payment')
->assertSee('Completed');
});
}
public function testOpenPayment(): void
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('iDEAL')
->waitForText('Test profile')
->press('ABN AMRO')
->radio('final_state', 'open')
->press('Continue')
->waitForText('Details of the payment')
->assertSee('Pending');
});
}
public function testFailedPayment(): void
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('iDEAL')
->waitForText('Test profile')
->press('ABN AMRO')
->radio('final_state', 'failed')
->press('Continue')
->waitForText('Failed.');
});
}
public function testCancelledPayment(): void
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('iDEAL')
->waitForText('Test profile')
->press('ABN AMRO')
->radio('final_state', 'canceled')
->press('Continue')
->waitForText('Cancelled.');
});
}
}

View File

@ -1,89 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Tests\Browser\ClientPortal\Gateways\Mollie;
use App\Models\CompanyGateway;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\ClientPortal\Login;
use Tests\DuskTestCase;
class KBCTest extends DuskTestCase
{
protected function setUp(): void
{
parent::setUp();
foreach (static::$browsers as $browser) {
$browser->driver->manage()->deleteAllCookies();
}
$this->disableCompanyGateways();
CompanyGateway::where('gateway_key', '1bd651fb213ca0c9d66ae3c336dc77e8')->restore();
$this->browse(function (Browser $browser) {
$browser
->visit(new Login())
->auth();
});
}
public function testSuccessfulPayment(): void
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('Undefined.')
->waitForText('Test profile')
->press('CBC')
->radio('final_state', 'paid')
->press('Continue')
->waitForText('Details of the payment')
->assertSee('Completed');
});
}
public function testFailedPayment(): void
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('Undefined.')
->waitForText('Test profile')
->press('CBC')
->radio('final_state', 'failed')
->press('Continue')
->waitForText('Failed.');
});
}
public function testCancelledTest(): void
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('Undefined.')
->waitForText('Test profile')
->press('CBC')
->radio('final_state', 'canceled')
->press('Continue')
->waitForText('Cancelled.');
});
}
}

View File

@ -1,40 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Tests\Browser\ClientPortal\Gateways\PayPal;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\ClientPortal\Login;
use Tests\DuskTestCase;
class PayPalTest extends DuskTestCase
{
protected function setUp(): void
{
parent::setUp();
foreach (static::$browsers as $browser) {
$browser->driver->manage()->deleteAllCookies();
}
$this->browse(function (Browser $browser) {
$browser
->visit(new Login())
->auth();
});
}
public function testOffsitePayment()
{
$this->markTestSkipped('Sometimes after redirect PayPal shows the register-like page with credit card, sometimes is login page.');
}
}

View File

@ -1,62 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Tests\Browser\ClientPortal\Gateways\PayTrace;
use App\Models\CompanyGateway;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\ClientPortal\Login;
use Tests\DuskTestCase;
class CreditCardTest extends DuskTestCase
{
protected function setUp(): void
{
parent::setUp();
foreach (static::$browsers as $browser) {
$browser->driver->manage()->deleteAllCookies();
}
$this->disableCompanyGateways();
CompanyGateway::where('gateway_key', 'bbd736b3254b0aabed6ad7fda1298c88')->restore();
$this->browse(function (Browser $browser) {
$browser
->visit(new Login())
->auth();
});
}
public function testPayingWithNewCreditCard()
{
$this->markTestSkipped('Credit card not supported.');
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('Credit Card')
->withinFrame('iframe', function (Browser $browser) {
$browser
->type('CC', '4012000098765439')
->select('EXP_MM', '12')
->select('EXP_YY', '30')
->type('SEC', '999');
})
->press('Pay Now')
->waitForText('Details of the payment', 60);
});
}
}

View File

@ -1,128 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Tests\Browser\ClientPortal\Gateways\Square;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\ClientPortal\Login;
use Tests\DuskTestCase;
class CreditCardTest extends DuskTestCase
{
protected function setUp(): void
{
parent::setUp();
foreach (static::$browsers as $browser) {
$browser->driver->manage()->deleteAllCookies();
}
$this->browse(function (Browser $browser) {
$browser
->visit(new Login())
->auth();
});
}
public function testPaymentWithNewCard()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->click('@pay-now-dropdown')
->clickLink('Credit Card')
->type('#cardholder-name', 'John Doe')
->withinFrame('iframe', function (Browser $browser) {
$browser
->type('#cardNumber', '4111 1111 1111 1111')
->type('#expirationDate', '04/22')
->type('#cvv', '1111')
->type('#postalCode', '12345');
})
->click('#pay-now')
->waitForText('Details of the payment', 60);
});
}
public function testPayWithNewCardAndSaveForFutureUse()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->click('@pay-now-dropdown')
->clickLink('Credit Card')
->type('#cardholder-name', 'John Doe')
->withinFrame('iframe', function (Browser $browser) {
$browser
->type('#cardNumber', '4111 1111 1111 1111')
->type('#expirationDate', '04/22')
->type('#cvv', '1111')
->type('#postalCode', '12345');
})
->radio('#proxy_is_default', true)
->click('#pay-now')
->waitForText('Details of the payment', 60)
->visitRoute('client.payment_methods.index')
->clickLink('View')
->assertSee('4242');
});
}
public function testPayWithSavedCreditCard()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->click('@pay-now-dropdown')
->clickLink('Credit Card')
->click('.toggle-payment-with-token')
->click('#pay-now')
->waitForText('Details of the payment', 60);
});
}
public function testRemoveCreditCard()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.payment_methods.index')
->clickLink('View')
->press('Remove Payment Method')
->waitForText('Confirmation')
->click('@confirm-payment-removal')
->assertSee('Payment method has been successfully removed.');
});
}
public function testAddingCreditCardStandalone()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.payment_methods.index')
->press('Add Payment Method')
->clickLink('Credit Card')
->type('#cardholder-name', 'John Doe')
->withinFrame('iframe', function (Browser $browser) {
$browser
->type('#cardNumber', '4111 1111 1111 1111')
->type('#expirationDate', '04/22')
->type('#cvv', '1111')
->type('#postalCode', '12345');
})
->press('Add Payment Method')
->waitForText('**** 1111');
});
}
}

View File

@ -1,133 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Tests\Browser\ClientPortal\Gateways\Stripe;
use App\DataMapper\FeesAndLimits;
use App\Models\Client;
use App\Models\CompanyGateway;
use App\Models\GatewayType;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\ClientPortal\Login;
use Tests\DuskTestCase;
class ACHTest extends DuskTestCase
{
protected function setUp(): void
{
parent::setUp();
foreach (static::$browsers as $browser) {
$browser->driver->manage()->deleteAllCookies();
}
$this->browse(function (Browser $browser) {
$browser
->visit(new Login())
->auth();
});
$this->disableCompanyGateways();
// Enable Stripe.
CompanyGateway::where('gateway_key', 'd14dd26a37cecc30fdd65700bfb55b23')->restore();
// Enable ACH.
$cg = CompanyGateway::where('gateway_key', 'd14dd26a37cecc30fdd65700bfb55b23')->firstOrFail();
$fees_and_limits = $cg->fees_and_limits;
$fees_and_limits->{GatewayType::BANK_TRANSFER} = new FeesAndLimits();
$cg->fees_and_limits = $fees_and_limits;
$cg->save();
// ACH required US to be billing country.
$client = Client::first();
$client->country_id = 840;
$client->save();
}
public function testAddingACHAccountAndVerifyingIt()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.payment_methods.index')
->press('Add Payment Method')
->clickLink('Bank Account')
->type('#account-holder-name', 'John Doe')
->select('#country', 'US')
->select('#currency', 'USD')
->type('#routing-number', '110000000')
->type('#account-number', '000123456789')
->check('#accept-terms')
->press('Add Payment Method')
->waitForText('ACH (Verification)', 60)
->type('@verification-1st', '32')
->type('@verification-2nd', '45')
->press('Complete Verification')
->assertSee('Verification completed successfully')
->assertSee('Bank Transfer');
});
}
public function testPayingWithExistingACH()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('Bank Transfer')
->click('.toggle-payment-with-token')
->press('Pay Now')
->waitForText('Details of the payment', 60);
});
}
public function testRemoveACHAccount()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.payment_methods.index')
->clickLink('View')
->press('Remove Payment Method')
->waitForText('Confirmation')
->click('@confirm-payment-removal')
->assertSee('Payment method has been successfully removed.');
});
}
public function testIntegerAndMinimumValueOnVerification()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.payment_methods.index')
->press('Add Payment Method')
->clickLink('Bank Account')
->type('#account-holder-name', 'John Doe')
->select('#country', 'US')
->select('#currency', 'USD')
->type('#routing-number', '110000000')
->type('#account-number', '000123456789')
->check('#accept-terms')
->press('Add Payment Method')
->waitForText('ACH (Verification)', 60)
->type('@verification-1st', '0.1')
->type('@verification-2nd', '0')
->press('Complete Verification')
->assertSee('The transactions.0 must be an integer')
->assertSee('The transactions.1 must be at least 1')
->type('@verification-1st', '32')
->type('@verification-2nd', '45')
->press('Complete Verification')
->assertSee('Bank Transfer');
});
}
}

View File

@ -1,75 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Tests\Browser\ClientPortal\Gateways\Stripe;
use App\DataMapper\FeesAndLimits;
use App\Models\Client;
use App\Models\CompanyGateway;
use App\Models\GatewayType;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\ClientPortal\Login;
use Tests\DuskTestCase;
class ACSSTest extends DuskTestCase
{
protected function setUp(): void
{
parent::setUp();
foreach (static::$browsers as $browser) {
$browser->driver->manage()->deleteAllCookies();
}
$this->browse(function (Browser $browser) {
$browser
->visit(new Login())
->auth();
});
$this->disableCompanyGateways();
// Enable Stripe.
CompanyGateway::where('gateway_key', 'd14dd26a37cecc30fdd65700bfb55b23')->restore();
// Enable SOFORT.
$cg = CompanyGateway::where('gateway_key', 'd14dd26a37cecc30fdd65700bfb55b23')->firstOrFail();
$fees_and_limits = $cg->fees_and_limits;
$fees_and_limits->{GatewayType::ACSS} = new FeesAndLimits();
$cg->fees_and_limits = $fees_and_limits;
$cg->save();
$client = Client::first();
$client->country_id = 276; // Change to US or Canada
$client->save();
}
public function testPayingWithACSS()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('ACSS')
->type('#acss-name', 'John Doe')
->type('#acss-name', 'John@Doe.com')
->withinFrame('iframe', function (Browser $browser) {
$browser->type('acss', '12345');
})
->click('#pay-now')
->waitForText('ACSS test payment page', 120)
->press('.common-Button.common-Button--default')
->waitForText('Details of the payment', 60);
});
}
}

View File

@ -1,71 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Tests\Browser\ClientPortal\Gateways\Stripe;
use App\DataMapper\FeesAndLimits;
use App\Models\Client;
use App\Models\CompanyGateway;
use App\Models\GatewayType;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\ClientPortal\Login;
use Tests\DuskTestCase;
class AlipayTest extends DuskTestCase
{
protected function setUp(): void
{
parent::setUp();
foreach (static::$browsers as $browser) {
$browser->driver->manage()->deleteAllCookies();
}
$this->browse(function (Browser $browser) {
$browser
->visit(new Login())
->auth();
});
$this->disableCompanyGateways();
// Enable Stripe.
CompanyGateway::where('gateway_key', 'd14dd26a37cecc30fdd65700bfb55b23')->restore();
// Enable Alipay.
$cg = CompanyGateway::where('gateway_key', 'd14dd26a37cecc30fdd65700bfb55b23')->firstOrFail();
$fees_and_limits = $cg->fees_and_limits;
$fees_and_limits->{GatewayType::ALIPAY} = new FeesAndLimits();
$cg->fees_and_limits = $fees_and_limits;
$cg->save();
// Setting country to DEU (276).
$client = Client::first();
$client->country_id = 276;
$client->save();
}
public function testPayingWithAlipay()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('Alipay')
->press('Pay Now')
->waitForText('Alipay test payment page', 120)
->press('.common-Button.common-Button--default')
->waitForText('Details of the payment', 60);
});
}
}

View File

@ -1,75 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Tests\Browser\ClientPortal\Gateways\Stripe;
use App\DataMapper\FeesAndLimits;
use App\Models\Client;
use App\Models\CompanyGateway;
use App\Models\GatewayType;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\ClientPortal\Login;
use Tests\DuskTestCase;
class BECSTest extends DuskTestCase
{
protected function setUp(): void
{
parent::setUp();
foreach (static::$browsers as $browser) {
$browser->driver->manage()->deleteAllCookies();
}
$this->browse(function (Browser $browser) {
$browser
->visit(new Login())
->auth();
});
$this->disableCompanyGateways();
// Enable Stripe.
CompanyGateway::where('gateway_key', 'd14dd26a37cecc30fdd65700bfb55b23')->restore();
// Enable SOFORT.
$cg = CompanyGateway::where('gateway_key', 'd14dd26a37cecc30fdd65700bfb55b23')->firstOrFail();
$fees_and_limits = $cg->fees_and_limits;
$fees_and_limits->{GatewayType::BECS} = new FeesAndLimits();
$cg->fees_and_limits = $fees_and_limits;
$cg->save();
$client = Client::first();
$client->country_id = 276; // Change to austria
$client->save();
}
public function testPayingWithBECS()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('BECS')
->type('#becs-name', 'John Doe')
->type('#becs-email', 'john@doe.com')
->withinFrame('iframe', function (Browser $browser) {
$browser->type('becs-iban', '000123456');
})
->click('#pay-now')
->waitForText('BECS test payment page', 120)
->press('.common-Button.common-Button--default')
->waitForText('Details of the payment', 60);
});
}
}

View File

@ -1,71 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Tests\Browser\ClientPortal\Gateways\Stripe;
use App\DataMapper\FeesAndLimits;
use App\Models\Client;
use App\Models\CompanyGateway;
use App\Models\GatewayType;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\ClientPortal\Login;
use Tests\DuskTestCase;
class BancontactTest extends DuskTestCase
{
protected function setUp(): void
{
parent::setUp();
foreach (static::$browsers as $browser) {
$browser->driver->manage()->deleteAllCookies();
}
$this->browse(function (Browser $browser) {
$browser
->visit(new Login())
->auth();
});
$this->disableCompanyGateways();
// Enable Stripe.
CompanyGateway::where('gateway_key', 'd14dd26a37cecc30fdd65700bfb55b23')->restore();
// Enable SOFORT.
$cg = CompanyGateway::where('gateway_key', 'd14dd26a37cecc30fdd65700bfb55b23')->firstOrFail();
$fees_and_limits = $cg->fees_and_limits;
$fees_and_limits->{GatewayType::BANCONTACT} = new FeesAndLimits();
$cg->fees_and_limits = $fees_and_limits;
$cg->save();
$client = Client::first();
$client->country_id = 276;
$client->save();
}
public function testPayingWithBancontact()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('EPS')
->type('#bancontact-name', 'John Doe')
->click('#pay-now')
->waitForText('Bancontact test payment page', 120)
->press('.common-Button.common-Button--default')
->waitForText('Details of the payment', 60);
});
}
}

View File

@ -1,139 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Tests\Browser\ClientPortal\Gateways\Stripe;
use App\DataMapper\FeesAndLimits;
use App\Models\CompanyGateway;
use App\Models\GatewayType;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\ClientPortal\Login;
use Tests\DuskTestCase;
class CreditCardTest extends DuskTestCase
{
protected function setUp(): void
{
parent::setUp();
foreach (static::$browsers as $browser) {
$browser->driver->manage()->deleteAllCookies();
}
$this->browse(function (Browser $browser) {
$browser
->visit(new Login())
->auth();
});
$this->disableCompanyGateways();
// Enable Stripe.
CompanyGateway::where('gateway_key', 'd14dd26a37cecc30fdd65700bfb55b23')->restore();
$cg = CompanyGateway::where('gateway_key', 'd14dd26a37cecc30fdd65700bfb55b23')->firstOrFail();
$fees_and_limits = $cg->fees_and_limits;
$fees_and_limits->{GatewayType::CREDIT_CARD} = new FeesAndLimits();
$cg->fees_and_limits = $fees_and_limits;
$cg->save();
}
public function testPaymentWithNewCard()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->click('@pay-now-dropdown')
->clickLink('Credit Card')
->type('#cardholder-name', 'John Doe')
->withinFrame('iframe', function (Browser $browser) {
$browser
->type('cardnumber', '4242 4242 4242 4242')
->type('exp-date', '04/22')
->type('cvc', '242');
})
->click('#pay-now')
->waitForText('Details of the payment', 60);
});
}
public function testPayWithNewCardAndSaveForFutureUse()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->click('@pay-now-dropdown')
->clickLink('Credit Card')
->type('#cardholder-name', 'John Doe')
->withinFrame('iframe', function (Browser $browser) {
$browser
->type('cardnumber', '4242 4242 4242 4242')
->type('exp-date', '04/22')
->type('cvc', '242');
})
->radio('#proxy_is_default', true)
->click('#pay-now')
->waitForText('Details of the payment', 60)
->visitRoute('client.payment_methods.index')
->clickLink('View')
->assertSee('4242');
});
}
public function testPayWithSavedCreditCard()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->click('@pay-now-dropdown')
->clickLink('Credit Card')
->click('.toggle-payment-with-token')
->click('#pay-now')
->waitForText('Details of the payment', 60);
});
}
public function testRemoveCreditCard()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.payment_methods.index')
->clickLink('View')
->press('Remove Payment Method')
->waitForText('Confirmation')
->click('@confirm-payment-removal')
->assertSee('Payment method has been successfully removed.');
});
}
public function testAddingCreditCardStandalone()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.payment_methods.index')
->press('Add Payment Method')
->clickLink('Credit Card')
->type('#cardholder-name', 'John Doe')
->withinFrame('iframe', function (Browser $browser) {
$browser
->type('cardnumber', '4242 4242 4242 4242')
->type('exp-date', '04/22')
->type('cvc', '242');
})
->press('Add Payment Method')
->waitForText('**** 4242');
});
}
}

View File

@ -1,74 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Tests\Browser\ClientPortal\Gateways\Stripe;
use App\DataMapper\FeesAndLimits;
use App\Models\Client;
use App\Models\CompanyGateway;
use App\Models\GatewayType;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\ClientPortal\Login;
use Tests\DuskTestCase;
class EPSTest extends DuskTestCase
{
protected function setUp(): void
{
parent::setUp();
foreach (static::$browsers as $browser) {
$browser->driver->manage()->deleteAllCookies();
}
$this->browse(function (Browser $browser) {
$browser
->visit(new Login())
->auth();
});
$this->disableCompanyGateways();
// Enable Stripe.
CompanyGateway::where('gateway_key', 'd14dd26a37cecc30fdd65700bfb55b23')->restore();
// Enable SOFORT.
$cg = CompanyGateway::where('gateway_key', 'd14dd26a37cecc30fdd65700bfb55b23')->firstOrFail();
$fees_and_limits = $cg->fees_and_limits;
$fees_and_limits->{GatewayType::EPS} = new FeesAndLimits();
$cg->fees_and_limits = $fees_and_limits;
$cg->save();
$client = Client::first();
$client->country_id = 276;
$client->save();
}
public function testPayingWithEPS()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('EPS')
->type('#eps-name', 'John Doe')
->withinFrame('iframe', function (Browser $browser) {
$browser->type('eps', '12345');
})
->click('#pay-now')
->waitForText('EPS test payment page', 120)
->press('.common-Button.common-Button--default')
->waitForText('Details of the payment', 60);
});
}
}

View File

@ -1,71 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Tests\Browser\ClientPortal\Gateways\Stripe;
use App\DataMapper\FeesAndLimits;
use App\Models\Client;
use App\Models\CompanyGateway;
use App\Models\GatewayType;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\ClientPortal\Login;
use Tests\DuskTestCase;
class GiropayTest extends DuskTestCase
{
protected function setUp(): void
{
parent::setUp();
foreach (static::$browsers as $browser) {
$browser->driver->manage()->deleteAllCookies();
}
$this->browse(function (Browser $browser) {
$browser
->visit(new Login())
->auth();
});
$this->disableCompanyGateways();
// Enable Stripe.
CompanyGateway::where('gateway_key', 'd14dd26a37cecc30fdd65700bfb55b23')->restore();
// Enable SOFORT.
$cg = CompanyGateway::where('gateway_key', 'd14dd26a37cecc30fdd65700bfb55b23')->firstOrFail();
$fees_and_limits = $cg->fees_and_limits;
$fees_and_limits->{GatewayType::GIROPAY} = new FeesAndLimits();
$cg->fees_and_limits = $fees_and_limits;
$cg->save();
$client = Client::first();
$client->country_id = 276;
$client->save();
}
public function testPayingWithGiropay()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('Giropay')
->type('#giropay-name', 'John Doe')
->click('#pay-now')
->waitForText('Giropay test payment page', 120)
->press('.common-Button.common-Button--default')
->waitForText('Details of the payment', 60);
});
}
}

View File

@ -1,76 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Tests\Browser\ClientPortal\Gateways\Stripe;
use App\DataMapper\FeesAndLimits;
use App\Models\Client;
use App\Models\CompanyGateway;
use App\Models\GatewayType;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\ClientPortal\Login;
use Tests\DuskTestCase;
class Prezelewy24Test extends DuskTestCase
{
protected function setUp(): void
{
parent::setUp();
foreach (static::$browsers as $browser) {
$browser->driver->manage()->deleteAllCookies();
}
$this->browse(function (Browser $browser) {
$browser
->visit(new Login())
->auth();
});
$this->disableCompanyGateways();
// Enable Stripe.
CompanyGateway::where('gateway_key', 'd14dd26a37cecc30fdd65700bfb55b23')->restore();
// Enable SOFORT.
$cg = CompanyGateway::where('gateway_key', 'd14dd26a37cecc30fdd65700bfb55b23')->firstOrFail();
$fees_and_limits = $cg->fees_and_limits;
$fees_and_limits->{GatewayType::PRZELEWY24} = new FeesAndLimits();
$cg->fees_and_limits = $fees_and_limits;
$cg->save();
$client = Client::first();
$client->country_id = 276;
$client->save();
}
public function testPayingWithPrezelewy24()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('EPS')
->type('#eps-name', 'John Doe')
->type('#eps-email', 'john@doe.com')
->check('#p24-mandate-acceptance', 'John Doe')
->withinFrame('iframe', function (Browser $browser) {
$browser->type('p24', '12345');
})
->click('#pay-now')
->waitForText('P24 test payment page', 120)
->press('.common-Button.common-Button--default')
->waitForText('Details of the payment', 60);
});
}
}

View File

@ -1,127 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Tests\Browser\ClientPortal\Gateways\Stripe;
use App\DataMapper\FeesAndLimits;
use App\Models\Client;
use App\Models\CompanyGateway;
use App\Models\GatewayType;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\ClientPortal\Login;
use Tests\DuskTestCase;
class SEPATest extends DuskTestCase
{
protected function setUp(): void
{
parent::setUp();
foreach (static::$browsers as $browser) {
$browser->driver->manage()->deleteAllCookies();
}
$this->browse(function (Browser $browser) {
$browser
->visit(new Login())
->auth();
});
$this->disableCompanyGateways();
// Enable Stripe.
CompanyGateway::where('gateway_key', 'd14dd26a37cecc30fdd65700bfb55b23')->restore();
// Enable SEPA.
$cg = CompanyGateway::where('gateway_key', 'd14dd26a37cecc30fdd65700bfb55b23')->firstOrFail();
$fees_and_limits = $cg->fees_and_limits;
$fees_and_limits->{GatewayType::SEPA} = new FeesAndLimits();
$cg->fees_and_limits = $fees_and_limits;
$cg->save();
// SEPA required DE to be billing country.
$client = Client::first();
$client->country_id = 276;
$settings = $client->settings;
$settings->currency_id = '3';
$client->settings = $settings;
$client->save();
}
public function testPayingWithNewSEPABankAccount(): void
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->click('@pay-now-dropdown')
->clickLink('SEPA Direct Debit')
->type('#sepa-name', 'John Doe')
->type('#sepa-email-address', 'test@invoiceninja.com')
->withinFrame('iframe', function (Browser $browser) {
$browser->type('iban', 'DE89370400440532013000');
})
->check('#sepa-mandate-acceptance', true)
->click('#pay-now')
->waitForText('Details of the payment', 60);
});
}
public function testPayingWithNewSEPABankAccountAndSaveForFuture(): void
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->click('@pay-now-dropdown')
->clickLink('SEPA Direct Debit')
->type('#sepa-name', 'John Doe')
->type('#sepa-email-address', 'test@invoiceninja.com')
->withinFrame('iframe', function (Browser $browser) {
$browser->type('iban', 'DE89370400440532013000');
})
->check('#sepa-mandate-acceptance', true)
->radio('#proxy_is_default', true)
->click('#pay-now')
->waitForText('Details of the payment', 60);
});
}
public function testPayWithSavedBankAccount()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->click('@pay-now-dropdown')
->clickLink('SEPA Direct Debit')
->click('.toggle-payment-with-token')
->click('#pay-now')
->waitForText('Details of the payment', 60);
});
}
public function testRemoveBankAccount()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.payment_methods.index')
->clickLink('View')
->press('Remove Payment Method')
->waitForText('Confirmation')
->click('@confirm-payment-removal')
->assertSee('Payment method has been successfully removed.');
});
}
}

View File

@ -1,72 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Tests\Browser\ClientPortal\Gateways\Stripe;
use App\DataMapper\FeesAndLimits;
use App\Models\Client;
use App\Models\CompanyGateway;
use App\Models\GatewayType;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\ClientPortal\Login;
use Tests\DuskTestCase;
class SofortTest extends DuskTestCase
{
protected function setUp(): void
{
parent::setUp();
foreach (static::$browsers as $browser) {
$browser->driver->manage()->deleteAllCookies();
}
$this->browse(function (Browser $browser) {
$browser
->visit(new Login())
->auth();
});
$this->disableCompanyGateways();
// Enable Stripe.
CompanyGateway::where('gateway_key', 'd14dd26a37cecc30fdd65700bfb55b23')->restore();
// Enable SOFORT.
$cg = CompanyGateway::where('gateway_key', 'd14dd26a37cecc30fdd65700bfb55b23')->firstOrFail();
$fees_and_limits = $cg->fees_and_limits;
$fees_and_limits->{GatewayType::SOFORT} = new FeesAndLimits();
$cg->fees_and_limits = $fees_and_limits;
$cg->save();
// SOFORT required ['AUT', 'BEL', 'DEU', 'ITA', 'NLD', 'ESP'] to be billing country.
// Setting country to DEU (276).
$client = Client::first();
$client->country_id = 276;
$client->save();
}
public function testPayingWithSofort()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('Sofort')
->press('Pay Now')
->waitForText('Sofort test payment page', 120)
->press('.common-Button.common-Button--default')
->waitForText('Details of the payment', 60);
});
}
}

View File

@ -1,74 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Tests\Browser\ClientPortal\Gateways\Stripe;
use App\DataMapper\FeesAndLimits;
use App\Models\Client;
use App\Models\CompanyGateway;
use App\Models\GatewayType;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\ClientPortal\Login;
use Tests\DuskTestCase;
class iDEAL extends DuskTestCase
{
protected function setUp(): void
{
parent::setUp();
foreach (static::$browsers as $browser) {
$browser->driver->manage()->deleteAllCookies();
}
$this->browse(function (Browser $browser) {
$browser
->visit(new Login())
->auth();
});
$this->disableCompanyGateways();
// Enable Stripe.
CompanyGateway::where('gateway_key', 'd14dd26a37cecc30fdd65700bfb55b23')->restore();
// Enable SOFORT.
$cg = CompanyGateway::where('gateway_key', 'd14dd26a37cecc30fdd65700bfb55b23')->firstOrFail();
$fees_and_limits = $cg->fees_and_limits;
$fees_and_limits->{GatewayType::IDEAL} = new FeesAndLimits();
$cg->fees_and_limits = $fees_and_limits;
$cg->save();
$client = Client::first();
$client->country_id = 276;
$client->save();
}
public function testPayingWithiDeal()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('iDeal')
->type('#ideal-name', 'John Doe')
->withinFrame('iframe', function (Browser $browser) {
$browser->type('ideal', '12345');
})
->click('#pay-now')
->waitForText('iDeal test payment page', 120)
->press('.common-Button.common-Button--default')
->waitForText('Details of the payment', 60);
});
}
}

View File

@ -1,62 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Tests\Browser\ClientPortal\Gateways\WePay;
use App\DataMapper\FeesAndLimits;
use App\Models\CompanyGateway;
use App\Models\GatewayType;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\ClientPortal\Login;
use Tests\DuskTestCase;
class ACHTest extends DuskTestCase
{
protected function setUp(): void
{
parent::setUp();
foreach (static::$browsers as $browser) {
$browser->driver->manage()->deleteAllCookies();
}
$this->disableCompanyGateways();
CompanyGateway::where('gateway_key', '8fdeed552015b3c7b44ed6c8ebd9e992')->restore();
// Enable ACH.
$cg = CompanyGateway::where('gateway_key', '8fdeed552015b3c7b44ed6c8ebd9e992')->firstOrFail();
$fees_and_limits = $cg->fees_and_limits;
$fees_and_limits->{GatewayType::BANK_TRANSFER} = new FeesAndLimits();
$cg->fees_and_limits = $fees_and_limits;
$cg->save();
$this->browse(function (Browser $browser) {
$browser
->visit(new Login())
->auth();
});
}
public function testPayingWithNoPreauthorizedIsntPossible()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('Bank Transfer')
->assertSee('To pay with a bank account, first you have to add it as payment method.');
});
}
}

View File

@ -1,126 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Tests\Browser\ClientPortal\Gateways\WePay;
use App\Models\Client;
use App\Models\CompanyGateway;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\ClientPortal\Login;
use Tests\DuskTestCase;
class CreditCardTest extends DuskTestCase
{
protected function setUp(): void
{
parent::setUp();
foreach (static::$browsers as $browser) {
$browser->driver->manage()->deleteAllCookies();
}
$this->disableCompanyGateways();
CompanyGateway::where('gateway_key', '8fdeed552015b3c7b44ed6c8ebd9e992')->restore();
$this->browse(function (Browser $browser) {
$browser
->visit(new Login())
->auth();
});
Client::first()->update(['postal_code' => 99501]);
}
public function testPayWithNewCard()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('Credit Card')
->type('card-number', '4003830171874018')
->type('card-holders-name', 'John Doe')
->type('.expiry', '12/28')
->type('cvc', '100')
->press('Pay Now')
->waitForText('Details of the payment', 60);
});
}
public function testPayWithNewCardAndSaveForFutureUse()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('Credit Card')
->type('card-number', '4003830171874018')
->type('card-holders-name', 'John Doe')
->type('.expiry', '12/28')
->type('cvc', '100')
->radio('#proxy_is_default', true)
->press('Pay Now')
->waitForText('Details of the payment', 60)
->visitRoute('client.payment_methods.index')
->clickLink('View')
->assertSee('4018');
});
}
public function testPayWithSavedCreditCard()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('Credit Card')
->click('.toggle-payment-with-token')
->press('Pay Now')
->waitForText('Details of the payment', 60);
});
}
public function testRemoveCreditCard()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.payment_methods.index')
->clickLink('View')
->press('Remove Payment Method')
->waitForText('Confirmation')
->click('@confirm-payment-removal')
->assertSee('Payment method has been successfully removed.');
});
}
public function testAddingCreditCardStandalone()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.payment_methods.index')
->press('Add Payment Method')
->clickLink('Credit Card')
->waitForText('Credit Card')
->type('#cardholder_name', 'John Doe')
->type('card-number', '4003830171874018')
->type('card-holders-name', 'John Doe')
->type('.expiry', '12/28')
->type('cvc', '100')
->press('Add Payment Method')
->waitForText(4018, 60);
});
}
}

View File

@ -1,101 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Tests\Browser\ClientPortal;
use App\Models\CompanyGateway;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\ClientPortal\Login;
use Tests\DuskTestCase;
class InvoicesTest extends DuskTestCase
{
protected function setUp(): void
{
parent::setUp();
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')
->assertSeeIn('span[data-ref="meta-title"]', 'Invoices')
->visitRoute('client.logout');
});
}
public function testClickingPayNowWithoutInvoices()
{
$this->browse(function (Browser $browser) {
$browser
->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.')
->visitRoute('client.logout');
});
}
public function testClickingDownloadWithoutInvoices()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->press('Download')
->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');
});
}
public function testPayNowButtonIsntShowingWhenNoGatewaysConfigured()
{
$this->disableCompanyGateways();
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->assertDontSee('Pay Now');
});
// Enable Stripe.
CompanyGateway::where('gateway_key', 'd14dd26a37cecc30fdd65700bfb55b23')->restore();
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->assertSee('Pay Now')
->visitRoute('client.logout');
});
}
}

View File

@ -1,64 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Tests\Browser\ClientPortal;
use Laravel\Dusk\Browser;
use Tests\DuskTestCase;
class LoginTest extends DuskTestCase
{
protected function setUp(): void
{
parent::setUp();
foreach (static::$browsers as $browser) {
$browser->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');
});
}
}

View File

@ -1,45 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Tests\Browser\ClientPortal;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\ClientPortal\Login;
use Tests\DuskTestCase;
class PaymentMethodsTest extends DuskTestCase
{
protected function setUp(): void
{
parent::setUp();
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.payment_methods.index')
->assertSeeIn('span[data-ref="meta-title"]', 'Payment Methods')
->visitRoute('client.logout');
});
}
}

View File

@ -1,80 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Tests\Browser\ClientPortal;
use App\Models\Client;
use App\Models\CompanyGateway;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\ClientPortal\Login;
use Tests\DuskTestCase;
class PaymentsTest extends DuskTestCase
{
protected function setUp(): void
{
parent::setUp();
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.payments.index')
->assertSeeIn('span[data-ref="meta-title"]', 'Payments')
->visitRoute('client.logout');
});
}
public function testRequiredFieldsCheck()
{
$this->disableCompanyGateways();
// Enable Stripe.
CompanyGateway::where('gateway_key', 'd14dd26a37cecc30fdd65700bfb55b23')->restore();
// Stripe requires post code.
Client::first()->update(['postal_code' => null]);
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.invoices.index')
->click('@pay-now')
->press('Pay Now')
->clickLink('Credit Card')
->assertSee('Postal Code')
->type('client_postal_code', 10000)
->press('Continue')
->pause(2000)
->type('#cardholder-name', 'John Doe')
->withinFrame('iframe', function (Browser $browser) {
$browser
->type('cardnumber', '4242 4242 4242 4242')
->type('exp-date', '04/22')
->type('cvc', '242');
})
->click('#pay-now')
->waitForText('Details of the payment', 60)
->visitRoute('client.logout');
});
}
}

View File

@ -1,210 +0,0 @@
<?php
namespace Tests\Browser\ClientPortal;
use Faker\Factory;
use Faker\Generator;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\ClientPortal\Login;
use Tests\DuskTestCase;
class ProfileSettingsTest extends DuskTestCase
{
/** @var Generator */
public $faker;
protected function setUp(): void
{
parent::setUp();
$this->faker = Factory::create();
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');
});
}
public function testClientDetailsUpdate()
{
$original = [
'name' => $this->faker->name(),
'vat_number' => (string) $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
->with('#update_contact', function (Browser $form) use ($original) {
$form
->type('#client_name', $original['name'])
->type('#client_vat_number', $original['vat_number'])
->type('#client_phone', $original['phone'])
->type('#client_website', $original['website'])
->press('Save');
})
->pause(2000)
->refresh();
$updated = [
'name' => $browser->value('#client_name'),
'vat_number' => $browser->value('#client_vat_number'),
'phone' => $browser->value('#client_phone'),
'website' => $browser->value('#client_website'),
];
$this->assertSame($original, $updated);
});
}
public function testContactDetailsUpdate()
{
$original = [
'first_name' => $this->faker->firstName(),
'last_name' => $this->faker->lastName(),
'email_address' => 'user@example.com',
'phone' => $this->faker->phoneNumber(),
];
$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
->with('#update_client', function (Browser $form) use ($original) {
$form
->type('#contact_first_name', $original['first_name'])
->type('#contact_last_name', $original['last_name'])
->scrollIntoView('#contact_email_address')
->type('#contact_email_address', $original['email_address'])
->type('#contact_phone', $original['phone'])
->click('button[data-ref="update-contact-details"]');
})
->pause(2000)
->refresh();
$updated = [
'first_name' => $browser->value('#contact_first_name'),
'last_name' => $browser->value('#contact_last_name'),
'email_address' => $browser->value('#contact_email_address'),
'phone' => $browser->value('#contact_phone'),
];
$this->assertSame($original, $updated);
});
}
public function testBillingAddressUpdate()
{
$original = [
'street' => $this->faker->streetName(),
'apt' => $this->faker->streetAddress(),
'city' => $this->faker->city(),
'state' => $this->faker->state(),
'postal_code' => $this->faker->postcode(),
];
$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
->with('#update_billing_address', function (Browser $form) use ($original) {
$form
->type('#address1', $original['street'])
->type('#address2', $original['apt'])
->type('#city', $original['city'])
->type('#state', $original['state'])
->type('#postal_code', $original['postal_code'])
->select('#country')
->press('Save');
})
->pause(1000)
->refresh();
$updated = [
'street' => $browser->value('#address1'),
'apt' => $browser->value('#address2'),
'city' => $browser->value('#city'),
'state' => $browser->value('#state'),
'postal_code' => $browser->value('#postal_code'),
];
$this->assertSame($original, $updated);
});
}
public function testShippingAddressUpdate()
{
$original = [
'street' => $this->faker->streetName(),
'apt' => $this->faker->streetAddress(),
'city' => $this->faker->city(),
'state' => $this->faker->state(),
'postal_code' => $this->faker->postcode(),
];
$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
->with('#update_shipping_address', function (Browser $form) use ($original) {
$form
->type('#shipping_address1', $original['street'])
->type('#shipping_address2', $original['apt'])
->type('#shipping_city', $original['city'])
->type('#shipping_state', $original['state'])
->type('#shipping_postal_code', $original['postal_code'])
->select('#shipping_country')
->press('Save');
})
->pause(1000)
->refresh();
$updated = [
'street' => $browser->value('#shipping_address1'),
'apt' => $browser->value('#shipping_address2'),
'city' => $browser->value('#shipping_city'),
'state' => $browser->value('#shipping_state'),
'postal_code' => $browser->value('#shipping_postal_code'),
];
$this->assertSame($original, $updated);
});
}
}

View File

@ -1,105 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Tests\Browser\ClientPortal;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\ClientPortal\Login;
use Tests\DuskTestCase;
class QuotesTest extends DuskTestCase
{
protected function setUp(): void
{
parent::setUp();
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.quotes.index')
->assertSeeIn('span[data-ref="meta-title"]', 'Quotes')
->visitRoute('client.logout');
});
}
public function testClickingApproveWithoutQuotesDoesntWork()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.quotes.index')
->press('Approve')
->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')
->clickLink('View')
->assertSee('Only quotes with "Sent" status can be approved.')
->visitRoute('client.logout');
});
}
public function testMessageForNonApprovableQuotesIsVisible()
{
$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.')
->assertSee('Only quotes with "Sent" status can be approved.')
->visitRoute('client.logout');
});
}
public function testNoQuotesAvailableForDownloadMessage()
{
$this->browse(function (Browser $browser) {
$browser
->visitRoute('client.quotes.index')
->press('Download')
->assertSee('No quotes available for download.');
});
}
}

View File

@ -1,65 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Tests\Browser\ClientPortal;
use App\Models\RecurringInvoice;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\ClientPortal\Login;
use Tests\DuskTestCase;
class RecurringInvoicesTest extends DuskTestCase
{
protected function setUp(): void
{
parent::setUp();
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.recurring_invoices.index')
->assertSeeIn('span[data-ref="meta-title"]', 'Recurring Invoices')
->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');
});
}
}

View File

@ -1,45 +0,0 @@
<?php
/**
* Invoice Ninja (https://invoiceninja.com).
*
* @link https://github.com/invoiceninja/invoiceninja source repository
*
* @copyright Copyright (c) 2021. Invoice Ninja LLC (https://invoiceninja.com)
*
* @license https://www.elastic.co/licensing/elastic-license
*/
namespace Tests\Browser\ClientPortal;
use Laravel\Dusk\Browser;
use Tests\Browser\Pages\ClientPortal\Login;
use Tests\DuskTestCase;
class SubscriptionsTest extends DuskTestCase
{
protected function setUp(): void
{
parent::setUp();
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.subscriptions.index')
->assertSeeIn('span[data-ref="meta-title"]', 'Subscriptions')
->visitRoute('client.logout');
});
}
}

View File

@ -1,51 +0,0 @@
<?php
namespace Tests\Browser\Pages\ClientPortal;
use Laravel\Dusk\Browser;
use Laravel\Dusk\Page;
class Login extends Page
{
/**
* Get the URL for the page.
*
* @return string
*/
public function url(): string
{
return '/client/login';
}
/**
* Assert that the browser is on the page.
*
* @param Browser $browser
* @return void
*/
public function assert(Browser $browser)
{
$browser->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');
}
}

View File

@ -1,2 +0,0 @@
*
!.gitignore

View File

@ -1,2 +0,0 @@
*
!.gitignore

View File

@ -1,73 +0,0 @@
<?php
namespace Tests;
use App\Models\CompanyGateway;
use Facebook\WebDriver\Chrome\ChromeOptions;
use Facebook\WebDriver\Remote\DesiredCapabilities;
use Facebook\WebDriver\Remote\RemoteWebDriver;
use Laravel\Dusk\TestCase as BaseTestCase;
abstract class DuskTestCase extends BaseTestCase
{
use CreatesApplication;
/**
* Prepare for Dusk test execution.
*
* @beforeClass
* @return void
*/
public static function prepare()
{
if (! static::runningInSail()) {
static::startChromeDriver();
}
}
/**
* Create the RemoteWebDriver instance.
*
* @return RemoteWebDriver
*/
protected function driver()
{
$options = (new ChromeOptions)->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']);
}
/**
* Disable all company gateways, test classes should enable them per need.
*
* @return void
*/
public function disableCompanyGateways()
{
CompanyGateway::where('company_id', 1)->delete();
}
}