Files
unsupervised-scheduler/tests/Unit/BlockPreviewTest.php
T
thatguygriff fc70cde9d5
CI / No Debug Code (pull_request) Successful in 4s
CI / Tests (PHP 8.2) (pull_request) Successful in 52s
CI / Tests (PHP 8.1) (pull_request) Successful in 54s
CI / Tests (PHP 8.3) (pull_request) Successful in 1m29s
CI / Coding Standards (pull_request) Successful in 1m57s
CI / PHPStan (pull_request) Successful in 2m14s
CI / Build Plugin Zip (pull_request) Has been skipped
Add Gutenberg dynamic-block wrappers for the front-end shortcodes
Wrap the four shortcodes (us_booking, us_student_login,
us_student_register, us_group_classes) in dynamic blocks so pages can be
previewed and styled in the block editor. Front-end rendering delegates
to the same page objects the shortcodes use; in the editor's
block-renderer REST preview a static, script-free BlockPreview is
rendered instead (no live REST calls, redirects, or Stripe.js). The
editor script (vanilla JS, no build step) registers each block with
wp.serverSideRender previews and shortcode transforms; frontend.css is
attached as the block style so previews pick up theme styling.

Resolves #44

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
2026-06-12 12:03:27 -03:00

58 lines
2.2 KiB
PHP

<?php
declare(strict_types=1);
namespace Unsupervised\Schedular\Tests\Unit;
use Brain\Monkey\Functions;
use Unsupervised\Schedular\BlockPreview;
class BlockPreviewTest extends TestCase
{
public function testBookingPreviewMirrorsTheLiveMarkup(): void
{
$html = BlockPreview::booking();
self::assertStringContainsString('id="us-booking-app"', $html);
self::assertStringContainsString('id="us-slot-list"', $html);
self::assertStringContainsString('class="us-day"', $html);
self::assertStringContainsString('class="us-slot"', $html);
self::assertStringContainsString('class="us-book-btn" disabled', $html);
self::assertStringContainsString('us-editor-note', $html);
}
public function testGroupClassesPreviewMirrorsTheLiveMarkup(): void
{
$html = BlockPreview::groupClasses();
self::assertStringContainsString('id="us-group-app"', $html);
self::assertStringContainsString('id="us-group-list"', $html);
self::assertStringContainsString('class="us-class"', $html);
self::assertStringContainsString('class="us-enrol-btn" disabled', $html);
self::assertStringContainsString('us-editor-note', $html);
}
public function testLoginPreviewIncludesTheRealLoginTemplate(): void
{
Functions\when('wp_nonce_field')->justReturn('');
$html = BlockPreview::login();
self::assertStringContainsString('class="us-login-form"', $html);
self::assertStringContainsString('name="log"', $html);
self::assertStringContainsString('name="pwd"', $html);
self::assertStringContainsString('us-editor-note', $html);
}
public function testRegistrationPreviewShowsADisabledSampleForm(): void
{
$html = BlockPreview::registration();
self::assertStringContainsString('class="us-register-form"', $html);
self::assertStringContainsString('id="us-reg-email"', $html);
self::assertStringContainsString('id="us-reg-name"', $html);
self::assertStringContainsString('id="us-reg-pass"', $html);
self::assertStringContainsString('disabled', $html);
self::assertStringContainsString('us-editor-note', $html);
}
}