feature: send thankscard page

This commit is contained in:
antv
2026-07-14 16:23:04 +07:00
parent 3aa9e04bd7
commit 05605ed1eb
28 changed files with 536 additions and 297 deletions
+73 -29
View File
@@ -29,7 +29,7 @@ class AdminUserListStatsTest extends TestCase
'name' => 'User A',
'mail' => 'usera@example.com',
'pass' => md5('password'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_MEMBER'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 10,
@@ -42,7 +42,7 @@ class AdminUserListStatsTest extends TestCase
'name' => 'User B',
'mail' => 'userb@example.com',
'pass' => md5('password'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_MEMBER'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 10,
@@ -109,7 +109,7 @@ class AdminUserListStatsTest extends TestCase
'name' => 'User A',
'mail' => 'usera@example.com',
'pass' => md5('password'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_MEMBER'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 10,
@@ -166,7 +166,7 @@ class AdminUserListStatsTest extends TestCase
'name' => 'DEV ALPHA',
'mail' => 'alpha@example.com',
'pass' => md5('password'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_MEMBER'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 10,
@@ -179,7 +179,7 @@ class AdminUserListStatsTest extends TestCase
'name' => 'DEV BETA',
'mail' => 'beta@example.com',
'pass' => md5('password'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_MEMBER'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 10,
@@ -210,7 +210,7 @@ class AdminUserListStatsTest extends TestCase
'name' => 'DEV ACTIVE',
'mail' => 'active@example.com',
'pass' => md5('password'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_MEMBER'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 10,
@@ -223,7 +223,7 @@ class AdminUserListStatsTest extends TestCase
'name' => 'DEV INACTIVE',
'mail' => 'inactive@example.com',
'pass' => md5('password'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_MEMBER'),
'status' => config('constants.STATUS_INACTIVE'),
'card' => 10,
@@ -299,7 +299,7 @@ class AdminUserListStatsTest extends TestCase
'name' => 'Admin User',
'mail' => 'admin@example.com',
'pass' => md5('password'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_ADMIN'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 10,
@@ -312,7 +312,7 @@ class AdminUserListStatsTest extends TestCase
'name' => 'Member User',
'mail' => 'member@example.com',
'pass' => md5('password'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_MEMBER'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 5,
@@ -521,7 +521,7 @@ class AdminUserListStatsTest extends TestCase
'name' => 'Admin User',
'mail' => 'admin@example.com',
'pass' => md5('password'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_ADMIN'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 10,
@@ -534,7 +534,7 @@ class AdminUserListStatsTest extends TestCase
'name' => 'Member User',
'mail' => 'member@example.com',
'pass' => md5('password'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_MEMBER'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 10, // currently has 10 cards
@@ -573,7 +573,7 @@ class AdminUserListStatsTest extends TestCase
'name' => 'Admin User',
'mail' => 'admin@example.com',
'pass' => md5('password'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_ADMIN'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 10,
@@ -586,7 +586,7 @@ class AdminUserListStatsTest extends TestCase
'name' => 'Member User',
'mail' => 'member@example.com',
'pass' => md5('password'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_MEMBER'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 10,
@@ -621,7 +621,7 @@ class AdminUserListStatsTest extends TestCase
'name' => 'Admin User',
'mail' => 'admin@example.com',
'pass' => md5('password'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_ADMIN'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 10,
@@ -634,7 +634,7 @@ class AdminUserListStatsTest extends TestCase
'name' => 'Member User',
'mail' => 'member@example.com',
'pass' => md5('password'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_MEMBER'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 10,
@@ -669,7 +669,7 @@ class AdminUserListStatsTest extends TestCase
'name' => 'Admin User',
'mail' => 'admin@example.com',
'pass' => md5('password'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_ADMIN'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 10,
@@ -682,7 +682,7 @@ class AdminUserListStatsTest extends TestCase
'name' => 'Member User',
'mail' => 'member@example.com',
'pass' => md5('password'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_MEMBER'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 2, // has 2 cards left
@@ -717,7 +717,7 @@ class AdminUserListStatsTest extends TestCase
'name' => 'Admin User',
'mail' => 'admin@example.com',
'pass' => md5('password'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_ADMIN'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 10,
@@ -730,7 +730,7 @@ class AdminUserListStatsTest extends TestCase
'name' => 'Member User',
'mail' => 'member@example.com',
'pass' => md5('password'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_MEMBER'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 15, // has 15 cards
@@ -778,7 +778,7 @@ class AdminUserListStatsTest extends TestCase
'name' => 'Admin User',
'mail' => 'admin@example.com',
'pass' => md5('password'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_ADMIN'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 0,
@@ -791,7 +791,7 @@ class AdminUserListStatsTest extends TestCase
'name' => 'Member User',
'mail' => 'member@example.com',
'pass' => md5('password'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_MEMBER'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 15,
@@ -844,7 +844,7 @@ class AdminUserListStatsTest extends TestCase
'name' => 'Admin User',
'mail' => 'admin@example.com',
'pass' => md5('password'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_ADMIN'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 10,
@@ -857,7 +857,7 @@ class AdminUserListStatsTest extends TestCase
'name' => 'Member User',
'mail' => 'member@example.com',
'pass' => md5('password'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_MEMBER'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 15,
@@ -890,7 +890,7 @@ class AdminUserListStatsTest extends TestCase
'name' => 'Admin User',
'mail' => 'admin@example.com',
'pass' => md5('password'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_ADMIN'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 10,
@@ -903,7 +903,7 @@ class AdminUserListStatsTest extends TestCase
'name' => 'Member User',
'mail' => 'member@example.com',
'pass' => md5('password'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_MEMBER'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 10,
@@ -946,7 +946,7 @@ class AdminUserListStatsTest extends TestCase
'name' => 'Admin User',
'mail' => 'admin@example.com',
'pass' => md5('password'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_ADMIN'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 10,
@@ -959,7 +959,7 @@ class AdminUserListStatsTest extends TestCase
'name' => 'Member User',
'mail' => 'member@example.com',
'pass' => md5('password'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_MEMBER'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 10,
@@ -998,7 +998,7 @@ class AdminUserListStatsTest extends TestCase
'name' => 'Admin User',
'mail' => 'admin@example.com',
'pass' => md5('password'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_ADMIN'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 0,
@@ -1011,7 +1011,7 @@ class AdminUserListStatsTest extends TestCase
'name' => 'Member User',
'mail' => 'member@example.com',
'pass' => md5('password'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_MEMBER'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 5,
@@ -1037,4 +1037,48 @@ class AdminUserListStatsTest extends TestCase
$this->assertCount(1, $addCards);
$this->assertEquals(15, $addCards->first()->num_card);
}
public function test_admin_updating_self_status_to_inactive_logs_out(): void
{
$admin = User::create([
'msnv' => 9001,
'name' => 'Admin User',
'mail' => 'admin@example.com',
'pass' => md5('password'),
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_ADMIN'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 10,
'flag_send' => config('constants.FLAG_SEND_ENABLED'),
'first_login' => config('constants.FIRST_LOGIN_FALSE'),
]);
$response = $this->actingAs($admin)->put(route('admin.users.update', 9001), [
'status' => config('constants.STATUS_INACTIVE'),
]);
$response->assertRedirect(route('login'));
$this->assertFalse(\Illuminate\Support\Facades\Auth::check());
}
public function test_admin_deactivating_self_via_destroy_logs_out(): void
{
$admin = User::create([
'msnv' => 9001,
'name' => 'Admin User',
'mail' => 'admin@example.com',
'pass' => md5('password'),
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_ADMIN'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 10,
'flag_send' => config('constants.FLAG_SEND_ENABLED'),
'first_login' => config('constants.FIRST_LOGIN_FALSE'),
]);
$response = $this->actingAs($admin)->delete(route('admin.users.destroy', 9001));
$response->assertRedirect(route('login'));
$this->assertFalse(\Illuminate\Support\Facades\Auth::check());
}
}
+7 -7
View File
@@ -28,7 +28,7 @@ class LoginNotificationTest extends TestCase
'name' => 'Test User',
'mail' => 'test@example.com',
'pass' => md5('password123'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_MEMBER'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 10,
@@ -87,7 +87,7 @@ class LoginNotificationTest extends TestCase
'name' => 'Inactive User',
'mail' => 'test@example.com',
'pass' => md5('password123'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_MEMBER'),
'status' => config('constants.STATUS_INACTIVE'), // 0
'card' => 10,
@@ -127,7 +127,7 @@ class LoginNotificationTest extends TestCase
'name' => 'Member User',
'mail' => 'member@example.com',
'pass' => md5('password123'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_MEMBER'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 10,
@@ -152,7 +152,7 @@ class LoginNotificationTest extends TestCase
'name' => 'Admin User',
'mail' => 'admin@example.com',
'pass' => md5('password123'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_ADMIN'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 10,
@@ -179,7 +179,7 @@ class LoginNotificationTest extends TestCase
'name' => 'First Login User',
'mail' => 'first@example.com',
'pass' => md5('password123'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_MEMBER'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 10,
@@ -204,7 +204,7 @@ class LoginNotificationTest extends TestCase
'name' => 'First Login Admin',
'mail' => 'first_admin@example.com',
'pass' => md5('password123'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_ADMIN'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 10,
@@ -232,7 +232,7 @@ class LoginNotificationTest extends TestCase
'name' => 'Lockout User',
'mail' => 'test@example.com',
'pass' => md5('password123'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_MEMBER'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 10,
+2 -2
View File
@@ -29,7 +29,7 @@ class PasswordMd5Test extends TestCase
'name' => 'Test User',
'mail' => 'test@example.com',
'pass' => md5('old_password'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_MEMBER'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 10,
@@ -51,7 +51,7 @@ class PasswordMd5Test extends TestCase
'msnv' => 4002,
'name' => 'Created User',
'mail' => 'created@example.com',
'departments' => 2,
'departments' => config('constants.DEPARTMENTS')[1],
'password' => 'admin_created_pass',
'role' => config('constants.ROLE_MEMBER'),
];
+1 -1
View File
@@ -21,7 +21,7 @@ class PasswordValidationTest extends TestCase
'name' => 'Test User',
'mail' => 'test@example.com',
'pass' => md5('password123'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_MEMBER'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 10,
+6 -3
View File
@@ -27,7 +27,7 @@ class SendThankCardTest extends TestCase
'name' => 'Sender User',
'mail' => 'sender@example.com',
'pass' => md5('password'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_MEMBER'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 10,
@@ -40,7 +40,7 @@ class SendThankCardTest extends TestCase
'name' => 'Receiver User',
'mail' => 'receiver@example.com',
'pass' => md5('password'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_MEMBER'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 0,
@@ -84,7 +84,10 @@ class SendThankCardTest extends TestCase
]);
$response->assertStatus(200);
$response->assertJson(['success' => true]);
$response->assertJson([
'success' => true,
'receiver_email' => 'receiver@example.com',
]);
$this->sender->refresh();
$this->assertEquals(8, $this->sender->card);
+8 -8
View File
@@ -16,7 +16,7 @@ class UserDashboardLayoutTest extends TestCase
'name' => 'System Admin',
'mail' => 'admin@runsystem.net',
'pass' => md5('password'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_ADMIN'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 10,
@@ -45,7 +45,7 @@ class UserDashboardLayoutTest extends TestCase
'name' => 'User A',
'mail' => 'usera@runsystem.net',
'pass' => md5('password'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_MEMBER'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 10,
@@ -58,7 +58,7 @@ class UserDashboardLayoutTest extends TestCase
'name' => 'User B',
'mail' => 'userb@runsystem.net',
'pass' => md5('password'),
'departments' => 2,
'departments' => config('constants.DEPARTMENTS')[1],
'role' => config('constants.ROLE_MEMBER'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 10,
@@ -100,7 +100,7 @@ class UserDashboardLayoutTest extends TestCase
'name' => 'User A',
'mail' => 'usera@runsystem.net',
'pass' => md5('password'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_MEMBER'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 10,
@@ -125,7 +125,7 @@ class UserDashboardLayoutTest extends TestCase
'name' => "User {$char}",
'mail' => "user{$char}@runsystem.net",
'pass' => md5('password'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_MEMBER'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 10,
@@ -162,7 +162,7 @@ class UserDashboardLayoutTest extends TestCase
'name' => 'Active User',
'mail' => 'active@runsystem.net',
'pass' => md5('password'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_MEMBER'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 10,
@@ -175,7 +175,7 @@ class UserDashboardLayoutTest extends TestCase
'name' => 'Inactive User',
'mail' => 'inactive@runsystem.net',
'pass' => md5('password'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_MEMBER'),
'status' => config('constants.STATUS_INACTIVE'),
'card' => 10,
@@ -217,7 +217,7 @@ class UserDashboardLayoutTest extends TestCase
'name' => 'User A',
'mail' => 'usera@runsystem.net',
'pass' => md5('password'),
'departments' => 1,
'departments' => config('constants.DEPARTMENTS')[0],
'role' => config('constants.ROLE_MEMBER'),
'status' => config('constants.STATUS_ACTIVE'),
'card' => 10,