Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions src/Filament/Resources/Products/Schemas/ProductForm.php
Original file line number Diff line number Diff line change
Expand Up @@ -298,6 +298,9 @@

RichEditor::make('description')
->label(__('Description'))
// What is stored, not the sanitised read: the sanitiser cuts input
// at 500,000 bytes, and saving any field would write the cut copy back.
->formatStateUsing(fn (?Product $record, mixed $state): mixed => $record?->getRawOriginal('description') ?? $state)

Check warning on line 303 in src/Filament/Resources/Products/Schemas/ProductForm.php

View check run for this annotation

SonarQubeCloud / SonarCloud Code Analysis

Split this 143 characters long line (which is greater than 120 authorized).

See more on https://sonarcloud.io/project/issues?id=saucebase-dev_billing&issues=AaG3DJvdZh2DBWnl9McN&open=AaG3DJvdZh2DBWnl9McN&pullRequest=41
->nullable()
->columnSpanFull(),
])
Expand Down
17 changes: 17 additions & 0 deletions tests/Feature/EntitlementCatalogueTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
use Filament\Resources\Events\RecordSaved;
use Filament\Support\Exceptions\Halt;
use Illuminate\Foundation\Testing\RefreshDatabase;
use Illuminate\Support\Facades\DB;
use Illuminate\Support\Facades\Event;
use Livewire\Livewire;
use Modules\Billing\Enums\PlanKind;
Expand Down Expand Up @@ -115,4 +116,20 @@ public function test_a_rolled_back_save_sends_no_warning(): void
->call('save')
->assertNotNotified(__('Not in the catalogue: :keys', ['keys' => 'legacy_flag']));
}

/** The sanitiser cuts input at 500,000 bytes: saving another field must not write the cut copy back. */
public function test_saving_another_field_keeps_a_long_description_whole(): void
{
$description = str_repeat('<p>Long description.</p>', 25_000);
$plan = Product::factory()->create(['kind' => PlanKind::OneOff, 'description' => $description]);
$this->assertGreaterThan(500_000, strlen($description));

Livewire::test(EditProduct::class, ['record' => $plan->getKey()])
->fillForm(['name' => 'Renamed'])
->call('save')
->assertHasNoFormErrors();

$stored = (string) DB::table('products')->where('id', $plan->getKey())->value('description');
$this->assertSame(strlen($description), strlen($stored), 'the stored description was cut');
}
}
8 changes: 5 additions & 3 deletions tests/Feature/ViewPathsTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
namespace Modules\Billing\Tests\Feature;

use Illuminate\Support\Facades\View;
use Illuminate\View\FileViewFinder;
use Tests\TestCase;

/**
Expand All @@ -13,12 +14,13 @@ class ViewPathsTest extends TestCase
{
public function test_every_view_folder_billing_registers_exists(): void
{
$paths = View::getFinder()->getHints()['billing'] ?? [];
$finder = View::getFinder();
$this->assertInstanceOf(FileViewFinder::class, $finder);

$paths = $finder->getHints()['billing'] ?? [];

foreach ($paths as $path) {
$this->assertDirectoryExists($path);
}

$this->addToAssertionCount(1);
}
}
Loading