новый дизайн
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Models\GameAccountUser;
|
||||
use App\Models\News;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Inertia\Testing\AssertableInertia as Assert;
|
||||
use Tests\TestCase;
|
||||
|
||||
class AdminNewsFeatureTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_admin_can_open_news_page_through_inertia(): void
|
||||
{
|
||||
News::query()->create([
|
||||
'title' => 'MoonWell Update',
|
||||
'body' => 'Подробности обновления.',
|
||||
'sort_order' => 5,
|
||||
'is_published' => true,
|
||||
'created_by_username' => 'ADMIN',
|
||||
]);
|
||||
|
||||
$this->actingAs($this->admin())
|
||||
->get(route('admin.news.index'))
|
||||
->assertOk()
|
||||
->assertInertia(fn (Assert $page) => $page
|
||||
->component('Admin/News', false)
|
||||
->where('newsItems.0.title', 'MoonWell Update')
|
||||
->where('newsItems.0.is_published', true)
|
||||
->where('newsStats.published', 1)
|
||||
->where('storeUrl', route('admin.news.store'))
|
||||
->etc()
|
||||
);
|
||||
}
|
||||
|
||||
public function test_regular_player_cannot_open_news_admin(): void
|
||||
{
|
||||
$this->actingAs($this->admin(0))
|
||||
->get(route('admin.news.index'))
|
||||
->assertForbidden();
|
||||
}
|
||||
|
||||
private function admin(int $gmLevel = 3): GameAccountUser
|
||||
{
|
||||
return new GameAccountUser(
|
||||
1,
|
||||
'ADMIN',
|
||||
'ADMIN@EXAMPLE.COM',
|
||||
'ADMIN@EXAMPLE.COM',
|
||||
$gmLevel,
|
||||
false,
|
||||
null,
|
||||
null,
|
||||
str_repeat('AA', 32),
|
||||
str_repeat('BB', 32),
|
||||
);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user