Merge pull request 'feat(tickets): suivi bidirectionnel des tickets utilisateur via Gitea' (#7) from feat/ci-cd-securisation-infcdaal3 into main
Reviewed-on: #7
This commit was merged in pull request #7.
This commit is contained in:
+1
-1
@@ -7,7 +7,7 @@ et le versionnage suit [SemVer](https://semver.org/lang/fr/).
|
|||||||
## [Non publié]
|
## [Non publié]
|
||||||
|
|
||||||
### Ajouté
|
### Ajouté
|
||||||
- Formulaire de suggestions/signalements (utilisateur connecté) créant un ticket dans Gitea via son API.
|
- Système de tickets connecté à Gitea : création, suivi de l'avancement (état, jalon, labels), fil de discussion et réponses depuis l'interface web.
|
||||||
- Pipeline d'intégration continue Gitea Actions (tests, Pint, audit de sécurité).
|
- Pipeline d'intégration continue Gitea Actions (tests, Pint, audit de sécurité).
|
||||||
- Pipeline de déploiement continu (build image → registre Gitea → webhook Portainer).
|
- Pipeline de déploiement continu (build image → registre Gitea → webhook Portainer).
|
||||||
- Middleware `SecurityHeaders` (HSTS, CSP, X-Frame-Options, etc.).
|
- Middleware `SecurityHeaders` (HSTS, CSP, X-Frame-Options, etc.).
|
||||||
|
|||||||
@@ -1,59 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace App\Http\Controllers\Web;
|
|
||||||
|
|
||||||
use App\Http\Controllers\Controller;
|
|
||||||
use App\Models\User;
|
|
||||||
use App\Services\GiteaIssueService;
|
|
||||||
use Illuminate\Http\Request;
|
|
||||||
use Illuminate\Support\Facades\Auth;
|
|
||||||
use Illuminate\Validation\Rule;
|
|
||||||
|
|
||||||
class SuggestionController extends Controller
|
|
||||||
{
|
|
||||||
// Afficher le formulaire de suggestion / signalement
|
|
||||||
public function create()
|
|
||||||
{
|
|
||||||
return view('suggestions.create');
|
|
||||||
}
|
|
||||||
|
|
||||||
// Traiter la demande et créer un ticket dans Gitea
|
|
||||||
public function store(Request $request, GiteaIssueService $gitea)
|
|
||||||
{
|
|
||||||
$data = $request->validate([
|
|
||||||
'type' => ['required', Rule::in(['Modification', 'Ajout', 'Correction'])],
|
|
||||||
'titre' => ['required', 'string', 'min:5', 'max:120'],
|
|
||||||
'description' => ['required', 'string', 'min:10', 'max:5000'],
|
|
||||||
], [
|
|
||||||
'type.required' => 'Veuillez choisir un type de demande.',
|
|
||||||
'type.in' => 'Type de demande invalide.',
|
|
||||||
'titre.required' => 'Le titre est requis.',
|
|
||||||
'titre.min' => 'Le titre doit contenir au moins 5 caractères.',
|
|
||||||
'titre.max' => 'Le titre ne peut pas dépasser 120 caractères.',
|
|
||||||
'description.required' => 'La description est requise.',
|
|
||||||
'description.min' => 'Merci de détailler un peu plus votre demande (10 caractères minimum).',
|
|
||||||
]);
|
|
||||||
|
|
||||||
/** @var User $user */
|
|
||||||
$user = Auth::user();
|
|
||||||
$auteur = $user->name ?? 'Utilisateur';
|
|
||||||
|
|
||||||
$title = "[{$data['type']}] {$data['titre']}";
|
|
||||||
|
|
||||||
$body = "**Type de demande :** {$data['type']}\n"
|
|
||||||
."**Proposé par :** {$auteur} (via le site CESIZen)\n\n"
|
|
||||||
."### Description\n"
|
|
||||||
.$data['description']."\n\n"
|
|
||||||
."---\n"
|
|
||||||
.'_Ticket créé automatiquement depuis le formulaire de suggestions du site CESIZen._';
|
|
||||||
|
|
||||||
if ($gitea->createIssue($title, $body)) {
|
|
||||||
return redirect()->route('suggestions.create')
|
|
||||||
->with('success', 'Merci ! Votre demande a bien été transmise à l\'équipe.');
|
|
||||||
}
|
|
||||||
|
|
||||||
return back()->withInput()->withErrors([
|
|
||||||
'gitea' => "L'envoi de votre demande a échoué. Merci de réessayer plus tard.",
|
|
||||||
]);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,131 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Http\Controllers\Web;
|
||||||
|
|
||||||
|
use App\Http\Controllers\Controller;
|
||||||
|
use App\Models\Ticket;
|
||||||
|
use App\Models\User;
|
||||||
|
use App\Services\GiteaIssueService;
|
||||||
|
use Illuminate\Http\Request;
|
||||||
|
use Illuminate\Support\Facades\Auth;
|
||||||
|
use Illuminate\Validation\Rule;
|
||||||
|
|
||||||
|
class TicketController extends Controller
|
||||||
|
{
|
||||||
|
public function __construct(private GiteaIssueService $gitea) {}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Liste des tickets de l'utilisateur, avec leur état courant récupéré
|
||||||
|
* depuis Gitea (ouvert / résolu, jalon).
|
||||||
|
*/
|
||||||
|
public function index()
|
||||||
|
{
|
||||||
|
/** @var User $user */
|
||||||
|
$user = Auth::user();
|
||||||
|
|
||||||
|
$tickets = $user->tickets()->latest()->get()->map(function (Ticket $ticket) {
|
||||||
|
$issue = $this->gitea->getIssue($ticket->gitea_number);
|
||||||
|
$ticket->setAttribute('state', $issue['state'] ?? null);
|
||||||
|
$ticket->setAttribute('milestone', $issue['milestone']['title'] ?? null);
|
||||||
|
|
||||||
|
return $ticket;
|
||||||
|
});
|
||||||
|
|
||||||
|
return view('tickets.index', compact('tickets'));
|
||||||
|
}
|
||||||
|
|
||||||
|
// Formulaire de création
|
||||||
|
public function create()
|
||||||
|
{
|
||||||
|
return view('tickets.create');
|
||||||
|
}
|
||||||
|
|
||||||
|
// Création d'un ticket -> issue Gitea + enregistrement local
|
||||||
|
public function store(Request $request)
|
||||||
|
{
|
||||||
|
$data = $request->validate([
|
||||||
|
'type' => ['required', Rule::in(['Modification', 'Ajout', 'Correction'])],
|
||||||
|
'titre' => ['required', 'string', 'min:5', 'max:120'],
|
||||||
|
'description' => ['required', 'string', 'min:10', 'max:5000'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
/** @var User $user */
|
||||||
|
$user = Auth::user();
|
||||||
|
$auteur = $user->name ?? 'Utilisateur';
|
||||||
|
|
||||||
|
$title = "[{$data['type']}] {$data['titre']}";
|
||||||
|
$body = "**Type de demande :** {$data['type']}\n"
|
||||||
|
."**Proposé par :** {$auteur} (via le site CESIZen)\n\n"
|
||||||
|
."### Description\n"
|
||||||
|
.$data['description']."\n\n"
|
||||||
|
."---\n"
|
||||||
|
.'_Ticket créé automatiquement depuis CESIZen._';
|
||||||
|
|
||||||
|
$issue = $this->gitea->createIssue($title, $body);
|
||||||
|
|
||||||
|
if (! $issue || ! isset($issue['number'])) {
|
||||||
|
return back()->withInput()->withErrors([
|
||||||
|
'gitea' => "L'envoi de votre demande a échoué. Merci de réessayer plus tard.",
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
// On mémorise le lien utilisateur <-> issue pour le suivi.
|
||||||
|
$user->tickets()->create([
|
||||||
|
'gitea_number' => (int) $issue['number'],
|
||||||
|
'title' => $data['titre'],
|
||||||
|
'type' => $data['type'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
return redirect()->route('tickets.show', $issue['number'])
|
||||||
|
->with('success', 'Votre demande a bien été transmise à l\'équipe.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Détail d'un ticket : état, jalon, labels et fil de discussion.
|
||||||
|
*/
|
||||||
|
public function show(int $number)
|
||||||
|
{
|
||||||
|
$ticket = $this->findOwnedTicket($number);
|
||||||
|
|
||||||
|
$issue = $this->gitea->getIssue($number);
|
||||||
|
$comments = $this->gitea->getComments($number);
|
||||||
|
|
||||||
|
return view('tickets.show', compact('ticket', 'issue', 'comments'));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Réponse de l'utilisateur : ajoute un commentaire sur l'issue Gitea.
|
||||||
|
*/
|
||||||
|
public function reply(Request $request, int $number)
|
||||||
|
{
|
||||||
|
$this->findOwnedTicket($number);
|
||||||
|
|
||||||
|
$data = $request->validate([
|
||||||
|
'message' => ['required', 'string', 'min:2', 'max:5000'],
|
||||||
|
]);
|
||||||
|
|
||||||
|
/** @var User $user */
|
||||||
|
$user = Auth::user();
|
||||||
|
$auteur = $user->name ?? 'Utilisateur';
|
||||||
|
$body = "**{$auteur}** (via CESIZen) :\n\n".$data['message'];
|
||||||
|
|
||||||
|
if (! $this->gitea->addComment($number, $body)) {
|
||||||
|
return back()->withErrors(['gitea' => "L'envoi de votre réponse a échoué."]);
|
||||||
|
}
|
||||||
|
|
||||||
|
return redirect()->route('tickets.show', $number)
|
||||||
|
->with('success', 'Votre réponse a été ajoutée au ticket.');
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Récupère le ticket s'il appartient bien à l'utilisateur connecté,
|
||||||
|
* sinon renvoie une 404 (empêche de consulter les tickets d'autrui).
|
||||||
|
*/
|
||||||
|
private function findOwnedTicket(int $number): Ticket
|
||||||
|
{
|
||||||
|
/** @var User $user */
|
||||||
|
$user = Auth::user();
|
||||||
|
|
||||||
|
return $user->tickets()->where('gitea_number', $number)->firstOrFail();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,28 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace App\Models;
|
||||||
|
|
||||||
|
use Illuminate\Database\Eloquent\Model;
|
||||||
|
use Illuminate\Database\Eloquent\Relations\BelongsTo;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @property int $id
|
||||||
|
* @property int $user_id
|
||||||
|
* @property int $gitea_number
|
||||||
|
* @property string $title
|
||||||
|
* @property string $type
|
||||||
|
*/
|
||||||
|
class Ticket extends Model
|
||||||
|
{
|
||||||
|
protected $fillable = [
|
||||||
|
'user_id',
|
||||||
|
'gitea_number',
|
||||||
|
'title',
|
||||||
|
'type',
|
||||||
|
];
|
||||||
|
|
||||||
|
public function user(): BelongsTo
|
||||||
|
{
|
||||||
|
return $this->belongsTo(User::class);
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -52,6 +52,14 @@ class User extends Authenticatable implements FilamentUser
|
|||||||
return $this->hasMany(EmotionRecord::class, 'user_id');
|
return $this->hasMany(EmotionRecord::class, 'user_id');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @return HasMany<Ticket, $this>
|
||||||
|
*/
|
||||||
|
public function tickets(): HasMany
|
||||||
|
{
|
||||||
|
return $this->hasMany(Ticket::class);
|
||||||
|
}
|
||||||
|
|
||||||
public function favoritedActivities(): BelongsToMany
|
public function favoritedActivities(): BelongsToMany
|
||||||
{
|
{
|
||||||
return $this->belongsToMany(RelaxationActivity::class, 'favorites', 'id_user', 'id_activite');
|
return $this->belongsToMany(RelaxationActivity::class, 'favorites', 'id_user', 'id_activite');
|
||||||
|
|||||||
@@ -2,52 +2,132 @@
|
|||||||
|
|
||||||
namespace App\Services;
|
namespace App\Services;
|
||||||
|
|
||||||
|
use Illuminate\Http\Client\PendingRequest;
|
||||||
use Illuminate\Support\Facades\Http;
|
use Illuminate\Support\Facades\Http;
|
||||||
use Illuminate\Support\Facades\Log;
|
use Illuminate\Support\Facades\Log;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Petit client de l'API Gitea (issues) utilisé par le système de tickets :
|
||||||
|
* création, consultation, commentaires.
|
||||||
|
*/
|
||||||
class GiteaIssueService
|
class GiteaIssueService
|
||||||
{
|
{
|
||||||
/**
|
/**
|
||||||
* Crée un ticket (issue) dans le dépôt Gitea configuré.
|
* Prépare un client HTTP authentifié, ou null si Gitea n'est pas configuré.
|
||||||
*
|
|
||||||
* @return bool true si le ticket a bien été créé, false sinon.
|
|
||||||
*/
|
*/
|
||||||
public function createIssue(string $title, string $body): bool
|
private function client(): ?PendingRequest
|
||||||
{
|
{
|
||||||
$url = rtrim((string) config('services.gitea.url'), '/');
|
$url = rtrim((string) config('services.gitea.url'), '/');
|
||||||
$repo = trim((string) config('services.gitea.repo'), '/');
|
$repo = trim((string) config('services.gitea.repo'), '/');
|
||||||
$token = (string) config('services.gitea.token');
|
$token = (string) config('services.gitea.token');
|
||||||
|
|
||||||
if ($url === '' || $repo === '' || $token === '') {
|
if ($url === '' || $repo === '' || $token === '') {
|
||||||
Log::warning('Gitea non configuré (URL / token / dépôt manquant) : ticket non créé.');
|
Log::warning('Gitea non configuré (URL / token / dépôt manquant).');
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Gitea attend l'en-tête "Authorization: token <TOKEN>".
|
||||||
|
return Http::withToken($token, 'token')
|
||||||
|
->acceptJson()
|
||||||
|
->timeout(10)
|
||||||
|
->baseUrl("{$url}/api/v1/repos/{$repo}");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Crée un ticket (issue). Retourne les données de l'issue créée
|
||||||
|
* (dont "number") ou null en cas d'échec.
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>|null
|
||||||
|
*/
|
||||||
|
public function createIssue(string $title, string $body): ?array
|
||||||
|
{
|
||||||
|
$client = $this->client();
|
||||||
|
if (! $client) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$response = $client->post('/issues', ['title' => $title, 'body' => $body]);
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
Log::error('Appel API Gitea impossible : '.$e->getMessage());
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
if ($response->failed()) {
|
||||||
|
Log::error('Création du ticket Gitea échouée', ['status' => $response->status()]);
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return (array) $response->json();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Récupère une issue (état, labels, jalon…).
|
||||||
|
*
|
||||||
|
* @return array<string, mixed>|null
|
||||||
|
*/
|
||||||
|
public function getIssue(int $number): ?array
|
||||||
|
{
|
||||||
|
$client = $this->client();
|
||||||
|
if (! $client) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$response = $client->get("/issues/{$number}");
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
Log::error('Lecture du ticket Gitea impossible : '.$e->getMessage());
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return $response->successful() ? (array) $response->json() : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Récupère les commentaires d'une issue (fil de discussion).
|
||||||
|
*
|
||||||
|
* @return array<int, mixed>
|
||||||
|
*/
|
||||||
|
public function getComments(int $number): array
|
||||||
|
{
|
||||||
|
$client = $this->client();
|
||||||
|
if (! $client) {
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
$response = $client->get("/issues/{$number}/comments");
|
||||||
|
} catch (\Throwable $e) {
|
||||||
|
Log::error('Lecture des commentaires Gitea impossible : '.$e->getMessage());
|
||||||
|
|
||||||
|
return [];
|
||||||
|
}
|
||||||
|
|
||||||
|
return $response->successful() ? (array) $response->json() : [];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Ajoute un commentaire (réponse) à une issue.
|
||||||
|
*/
|
||||||
|
public function addComment(int $number, string $body): bool
|
||||||
|
{
|
||||||
|
$client = $this->client();
|
||||||
|
if (! $client) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Gitea attend l'en-tête "Authorization: token <TOKEN>".
|
$response = $client->post("/issues/{$number}/comments", ['body' => $body]);
|
||||||
$response = Http::withToken($token, 'token')
|
|
||||||
->acceptJson()
|
|
||||||
->timeout(10)
|
|
||||||
->post("{$url}/api/v1/repos/{$repo}/issues", [
|
|
||||||
'title' => $title,
|
|
||||||
'body' => $body,
|
|
||||||
]);
|
|
||||||
} catch (\Throwable $e) {
|
} catch (\Throwable $e) {
|
||||||
Log::error('Appel API Gitea impossible : '.$e->getMessage());
|
Log::error('Ajout de commentaire Gitea impossible : '.$e->getMessage());
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($response->failed()) {
|
return $response->successful();
|
||||||
Log::error('Création du ticket Gitea échouée', [
|
|
||||||
'status' => $response->status(),
|
|
||||||
'body' => $response->body(),
|
|
||||||
]);
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -0,0 +1,32 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
use Illuminate\Database\Migrations\Migration;
|
||||||
|
use Illuminate\Database\Schema\Blueprint;
|
||||||
|
use Illuminate\Support\Facades\Schema;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Table de liaison entre un utilisateur CESIZen et le ticket (issue) qu'il a
|
||||||
|
* ouvert dans Gitea. Elle permet de retrouver « ses » tickets alors que
|
||||||
|
* l'application les crée toutes sous un même compte de service.
|
||||||
|
*/
|
||||||
|
return new class extends Migration
|
||||||
|
{
|
||||||
|
public function up(): void
|
||||||
|
{
|
||||||
|
Schema::create('tickets', function (Blueprint $table) {
|
||||||
|
$table->id();
|
||||||
|
$table->foreignId('user_id')->constrained()->cascadeOnDelete();
|
||||||
|
$table->unsignedInteger('gitea_number'); // numéro de l'issue Gitea
|
||||||
|
$table->string('title');
|
||||||
|
$table->string('type');
|
||||||
|
$table->timestamps();
|
||||||
|
|
||||||
|
$table->index(['user_id', 'gitea_number']);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
public function down(): void
|
||||||
|
{
|
||||||
|
Schema::dropIfExists('tickets');
|
||||||
|
}
|
||||||
|
};
|
||||||
@@ -50,15 +50,15 @@
|
|||||||
Guides & Informations
|
Guides & Informations
|
||||||
</a>
|
</a>
|
||||||
|
|
||||||
<!-- Signaler / Suggérer (utilisateur connecté → ticket Gitea) -->
|
<!-- Mes tickets (utilisateur connecté → suivi Gitea) -->
|
||||||
@auth
|
@auth
|
||||||
<a href="{{ route('suggestions.create') }}"
|
<a href="{{ route('tickets.index') }}"
|
||||||
class="flex items-center gap-4 px-4 py-3 rounded-sm transition-all group {{ request()->routeIs('suggestions.*') ? 'text-white bg-[#000091] font-bold shadow-md' : 'text-slate-700 hover:bg-slate-50 font-medium border-b border-slate-100/50' }}"
|
class="flex items-center gap-4 px-4 py-3 rounded-sm transition-all group {{ request()->routeIs('tickets.*') ? 'text-white bg-[#000091] font-bold shadow-md' : 'text-slate-700 hover:bg-slate-50 font-medium border-b border-slate-100/50' }}"
|
||||||
{!! request()->routeIs('suggestions.*') ? 'aria-current="page"' : '' !!}>
|
{!! request()->routeIs('tickets.*') ? 'aria-current="page"' : '' !!}>
|
||||||
<div class="w-8 h-8 rounded-sm flex items-center justify-center transition-colors {{ request()->routeIs('suggestions.*') ? 'bg-white/20 text-white' : 'bg-green-50 text-[--cz-jade]' }}" aria-hidden="true">
|
<div class="w-8 h-8 rounded-sm flex items-center justify-center transition-colors {{ request()->routeIs('tickets.*') ? 'bg-white/20 text-white' : 'bg-green-50 text-[--cz-jade]' }}" aria-hidden="true">
|
||||||
<x-heroicon-o-chat-bubble-left-right class="h-4 w-4" />
|
<x-heroicon-o-chat-bubble-left-right class="h-4 w-4" />
|
||||||
</div>
|
</div>
|
||||||
Signaler / Suggérer
|
Mes tickets
|
||||||
</a>
|
</a>
|
||||||
@endauth
|
@endauth
|
||||||
|
|
||||||
|
|||||||
+11
-33
@@ -1,27 +1,23 @@
|
|||||||
@extends('layouts.app')
|
@extends('layouts.app')
|
||||||
|
|
||||||
@section('title', 'Signaler / Proposer une amélioration')
|
@section('title', 'Nouvelle demande')
|
||||||
|
|
||||||
@section('content')
|
@section('content')
|
||||||
<div class="max-w-2xl mx-auto space-y-8">
|
<div class="max-w-2xl mx-auto space-y-8">
|
||||||
|
|
||||||
<!-- En-tête -->
|
<div class="flex items-center justify-between">
|
||||||
<div>
|
<div>
|
||||||
<h1 class="text-3xl font-bold text-[#161616] mb-2">Signaler ou proposer une amélioration</h1>
|
<h1 class="text-3xl font-bold text-[#161616] mb-2">Nouvelle demande</h1>
|
||||||
<p class="text-slate-600">
|
<p class="text-slate-600">
|
||||||
Une idée, une correction, un bug à signaler ? Votre demande est directement transmise à
|
Une idée, une correction, un bug ? Votre demande crée un ticket de suivi que
|
||||||
l'équipe sous forme de ticket de suivi. Merci de votre contribution !
|
vous pourrez consulter à tout moment.
|
||||||
</p>
|
</p>
|
||||||
</div>
|
</div>
|
||||||
|
<a href="{{ route('tickets.index') }}" class="shrink-0 text-sm font-bold text-[--fr-blue] hover:underline">
|
||||||
<!-- Message de succès -->
|
← Mes tickets
|
||||||
@if (session('success'))
|
</a>
|
||||||
<div class="p-4 bg-green-50 border border-green-200 rounded-lg">
|
|
||||||
<p class="text-green-700 font-semibold">✅ {{ session('success') }}</p>
|
|
||||||
</div>
|
</div>
|
||||||
@endif
|
|
||||||
|
|
||||||
<!-- Erreurs -->
|
|
||||||
@if ($errors->any())
|
@if ($errors->any())
|
||||||
<div class="p-4 bg-red-50 border border-red-200 rounded-lg space-y-1">
|
<div class="p-4 bg-red-50 border border-red-200 rounded-lg space-y-1">
|
||||||
@foreach ($errors->all() as $error)
|
@foreach ($errors->all() as $error)
|
||||||
@@ -31,10 +27,9 @@
|
|||||||
@endif
|
@endif
|
||||||
|
|
||||||
<div class="bg-white p-8 border border-slate-200 shadow-sm">
|
<div class="bg-white p-8 border border-slate-200 shadow-sm">
|
||||||
<form action="{{ route('suggestions.store') }}" method="POST" class="space-y-6">
|
<form action="{{ route('tickets.store') }}" method="POST" class="space-y-6">
|
||||||
@csrf
|
@csrf
|
||||||
|
|
||||||
<!-- Type de demande -->
|
|
||||||
<div>
|
<div>
|
||||||
<label for="type" class="block text-sm font-bold text-slate-700 mb-2">Type de demande</label>
|
<label for="type" class="block text-sm font-bold text-slate-700 mb-2">Type de demande</label>
|
||||||
<select id="type" name="type" required
|
<select id="type" name="type" required
|
||||||
@@ -44,50 +39,33 @@
|
|||||||
<option value="Ajout" @selected($typeChoisi === 'Ajout')>➕ Ajout d'un contenu / d'une fonctionnalité</option>
|
<option value="Ajout" @selected($typeChoisi === 'Ajout')>➕ Ajout d'un contenu / d'une fonctionnalité</option>
|
||||||
<option value="Correction" @selected($typeChoisi === 'Correction')>🐛 Correction d'une erreur / d'un bug</option>
|
<option value="Correction" @selected($typeChoisi === 'Correction')>🐛 Correction d'une erreur / d'un bug</option>
|
||||||
</select>
|
</select>
|
||||||
@error('type')
|
|
||||||
<p class="text-red-600 text-xs mt-1">{{ $message }}</p>
|
|
||||||
@enderror
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Titre -->
|
|
||||||
<div>
|
<div>
|
||||||
<label for="titre" class="block text-sm font-bold text-slate-700 mb-2">Titre</label>
|
<label for="titre" class="block text-sm font-bold text-slate-700 mb-2">Titre</label>
|
||||||
<input type="text" id="titre" name="titre" required minlength="5" maxlength="120"
|
<input type="text" id="titre" name="titre" required minlength="5" maxlength="120"
|
||||||
value="{{ old('titre') }}"
|
value="{{ old('titre') }}" placeholder="Résumez votre demande en une phrase"
|
||||||
placeholder="Résumez votre demande en une phrase"
|
|
||||||
class="w-full border-slate-200 rounded-lg focus:ring-[--fr-blue] focus:border-[--fr-blue] @error('titre') border-red-500 @enderror">
|
class="w-full border-slate-200 rounded-lg focus:ring-[--fr-blue] focus:border-[--fr-blue] @error('titre') border-red-500 @enderror">
|
||||||
@error('titre')
|
|
||||||
<p class="text-red-600 text-xs mt-1">{{ $message }}</p>
|
|
||||||
@enderror
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Description -->
|
|
||||||
<div>
|
<div>
|
||||||
<label for="description" class="block text-sm font-bold text-slate-700 mb-2">Description détaillée</label>
|
<label for="description" class="block text-sm font-bold text-slate-700 mb-2">Description détaillée</label>
|
||||||
<textarea id="description" name="description" required minlength="10" maxlength="5000" rows="8"
|
<textarea id="description" name="description" required minlength="10" maxlength="5000" rows="8"
|
||||||
placeholder="Décrivez précisément votre demande : quoi, où, pourquoi…"
|
placeholder="Décrivez précisément votre demande : quoi, où, pourquoi…"
|
||||||
class="w-full border-slate-200 rounded-lg focus:ring-[--fr-blue] focus:border-[--fr-blue] @error('description') border-red-500 @enderror">{{ old('description') }}</textarea>
|
class="w-full border-slate-200 rounded-lg focus:ring-[--fr-blue] focus:border-[--fr-blue] @error('description') border-red-500 @enderror">{{ old('description') }}</textarea>
|
||||||
@error('description')
|
|
||||||
<p class="text-red-600 text-xs mt-1">{{ $message }}</p>
|
|
||||||
@enderror
|
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<!-- Boutons -->
|
|
||||||
<div class="flex gap-4 pt-2">
|
<div class="flex gap-4 pt-2">
|
||||||
<button type="submit"
|
<button type="submit"
|
||||||
class="px-8 py-3 bg-[#000091] text-white font-bold rounded-sm hover:bg-blue-800 shadow-md transition-all uppercase tracking-widest">
|
class="px-8 py-3 bg-[#000091] text-white font-bold rounded-sm hover:bg-blue-800 shadow-md transition-all uppercase tracking-widest">
|
||||||
Envoyer ma demande
|
Envoyer ma demande
|
||||||
</button>
|
</button>
|
||||||
<a href="{{ route('home') }}"
|
<a href="{{ route('tickets.index') }}"
|
||||||
class="px-8 py-3 bg-slate-200 text-slate-900 font-bold rounded-sm hover:bg-slate-300 transition-all">
|
class="px-8 py-3 bg-slate-200 text-slate-900 font-bold rounded-sm hover:bg-slate-300 transition-all">
|
||||||
Annuler
|
Annuler
|
||||||
</a>
|
</a>
|
||||||
</div>
|
</div>
|
||||||
</form>
|
</form>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<p class="text-xs text-slate-500">
|
|
||||||
ℹ️ Votre demande sera examinée par l'équipe avant toute prise en compte. Merci de rester courtois et constructif.
|
|
||||||
</p>
|
|
||||||
</div>
|
</div>
|
||||||
@endsection
|
@endsection
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
@extends('layouts.app')
|
||||||
|
|
||||||
|
@section('title', 'Mes tickets')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="max-w-3xl mx-auto space-y-8">
|
||||||
|
|
||||||
|
<div class="flex items-center justify-between">
|
||||||
|
<h1 class="text-3xl font-bold text-[#161616]">Mes tickets</h1>
|
||||||
|
<a href="{{ route('tickets.create') }}"
|
||||||
|
class="px-5 py-2.5 bg-[#000091] text-white font-bold rounded-sm hover:bg-blue-800 shadow-md transition-all text-sm uppercase tracking-widest">
|
||||||
|
+ Nouvelle demande
|
||||||
|
</a>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if (session('success'))
|
||||||
|
<div class="p-4 bg-green-50 border border-green-200 rounded-lg">
|
||||||
|
<p class="text-green-700 font-semibold">✅ {{ session('success') }}</p>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@forelse ($tickets as $ticket)
|
||||||
|
<a href="{{ route('tickets.show', $ticket->gitea_number) }}"
|
||||||
|
class="block bg-white p-5 border border-slate-200 shadow-sm hover:border-[--fr-blue] transition-colors">
|
||||||
|
<div class="flex items-center justify-between gap-4">
|
||||||
|
<div class="min-w-0">
|
||||||
|
<p class="font-bold text-slate-900 truncate">{{ $ticket->title }}</p>
|
||||||
|
<p class="text-xs text-slate-500 mt-1">
|
||||||
|
#{{ $ticket->gitea_number }} · {{ $ticket->type }} · {{ $ticket->created_at->format('d/m/Y') }}
|
||||||
|
@if ($ticket->milestone)
|
||||||
|
· 🎯 {{ $ticket->milestone }}
|
||||||
|
@endif
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
@php($state = $ticket->state)
|
||||||
|
<span class="shrink-0 text-xs font-bold px-3 py-1 rounded-full
|
||||||
|
{{ $state === 'closed' ? 'bg-green-100 text-green-700' : ($state === 'open' ? 'bg-blue-100 text-blue-700' : 'bg-slate-100 text-slate-500') }}">
|
||||||
|
{{ $state === 'closed' ? 'Résolu' : ($state === 'open' ? 'En cours' : 'Inconnu') }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
</a>
|
||||||
|
@empty
|
||||||
|
<div class="bg-white p-8 border border-slate-200 shadow-sm text-center text-slate-500">
|
||||||
|
Vous n'avez pas encore de ticket.
|
||||||
|
<a href="{{ route('tickets.create') }}" class="text-[--fr-blue] font-bold hover:underline">Créer une demande</a>.
|
||||||
|
</div>
|
||||||
|
@endforelse
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
@@ -0,0 +1,90 @@
|
|||||||
|
@extends('layouts.app')
|
||||||
|
|
||||||
|
@section('title', 'Suivi du ticket')
|
||||||
|
|
||||||
|
@section('content')
|
||||||
|
<div class="max-w-3xl mx-auto space-y-6">
|
||||||
|
|
||||||
|
<a href="{{ route('tickets.index') }}" class="text-sm font-bold text-[--fr-blue] hover:underline">← Mes tickets</a>
|
||||||
|
|
||||||
|
@if (session('success'))
|
||||||
|
<div class="p-4 bg-green-50 border border-green-200 rounded-lg">
|
||||||
|
<p class="text-green-700 font-semibold">✅ {{ session('success') }}</p>
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
@if ($errors->any())
|
||||||
|
<div class="p-4 bg-red-50 border border-red-200 rounded-lg space-y-1">
|
||||||
|
@foreach ($errors->all() as $error)<p class="text-red-700 text-sm">{{ $error }}</p>@endforeach
|
||||||
|
</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@php($state = $issue['state'] ?? null)
|
||||||
|
|
||||||
|
<div class="bg-white p-6 border border-slate-200 shadow-sm space-y-4">
|
||||||
|
<div class="flex items-start justify-between gap-4">
|
||||||
|
<h1 class="text-2xl font-bold text-[#161616]">{{ $ticket->title }}</h1>
|
||||||
|
<span class="shrink-0 text-xs font-bold px-3 py-1 rounded-full
|
||||||
|
{{ $state === 'closed' ? 'bg-green-100 text-green-700' : ($state === 'open' ? 'bg-blue-100 text-blue-700' : 'bg-slate-100 text-slate-500') }}">
|
||||||
|
{{ $state === 'closed' ? 'Résolu' : ($state === 'open' ? 'En cours' : 'Inconnu') }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<div class="flex flex-wrap items-center gap-2 text-xs">
|
||||||
|
<span class="text-slate-500">#{{ $ticket->gitea_number }} · {{ $ticket->type }}</span>
|
||||||
|
@if (!empty($issue['milestone']['title']))
|
||||||
|
<span class="font-bold px-2 py-0.5 rounded bg-purple-100 text-purple-700">🎯 {{ $issue['milestone']['title'] }}</span>
|
||||||
|
@endif
|
||||||
|
@foreach ($issue['labels'] ?? [] as $label)
|
||||||
|
<span class="font-bold px-2 py-0.5 rounded bg-slate-100 text-slate-700">{{ $label['name'] }}</span>
|
||||||
|
@endforeach
|
||||||
|
</div>
|
||||||
|
|
||||||
|
@if (!empty($issue['body']))
|
||||||
|
<div class="text-sm text-slate-700 whitespace-pre-line bg-slate-50 border border-slate-100 rounded p-4">{{ $issue['body'] }}</div>
|
||||||
|
@endif
|
||||||
|
|
||||||
|
@unless ($issue)
|
||||||
|
<p class="text-sm text-amber-700 bg-amber-50 border border-amber-200 rounded p-3">
|
||||||
|
Impossible de récupérer l'état du ticket pour le moment. Réessayez plus tard.
|
||||||
|
</p>
|
||||||
|
@endunless
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Fil de discussion -->
|
||||||
|
<div class="space-y-3">
|
||||||
|
<h2 class="text-lg font-bold text-slate-800">Échanges</h2>
|
||||||
|
|
||||||
|
@forelse ($comments as $comment)
|
||||||
|
<div class="bg-white p-4 border border-slate-200 shadow-sm">
|
||||||
|
<div class="flex items-center justify-between mb-2">
|
||||||
|
<span class="text-sm font-bold text-slate-800">{{ $comment['user']['login'] ?? 'Équipe' }}</span>
|
||||||
|
<span class="text-xs text-slate-400">
|
||||||
|
{{ \Illuminate\Support\Carbon::parse($comment['created_at'])->format('d/m/Y H:i') }}
|
||||||
|
</span>
|
||||||
|
</div>
|
||||||
|
<div class="text-sm text-slate-700 whitespace-pre-line">{{ $comment['body'] }}</div>
|
||||||
|
</div>
|
||||||
|
@empty
|
||||||
|
<p class="text-sm text-slate-500">Aucune réponse pour le moment.</p>
|
||||||
|
@endforelse
|
||||||
|
</div>
|
||||||
|
|
||||||
|
<!-- Répondre -->
|
||||||
|
@if ($state !== 'closed')
|
||||||
|
<form action="{{ route('tickets.reply', $ticket->gitea_number) }}" method="POST"
|
||||||
|
class="bg-white p-4 border border-slate-200 shadow-sm space-y-3">
|
||||||
|
@csrf
|
||||||
|
<label for="message" class="block text-sm font-bold text-slate-700">Répondre</label>
|
||||||
|
<textarea id="message" name="message" required minlength="2" maxlength="5000" rows="4"
|
||||||
|
placeholder="Ajouter une précision, une réponse…"
|
||||||
|
class="w-full border-slate-200 rounded-lg focus:ring-[--fr-blue] focus:border-[--fr-blue]">{{ old('message') }}</textarea>
|
||||||
|
<button type="submit"
|
||||||
|
class="px-6 py-2.5 bg-[#000091] text-white font-bold rounded-sm hover:bg-blue-800 shadow-md transition-all text-sm uppercase tracking-widest">
|
||||||
|
Envoyer
|
||||||
|
</button>
|
||||||
|
</form>
|
||||||
|
@else
|
||||||
|
<p class="text-sm text-slate-500 italic">Ce ticket est clôturé — il n'est plus possible d'y répondre.</p>
|
||||||
|
@endif
|
||||||
|
</div>
|
||||||
|
@endsection
|
||||||
+7
-4
@@ -7,7 +7,7 @@ use App\Http\Controllers\Web\EmotionController;
|
|||||||
use App\Http\Controllers\Web\InformationController;
|
use App\Http\Controllers\Web\InformationController;
|
||||||
use App\Http\Controllers\Web\ProfileController;
|
use App\Http\Controllers\Web\ProfileController;
|
||||||
use App\Http\Controllers\Web\RelaxationController;
|
use App\Http\Controllers\Web\RelaxationController;
|
||||||
use App\Http\Controllers\Web\SuggestionController;
|
use App\Http\Controllers\Web\TicketController;
|
||||||
use Illuminate\Support\Facades\Route;
|
use Illuminate\Support\Facades\Route;
|
||||||
|
|
||||||
// Public Routes
|
// Public Routes
|
||||||
@@ -43,7 +43,10 @@ Route::middleware('auth')->group(function () {
|
|||||||
// Pages Relaxation
|
// Pages Relaxation
|
||||||
Route::post('/relaxation/{id}/favorite', [RelaxationController::class, 'toggleFavorite'])->name('relaxation.favorite');
|
Route::post('/relaxation/{id}/favorite', [RelaxationController::class, 'toggleFavorite'])->name('relaxation.favorite');
|
||||||
|
|
||||||
// Suggestions / signalements (créent un ticket dans Gitea)
|
// Système de tickets (connecté à Gitea) : création, suivi, réponses
|
||||||
Route::get('/suggestions/nouveau', [SuggestionController::class, 'create'])->name('suggestions.create');
|
Route::get('/tickets', [TicketController::class, 'index'])->name('tickets.index');
|
||||||
Route::post('/suggestions', [SuggestionController::class, 'store'])->name('suggestions.store');
|
Route::get('/tickets/nouveau', [TicketController::class, 'create'])->name('tickets.create');
|
||||||
|
Route::post('/tickets', [TicketController::class, 'store'])->name('tickets.store');
|
||||||
|
Route::get('/tickets/{number}', [TicketController::class, 'show'])->whereNumber('number')->name('tickets.show');
|
||||||
|
Route::post('/tickets/{number}/reponse', [TicketController::class, 'reply'])->whereNumber('number')->name('tickets.reply');
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -1,63 +0,0 @@
|
|||||||
<?php
|
|
||||||
|
|
||||||
namespace Tests\Feature;
|
|
||||||
|
|
||||||
use App\Models\User;
|
|
||||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
|
||||||
use Illuminate\Support\Facades\Http;
|
|
||||||
use PHPUnit\Framework\Attributes\Test;
|
|
||||||
use Tests\TestCase;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Système de tickets utilisateur : le formulaire de suggestions crée une
|
|
||||||
* issue dans Gitea via son API.
|
|
||||||
*/
|
|
||||||
class SuggestionTest extends TestCase
|
|
||||||
{
|
|
||||||
use RefreshDatabase;
|
|
||||||
|
|
||||||
#[Test]
|
|
||||||
public function un_invite_est_redirige_vers_login()
|
|
||||||
{
|
|
||||||
$this->get('/suggestions/nouveau')->assertRedirect('/login');
|
|
||||||
}
|
|
||||||
|
|
||||||
#[Test]
|
|
||||||
public function un_utilisateur_connecte_voit_le_formulaire()
|
|
||||||
{
|
|
||||||
$this->actingAs(User::factory()->create())
|
|
||||||
->get('/suggestions/nouveau')
|
|
||||||
->assertOk()
|
|
||||||
->assertSee('Signaler');
|
|
||||||
}
|
|
||||||
|
|
||||||
#[Test]
|
|
||||||
public function une_demande_valide_cree_un_ticket_gitea()
|
|
||||||
{
|
|
||||||
config([
|
|
||||||
'services.gitea.url' => 'https://gitea.test',
|
|
||||||
'services.gitea.token' => 'fake-token',
|
|
||||||
'services.gitea.repo' => 'sam/cesizen',
|
|
||||||
]);
|
|
||||||
Http::fake(['*' => Http::response(['number' => 1], 201)]);
|
|
||||||
|
|
||||||
$this->actingAs(User::factory()->create())
|
|
||||||
->post('/suggestions', [
|
|
||||||
'type' => 'Correction',
|
|
||||||
'titre' => 'Un bug sur la page',
|
|
||||||
'description' => 'Description suffisamment longue du problème rencontré.',
|
|
||||||
])
|
|
||||||
->assertRedirect(route('suggestions.create'))
|
|
||||||
->assertSessionHas('success');
|
|
||||||
|
|
||||||
Http::assertSent(fn ($request) => str_contains($request->url(), '/api/v1/repos/sam/cesizen/issues'));
|
|
||||||
}
|
|
||||||
|
|
||||||
#[Test]
|
|
||||||
public function une_demande_invalide_est_rejetee()
|
|
||||||
{
|
|
||||||
$this->actingAs(User::factory()->create())
|
|
||||||
->post('/suggestions', ['type' => 'Invalide', 'titre' => 'a', 'description' => 'b'])
|
|
||||||
->assertSessionHasErrors(['type', 'titre', 'description']);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
<?php
|
||||||
|
|
||||||
|
namespace Tests\Feature;
|
||||||
|
|
||||||
|
use App\Models\Ticket;
|
||||||
|
use App\Models\User;
|
||||||
|
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||||
|
use Illuminate\Support\Facades\Http;
|
||||||
|
use PHPUnit\Framework\Attributes\Test;
|
||||||
|
use Tests\TestCase;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Système de tickets utilisateur connecté à Gitea :
|
||||||
|
* création (issue), suivi (état + commentaires) et réponse.
|
||||||
|
*/
|
||||||
|
class TicketTest extends TestCase
|
||||||
|
{
|
||||||
|
use RefreshDatabase;
|
||||||
|
|
||||||
|
protected function setUp(): void
|
||||||
|
{
|
||||||
|
parent::setUp();
|
||||||
|
config([
|
||||||
|
'services.gitea.url' => 'https://gitea.test',
|
||||||
|
'services.gitea.token' => 'fake-token',
|
||||||
|
'services.gitea.repo' => 'sam/cesizen',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Test]
|
||||||
|
public function un_invite_ne_peut_pas_acceder_aux_tickets()
|
||||||
|
{
|
||||||
|
$this->get('/tickets')->assertRedirect('/login');
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Test]
|
||||||
|
public function creer_un_ticket_cree_une_issue_et_un_enregistrement_local()
|
||||||
|
{
|
||||||
|
Http::fake([
|
||||||
|
'*/issues' => Http::response(['number' => 42], 201),
|
||||||
|
]);
|
||||||
|
$user = User::factory()->create();
|
||||||
|
|
||||||
|
$this->actingAs($user)->post('/tickets', [
|
||||||
|
'type' => 'Correction',
|
||||||
|
'titre' => 'Un bug à corriger',
|
||||||
|
'description' => 'Description suffisamment longue du problème.',
|
||||||
|
])->assertRedirect(route('tickets.show', 42));
|
||||||
|
|
||||||
|
$this->assertDatabaseHas('tickets', [
|
||||||
|
'user_id' => $user->id,
|
||||||
|
'gitea_number' => 42,
|
||||||
|
'type' => 'Correction',
|
||||||
|
]);
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Test]
|
||||||
|
public function l_utilisateur_voit_le_suivi_de_son_ticket()
|
||||||
|
{
|
||||||
|
Http::fake([
|
||||||
|
'*/issues/42/comments' => Http::response([
|
||||||
|
['body' => 'Nous regardons cela.', 'user' => ['login' => 'admin'], 'created_at' => '2026-07-08T10:00:00Z'],
|
||||||
|
], 200),
|
||||||
|
'*/issues/42' => Http::response(['number' => 42, 'state' => 'open', 'title' => 'Un bug', 'body' => 'détail'], 200),
|
||||||
|
]);
|
||||||
|
$user = User::factory()->create();
|
||||||
|
Ticket::create(['user_id' => $user->id, 'gitea_number' => 42, 'title' => 'Un bug', 'type' => 'Correction']);
|
||||||
|
|
||||||
|
$this->actingAs($user)->get('/tickets/42')
|
||||||
|
->assertOk()
|
||||||
|
->assertSee('Nous regardons cela.')
|
||||||
|
->assertSee('En cours');
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Test]
|
||||||
|
public function on_ne_peut_pas_consulter_le_ticket_d_un_autre()
|
||||||
|
{
|
||||||
|
$autre = User::factory()->create();
|
||||||
|
Ticket::create(['user_id' => $autre->id, 'gitea_number' => 99, 'title' => 'Privé', 'type' => 'Ajout']);
|
||||||
|
|
||||||
|
$this->actingAs(User::factory()->create())->get('/tickets/99')->assertNotFound();
|
||||||
|
}
|
||||||
|
|
||||||
|
#[Test]
|
||||||
|
public function l_utilisateur_peut_repondre_a_son_ticket()
|
||||||
|
{
|
||||||
|
Http::fake(['*/issues/42/comments' => Http::response(['id' => 1], 201)]);
|
||||||
|
$user = User::factory()->create();
|
||||||
|
Ticket::create(['user_id' => $user->id, 'gitea_number' => 42, 'title' => 'Un bug', 'type' => 'Correction']);
|
||||||
|
|
||||||
|
$this->actingAs($user)->post('/tickets/42/reponse', ['message' => 'Merci pour le suivi !'])
|
||||||
|
->assertRedirect(route('tickets.show', 42))
|
||||||
|
->assertSessionHas('success');
|
||||||
|
|
||||||
|
Http::assertSent(fn ($r) => str_contains($r->url(), '/issues/42/comments') && $r->method() === 'POST');
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user