CI / Tests (PHP 8.1) (pull_request) Successful in 47s
CI / Tests (PHP 8.2) (pull_request) Successful in 54s
CI / No Debug Code (pull_request) Successful in 2s
CI / PHPStan (pull_request) Successful in 2m51s
CI / Coding Standards (pull_request) Successful in 2m56s
CI / Tests (PHP 8.3) (pull_request) Successful in 2m42s
CI / Build Plugin Zip (pull_request) Skipped
Three sidebar options on the Lesson Booking block, all mirrored as shortcode attributes and carried to the front end as data attributes on #us-booking-app (or as omitted containers): - Lesson type (lessonTypeId / lesson_type) pins the calendar to a single private-lesson type: only the times bookable as it are listed, and it is the only type bookable there, auto-selected on the registration form. A pinned type that is no longer offered says so instead of showing an empty calendar. - Show the lesson-type filter (showTypeFilter / show_filter) drops the "Show Only" control for studios that do not want it. - Sections (displayMode / show) embeds one half of the page — the booking calendar or the student's upcoming lessons — so the two can live on different pages. The script skips the work belonging to a missing half: no availability or catalog request for an upcoming-only embed, no bookings request for a booking-only one. An unrecognised value renders the whole page. The editor preview follows the same setting. Also fixes the expanded filter's first lesson type sharing a line with the "Lesson type" heading — the choices now sit in their own row beneath it. Co-Authored-By: Claude Opus 5 <[email protected]>
89 lines
3.6 KiB
PHP
89 lines
3.6 KiB
PHP
<?php
|
|
declare(strict_types=1);
|
|
|
|
namespace Unsupervised\Schedular\Tests\Unit;
|
|
|
|
use Brain\Monkey\Functions;
|
|
use Unsupervised\Schedular\BlockPreview;
|
|
use Unsupervised\Schedular\Booking\BookingPage;
|
|
|
|
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);
|
|
self::assertStringContainsString('id="us-my-lessons"', $html);
|
|
}
|
|
|
|
public function testBookingOnlyPreviewLeavesOutTheUpcomingLessons(): void
|
|
{
|
|
$html = BlockPreview::booking(BookingPage::MODE_BOOKING);
|
|
|
|
self::assertStringContainsString('id="us-slot-list"', $html);
|
|
self::assertStringNotContainsString('us-my-lessons', $html);
|
|
}
|
|
|
|
public function testUpcomingOnlyPreviewLeavesOutTheCalendar(): void
|
|
{
|
|
$html = BlockPreview::booking(BookingPage::MODE_UPCOMING);
|
|
|
|
self::assertStringContainsString('id="us-my-lessons"', $html);
|
|
self::assertStringContainsString('Your upcoming lessons', $html);
|
|
self::assertStringNotContainsString('us-slot-list', $html);
|
|
self::assertStringNotContainsString('us-book-btn', $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);
|
|
self::assertStringContainsString('A sample class shown so the page can be styled.', $html);
|
|
}
|
|
|
|
public function testSingleClassGroupPreviewDropsTheDescriptionButKeepsScheduleAndEnrolment(): void
|
|
{
|
|
$html = BlockPreview::groupClasses(true);
|
|
|
|
self::assertStringNotContainsString('A sample class shown so the page can be styled.', $html);
|
|
self::assertStringContainsString('class="us-class-when"', $html);
|
|
self::assertStringContainsString('class="us-enrol-deadline"', $html);
|
|
self::assertStringContainsString('class="us-enrol-btn" disabled', $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);
|
|
}
|
|
}
|