Admin tables: scroll containers and phone cards; Alerts list flags missing media
Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
afa768fa42
commit
fb200594ce
8 files changed
+190
-54
No files matched your search
@@ -0,0 +1,40 @@
|
||||
<?php
|
||||
declare( strict_types=1 );
|
||||
|
||||
namespace StreamGoals\Tests\Unit;
|
||||
|
||||
use PHPUnit\Framework\TestCase;
|
||||
use StreamGoals\Admin\Admin;
|
||||
use StreamGoals\Admin\AlertsPage;
|
||||
|
||||
final class AdminTableAlertMediaTest extends TestCase {
|
||||
|
||||
public function test_media_parts_present_and_missing(): void {
|
||||
$d = array( 'visual_id' => 5, 'visual_type' => 'image', 'sound_id' => 6 );
|
||||
$this->assertSame( array( array( 'Picture/GIF', false ), array( 'Sound', false ) ), AlertsPage::mediaParts( $d, array( 5 => true, 6 => true ) ) );
|
||||
$this->assertSame( array( array( 'Picture missing', true ), array( 'Sound', false ) ), AlertsPage::mediaParts( $d, array( 6 => true ) ) );
|
||||
$this->assertSame( array( array( 'Picture missing', true ), array( 'Sound missing', true ) ), AlertsPage::mediaParts( $d, array() ) );
|
||||
}
|
||||
|
||||
public function test_media_parts_video_and_text_only(): void {
|
||||
$this->assertSame( array( array( 'Video missing', true ) ), AlertsPage::mediaParts( array( 'visual_id' => 9, 'visual_type' => 'video', 'sound_id' => 0 ), array() ) );
|
||||
$this->assertSame( array( array( 'Video', false ) ), AlertsPage::mediaParts( array( 'visual_id' => 9, 'visual_type' => 'video', 'sound_id' => 0 ), array( 9 => true ) ) );
|
||||
$this->assertSame( array(), AlertsPage::mediaParts( array( 'visual_id' => 0, 'sound_id' => 0 ), array() ) );
|
||||
}
|
||||
|
||||
public function test_table_open_is_focusable_region_with_hint_only_when_scrolling(): void {
|
||||
$cards = Admin::tableOpen( array( 'Goal', '' ), 'Goals "x"' );
|
||||
$this->assertStringContainsString( 'tabindex="0" role="region" aria-label="Goals "x""', $cards );
|
||||
$this->assertStringContainsString( 'sg-cards', $cards );
|
||||
$this->assertStringNotContainsString( 'Swipe sideways', $cards );
|
||||
$this->assertStringContainsString( 'screen-reader-text', $cards );
|
||||
$scroll = Admin::tableOpen( array( 'A' ), 'Donations', false );
|
||||
$this->assertStringContainsString( 'Swipe sideways to see more', $scroll );
|
||||
$this->assertStringNotContainsString( 'sg-cards', $scroll );
|
||||
$this->assertSame( '</tbody></table></div>', Admin::tableClose() );
|
||||
}
|
||||
|
||||
public function test_td_escapes_label(): void {
|
||||
$this->assertSame( '<td class="sg-actions" data-label="A&"">', Admin::td( 'A&"', 'sg-actions' ) );
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user