mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-28 17:01:16 +00:00
Fix content delete button
This commit is contained in:
@@ -49,7 +49,7 @@ PHPUnit only (no Pest). Create tests: `php artisan make:test --phpunit {name}`
|
||||
|
||||
- In-memory SQLite (`DB_CONNECTION=testing`)
|
||||
- App boot can hit `Settings::settingValue()` via `CategorizationPipeline` (`app/Providers/CategorizationServiceProvider.php` → `app/Services/Categorization/CategorizationPipeline.php`), even in focused controller tests
|
||||
- For isolated tests that bypass the normal app test DB setup, create a minimal `settings` table/rows first; `categorizeforeign` and `catwebdl` are the minimum keys needed for this bootstrap path
|
||||
- For isolated tests that bypass the normal app test DB setup, seed a minimal `settings` table before app bootstrap; `categorizeforeign` and `catwebdl` are the minimum keys needed for this path, and `tests/Feature/AdminContentControllerTest.php` shows the file-backed SQLite workaround when `php artisan test` would otherwise fail during startup
|
||||
- All HTTP mocked - no real API calls
|
||||
- Suites: `Install`, `Unit`, `Feature` (also `tests/Integration/` for live API tests, not in CI)
|
||||
- Use model factories; check for custom states first
|
||||
@@ -113,6 +113,7 @@ Blade + TailwindCSS v4 + Vite bundling. Run `npm run build` after changes.
|
||||
- **Alpine.js**: CSP-safe build with component architecture in `resources/js/alpine/`
|
||||
- Core components loaded eagerly in `alpine/index.js`
|
||||
- Page-specific components lazy-loaded via `alpine/lazy-loader.js`
|
||||
- Lazy-loaded pages must declare an `x-data` name that matches a key in `alpine/lazy-loader.js`, or the component JS will never load; example: `resources/views/admin/content/index.blade.php` uses `x-data="contentToggle"` so delete/toggle handlers from `resources/js/alpine/components/content-toggle.js` are available
|
||||
- Stores in `alpine/stores/`, components in `alpine/components/`
|
||||
- **CSS**: Main entry is `resources/css/app.css` (imports `csp-safe.css` for component styles)
|
||||
- **Vite entry points**: `resources/js/app.js`, `resources/css/app.css`, plus forum assets
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
@extends('layouts.admin')
|
||||
|
||||
@section('content')
|
||||
<div class="space-y-6">
|
||||
<div class="space-y-6" x-data="contentToggle">
|
||||
<x-admin.card>
|
||||
<x-admin.page-header :title="$title" icon="fas fa-file-alt">
|
||||
<x-slot:actions>
|
||||
@@ -90,6 +90,7 @@
|
||||
class="content-toggle-status text-{{ $item->status == 1 ? 'green' : 'gray' }}-600 dark:text-{{ $item->status == 1 ? 'green' : 'gray' }}-400 hover:text-{{ $item->status == 1 ? 'green' : 'gray' }}-900 dark:hover:text-{{ $item->status == 1 ? 'green' : 'gray' }}-300"
|
||||
data-content-id="{{ $item->id }}"
|
||||
data-current-status="{{ $item->status }}"
|
||||
x-on:click.prevent="toggleStatus({{ $item->id }}, {{ $item->status }}, $el)"
|
||||
title="{{ $item->status == 1 ? 'Disable' : 'Enable' }}">
|
||||
<i class="fas fa-toggle-{{ $item->status == 1 ? 'on' : 'off' }}"></i>
|
||||
</button>
|
||||
@@ -97,6 +98,7 @@
|
||||
class="content-delete text-red-600 dark:text-red-400 hover:text-red-900 dark:hover:text-red-300"
|
||||
data-content-id="{{ $item->id }}"
|
||||
data-content-title="{{ filled($item->title) ? $item->title : 'Untitled' }}"
|
||||
x-on:click.prevent="deleteContent({{ $item->id }}, @js(filled($item->title) ? $item->title : 'Untitled'), $el)"
|
||||
title="Delete">
|
||||
<i class="fas fa-trash"></i>
|
||||
</button>
|
||||
|
||||
@@ -197,6 +197,39 @@ class AdminContentControllerTest extends TestCase
|
||||
|
||||
$response->assertOk();
|
||||
$response->assertSee('Untitled');
|
||||
$response->assertSee('x-data="contentToggle"', false);
|
||||
$response->assertSee('x-on:click.prevent="deleteContent(', false);
|
||||
}
|
||||
|
||||
public function test_admin_can_delete_content_via_ajax(): void
|
||||
{
|
||||
$admin = $this->createUserWithRole('Admin');
|
||||
/** @var Authenticatable $authenticatedAdmin */
|
||||
$authenticatedAdmin = $admin;
|
||||
|
||||
$content = Content::query()->create([
|
||||
'title' => 'Delete Me',
|
||||
'url' => '/delete-me/',
|
||||
'body' => '<p>Delete me</p>',
|
||||
'metadescription' => 'Delete me description',
|
||||
'metakeywords' => 'delete',
|
||||
'contenttype' => Content::TYPE_USEFUL,
|
||||
'status' => Content::STATUS_ENABLED,
|
||||
'ordinal' => 3,
|
||||
'role' => Content::ROLE_EVERYONE,
|
||||
'created_at' => now(),
|
||||
'updated_at' => now(),
|
||||
]);
|
||||
|
||||
$response = $this->actingAs($authenticatedAdmin)
|
||||
->postJson(route('admin.content-delete'), ['id' => $content->id]);
|
||||
|
||||
$response->assertOk();
|
||||
$response->assertJson([
|
||||
'success' => true,
|
||||
'message' => 'Content deleted successfully',
|
||||
]);
|
||||
$this->assertDatabaseMissing('content', ['id' => $content->id]);
|
||||
}
|
||||
|
||||
private function createSchema(): void
|
||||
|
||||
Reference in New Issue
Block a user