mirror of
https://github.com/InvoiceShelf/InvoiceShelf.git
synced 2026-09-02 05:10:59 +00:00
* refactor: stabilize model identities for domain migration * refactor: extract module platform context * refactor: assign models to domain contexts * refactor: extract ai platform context * refactor: extract storage platform context * refactor: extract mail platform context * refactor: extract pdf platform context * refactor: extract operations platform context * refactor: move installation into operations platform * refactor: extract money domain context * refactor: extract taxation domain context * refactor: extract catalog domain context * refactor: extract metadata domain context * refactor: extract reporting domain context * refactor: extract purchases domain context * refactor: extract receivables domain context * refactor: extract accounts domain context * refactor: complete reporting statement boundary * refactor: extract contacts domain context * refactor: extract sales domain context * refactor: remove legacy application layers * fix: migrate legacy bouncer role identities
84 lines
2.6 KiB
PHP
84 lines
2.6 KiB
PHP
<?php
|
|
|
|
use App\Domains\Contacts\Models\Customer;
|
|
use Illuminate\Support\Facades\Artisan;
|
|
|
|
use function Pest\Laravel\postJson;
|
|
|
|
beforeEach(function () {
|
|
Artisan::call('db:seed', ['--class' => 'DatabaseSeeder', '--force' => true]);
|
|
Artisan::call('db:seed', ['--class' => 'DemoSeeder', '--force' => true]);
|
|
});
|
|
|
|
test('customer portal guest entrypoints return the spa shell', function () {
|
|
$customer = Customer::factory()->create();
|
|
$companySlug = $customer->company->slug;
|
|
|
|
$this->followingRedirects()->get("/{$companySlug}/customer")
|
|
->assertOk()
|
|
->assertSee('window.InvoiceShelf.start()', false);
|
|
|
|
$this->followingRedirects()->get("/{$companySlug}/customer/login")
|
|
->assertOk()
|
|
->assertSee('window.InvoiceShelf.start()', false);
|
|
|
|
$this->followingRedirects()->get("/{$companySlug}/customer/forgot-password")
|
|
->assertOk()
|
|
->assertSee('window.InvoiceShelf.start()', false);
|
|
|
|
$this->followingRedirects()->get("/{$companySlug}/customer/reset/password/example-token")
|
|
->assertOk()
|
|
->assertSee('window.InvoiceShelf.start()', false);
|
|
});
|
|
|
|
test('customer can login to the customer portal', function () {
|
|
$customer = Customer::factory()->create([
|
|
'password' => 'secret123',
|
|
'enable_portal' => true,
|
|
]);
|
|
|
|
$response = postJson("/{$customer->company->slug}/customer/login", [
|
|
'email' => $customer->email,
|
|
'password' => 'secret123',
|
|
'device_name' => 'customer-portal-web',
|
|
]);
|
|
|
|
$response
|
|
->assertOk()
|
|
->assertJson([
|
|
'success' => true,
|
|
]);
|
|
|
|
$this->assertAuthenticatedAs($customer, 'customer');
|
|
});
|
|
|
|
test('customer portal login rejects invalid credentials', function () {
|
|
$customer = Customer::factory()->create([
|
|
'password' => 'secret123',
|
|
'enable_portal' => true,
|
|
]);
|
|
|
|
postJson("/{$customer->company->slug}/customer/login", [
|
|
'email' => $customer->email,
|
|
'password' => 'wrong-password',
|
|
'device_name' => 'customer-portal-web',
|
|
])
|
|
->assertStatus(422)
|
|
->assertJsonValidationErrors(['email']);
|
|
});
|
|
|
|
test('customer portal login rejects portal-disabled customers', function () {
|
|
$customer = Customer::factory()->create([
|
|
'password' => 'secret123',
|
|
'enable_portal' => false,
|
|
]);
|
|
|
|
postJson("/{$customer->company->slug}/customer/login", [
|
|
'email' => $customer->email,
|
|
'password' => 'secret123',
|
|
'device_name' => 'customer-portal-web',
|
|
])
|
|
->assertStatus(422)
|
|
->assertJsonValidationErrors(['email']);
|
|
});
|