Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function table(Table $table): Table
protected function getTableQuery(): Builder|Relation|null
{
/** @var Builder<Expense> $query */
$query = Expense::query()->latest()->limit(10);
$query = Expense::query()->latest('id')->limit(10);

return $query;
}
Expand Down
22 changes: 22 additions & 0 deletions Modules/Expenses/Tests/Feature/RecentExpensesWidgetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,26 @@ public function it_links_each_row_to_the_expenses_index_page(): void
$component->assertSuccessful();
$component->assertSee(ExpenseResource::getUrl('index'), false);
}

#[Test]
#[Group('smoke')]
public function it_lists_newer_expenses_before_older_expenses(): void
{
/* Arrange */
$olderExpense = Expense::factory()
->for($this->company)
->create(['expense_number' => 'EXP-OLDER']);
$newerExpense = Expense::factory()
->for($this->company)
->create(['expense_number' => 'EXP-NEWER']);

/* Act */
$component = Livewire::actingAs($this->user)
->test(RecentExpensesWidget::class);

/* Assert */
$component
->assertSuccessful()
->assertCanSeeTableRecords([$newerExpense, $olderExpense], inOrder: true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ public function table(Table $table): Table
protected function getTableQuery(): Builder|Relation|null
{
/** @var Builder<Payment> $query */
$query = Payment::query()->latest()->limit(10);
$query = Payment::query()->latest('id')->limit(10);

return $query;
}
Expand Down
37 changes: 37 additions & 0 deletions Modules/Payments/Tests/Feature/RecentPaymentsWidgetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -45,4 +45,41 @@ public function it_links_each_row_to_the_payments_index_page(): void
$component->assertSuccessful();
$component->assertSee(PaymentResource::getUrl('index'), false);
}

#[Test]
#[Group('smoke')]
public function it_lists_newer_payments_before_older_payments(): void
{
/* Arrange */
$customer = Relation::factory()->for($this->company)->customer()->create();
$invoice = Invoice::factory()
->for($this->company)
->create([
'customer_id' => $customer->id,
'user_id' => $this->user->id,
]);
$olderPayment = Payment::factory()
->for($this->company)
->create([
'payment_number' => 'PAY-OLDER',
'customer_id' => $customer->id,
'invoice_id' => $invoice->id,
]);
$newerPayment = Payment::factory()
->for($this->company)
->create([
'payment_number' => 'PAY-NEWER',
'customer_id' => $customer->id,
'invoice_id' => $invoice->id,
]);

/* Act */
$component = Livewire::actingAs($this->user)
->test(RecentPaymentsWidget::class);

/* Assert */
$component
->assertSuccessful()
->assertCanSeeTableRecords([$newerPayment, $olderPayment], inOrder: true);
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function table(Table $table): Table
protected function getTableQuery(): Builder|Relation|null
{
/** @var Builder<Project> $query */
$query = Project::query()->latest()->limit(10);
$query = Project::query()->latest('id')->limit(10);

return $query;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ public function table(Table $table): Table
protected function getTableQuery(): Builder|Relation|null
{
/** @var Builder<Task> $query */
$query = Task::query()->latest()->limit(10);
$query = Task::query()->latest('id')->limit(10);

return $query;
}
Expand Down
29 changes: 29 additions & 0 deletions Modules/Projects/Tests/Feature/RecentProjectsWidgetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -37,4 +37,33 @@ public function it_links_each_row_to_the_projects_index_page(): void
$component->assertSuccessful();
$component->assertSee(ProjectResource::getUrl('index'), false);
}

#[Test]
#[Group('smoke')]
public function it_lists_newer_projects_before_older_projects(): void
{
/* Arrange */
$customer = Relation::factory()->for($this->company)->customer()->create();
$olderProject = Project::factory()
->for($this->company)
->create([
'project_number' => 'PRJ-OLDER',
'customer_id' => $customer->id,
]);
$newerProject = Project::factory()
->for($this->company)
->create([
'project_number' => 'PRJ-NEWER',
'customer_id' => $customer->id,
]);

/* Act */
$component = Livewire::actingAs($this->user)
->test(RecentProjectsWidget::class);

/* Assert */
$component
->assertSuccessful()
->assertCanSeeTableRecords([$newerProject, $olderProject], inOrder: true);
}
}
22 changes: 22 additions & 0 deletions Modules/Projects/Tests/Feature/RecentTasksWidgetTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -31,4 +31,26 @@ public function it_links_each_row_to_the_tasks_index_page(): void
$component->assertSuccessful();
$component->assertSee(TaskResource::getUrl('index'), false);
}

#[Test]
#[Group('smoke')]
public function it_lists_newer_tasks_before_older_tasks(): void
{
/* Arrange */
$olderTask = Task::factory()
->for($this->company)
->create(['task_number' => 'TSK-OLDER']);
$newerTask = Task::factory()
->for($this->company)
->create(['task_number' => 'TSK-NEWER']);

/* Act */
$component = Livewire::actingAs($this->user)
->test(RecentTasksWidget::class);

/* Assert */
$component
->assertSuccessful()
->assertCanSeeTableRecords([$newerTask, $olderTask], inOrder: true);
}
}
Loading