Added call later, option to limit auto mail so for a client person email you can limit which decision activity will be send to that specific email and moved SMS packages from admin panel to default app view
This commit is contained in:
@@ -72,7 +72,7 @@
|
||||
$contract3->segments()->attach($segment->id, ['active' => true]);
|
||||
|
||||
// Test without date filters - should return all contracts
|
||||
$response = $this->getJson(route('admin.packages.contracts', [
|
||||
$response = $this->getJson(route('packages.contracts', [
|
||||
'segment_id' => $segment->id,
|
||||
]));
|
||||
|
||||
@@ -81,7 +81,7 @@
|
||||
expect($data)->toHaveCount(3);
|
||||
|
||||
// Test with start_date_from filter
|
||||
$response = $this->getJson(route('admin.packages.contracts', [
|
||||
$response = $this->getJson(route('packages.contracts', [
|
||||
'segment_id' => $segment->id,
|
||||
'start_date_from' => '2024-02-01',
|
||||
]));
|
||||
@@ -92,7 +92,7 @@
|
||||
expect(collect($data)->pluck('reference'))->toContain('CONTRACT-2024-002', 'CONTRACT-2024-003');
|
||||
|
||||
// Test with start_date_to filter
|
||||
$response = $this->getJson(route('admin.packages.contracts', [
|
||||
$response = $this->getJson(route('packages.contracts', [
|
||||
'segment_id' => $segment->id,
|
||||
'start_date_to' => '2024-03-31',
|
||||
]));
|
||||
@@ -103,7 +103,7 @@
|
||||
expect(collect($data)->pluck('reference'))->toContain('CONTRACT-2024-001', 'CONTRACT-2024-002');
|
||||
|
||||
// Test with both date filters
|
||||
$response = $this->getJson(route('admin.packages.contracts', [
|
||||
$response = $this->getJson(route('packages.contracts', [
|
||||
'segment_id' => $segment->id,
|
||||
'start_date_from' => '2024-02-01',
|
||||
'start_date_to' => '2024-04-30',
|
||||
@@ -133,7 +133,7 @@
|
||||
$segment = Segment::factory()->create(['active' => true]);
|
||||
|
||||
// Test invalid start_date_from
|
||||
$response = $this->getJson(route('admin.packages.contracts', [
|
||||
$response = $this->getJson(route('packages.contracts', [
|
||||
'segment_id' => $segment->id,
|
||||
'start_date_from' => 'invalid-date',
|
||||
]));
|
||||
@@ -142,7 +142,7 @@
|
||||
$response->assertJsonValidationErrors('start_date_from');
|
||||
|
||||
// Test invalid start_date_to
|
||||
$response = $this->getJson(route('admin.packages.contracts', [
|
||||
$response = $this->getJson(route('packages.contracts', [
|
||||
'segment_id' => $segment->id,
|
||||
'start_date_to' => 'invalid-date',
|
||||
]));
|
||||
|
||||
@@ -0,0 +1,46 @@
|
||||
<?php
|
||||
|
||||
// Override the global uses() so these pure-logic tests skip RefreshDatabase
|
||||
uses(\PHPUnit\Framework\TestCase::class);
|
||||
|
||||
/**
|
||||
* Unit-level tests for the decision_ids filter logic used in AutoMailDispatcher.
|
||||
* These tests execute the filter predicate in isolation without database interaction.
|
||||
*/
|
||||
|
||||
/**
|
||||
* Simulates the filter closure from AutoMailDispatcher::maybeQueue().
|
||||
*
|
||||
* @param array<string,mixed> $preferences
|
||||
*/
|
||||
function emailPassesDecisionFilter(array $preferences, int $decisionId): bool
|
||||
{
|
||||
$decisionIds = $preferences['decision_ids'] ?? [];
|
||||
|
||||
if (empty($decisionIds)) {
|
||||
return true;
|
||||
}
|
||||
|
||||
return in_array($decisionId, array_map('intval', $decisionIds), true);
|
||||
}
|
||||
|
||||
it('email with no decision_ids restriction passes the filter for any decision', function () {
|
||||
expect(emailPassesDecisionFilter([], 5))->toBeTrue();
|
||||
});
|
||||
|
||||
it('email with a matching decision_id in preferences passes the filter', function () {
|
||||
expect(emailPassesDecisionFilter(['decision_ids' => [3, 7]], 7))->toBeTrue();
|
||||
});
|
||||
|
||||
it('email with a non-matching decision_id in preferences is filtered out', function () {
|
||||
expect(emailPassesDecisionFilter(['decision_ids' => [3, 7]], 99))->toBeFalse();
|
||||
});
|
||||
|
||||
it('email with empty preferences is treated as no restriction', function () {
|
||||
expect(emailPassesDecisionFilter([], 42))->toBeTrue();
|
||||
});
|
||||
|
||||
it('string decision ids in preferences are cast to int for comparison', function () {
|
||||
expect(emailPassesDecisionFilter(['decision_ids' => ['3', '7']], 7))->toBeTrue();
|
||||
expect(emailPassesDecisionFilter(['decision_ids' => ['3', '7']], 99))->toBeFalse();
|
||||
});
|
||||
Reference in New Issue
Block a user