-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7 from chinmaypurav/fix/no-future-dates-allowed-f…
…or-normal-transactions Feat: no future dates allowed for normal transactions
- Loading branch information
Showing
8 changed files
with
186 additions
and
2 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,48 @@ | ||
<?php | ||
|
||
use App\Filament\Resources\AccountResource; | ||
use App\Models\Account; | ||
use App\Models\User; | ||
use Illuminate\Foundation\Testing\RefreshDatabase; | ||
use Illuminate\Support\Carbon; | ||
|
||
use function Pest\Livewire\livewire; | ||
|
||
uses(RefreshDatabase::class); | ||
|
||
beforeEach(function () { | ||
$this->user = User::factory()->create(); | ||
$this->actingAs($this->user); | ||
Carbon::setTestNow(now()); | ||
}); | ||
|
||
it('cannot add future date as initial date', function () { | ||
$newData = Account::factory()->tomorrow()->make(); | ||
|
||
livewire(AccountResource\Pages\CreateAccount::class) | ||
->fillForm([ | ||
'name' => $newData->name, | ||
'account_type' => $newData->account_type, | ||
'current_balance' => $newData->current_balance, | ||
'initial_date' => $newData->initial_date, | ||
]) | ||
->call('create') | ||
->assertHasFormErrors([ | ||
'initial_date', | ||
]); | ||
}); | ||
|
||
it('cannot update future date as initial date', function () { | ||
$account = Account::factory()->for($this->user)->create(); | ||
|
||
livewire(AccountResource\Pages\EditAccount::class, [ | ||
'record' => $account->getRouteKey(), | ||
]) | ||
->fillForm([ | ||
'initial_date' => today()->addDay(), | ||
]) | ||
->call('save') | ||
->assertHasFormErrors([ | ||
'initial_date', | ||
]); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
use App\Filament\Resources\ExpenseResource; | ||
use App\Models\Account; | ||
use App\Models\Category; | ||
use App\Models\Expense; | ||
use App\Models\Person; | ||
use App\Models\User; | ||
use Illuminate\Foundation\Testing\RefreshDatabase; | ||
use Illuminate\Support\Carbon; | ||
|
||
use function Pest\Livewire\livewire; | ||
|
||
uses(RefreshDatabase::class); | ||
|
||
beforeEach(function () { | ||
$this->user = User::factory()->create(); | ||
$this->actingAs($this->user); | ||
Carbon::setTestNow(now()); | ||
}); | ||
|
||
it('cannot add future date as transacted_at', function () { | ||
$newData = Expense::factory()->tomorrow()->make(); | ||
$account = Account::factory()->create(); | ||
$person = Person::factory()->create(); | ||
$category = Category::factory()->create(); | ||
|
||
livewire(ExpenseResource\Pages\CreateExpense::class) | ||
->fillForm([ | ||
'description' => $newData->description, | ||
'person_id' => $person->id, | ||
'account_id' => $account->id, | ||
'category_id' => $category->id, | ||
'amount' => $newData->amount, | ||
'transacted_at' => $newData->transacted_at, | ||
]) | ||
->call('create') | ||
->assertHasFormErrors([ | ||
'transacted_at', | ||
]); | ||
}); | ||
|
||
it('cannot update future date as transacted_at', function () { | ||
$expense = Expense::factory()->for($this->user)->create(); | ||
|
||
livewire(ExpenseResource\Pages\EditExpense::class, [ | ||
'record' => $expense->getRouteKey(), | ||
]) | ||
->fillForm([ | ||
'transacted_at' => today()->addDay(), | ||
]) | ||
->call('save') | ||
->assertHasFormErrors([ | ||
'transacted_at', | ||
]); | ||
}); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,56 @@ | ||
<?php | ||
|
||
use App\Filament\Resources\IncomeResource; | ||
use App\Models\Account; | ||
use App\Models\Category; | ||
use App\Models\Income; | ||
use App\Models\Person; | ||
use App\Models\User; | ||
use Illuminate\Foundation\Testing\RefreshDatabase; | ||
use Illuminate\Support\Carbon; | ||
|
||
use function Pest\Livewire\livewire; | ||
|
||
uses(RefreshDatabase::class); | ||
|
||
beforeEach(function () { | ||
$this->user = User::factory()->create(); | ||
$this->actingAs($this->user); | ||
Carbon::setTestNow(now()); | ||
}); | ||
|
||
it('cannot add future date as transacted_at', function () { | ||
$newData = Income::factory()->tomorrow()->make(); | ||
$account = Account::factory()->create(); | ||
$person = Person::factory()->create(); | ||
$category = Category::factory()->create(); | ||
|
||
livewire(IncomeResource\Pages\CreateIncome::class) | ||
->fillForm([ | ||
'description' => $newData->description, | ||
'person_id' => $person->id, | ||
'account_id' => $account->id, | ||
'category_id' => $category->id, | ||
'amount' => $newData->amount, | ||
'transacted_at' => $newData->transacted_at, | ||
]) | ||
->call('create') | ||
->assertHasFormErrors([ | ||
'transacted_at', | ||
]); | ||
}); | ||
|
||
it('cannot update future date as transacted_at', function () { | ||
$income = Income::factory()->for($this->user)->create(); | ||
|
||
livewire(IncomeResource\Pages\EditIncome::class, [ | ||
'record' => $income->getRouteKey(), | ||
]) | ||
->fillForm([ | ||
'transacted_at' => today()->addDay(), | ||
]) | ||
->call('save') | ||
->assertHasFormErrors([ | ||
'transacted_at', | ||
]); | ||
}); |