前端极简黑白重设计,并纳入客户端注册、站点设置与后台相关改动
- storefront 全站改为极简黑白配色:直角、细线分隔、卡片 hover 浅底、深色模式(跟随系统+手动切换) - 抽出 storefront/partials/card 复用卡片 - 一并提交此前暂存的客户端注册 API、站点设置、后台页面与测试 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,94 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Facades\Hash;
|
||||
use Tests\TestCase;
|
||||
|
||||
class WebAdminAccountPageTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_authenticated_admin_can_view_account_page(): void
|
||||
{
|
||||
$user = User::factory()->create([
|
||||
'name' => 'Security Admin',
|
||||
'email' => 'security@example.com',
|
||||
]);
|
||||
|
||||
$this->actingAs($user)
|
||||
->get('/admin/account')
|
||||
->assertOk()
|
||||
->assertSee('账户安全')
|
||||
->assertSee('Security Admin')
|
||||
->assertSee('security@example.com')
|
||||
->assertSee('修改密码');
|
||||
}
|
||||
|
||||
public function test_authenticated_admin_can_update_password(): void
|
||||
{
|
||||
$user = User::factory()->create([
|
||||
'email' => 'security@example.com',
|
||||
'password' => 'OldPassword123',
|
||||
]);
|
||||
|
||||
$this->actingAs($user)
|
||||
->put('/admin/account/password', [
|
||||
'current_password' => 'OldPassword123',
|
||||
'new_password' => 'NewPassword456',
|
||||
'new_password_confirmation' => 'NewPassword456',
|
||||
])
|
||||
->assertRedirect('/admin/account')
|
||||
->assertSessionHas('success', '密码已更新');
|
||||
|
||||
$user->refresh();
|
||||
|
||||
$this->assertTrue(Hash::check('NewPassword456', $user->password));
|
||||
$this->assertFalse(Hash::check('OldPassword123', $user->password));
|
||||
}
|
||||
|
||||
public function test_password_update_requires_correct_current_password(): void
|
||||
{
|
||||
$user = User::factory()->create([
|
||||
'password' => 'OldPassword123',
|
||||
]);
|
||||
|
||||
$this->actingAs($user)
|
||||
->from('/admin/account')
|
||||
->put('/admin/account/password', [
|
||||
'current_password' => 'WrongPassword999',
|
||||
'new_password' => 'NewPassword456',
|
||||
'new_password_confirmation' => 'NewPassword456',
|
||||
])
|
||||
->assertRedirect('/admin/account')
|
||||
->assertSessionHasErrors('current_password');
|
||||
|
||||
$user->refresh();
|
||||
|
||||
$this->assertTrue(Hash::check('OldPassword123', $user->password));
|
||||
$this->assertFalse(Hash::check('NewPassword456', $user->password));
|
||||
}
|
||||
|
||||
public function test_authenticated_admin_can_update_profile(): void
|
||||
{
|
||||
$user = User::factory()->create([
|
||||
'name' => 'Old Admin',
|
||||
'email' => 'old@example.com',
|
||||
]);
|
||||
|
||||
$this->actingAs($user)
|
||||
->put('/admin/account/profile', [
|
||||
'name' => 'New Admin',
|
||||
'email' => 'new@example.com',
|
||||
])
|
||||
->assertRedirect('/admin/account')
|
||||
->assertSessionHas('success', '账户资料已更新');
|
||||
|
||||
$user->refresh();
|
||||
|
||||
$this->assertSame('New Admin', $user->name);
|
||||
$this->assertSame('new@example.com', $user->email);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user