Add CMS module
Static content pages (CmsPage) manageable from a new Filament resource and readable via a public API endpoint. Wired into the admin panel with its own CmsPlugin and "CMS" navigation group.
This commit is contained in:
@@ -0,0 +1,37 @@
|
||||
<?php
|
||||
|
||||
use Modules\Cms\Models\CmsPage;
|
||||
|
||||
test('lists active cms pages', function () {
|
||||
$active = CmsPage::factory()->create(['is_active' => true]);
|
||||
CmsPage::factory()->create(['is_active' => false]);
|
||||
|
||||
$this->getJson('/api/v1/cms-pages')
|
||||
->assertSuccessful()
|
||||
->assertJsonCount(1, 'data')
|
||||
->assertJsonFragment(['id' => $active->id]);
|
||||
});
|
||||
|
||||
test('does not require authentication', function () {
|
||||
CmsPage::factory()->create(['is_active' => true]);
|
||||
|
||||
$this->getJson('/api/v1/cms-pages')->assertSuccessful();
|
||||
});
|
||||
|
||||
test('shows an active cms page by its page slug', function () {
|
||||
$page = CmsPage::factory()->create(['page' => 'miniapp_faq', 'is_active' => true]);
|
||||
|
||||
$this->getJson('/api/v1/cms-pages/miniapp_faq')
|
||||
->assertSuccessful()
|
||||
->assertJsonFragment(['id' => $page->id, 'page' => 'miniapp_faq']);
|
||||
});
|
||||
|
||||
test('returns not found for an inactive page', function () {
|
||||
CmsPage::factory()->create(['page' => 'miniapp_faq', 'is_active' => false]);
|
||||
|
||||
$this->getJson('/api/v1/cms-pages/miniapp_faq')->assertNotFound();
|
||||
});
|
||||
|
||||
test('returns not found for an unknown page slug', function () {
|
||||
$this->getJson('/api/v1/cms-pages/unknown-page')->assertNotFound();
|
||||
});
|
||||
Reference in New Issue
Block a user