feat(KAN-68): add visual Markdown ticket description editor
CI/CD / preconditions (pull_request) Successful in 1s
macOS checks / Native Rust tests and unsigned build (pull_request) Canceled after 0s
Native JavaScript checks / Native launcher and release tests (pull_request) Successful in 1m11s
CI/CD / test_and_check_app (pull_request) Successful in 5m58s
CI/CD / Publish immutable image (pull_request) Skipped
CI/CD / preconditions (pull_request) Successful in 1s
macOS checks / Native Rust tests and unsigned build (pull_request) Canceled after 0s
Native JavaScript checks / Native launcher and release tests (pull_request) Successful in 1m11s
CI/CD / test_and_check_app (pull_request) Successful in 5m58s
CI/CD / Publish immutable image (pull_request) Skipped
This commit is contained in:
@@ -0,0 +1,66 @@
|
||||
<?php
|
||||
|
||||
namespace Tests\Feature;
|
||||
|
||||
use App\Actions\ProjectTicketMetadata\InitializeProjectTicketMetadata;
|
||||
use App\Models\Project;
|
||||
use App\Models\User;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Inertia\Testing\AssertableInertia as Assert;
|
||||
use Symfony\Component\Process\Process;
|
||||
use Tests\TestCase;
|
||||
|
||||
class TicketDescriptionTest extends TestCase
|
||||
{
|
||||
use RefreshDatabase;
|
||||
|
||||
public function test_description_formatting_and_safe_rendering(): void
|
||||
{
|
||||
$process = new Process(['node', 'tests/Fixtures/ticket-description.mjs'], base_path());
|
||||
$process->setTimeout(60);
|
||||
$process->run();
|
||||
|
||||
$this->assertTrue($process->isSuccessful(), $process->getOutput().$process->getErrorOutput());
|
||||
$this->assertStringContainsString('Ticket description checks passed.', $process->getOutput());
|
||||
}
|
||||
|
||||
public function test_markdown_descriptions_can_be_created_read_updated_and_cleared(): void
|
||||
{
|
||||
$this->withoutVite();
|
||||
$user = User::factory()->create();
|
||||
$project = Project::factory()->create();
|
||||
app(InitializeProjectTicketMetadata::class)->handle($project);
|
||||
$this->syncProjectPermissions($project, $user, ['view', 'write']);
|
||||
$description = "## Plan\n\n**Bold** and *italic*\n\n- First\n- [Second](https://example.test)\n\n```php\necho '<tag>';\n```";
|
||||
$payload = [
|
||||
'title' => 'Formatted description',
|
||||
'description' => $description,
|
||||
'ticket_type_id' => $project->ticketTypes()->where('is_parent', false)->firstOrFail()->id,
|
||||
'ticket_priority_id' => $project->ticketPriorities()->firstOrFail()->id,
|
||||
'ticket_status_id' => $project->ticketStatuses()->whereNull('board_column_id')->firstOrFail()->id,
|
||||
];
|
||||
|
||||
$this->actingAs($user)->post(route('projects.tickets.store', $project), $payload)
|
||||
->assertSessionHasNoErrors()->assertRedirect();
|
||||
$ticket = $project->tickets()->sole();
|
||||
$this->assertSame($description, $ticket->description);
|
||||
$this->get(route('projects.tickets.show', [$project, $ticket]))
|
||||
->assertInertia(fn (Assert $page) => $page->where('ticket.description', $description));
|
||||
|
||||
$updated = "> Updated quote\n\n1. One\n2. Two\n\n`inline`";
|
||||
$this->patch(route('projects.tickets.update', [$project, $ticket]), [
|
||||
...$payload, 'description' => $updated, 'is_blocked' => false,
|
||||
])->assertSessionHasNoErrors()->assertRedirect();
|
||||
$this->assertSame($updated, $ticket->fresh()->description);
|
||||
|
||||
$this->patch(route('projects.tickets.update', [$project, $ticket]), [
|
||||
...$payload, 'description' => ['invalid'], 'is_blocked' => false,
|
||||
])->assertSessionHasErrors('description');
|
||||
$this->assertSame($updated, $ticket->fresh()->description);
|
||||
|
||||
$this->patch(route('projects.tickets.update', [$project, $ticket]), [
|
||||
...$payload, 'description' => '', 'is_blocked' => false,
|
||||
])->assertSessionHasNoErrors()->assertRedirect();
|
||||
$this->assertNull($ticket->fresh()->description);
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user