From 9ec4051f49e0adfc97afd7593b8013f19d48e23f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Benjamin=20Beganovi=C4=87?= Date: Mon, 5 Jul 2021 11:15:03 +0200 Subject: [PATCH] Invoices: Paid, unpaid, past due filters --- tests/Feature/ClientPortal/InvoicesTest.php | 90 +++++++++++++++++++++ 1 file changed, 90 insertions(+) create mode 100644 tests/Feature/ClientPortal/InvoicesTest.php diff --git a/tests/Feature/ClientPortal/InvoicesTest.php b/tests/Feature/ClientPortal/InvoicesTest.php new file mode 100644 index 000000000000..2ec29de8ca01 --- /dev/null +++ b/tests/Feature/ClientPortal/InvoicesTest.php @@ -0,0 +1,90 @@ +faker = Factory::create(); + } + + public function testInvoiceTableFilters() + { + $account = Account::factory()->create(); + + $user = User::factory()->create( + ['account_id' => $account->id, 'email' => $this->faker->safeEmail] + ); + + $company = Company::factory()->create(['account_id' => $account->id]); + + $client = Client::factory()->create(['company_id' => $company->id, 'user_id' => $user->id]); + + ClientContact::factory()->count(2)->create([ + 'user_id' => $user->id, + 'client_id' => $client->id, + 'company_id' => $company->id, + ]); + + $sent = Invoice::factory()->create([ + 'user_id' => $user->id, + 'company_id' => $company->id, + 'client_id' => $client->id, + 'status_id' => Invoice::STATUS_SENT, + ]); + + $paid = Invoice::factory()->create([ + 'user_id' => $user->id, + 'company_id' => $company->id, + 'client_id' => $client->id, + 'status_id' => Invoice::STATUS_PAID, + ]); + + $unpaid = Invoice::factory()->create([ + 'user_id' => $user->id, + 'company_id' => $company->id, + 'client_id' => $client->id, + 'status_id' => Invoice::STATUS_UNPAID, + ]); + + $this->actingAs($client->contacts->first(), 'contact'); + + Livewire::test(InvoicesTable::class, ['company' => $company]) + ->assertSee($sent->number) + ->assertSee($paid->number) + ->assertSee($unpaid->number); + + Livewire::test(InvoicesTable::class, ['company' => $company]) + ->set('status', ['paid']) + ->assertSee($paid->number) + ->assertDontSee($unpaid->number); + } +}