Skip to content

test: add Playwright UI tests and expand Kotlin test coverage#17

Merged
twangodev merged 4 commits intomainfrom
test/playwright-kotlin-coverage
Apr 5, 2026
Merged

test: add Playwright UI tests and expand Kotlin test coverage#17
twangodev merged 4 commits intomainfrom
test/playwright-kotlin-coverage

Conversation

@twangodev
Copy link
Copy Markdown
Owner

@twangodev twangodev commented Apr 5, 2026

Summary by CodeRabbit

  • Tests

    • Added comprehensive Playwright UI test suites covering audio/video playback, seeking, keyboard controls, state transitions, and format-specific cases.
    • Expanded unit tests for player HTML/config generation and string-escaping logic; extended editor provider tests for additional media types.
  • Chores

    • Automated UI tests integrated into CI to run after build (reports uploaded on failure); added local test scripts and ignored Playwright output directories.

Copilot AI review requested due to automatic review settings April 5, 2026 16:34
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented Apr 5, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 5615e8f8-c792-40e6-8dce-f7f9661a0a5b

📥 Commits

Reviewing files that changed from the base of the PR and between 64f79a5 and e273268.

📒 Files selected for processing (3)
  • ui/tests/audio-player.spec.ts
  • ui/tests/fixtures.ts
  • ui/tests/video-player.spec.ts
✅ Files skipped from review due to trivial changes (1)
  • ui/tests/video-player.spec.ts
🚧 Files skipped from review as they are similar to previous changes (2)
  • ui/tests/fixtures.ts
  • ui/tests/audio-player.spec.ts

📝 Walkthrough

Walkthrough

Replaces the Gradle/Robot-based UI test setup with Playwright end-to-end tests, removes the legacy workflow and Gradle UI run configuration, exposes a testable HTML-script builder, and adds Playwright config, fixtures, and multiple E2E and unit tests for player behavior and escaping.

Changes

Cohort / File(s) Summary
CI Workflows
\.github/workflows/build.yml, \.github/workflows/run-ui-tests.yml
Added ui-test job to build.yml to run Playwright after build; removed legacy run-ui-tests.yml that ran Gradle/Robot UI tests.
Build config
build.gradle.kts
Removed intellijPlatformTesting / runIdeForUiTests registration, its JVM argument provider, and Robot Server plugin registration.
Source: test helper exposure
src/main/kotlin/dev/twango/jetplay/browser/PlayerHtmlLoader.kt
Moved buildConfigScript from a private instance method to an internal companion-object function for testability.
Unit tests (Kotlin)
src/test/kotlin/dev/twango/jetplay/browser/PlayerBridgeEscapeTest.kt, src/test/kotlin/dev/twango/jetplay/browser/PlayerHtmlLoaderTest.kt
Added tests for PlayerBridge.escapeJs and PlayerHtmlLoader.buildConfigScript (escaping, optional fields, UI strings, injected openLinkJs).
Unit tests (Kotlin) — media provider
src/test/kotlin/dev/twango/jetplay/editor/MediaFileEditorProviderTest.kt
Expanded tests to accept additional media extensions (mkv,avi,mov,flac,aac,opus) and reject non-media (png,json).
Playwright setup
ui/playwright.config.ts, ui/package.json, ui/.gitignore, ui/public/assets
Added Playwright config (Chromium, baseURL, webServer), npm scripts (test, test:ui), gitignore entries for reports, and ui/public/assets pointer.
Playwright fixtures
ui/tests/fixtures.ts
Introduced JetplayConfig type and loadApp fixture that injects window.jetplay via page.addInitScript and navigates to /; re-exports expect.
E2E tests — audio
ui/tests/audio-player.spec.ts
Added audio-player E2E tests: play toggle, skip forward/back, keyboard controls, seek bar interactions.
E2E tests — video
ui/tests/video-player.spec.ts
Added video-player E2E tests: click-to-play, overlay button, keyboard controls, seeking, control-bar auto-hide, time display checks.
E2E tests — states & transitions
ui/tests/states.spec.ts, ui/tests/transitions.spec.ts
Added tests for ready/downloading/transcoding/error states and global-callback-driven transitions (jetplayReady, jetplayStartTranscoding, jetplayError, progress updates).

Sequence Diagram(s)

sequenceDiagram
  participant CI as CI Job
  participant WS as Dev Web Server
  participant PW as Playwright Runner
  participant Browser as Headless Chromium

  CI->>WS: start dev server (`npm run dev`) on :5173
  CI->>PW: run `npx playwright test`
  PW->>Browser: launch Chromium, addInitScript to inject `window.jetplay`
  Browser->>WS: request `/` (baseURL)
  WS-->>Browser: serve app (index.html + JS)
  Browser->>PW: execute test actions (clicks, keypresses, media asserts)
  PW-->>CI: report results (upload `ui/playwright-report` artifact on failure)
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~25 minutes

Possibly related PRs

Poem

🐰 I hop through pages, scripts aglow,
I seed window.jetplay where tests must go.
Playwright paws click, keyboard taps and sings,
Audio, video — I check all things.
Hooray — green runs, and CI happily springs! 🎉

🚥 Pre-merge checks | ✅ 2 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (2 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately and concisely summarizes the main changes: adding Playwright UI tests and expanding Kotlin test coverage, which aligns with the changeset's introduction of multiple UI test files and new Kotlin test classes.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch test/playwright-kotlin-coverage

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds Playwright-based UI coverage for the bundled Svelte player UI and expands Kotlin-side unit tests around player HTML/config generation, while removing the previous IntelliJ UI-robot workflow.

Changes:

  • Add Playwright test harness + new UI specs for player states, transitions, and audio/video controls.
  • Integrate Playwright into UI package scripts and CI (new UI Tests job), and ignore Playwright artifacts.
  • Expand Kotlin test coverage for accepted media extensions and JS escaping/config script generation.

Reviewed changes

Copilot reviewed 15 out of 17 changed files in this pull request and generated 4 comments.

Show a summary per file
File Description
ui/tests/video-player.spec.ts Adds E2E coverage for video playback controls, keyboard shortcuts, and overlay visibility.
ui/tests/audio-player.spec.ts Adds E2E coverage for audio playback controls, shortcuts, and seeking.
ui/tests/states.spec.ts Validates UI rendering for ready/downloading/loading/error states and custom strings.
ui/tests/transitions.spec.ts Verifies window bridge callbacks transition the UI between states/players.
ui/tests/fixtures.ts Introduces a Playwright fixture to inject window.jetplay config before navigation.
ui/playwright.config.ts Defines Playwright config, baseURL, and a dev-server-backed webServer.
ui/package.json Adds Playwright scripts and dependency.
ui/package-lock.json Locks Playwright dependency tree.
ui/.gitignore Ignores Playwright report and test-results outputs.
src/test/kotlin/dev/twango/jetplay/editor/MediaFileEditorProviderTest.kt Expands extension acceptance/rejection coverage.
src/test/kotlin/dev/twango/jetplay/browser/PlayerHtmlLoaderTest.kt Adds unit tests for generated config script contents/escaping.
src/test/kotlin/dev/twango/jetplay/browser/PlayerBridgeEscapeTest.kt Adds focused unit tests for JS escaping behavior.
src/main/kotlin/dev/twango/jetplay/browser/PlayerHtmlLoader.kt Makes config-script builder testable (moved to companion).
build.gradle.kts Removes IDE UI-test runner configuration tied to the old robot-based approach.
.github/workflows/run-ui-tests.yml Removes the legacy IntelliJ UI-robot workflow.
.github/workflows/build.yml Adds a CI job to run Playwright UI tests and upload the report on failure.
Files not reviewed (1)
  • ui/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ui/tests/audio-player.spec.ts
Comment thread ui/tests/video-player.spec.ts Outdated
Comment thread ui/tests/video-player.spec.ts Outdated
Comment thread ui/tests/video-player.spec.ts
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🧹 Nitpick comments (3)
ui/playwright.config.ts (1)

3-16: Configuration looks good with one consideration.

The Playwright setup is well-structured with appropriate CI-specific retries and web server configuration.

Consider adding Firefox and/or WebKit to the test matrix in the future to catch browser-specific rendering issues, especially since this is a media player UI:

💡 Optional: Multi-browser configuration
 use: {
   baseURL: 'http://localhost:5173',
-  browserName: 'chromium',
 },
+projects: [
+  { name: 'chromium', use: { browserName: 'chromium' } },
+  { name: 'firefox', use: { browserName: 'firefox' } },
+],
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ui/playwright.config.ts` around lines 3 - 16, The Playwright config currently
pins browserName to 'chromium' in the defineConfig block (use.browserName) which
limits cross-browser coverage; update the config to run tests across multiple
browsers by replacing the single-use browserName setting with a projects matrix
(or multiple defineConfig projects) that includes 'chromium', 'firefox', and
optionally 'webkit', while keeping existing settings (testDir, timeout, retries,
webServer) intact and reusing reuseExistingServer behavior for CI; locate the
defineConfig export and modify the use/browserName or add projects entries to
introduce the multi-browser configuration.
.github/workflows/build.yml (1)

88-90: Consider removing the build dependency for faster CI.

The ui-test job depends on build but doesn't consume any artifacts from it. The UI tests run against the dev server (npm run dev), not the built plugin. Removing this dependency would allow ui-test to run in parallel with the build, reducing overall CI time.

♻️ Suggested change
   ui-test:
     name: UI Tests
-    needs: [ build ]
     runs-on: ubuntu-latest
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In @.github/workflows/build.yml around lines 88 - 90, The ui-test job currently
lists a dependency on the build job which is unnecessary; update the GitHub
Actions workflow by removing "build" from the needs array of the ui-test job
(job name: ui-test) so it no longer depends on the build job and can run in
parallel—ensure you only modify the needs: [ build ] entry for ui-test and leave
other job relationships unchanged.
ui/tests/fixtures.ts (1)

3-18: Avoid duplicating the jetplay config contract in tests.

JetplayConfig here mirrors ui/src/global.d.ts and can drift over time. Prefer reusing a single source of truth (for example, a shared exported type used by both global.d.ts and tests).

♻️ Suggested direction
-interface JetplayConfig {
-  mediaUrl?: string
-  fileName?: string
-  fileExtension?: string
-  isVideo?: boolean
-  state?: 'downloading' | 'loading' | 'ready' | 'error'
-  errorMessage?: string
-  transcodingReason?: string
-  downloadingReason?: string
-  ui?: {
-    downloadingLabel?: string
-    transcodingLabel?: string
-    transcodingTip?: string
-    errorTitle?: string
-  }
-}
+type JetplayConfig = NonNullable<Window['jetplay']>
🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@ui/tests/fixtures.ts` around lines 3 - 18, The test file defines a duplicate
JetplayConfig interface which can drift from the canonical type; replace this
local JetplayConfig with the shared exported type from the app (e.g., the type
declared in ui/src/global.d.ts), import or reference that single exported symbol
in the tests instead of redefining it, and remove the local interface so tests
consume the authoritative contract (update any test imports/fixtures to use the
shared type name).
🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@ui/tests/audio-player.spec.ts`:
- Around line 26-58: The tests are flaky because they interact with the audio
element before metadata is loaded; update both tests to wait for media readiness
by awaiting the audio element's loadedmetadata (or readyState >= HAVE_METADATA)
before performing seeks or reads: in the "skip forward" test, after starting
playback (the play button click) await the audio's metadata ready event before
capturing timeBefore and clicking skipForwardBtn; in the "skip backward" test,
after setting el.currentTime = 15 await the audio's metadata ready event (or
verify readyState) before clicking skipBackBtn and asserting timeAfter; use the
existing audio locator and the skipForwardBtn/skipBackBtn variables to place the
waits so seeks are effective.

---

Nitpick comments:
In @.github/workflows/build.yml:
- Around line 88-90: The ui-test job currently lists a dependency on the build
job which is unnecessary; update the GitHub Actions workflow by removing "build"
from the needs array of the ui-test job (job name: ui-test) so it no longer
depends on the build job and can run in parallel—ensure you only modify the
needs: [ build ] entry for ui-test and leave other job relationships unchanged.

In `@ui/playwright.config.ts`:
- Around line 3-16: The Playwright config currently pins browserName to
'chromium' in the defineConfig block (use.browserName) which limits
cross-browser coverage; update the config to run tests across multiple browsers
by replacing the single-use browserName setting with a projects matrix (or
multiple defineConfig projects) that includes 'chromium', 'firefox', and
optionally 'webkit', while keeping existing settings (testDir, timeout, retries,
webServer) intact and reusing reuseExistingServer behavior for CI; locate the
defineConfig export and modify the use/browserName or add projects entries to
introduce the multi-browser configuration.

In `@ui/tests/fixtures.ts`:
- Around line 3-18: The test file defines a duplicate JetplayConfig interface
which can drift from the canonical type; replace this local JetplayConfig with
the shared exported type from the app (e.g., the type declared in
ui/src/global.d.ts), import or reference that single exported symbol in the
tests instead of redefining it, and remove the local interface so tests consume
the authoritative contract (update any test imports/fixtures to use the shared
type name).
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: e61ab866-3c30-4f85-a0ab-0f520378317c

📥 Commits

Reviewing files that changed from the base of the PR and between 61a0e0d and 0eac5c0.

⛔ Files ignored due to path filters (1)
  • ui/package-lock.json is excluded by !**/package-lock.json
📒 Files selected for processing (16)
  • .github/workflows/build.yml
  • .github/workflows/run-ui-tests.yml
  • build.gradle.kts
  • src/main/kotlin/dev/twango/jetplay/browser/PlayerHtmlLoader.kt
  • src/test/kotlin/dev/twango/jetplay/browser/PlayerBridgeEscapeTest.kt
  • src/test/kotlin/dev/twango/jetplay/browser/PlayerHtmlLoaderTest.kt
  • src/test/kotlin/dev/twango/jetplay/editor/MediaFileEditorProviderTest.kt
  • ui/.gitignore
  • ui/package.json
  • ui/playwright.config.ts
  • ui/public/assets
  • ui/tests/audio-player.spec.ts
  • ui/tests/fixtures.ts
  • ui/tests/states.spec.ts
  • ui/tests/transitions.spec.ts
  • ui/tests/video-player.spec.ts
💤 Files with no reviewable changes (2)
  • .github/workflows/run-ui-tests.yml
  • build.gradle.kts

Comment thread ui/tests/audio-player.spec.ts
@codecov
Copy link
Copy Markdown

codecov Bot commented Apr 5, 2026

Codecov Report

✅ All modified and coverable lines are covered by tests.

Files with missing lines Coverage Δ
...lin/dev/twango/jetplay/browser/PlayerHtmlLoader.kt 76.92% <100.00%> (+76.92%) ⬆️

... and 2 files with indirect coverage changes

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@github-actions
Copy link
Copy Markdown
Contributor

github-actions Bot commented Apr 5, 2026

Qodana Community for JVM

It seems all right 👌

No new problems were found according to the checks applied

💡 Qodana analysis was run in the pull request mode: only the changed files were checked

View the detailed Qodana report

To be able to view the detailed Qodana report, you can either:

To get *.log files or any other Qodana artifacts, run the action with upload-result option set to true,
so that the action will upload the files as the job artifacts:

      - name: 'Qodana Scan'
        uses: JetBrains/qodana-action@v2025.1.1
        with:
          upload-result: true
Contact Qodana team

Contact us at qodana-support@jetbrains.com

Copilot AI review requested due to automatic review settings April 5, 2026 17:26
Copy link
Copy Markdown

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Copilot reviewed 15 out of 17 changed files in this pull request and generated 4 comments.

Files not reviewed (1)
  • ui/package-lock.json: Language not supported

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread ui/tests/audio-player.spec.ts Outdated
Comment thread ui/tests/audio-player.spec.ts Outdated
Comment thread ui/tests/audio-player.spec.ts
Comment thread ui/tests/video-player.spec.ts Outdated
@twangodev twangodev merged commit ef4a51f into main Apr 5, 2026
14 checks passed
@twangodev twangodev deleted the test/playwright-kotlin-coverage branch April 5, 2026 18:33
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants