@therealtinhtute/baroiplayer 1.2.0 → 2.0.0-beta.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +91 -73
- package/dist/components/icons/index.d.ts +36 -0
- package/dist/components/icons/index.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/ArrowLeftIcon.d.ts +4 -0
- package/dist/components/icons/svg-icons/ArrowLeftIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/ArrowRightIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/ArrowRightIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/AudioIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/AudioIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/BackwardIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/BackwardIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/CameraIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/CameraIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/CheckIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/CheckIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/EnablePiPIcon.d.ts +4 -0
- package/dist/components/icons/svg-icons/EnablePiPIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/ForwardIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/ForwardIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/FullscreenEnterIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/FullscreenEnterIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/FullscreenExitIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/FullscreenExitIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/LoadingIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/LoadingIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/PauseIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/PauseIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/PlayIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/PlayIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/PlaybackSpeedIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/PlaybackSpeedIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/QualityIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/QualityIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/SettingsIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/SettingsIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/SliderIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/SliderIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/SubtitleIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/SubtitleIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/SubtitleOffIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/SubtitleOffIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/UnPiPIcon.d.ts +4 -0
- package/dist/components/icons/svg-icons/UnPiPIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/VolumeMutedIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/VolumeMutedIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/VolumeOneIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/VolumeOneIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/VolumeThreeIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/VolumeThreeIcon.d.ts.map +1 -0
- package/dist/components/icons/svg-icons/VolumeTwoIcon.d.ts +5 -0
- package/dist/components/icons/svg-icons/VolumeTwoIcon.d.ts.map +1 -0
- package/dist/components/variants/gradient/gradient-audio.d.ts +13 -0
- package/dist/components/variants/gradient/gradient-audio.d.ts.map +1 -0
- package/dist/components/variants/gradient/gradient-controls.d.ts +4 -0
- package/dist/components/variants/gradient/gradient-controls.d.ts.map +1 -0
- package/dist/components/variants/gradient/gradient-glyphs.d.ts +30 -0
- package/dist/components/variants/gradient/gradient-glyphs.d.ts.map +1 -0
- package/dist/components/variants/gradient/gradient-video.d.ts +16 -0
- package/dist/components/variants/gradient/gradient-video.d.ts.map +1 -0
- package/dist/index.css +1 -1
- package/dist/index.d.ts +5 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +2 -112
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +786 -6271
- package/dist/index.mjs.map +1 -1
- package/dist/package.json +3 -0
- package/package.json +110 -108
- package/src/components/variants/gradient/gradient-audio.tsx +47 -0
- package/src/components/variants/gradient/gradient-controls.tsx +254 -0
- package/src/components/variants/gradient/gradient-glyphs.test.tsx +69 -0
- package/src/components/variants/gradient/gradient-glyphs.tsx +129 -0
- package/src/components/variants/gradient/gradient-skin.css +211 -0
- package/src/components/variants/gradient/gradient-video.tsx +70 -0
- package/src/index.ts +5 -198
- package/src/test/accessibility-utils.ts +0 -59
- package/dist/context/media.js +0 -2
- package/dist/context/media.js.map +0 -1
- package/dist/context/media.mjs +0 -15
- package/dist/context/media.mjs.map +0 -1
- package/dist/context/store.js +0 -2
- package/dist/context/store.js.map +0 -1
- package/dist/context/store.mjs +0 -5
- package/dist/context/store.mjs.map +0 -1
- package/dist/context-BYwDoSRX.js +0 -1172
- package/dist/context-BYwDoSRX.js.map +0 -1
- package/dist/context-eNS62_ac.cjs +0 -23
- package/dist/context-eNS62_ac.cjs.map +0 -1
- package/dist/core-events-B1iM2F46.cjs +0 -2
- package/dist/core-events-B1iM2F46.cjs.map +0 -1
- package/dist/core-events-DunPHKRE.js +0 -484
- package/dist/core-events-DunPHKRE.js.map +0 -1
- package/dist/core-plugins-By-4-kGs.cjs +0 -2
- package/dist/core-plugins-By-4-kGs.cjs.map +0 -1
- package/dist/core-plugins-DSBWcTuX.js +0 -821
- package/dist/core-plugins-DSBWcTuX.js.map +0 -1
- package/dist/core.js +0 -37
- package/dist/core.js.map +0 -1
- package/dist/core.mjs +0 -1233
- package/dist/core.mjs.map +0 -1
- package/dist/enhanced-components-B_l3cist.js +0 -1142
- package/dist/enhanced-components-B_l3cist.js.map +0 -1
- package/dist/enhanced-components-BspFs9OO.cjs +0 -2
- package/dist/enhanced-components-BspFs9OO.cjs.map +0 -1
- package/dist/hooks-BXwI8QG6.cjs +0 -4
- package/dist/hooks-BXwI8QG6.cjs.map +0 -1
- package/dist/hooks-Bpi-jDiO.js +0 -1816
- package/dist/hooks-Bpi-jDiO.js.map +0 -1
- package/dist/minimal-components-C4z900Ro.js +0 -1926
- package/dist/minimal-components-C4z900Ro.js.map +0 -1
- package/dist/minimal-components-v4qBp6jv.cjs +0 -2
- package/dist/minimal-components-v4qBp6jv.cjs.map +0 -1
- package/dist/minimal-components.css +0 -1
- package/dist/mona-loading.gif +0 -0
- package/dist/performance-monitor-C5k6FDXw.js +0 -301
- package/dist/performance-monitor-C5k6FDXw.js.map +0 -1
- package/dist/performance-monitor-lJmuUjQQ.cjs +0 -2
- package/dist/performance-monitor-lJmuUjQQ.cjs.map +0 -1
- package/dist/utils-CFOue_9K.cjs +0 -9
- package/dist/utils-CFOue_9K.cjs.map +0 -1
- package/dist/utils-Dzpl2ArK.js +0 -2844
- package/dist/utils-Dzpl2ArK.js.map +0 -1
- package/dist/utils.js +0 -2
- package/dist/utils.js.map +0 -1
- package/dist/utils.mjs +0 -11
- package/dist/utils.mjs.map +0 -1
- package/src/adapters/videojs-adapter.tsx +0 -470
- package/src/assets/mona-loading.gif +0 -0
- package/src/components/AnimateLoading.tsx +0 -107
- package/src/components/LoadingState.tsx +0 -239
- package/src/components/__tests__/media-player-accessibility.test.tsx +0 -510
- package/src/components/__tests__/media-player-react19.test.tsx +0 -457
- package/src/components/accessibility/keyboard-help-overlay.tsx +0 -207
- package/src/components/audio-player.tsx +0 -85
- package/src/components/basic/index.ts +0 -37
- package/src/components/enhanced/advanced-features.tsx +0 -311
- package/src/components/enhanced/debug-panel.tsx +0 -448
- package/src/components/enhanced/enhanced-controls.tsx +0 -597
- package/src/components/enhanced/enhanced-media-player.tsx +0 -566
- package/src/components/enhanced/error-handling.tsx +0 -338
- package/src/components/enhanced/index.ts +0 -39
- package/src/components/enhanced/media-player-enhanced.tsx +0 -383
- package/src/components/examples/basic-video-player.tsx +0 -50
- package/src/components/examples/custom-controls-example.tsx +0 -63
- package/src/components/examples/enhanced-controls-example.tsx +0 -100
- package/src/components/examples/enhanced-media-player-example.tsx +0 -302
- package/src/components/examples/loading-states-demo.tsx +0 -142
- package/src/components/examples/react-19-demo.tsx +0 -353
- package/src/components/examples/volume-orientation-demo.tsx +0 -106
- package/src/components/icon-demo.tsx +0 -196
- package/src/components/legacy.tsx +0 -87
- package/src/components/media-metadata-display.tsx +0 -99
- package/src/components/media-player-audio.tsx +0 -39
- package/src/components/media-player-controls.tsx +0 -223
- package/src/components/media-player-error.tsx +0 -163
- package/src/components/media-player-fullscreen.tsx +0 -109
- package/src/components/media-player-hls.tsx +0 -111
- package/src/components/media-player-loading.tsx +0 -76
- package/src/components/media-player-play.tsx +0 -75
- package/src/components/media-player-root.tsx +0 -338
- package/src/components/media-player-seek.tsx +0 -168
- package/src/components/media-player-time.tsx +0 -99
- package/src/components/media-player-tooltip.tsx +0 -58
- package/src/components/media-player-video.tsx +0 -54
- package/src/components/media-player-volume.tsx +0 -155
- package/src/components/media-player.tsx +0 -292
- package/src/components/media-suspense.tsx +0 -344
- package/src/components/player-settings-form.tsx +0 -158
- package/src/components/react-player-wrapper.tsx +0 -651
- package/src/components/simple-video-player.tsx +0 -62
- package/src/components/ui/blur-poster.tsx +0 -93
- package/src/components/ui/empty-state.tsx +0 -91
- package/src/components/ui/enhanced-seek-bar.tsx +0 -254
- package/src/components/ui/error-state.tsx +0 -124
- package/src/components/ui/fullscreen-button.tsx +0 -81
- package/src/components/ui/loading-skeleton.tsx +0 -107
- package/src/components/ui/media-resource-preloader.tsx +0 -458
- package/src/components/ui/offline-message.tsx +0 -98
- package/src/components/ui/play-button.tsx +0 -99
- package/src/components/ui/seek-bar.tsx +0 -191
- package/src/components/ui/time-display.tsx +0 -61
- package/src/components/ui/volume-control.tsx +0 -190
- package/src/components/unified/base-media-player.tsx +0 -252
- package/src/components/unified/media-player.tsx +0 -75
- package/src/components/variants/minimal/AccessibleMinimalPlayer.tsx +0 -587
- package/src/components/variants/minimal/EnhancedMinimalMediaPlayer.tsx +0 -573
- package/src/components/variants/minimal/MinimalControls.tsx +0 -124
- package/src/components/variants/minimal/MinimalLoading.tsx +0 -28
- package/src/components/variants/minimal/MinimalMediaPlayer.tsx +0 -318
- package/src/components/variants/minimal/MinimalOverlay.tsx +0 -58
- package/src/components/variants/minimal/MinimalPlayButton.tsx +0 -56
- package/src/components/variants/minimal/MinimalSeekBar.tsx +0 -140
- package/src/components/variants/minimal/MinimalVolumeControl.tsx +0 -75
- package/src/components/variants/minimal/SimpleMinimalPlayer.tsx +0 -206
- package/src/components/variants/minimal/components/CenterPlayButton.tsx +0 -22
- package/src/components/variants/minimal/components/ControlBar.tsx +0 -142
- package/src/components/variants/minimal/components/EnhancedSettingsMenu.tsx +0 -412
- package/src/components/variants/minimal/components/PlaybackControls.tsx +0 -46
- package/src/components/variants/minimal/components/RightControls.tsx +0 -164
- package/src/components/variants/minimal/components/SeekBar.tsx +0 -127
- package/src/components/variants/minimal/components/SettingsDropdown.tsx +0 -68
- package/src/components/variants/minimal/components/SubtitleDisplay.tsx +0 -21
- package/src/components/variants/minimal/components/TimeDisplay.tsx +0 -15
- package/src/components/variants/minimal/components/VideoElement.tsx +0 -33
- package/src/components/variants/minimal/components/VolumeControl.tsx +0 -220
- package/src/components/variants/minimal/index.ts +0 -23
- package/src/components/video-player.tsx +0 -100
- package/src/context/__tests__/media-store.test.ts +0 -509
- package/src/context/error-handling.ts +0 -398
- package/src/context/media-context.tsx +0 -254
- package/src/context/media-provider.tsx +0 -264
- package/src/context/media-store.ts +0 -387
- package/src/context/persistence.ts +0 -462
- package/src/core/events/event-system.ts +0 -448
- package/src/core/events/hooks.ts +0 -325
- package/src/core/events/index.ts +0 -22
- package/src/core/events/middleware.ts +0 -286
- package/src/core/index.ts +0 -22
- package/src/core/optimization/bundle-optimizer.tsx +0 -312
- package/src/core/performance/cicd.ts +0 -98
- package/src/core/performance/index.ts +0 -38
- package/src/core/performance/media-loading-optimizer.ts +0 -544
- package/src/core/performance/performance-budgets.ts +0 -437
- package/src/core/performance/performance-monitor.tsx +0 -488
- package/src/core/performance/performance-testing.ts +0 -461
- package/src/core/plugins/__tests__/registry.test.ts +0 -595
- package/src/core/plugins/base-plugin.ts +0 -225
- package/src/core/plugins/enhanced-plugin-system.ts +0 -435
- package/src/core/plugins/examples/analytics-plugin.ts +0 -241
- package/src/core/plugins/index.ts +0 -39
- package/src/core/plugins/registry.ts +0 -546
- package/src/core/plugins/types.ts +0 -169
- package/src/core/plugins/utils.ts +0 -317
- package/src/core/progressive-loading.tsx +0 -331
- package/src/core/providers/enhanced-hls-provider.ts +0 -307
- package/src/core/providers/lazy-provider.tsx +0 -14
- package/src/core/providers/service-provider.tsx +0 -164
- package/src/core/utils.tsx +0 -34
- package/src/features/media-session/media-session-manager.ts +0 -411
- package/src/features/picture-in-picture/pip-manager.ts +0 -428
- package/src/features/playlist/playlist-manager.ts +0 -626
- package/src/features/subtitles/subtitle-manager.ts +0 -435
- package/src/features/subtitles/subtitle-parser.ts +0 -284
- package/src/features/thumbnails/thumbnail-generator.ts +0 -528
- package/src/hooks/__tests__/currentTime-fix.test.ts +0 -149
- package/src/hooks/__tests__/use-media-player.test.ts +0 -712
- package/src/hooks/__tests__/use-media-state.test.tsx +0 -316
- package/src/hooks/accessibility/index.ts +0 -27
- package/src/hooks/accessibility/use-accessibility-preferences.ts +0 -190
- package/src/hooks/accessibility/use-focus-management.ts +0 -183
- package/src/hooks/accessibility/use-keyboard-shortcuts.ts +0 -152
- package/src/hooks/accessibility/use-screen-reader.ts +0 -212
- package/src/hooks/core/index.ts +0 -47
- package/src/hooks/legacy.ts +0 -21
- package/src/hooks/use-buffer-health.ts +0 -218
- package/src/hooks/use-enhanced-media-player.ts +0 -575
- package/src/hooks/use-focus-trap.tsx +0 -162
- package/src/hooks/use-intelligent-preloading.ts +0 -387
- package/src/hooks/use-keyboard-controls.ts +0 -115
- package/src/hooks/use-keyboard-shortcuts.ts +0 -255
- package/src/hooks/use-media-actions.ts +0 -184
- package/src/hooks/use-media-metadata.ts +0 -91
- package/src/hooks/use-media-optimistic.ts +0 -264
- package/src/hooks/use-media-player.ts +0 -343
- package/src/hooks/use-media-state.ts +0 -194
- package/src/hooks/use-memory-optimization.ts +0 -360
- package/src/hooks/use-network-status.ts +0 -124
- package/src/hooks/use-optimistic-controls.ts +0 -95
- package/src/hooks/use-optimized-media.ts +0 -283
- package/src/hooks/use-smart-preload.ts +0 -229
- package/src/hooks/use-touch-gestures.ts +0 -461
- package/src/hooks/useEnhancedSubtitles.ts +0 -258
- package/src/hooks/useKeyboardShortcuts.ts +0 -106
- package/src/hooks/useMediaControls.ts +0 -52
- package/src/hooks/useScreenshot.ts +0 -61
- package/src/hooks/useSubtitles.ts +0 -91
- package/src/hooks/useVideoPlayer.ts +0 -278
- package/src/icons/components/FullscreenIcon.tsx +0 -36
- package/src/icons/components/SettingsIcon.tsx +0 -37
- package/src/icons/components/animated/LoadingIcon.tsx +0 -27
- package/src/icons/components/animated/PlayPauseIcon.tsx +0 -42
- package/src/icons/components/media/PauseIcon.tsx +0 -38
- package/src/icons/components/media/PlayIcon.tsx +0 -37
- package/src/icons/components/volume/VolumeIcon.tsx +0 -38
- package/src/icons/components/volume/VolumeOffIcon.tsx +0 -38
- package/src/icons/index.ts +0 -56
- package/src/icons/provider.tsx +0 -58
- package/src/icons/types.ts +0 -60
- package/src/index-enhanced.ts +0 -35
- package/src/index-legacy.ts +0 -324
- package/src/index.css +0 -102
- package/src/lib/__tests__/async-utils.test.ts +0 -291
- package/src/lib/async-utils.ts +0 -194
- package/src/lib/deprecation.ts +0 -51
- package/src/lib/format-time.ts +0 -37
- package/src/lib/index.ts +0 -4
- package/src/lib/utils.ts +0 -6
- package/src/styles/globals.css +0 -462
- package/src/styles/minimal-player.css +0 -621
- package/src/styles/pixel-art.css +0 -41
- package/src/styles/videojs.css +0 -100
- package/src/types/events.ts +0 -47
- package/src/types/formats.ts +0 -79
- package/src/types/index.ts +0 -203
- package/src/types/videojs-plugins.d.ts +0 -14
|
@@ -1,510 +0,0 @@
|
|
|
1
|
-
import { render, screen, waitFor } from "@testing-library/react"
|
|
2
|
-
import { userEvent } from "@testing-library/user-event"
|
|
3
|
-
import { afterEach, beforeEach, describe, expect, it } from "vitest"
|
|
4
|
-
import { a11yTestUtils } from "../../test/accessibility-utils"
|
|
5
|
-
import { setupMediaMocks } from "../../test/media-mocks"
|
|
6
|
-
import { MediaPlayer } from "../media-player"
|
|
7
|
-
|
|
8
|
-
// Mock axe for accessibility testing
|
|
9
|
-
const mockAxe = {
|
|
10
|
-
run: vi.fn().mockResolvedValue({
|
|
11
|
-
violations: [],
|
|
12
|
-
passes: [],
|
|
13
|
-
incomplete: [],
|
|
14
|
-
url: "mock-url"
|
|
15
|
-
})
|
|
16
|
-
}
|
|
17
|
-
|
|
18
|
-
describe("Media Player Accessibility", () => {
|
|
19
|
-
beforeEach(() => {
|
|
20
|
-
setupMediaMocks()
|
|
21
|
-
vi.clearAllMocks()
|
|
22
|
-
|
|
23
|
-
// Mock window.getComputedStyle for color contrast testing
|
|
24
|
-
Object.defineProperty(window, "getComputedStyle", {
|
|
25
|
-
writable: true,
|
|
26
|
-
value: vi.fn().mockImplementation((element) => ({
|
|
27
|
-
color: "rgb(0, 0, 0)",
|
|
28
|
-
backgroundColor: "rgb(255, 255, 255)",
|
|
29
|
-
getPropertyValue: vi.fn().mockReturnValue("")
|
|
30
|
-
}))
|
|
31
|
-
})
|
|
32
|
-
|
|
33
|
-
// Mock CSS.supports for feature detection
|
|
34
|
-
Object.defineProperty(CSS, "supports", {
|
|
35
|
-
writable: true,
|
|
36
|
-
value: vi.fn().mockReturnValue(true)
|
|
37
|
-
})
|
|
38
|
-
})
|
|
39
|
-
|
|
40
|
-
afterEach(() => {
|
|
41
|
-
vi.restoreAllMocks()
|
|
42
|
-
})
|
|
43
|
-
|
|
44
|
-
describe("WCAG Compliance", () => {
|
|
45
|
-
it("should pass automated accessibility checks", async () => {
|
|
46
|
-
const { container } = render(<MediaPlayer src="test.mp4" />)
|
|
47
|
-
|
|
48
|
-
const results = await mockAxe.run(container)
|
|
49
|
-
expect(results.violations).toHaveLength(0)
|
|
50
|
-
})
|
|
51
|
-
|
|
52
|
-
it("should have proper ARIA labels and roles", () => {
|
|
53
|
-
render(<MediaPlayer src="test.mp4" />)
|
|
54
|
-
|
|
55
|
-
// Main media player should have appropriate role
|
|
56
|
-
const mediaContainer = screen.getByRole("application")
|
|
57
|
-
expect(mediaContainer).toHaveAttribute("aria-label", expect.stringContaining("player"))
|
|
58
|
-
expect(mediaContainer).toHaveAttribute("role", "application")
|
|
59
|
-
|
|
60
|
-
// Controls should have accessible names
|
|
61
|
-
const playButton = screen.getByRole("button", { name: /play/i })
|
|
62
|
-
expect(playButton).toHaveAccessibleName()
|
|
63
|
-
|
|
64
|
-
const volumeSlider = screen.getByRole("slider", { name: /volume/i })
|
|
65
|
-
expect(volumeSlider).toHaveAccessibleName()
|
|
66
|
-
|
|
67
|
-
const seekBar = screen.getByRole("slider", { name: /seek/i })
|
|
68
|
-
expect(seekBar).toHaveAccessibleName()
|
|
69
|
-
})
|
|
70
|
-
|
|
71
|
-
it("should provide sufficient color contrast", () => {
|
|
72
|
-
const { container } = render(<MediaPlayer src="test.mp4" />)
|
|
73
|
-
|
|
74
|
-
const contrastViolations = a11yTestUtils.testColorContrast(container)
|
|
75
|
-
expect(contrastViolations).toHaveLength(0)
|
|
76
|
-
})
|
|
77
|
-
|
|
78
|
-
it("should support keyboard navigation", async () => {
|
|
79
|
-
const user = userEvent.setup()
|
|
80
|
-
const { container } = render(<MediaPlayer src="test.mp4" />)
|
|
81
|
-
|
|
82
|
-
// Test keyboard navigation
|
|
83
|
-
const keyboardIssues = a11yTestUtils.testKeyboardNavigation(container)
|
|
84
|
-
expect(keyboardIssues).toHaveLength(0)
|
|
85
|
-
|
|
86
|
-
// Test tab order
|
|
87
|
-
const mediaContainer = screen.getByRole("application")
|
|
88
|
-
mediaContainer.focus()
|
|
89
|
-
expect(document.activeElement).toBe(mediaContainer)
|
|
90
|
-
|
|
91
|
-
// Test keyboard shortcuts
|
|
92
|
-
await user.keyboard(" ") // Space bar for play/pause
|
|
93
|
-
expect(screen.getByRole("button", { name: /pause/i })).toBeInTheDocument()
|
|
94
|
-
|
|
95
|
-
await user.keyboard("m") // Mute/unmute
|
|
96
|
-
expect(screen.getByRole("button", { name: /unmute/i })).toBeInTheDocument()
|
|
97
|
-
|
|
98
|
-
await user.keyboard("ArrowRight") // Seek forward
|
|
99
|
-
expect(mediaContainer).toHaveFocus()
|
|
100
|
-
})
|
|
101
|
-
|
|
102
|
-
it("should have proper focus management", () => {
|
|
103
|
-
const { container } = render(<MediaPlayer src="test.mp4" />)
|
|
104
|
-
|
|
105
|
-
const focusIssues = a11yTestUtils.testFocusManagement(container)
|
|
106
|
-
expect(focusIssues).toHaveLength(0)
|
|
107
|
-
|
|
108
|
-
// Test focus indicators
|
|
109
|
-
const playButton = screen.getByRole("button", { name: /play/i })
|
|
110
|
-
playButton.focus()
|
|
111
|
-
expect(playButton).toHaveFocus()
|
|
112
|
-
})
|
|
113
|
-
})
|
|
114
|
-
|
|
115
|
-
describe("Screen Reader Support", () => {
|
|
116
|
-
it("should announce media state changes", async () => {
|
|
117
|
-
const user = userEvent.setup()
|
|
118
|
-
render(<MediaPlayer src="test.mp4" />)
|
|
119
|
-
|
|
120
|
-
const playButton = screen.getByRole("button", { name: /play/i })
|
|
121
|
-
|
|
122
|
-
// Should announce play state
|
|
123
|
-
await user.click(playButton)
|
|
124
|
-
|
|
125
|
-
const statusRegion = screen.getByRole("status")
|
|
126
|
-
expect(statusRegion).toBeInTheDocument()
|
|
127
|
-
expect(statusRegion).toHaveTextContent(/playing/i)
|
|
128
|
-
|
|
129
|
-
// Should announce pause state
|
|
130
|
-
await user.click(playButton)
|
|
131
|
-
expect(statusRegion).toHaveTextContent(/paused/i)
|
|
132
|
-
})
|
|
133
|
-
|
|
134
|
-
it("should announce errors to screen readers", async () => {
|
|
135
|
-
render(<MediaPlayer src="invalid.mp4" />)
|
|
136
|
-
|
|
137
|
-
// Simulate error
|
|
138
|
-
const video = screen.getByRole("application") as HTMLVideoElement
|
|
139
|
-
|
|
140
|
-
act(() => {
|
|
141
|
-
video.error = new Error("Media format not supported")
|
|
142
|
-
const errorEvent = new Event("error")
|
|
143
|
-
video.dispatchEvent(errorEvent)
|
|
144
|
-
})
|
|
145
|
-
|
|
146
|
-
const errorMessage = screen.getByRole("alert")
|
|
147
|
-
expect(errorMessage).toBeInTheDocument()
|
|
148
|
-
expect(errorMessage).toHaveTextContent(/media format not supported/i)
|
|
149
|
-
})
|
|
150
|
-
|
|
151
|
-
it("should provide descriptive labels for controls", () => {
|
|
152
|
-
render(<MediaPlayer src="test.mp4" showControls={true} />)
|
|
153
|
-
|
|
154
|
-
// All controls should have accessible descriptions
|
|
155
|
-
const controls = screen.getAllByRole("button")
|
|
156
|
-
controls.forEach((control) => {
|
|
157
|
-
expect(control).toHaveAccessibleName()
|
|
158
|
-
})
|
|
159
|
-
|
|
160
|
-
// Sliders should have accessible labels and descriptions
|
|
161
|
-
const sliders = screen.getAllByRole("slider")
|
|
162
|
-
sliders.forEach((slider) => {
|
|
163
|
-
expect(slider).toHaveAccessibleName()
|
|
164
|
-
expect(slider).toHaveAttribute("aria-valuenow")
|
|
165
|
-
expect(slider).toHaveAttribute("aria-valuemin")
|
|
166
|
-
expect(slider).toHaveAttribute("aria-valuemax")
|
|
167
|
-
})
|
|
168
|
-
})
|
|
169
|
-
|
|
170
|
-
it("should announce time progress and duration", async () => {
|
|
171
|
-
const user = userEvent.setup()
|
|
172
|
-
render(<MediaPlayer src="test.mp4" />)
|
|
173
|
-
|
|
174
|
-
const video = screen.getByRole("application") as HTMLVideoElement
|
|
175
|
-
|
|
176
|
-
// Simulate video metadata loading
|
|
177
|
-
act(() => {
|
|
178
|
-
video.duration = 120 // 2 minutes
|
|
179
|
-
video.readyState = 1
|
|
180
|
-
const loadedMetadataEvent = new Event("loadedmetadata")
|
|
181
|
-
video.dispatchEvent(loadedMetadataEvent)
|
|
182
|
-
})
|
|
183
|
-
|
|
184
|
-
const timeDisplay = screen.getByTestId("time-display")
|
|
185
|
-
expect(timeDisplay).toHaveAttribute("aria-live", "polite")
|
|
186
|
-
expect(timeDisplay).toHaveTextContent(/0:00 \/ 2:00/i)
|
|
187
|
-
|
|
188
|
-
// Simulate time update
|
|
189
|
-
act(() => {
|
|
190
|
-
video.currentTime = 30
|
|
191
|
-
const timeUpdateEvent = new Event("timeupdate")
|
|
192
|
-
video.dispatchEvent(timeUpdateEvent)
|
|
193
|
-
})
|
|
194
|
-
|
|
195
|
-
await waitFor(() => {
|
|
196
|
-
expect(timeDisplay).toHaveTextContent(/0:30 \/ 2:00/i)
|
|
197
|
-
})
|
|
198
|
-
})
|
|
199
|
-
})
|
|
200
|
-
|
|
201
|
-
describe("Keyboard Accessibility", () => {
|
|
202
|
-
it("should support all keyboard shortcuts", async () => {
|
|
203
|
-
const user = userEvent.setup()
|
|
204
|
-
render(<MediaPlayer src="test.mp4" />)
|
|
205
|
-
|
|
206
|
-
const mediaContainer = screen.getByRole("application")
|
|
207
|
-
mediaContainer.focus()
|
|
208
|
-
|
|
209
|
-
// Test play/pause (Space)
|
|
210
|
-
await user.keyboard(" ")
|
|
211
|
-
expect(screen.getByRole("button", { name: /pause/i })).toBeInTheDocument()
|
|
212
|
-
|
|
213
|
-
// Test mute (M)
|
|
214
|
-
await user.keyboard("m")
|
|
215
|
-
expect(screen.getByRole("button", { name: /unmute/i })).toBeInTheDocument()
|
|
216
|
-
|
|
217
|
-
// Test fullscreen (F)
|
|
218
|
-
await user.keyboard("f")
|
|
219
|
-
expect(document.fullscreenElement).toBe(mediaContainer)
|
|
220
|
-
|
|
221
|
-
// Test volume controls (Arrow Up/Down)
|
|
222
|
-
await user.keyboard("{ArrowUp}")
|
|
223
|
-
const volumeSlider = screen.getByRole("slider", { name: /volume/i })
|
|
224
|
-
expect(volumeSlider).toHaveValue("1")
|
|
225
|
-
|
|
226
|
-
await user.keyboard("{ArrowDown}")
|
|
227
|
-
expect(volumeSlider).toHaveValue("0.9")
|
|
228
|
-
|
|
229
|
-
// Test seeking (Arrow Left/Right)
|
|
230
|
-
await user.keyboard("{ArrowRight}")
|
|
231
|
-
const seekBar = screen.getByRole("slider", { name: /seek/i })
|
|
232
|
-
expect(seekBar).toHaveValueGreaterThan("0")
|
|
233
|
-
})
|
|
234
|
-
|
|
235
|
-
it("should show keyboard help overlay", async () => {
|
|
236
|
-
const user = userEvent.setup()
|
|
237
|
-
render(<MediaPlayer src="test.mp4" />)
|
|
238
|
-
|
|
239
|
-
// Open keyboard help
|
|
240
|
-
await user.keyboard("?")
|
|
241
|
-
|
|
242
|
-
const helpOverlay = screen.getByRole("dialog", { name: /keyboard shortcuts/i })
|
|
243
|
-
expect(helpOverlay).toBeInTheDocument()
|
|
244
|
-
|
|
245
|
-
// Should list all available shortcuts
|
|
246
|
-
expect(screen.getByText(/play or pause/i)).toBeInTheDocument()
|
|
247
|
-
expect(screen.getByText(/mute or unmute/i)).toBeInTheDocument()
|
|
248
|
-
expect(screen.getByText(/toggle fullscreen/i)).toBeInTheDocument()
|
|
249
|
-
|
|
250
|
-
// Should be focusable and closeable
|
|
251
|
-
const closeButton = screen.getByRole("button", { name: /close/i })
|
|
252
|
-
expect(closeButton).toBeInTheDocument()
|
|
253
|
-
|
|
254
|
-
await user.click(closeButton)
|
|
255
|
-
expect(helpOverlay).not.toBeInTheDocument()
|
|
256
|
-
})
|
|
257
|
-
|
|
258
|
-
it("should handle focus trapping in modals", async () => {
|
|
259
|
-
const user = userEvent.setup()
|
|
260
|
-
render(<MediaPlayer src="test.mp4" />)
|
|
261
|
-
|
|
262
|
-
// Open settings modal
|
|
263
|
-
await user.keyboard("s")
|
|
264
|
-
|
|
265
|
-
const settingsModal = screen.getByRole("dialog", { name: /settings/i })
|
|
266
|
-
expect(settingsModal).toBeInTheDocument()
|
|
267
|
-
|
|
268
|
-
// Focus should be trapped within modal
|
|
269
|
-
const firstFocusable = settingsModal.querySelector(
|
|
270
|
-
'button, input, select, [tabindex]:not([tabindex="-1"])'
|
|
271
|
-
)
|
|
272
|
-
expect(firstFocusable).toHaveFocus()
|
|
273
|
-
|
|
274
|
-
// Tab should cycle through modal elements
|
|
275
|
-
await user.keyboard("{Tab}")
|
|
276
|
-
expect(settingsModal.contains(document.activeElement || document.body)).toBe(true)
|
|
277
|
-
|
|
278
|
-
// Escape should close modal
|
|
279
|
-
await user.keyboard("{Escape}")
|
|
280
|
-
expect(settingsModal).not.toBeInTheDocument()
|
|
281
|
-
})
|
|
282
|
-
|
|
283
|
-
it("should support skip links", () => {
|
|
284
|
-
render(<MediaPlayer src="test.mp4" />)
|
|
285
|
-
|
|
286
|
-
const skipLink = screen.getByRole("link", { name: /skip to main content/i })
|
|
287
|
-
expect(skipLink).toBeInTheDocument()
|
|
288
|
-
|
|
289
|
-
// Should be visible on focus
|
|
290
|
-
skipLink.focus()
|
|
291
|
-
expect(skipLink).toBeVisible()
|
|
292
|
-
})
|
|
293
|
-
})
|
|
294
|
-
|
|
295
|
-
describe("Visual Accessibility", () => {
|
|
296
|
-
it("should respect reduced motion preferences", () => {
|
|
297
|
-
// Mock reduced motion preference
|
|
298
|
-
Object.defineProperty(window, "matchMedia", {
|
|
299
|
-
writable: true,
|
|
300
|
-
value: vi.fn().mockImplementation((query) => ({
|
|
301
|
-
matches: query === "(prefers-reduced-motion: reduce)",
|
|
302
|
-
media: query,
|
|
303
|
-
onchange: null,
|
|
304
|
-
addListener: vi.fn(),
|
|
305
|
-
removeListener: vi.fn(),
|
|
306
|
-
addEventListener: vi.fn(),
|
|
307
|
-
removeEventListener: vi.fn(),
|
|
308
|
-
dispatchEvent: vi.fn()
|
|
309
|
-
}))
|
|
310
|
-
})
|
|
311
|
-
|
|
312
|
-
const { container } = render(<MediaPlayer src="test.mp4" />)
|
|
313
|
-
|
|
314
|
-
// Animations should be disabled
|
|
315
|
-
const animatedElements = container.querySelectorAll(
|
|
316
|
-
'[class*="animate-"], [class*="transition-"]'
|
|
317
|
-
)
|
|
318
|
-
animatedElements.forEach((element) => {
|
|
319
|
-
const styles = window.getComputedStyle(element)
|
|
320
|
-
expect(styles.animation).toBe("none")
|
|
321
|
-
expect(styles.transition).toBe("none")
|
|
322
|
-
})
|
|
323
|
-
})
|
|
324
|
-
|
|
325
|
-
it("should support high contrast mode", () => {
|
|
326
|
-
// Mock high contrast mode
|
|
327
|
-
Object.defineProperty(window, "matchMedia", {
|
|
328
|
-
writable: true,
|
|
329
|
-
value: vi.fn().mockImplementation((query) => ({
|
|
330
|
-
matches: query === "(prefers-contrast: high)",
|
|
331
|
-
media: query,
|
|
332
|
-
onchange: null,
|
|
333
|
-
addListener: vi.fn(),
|
|
334
|
-
removeListener: vi.fn(),
|
|
335
|
-
addEventListener: vi.fn(),
|
|
336
|
-
removeEventListener: vi.fn(),
|
|
337
|
-
dispatchEvent: vi.fn()
|
|
338
|
-
}))
|
|
339
|
-
})
|
|
340
|
-
|
|
341
|
-
render(<MediaPlayer src="test.mp4" />)
|
|
342
|
-
|
|
343
|
-
// Should apply high contrast styles
|
|
344
|
-
const mediaContainer = screen.getByRole("application")
|
|
345
|
-
expect(mediaContainer).toHaveClass("high-contrast")
|
|
346
|
-
})
|
|
347
|
-
|
|
348
|
-
it("should have sufficient tap targets for touch devices", () => {
|
|
349
|
-
// Mock touch device
|
|
350
|
-
Object.defineProperty(navigator, "maxTouchPoints", {
|
|
351
|
-
writable: true,
|
|
352
|
-
value: 1
|
|
353
|
-
})
|
|
354
|
-
|
|
355
|
-
const { container } = render(<MediaPlayer src="test.mp4" />)
|
|
356
|
-
|
|
357
|
-
// All interactive elements should have sufficient touch target size
|
|
358
|
-
const interactiveElements = container.querySelectorAll('button, [role="slider"]')
|
|
359
|
-
interactiveElements.forEach((element) => {
|
|
360
|
-
const styles = window.getComputedStyle(element)
|
|
361
|
-
const width = parseInt(styles.width)
|
|
362
|
-
const height = parseInt(styles.height)
|
|
363
|
-
|
|
364
|
-
// Should be at least 44x44 pixels
|
|
365
|
-
expect(width).toBeGreaterThanOrEqual(44)
|
|
366
|
-
expect(height).toBeGreaterThanOrEqual(44)
|
|
367
|
-
})
|
|
368
|
-
})
|
|
369
|
-
|
|
370
|
-
it("should maintain readability at different zoom levels", () => {
|
|
371
|
-
// Mock different zoom levels
|
|
372
|
-
const zoomLevels = [1, 1.5, 2]
|
|
373
|
-
|
|
374
|
-
zoomLevels.forEach((zoom) => {
|
|
375
|
-
Object.defineProperty(document.body.style, "zoom", {
|
|
376
|
-
writable: true,
|
|
377
|
-
value: zoom
|
|
378
|
-
})
|
|
379
|
-
|
|
380
|
-
const { container } = render(<MediaPlayer src="test.mp4" />)
|
|
381
|
-
|
|
382
|
-
// Text should remain readable
|
|
383
|
-
const textElements = container.querySelectorAll(
|
|
384
|
-
'button span, [role="status"], .time-display'
|
|
385
|
-
)
|
|
386
|
-
textElements.forEach((element) => {
|
|
387
|
-
const styles = window.getComputedStyle(element)
|
|
388
|
-
const fontSize = parseInt(styles.fontSize)
|
|
389
|
-
expect(fontSize).toBeGreaterThanOrEqual(14) // Minimum readable font size
|
|
390
|
-
})
|
|
391
|
-
})
|
|
392
|
-
})
|
|
393
|
-
})
|
|
394
|
-
|
|
395
|
-
describe("Cognitive Accessibility", () => {
|
|
396
|
-
it("should provide clear error messages", async () => {
|
|
397
|
-
render(<MediaPlayer src="invalid.mp4" />)
|
|
398
|
-
|
|
399
|
-
const video = screen.getByRole("application") as HTMLVideoElement
|
|
400
|
-
|
|
401
|
-
act(() => {
|
|
402
|
-
video.error = new Error("Network error - unable to load media")
|
|
403
|
-
const errorEvent = new Event("error")
|
|
404
|
-
video.dispatchEvent(errorEvent)
|
|
405
|
-
})
|
|
406
|
-
|
|
407
|
-
const errorMessage = screen.getByRole("alert")
|
|
408
|
-
expect(errorMessage).toBeInTheDocument()
|
|
409
|
-
|
|
410
|
-
// Error message should be clear and actionable
|
|
411
|
-
expect(errorMessage).toHaveTextContent(/network error/i)
|
|
412
|
-
expect(errorMessage).toHaveTextContent(/unable to load media/i)
|
|
413
|
-
|
|
414
|
-
// Should provide recovery options
|
|
415
|
-
const retryButton = screen.getByRole("button", { name: /try again/i })
|
|
416
|
-
expect(retryButton).toBeInTheDocument()
|
|
417
|
-
})
|
|
418
|
-
|
|
419
|
-
it("should provide clear status indicators", async () => {
|
|
420
|
-
const user = userEvent.setup()
|
|
421
|
-
render(<MediaPlayer src="test.mp4" />)
|
|
422
|
-
|
|
423
|
-
// Should show loading status
|
|
424
|
-
expect(screen.getByRole("status")).toHaveTextContent(/ready/i)
|
|
425
|
-
|
|
426
|
-
// Should show playing status
|
|
427
|
-
const playButton = screen.getByRole("button", { name: /play/i })
|
|
428
|
-
await user.click(playButton)
|
|
429
|
-
|
|
430
|
-
await waitFor(() => {
|
|
431
|
-
expect(screen.getByRole("status")).toHaveTextContent(/playing/i)
|
|
432
|
-
})
|
|
433
|
-
|
|
434
|
-
// Should show buffering status
|
|
435
|
-
const video = screen.getByRole("application") as HTMLVideoElement
|
|
436
|
-
act(() => {
|
|
437
|
-
const waitingEvent = new Event("waiting")
|
|
438
|
-
video.dispatchEvent(waitingEvent)
|
|
439
|
-
})
|
|
440
|
-
|
|
441
|
-
await waitFor(() => {
|
|
442
|
-
expect(screen.getByRole("status")).toHaveTextContent(/buffering/i)
|
|
443
|
-
})
|
|
444
|
-
})
|
|
445
|
-
|
|
446
|
-
it("should use consistent navigation patterns", async () => {
|
|
447
|
-
const user = userEvent.setup()
|
|
448
|
-
render(<MediaPlayer src="test.mp4" />)
|
|
449
|
-
|
|
450
|
-
// Controls should be in consistent order
|
|
451
|
-
const controls = screen.getAllByRole("button")
|
|
452
|
-
const playButton = controls.find((btn) => btn.getAttribute("aria-label")?.includes("play"))
|
|
453
|
-
const volumeButton = controls.find((btn) =>
|
|
454
|
-
btn.getAttribute("aria-label")?.includes("volume")
|
|
455
|
-
)
|
|
456
|
-
const fullscreenButton = controls.find((btn) =>
|
|
457
|
-
btn.getAttribute("aria-label")?.includes("fullscreen")
|
|
458
|
-
)
|
|
459
|
-
|
|
460
|
-
expect(playButton).toBeInTheDocument()
|
|
461
|
-
expect(volumeButton).toBeInTheDocument()
|
|
462
|
-
expect(fullscreenButton).toBeInTheDocument()
|
|
463
|
-
|
|
464
|
-
// Tab order should be logical
|
|
465
|
-
playButton?.focus()
|
|
466
|
-
expect(playButton).toHaveFocus()
|
|
467
|
-
|
|
468
|
-
await user.keyboard("{Tab}")
|
|
469
|
-
expect(volumeButton).toHaveFocus()
|
|
470
|
-
|
|
471
|
-
await user.keyboard("{Tab}")
|
|
472
|
-
expect(fullscreenButton).toHaveFocus()
|
|
473
|
-
})
|
|
474
|
-
|
|
475
|
-
it("should provide help and instructions", () => {
|
|
476
|
-
render(<MediaPlayer src="test.mp4" />)
|
|
477
|
-
|
|
478
|
-
// Should have help button
|
|
479
|
-
const helpButton = screen.getByRole("button", { name: /help/i })
|
|
480
|
-
expect(helpButton).toBeInTheDocument()
|
|
481
|
-
|
|
482
|
-
// Should have keyboard shortcut indicator
|
|
483
|
-
const shortcutsIndicator = screen.getByText(/press \? for keyboard shortcuts/i)
|
|
484
|
-
expect(shortcutsIndicator).toBeInTheDocument()
|
|
485
|
-
})
|
|
486
|
-
})
|
|
487
|
-
|
|
488
|
-
describe("Accessibility Testing Utilities", () => {
|
|
489
|
-
it("should validate ARIA attributes correctly", () => {
|
|
490
|
-
const { container } = render(<MediaPlayer src="test.mp4" />)
|
|
491
|
-
|
|
492
|
-
const ariaViolations = a11yTestUtils.testAriaAttributes(container)
|
|
493
|
-
expect(ariaViolations).toHaveLength(0)
|
|
494
|
-
})
|
|
495
|
-
|
|
496
|
-
it("should validate keyboard navigation correctly", async () => {
|
|
497
|
-
const { container } = render(<MediaPlayer src="test.mp4" />)
|
|
498
|
-
|
|
499
|
-
const keyboardIssues = a11yTestUtils.testKeyboardNavigation(container)
|
|
500
|
-
expect(keyboardIssues).toHaveLength(0)
|
|
501
|
-
})
|
|
502
|
-
|
|
503
|
-
it("should detect screen reader announcements", () => {
|
|
504
|
-
const { container } = render(<MediaPlayer src="test.mp4" />)
|
|
505
|
-
|
|
506
|
-
const announcements = a11yTestUtils.testScreenReaderAnnouncements(container)
|
|
507
|
-
expect(announcements).toBeInstanceOf(Array)
|
|
508
|
-
})
|
|
509
|
-
})
|
|
510
|
-
})
|