Implemented a block editor for changing the layout of the page
This commit is contained in:
@@ -7,6 +7,7 @@ namespace Tests\Feature;
|
||||
use App\Models\PreregistrationPage;
|
||||
use App\Models\Subscriber;
|
||||
use App\Models\User;
|
||||
use App\Services\PreregistrationPageBlockWriter;
|
||||
use Illuminate\Foundation\Testing\RefreshDatabase;
|
||||
use Illuminate\Support\Str;
|
||||
use Tests\TestCase;
|
||||
@@ -199,7 +200,7 @@ class PublicPageTest extends TestCase
|
||||
{
|
||||
$user = User::factory()->create(['role' => 'user']);
|
||||
|
||||
return PreregistrationPage::query()->create(array_merge([
|
||||
$page = PreregistrationPage::query()->create(array_merge([
|
||||
'slug' => (string) Str::uuid(),
|
||||
'user_id' => $user->id,
|
||||
'title' => 'Test page',
|
||||
@@ -211,7 +212,36 @@ class PublicPageTest extends TestCase
|
||||
'start_date' => now()->subHour(),
|
||||
'end_date' => now()->addMonth(),
|
||||
'phone_enabled' => false,
|
||||
'background_image' => null,
|
||||
'logo_image' => null,
|
||||
'is_active' => true,
|
||||
], $overrides));
|
||||
|
||||
$writer = app(PreregistrationPageBlockWriter::class);
|
||||
if (! $page->blocks()->exists()) {
|
||||
$writer->seedDefaultBlocks($page);
|
||||
}
|
||||
|
||||
$page->refresh();
|
||||
$hero = $page->getHeroBlock();
|
||||
if ($hero !== null) {
|
||||
$c = $hero->content;
|
||||
$c['headline'] = $page->heading;
|
||||
$hero->update(['content' => $c]);
|
||||
}
|
||||
|
||||
if (($overrides['phone_enabled'] ?? false) === true) {
|
||||
$page->load('blocks');
|
||||
$form = $page->getFormBlock();
|
||||
if ($form !== null) {
|
||||
$c = $form->content;
|
||||
data_set($c, 'fields.phone.enabled', true);
|
||||
$form->update(['content' => $c]);
|
||||
}
|
||||
}
|
||||
|
||||
$page->syncLegacyContentColumnsFromBlocks();
|
||||
|
||||
return $page->fresh(['blocks']);
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user