1- import { test , expect } from '@playwright/test' ;
1+ import { expect , test } from '@playwright/test' ;
2+ import { getAlpineStore , waitForAlpine } from './fixtures/helpers.js' ;
23import {
3- waitForAlpine ,
4- getAlpineStore ,
5- } from './fixtures/helpers.js' ;
6- import {
7- createPlaylistState ,
8- setupPlaylistMocks ,
94 clearApiCalls ,
5+ createPlaylistState ,
106 findApiCalls ,
7+ setupPlaylistMocks ,
118} from './fixtures/mock-playlists.js' ;
129
1310test . describe ( 'Sidebar Navigation' , ( ) => {
@@ -104,7 +101,9 @@ test.describe('Sidebar Collapse/Expand', () => {
104101 const initialBox = await sidebar . boundingBox ( ) ;
105102
106103 // Click collapse button
107- const collapseButton = page . locator ( 'aside button[title*="Collapse"], aside button[title*="Expand"]' ) . last ( ) ;
104+ const collapseButton = page . locator (
105+ 'aside button[title*="Collapse"], aside button[title*="Expand"]' ,
106+ ) . last ( ) ;
108107 await collapseButton . click ( ) ;
109108
110109 // Wait for transition
@@ -129,7 +128,9 @@ test.describe('Sidebar Collapse/Expand', () => {
129128 const collapsedBox = await sidebar . boundingBox ( ) ;
130129
131130 // Click expand button
132- const expandButton = page . locator ( 'aside button[title*="Expand"], aside button[title*="Collapse"]' ) . last ( ) ;
131+ const expandButton = page . locator (
132+ 'aside button[title*="Expand"], aside button[title*="Collapse"]' ,
133+ ) . last ( ) ;
133134 await expandButton . click ( ) ;
134135
135136 // Wait for transition
@@ -457,14 +458,36 @@ test.describe('Playlist Feature Parity (task-150)', () => {
457458 test . beforeEach ( async ( { page } ) => {
458459 clearApiCalls ( playlistState ) ;
459460 await setupPlaylistMocks ( page , playlistState ) ;
461+ // Mock library count endpoint (pagination support)
462+ await page . route ( / \/ a p i \/ l i b r a r y \/ c o u n t ( \? .* ) ? $ / , async ( route ) => {
463+ await route . fulfill ( {
464+ status : 200 ,
465+ contentType : 'application/json' ,
466+ body : JSON . stringify ( { total : 2 , total_duration : 380 } ) ,
467+ } ) ;
468+ } ) ;
460469 await page . route ( / \/ a p i \/ l i b r a r y ( \? .* ) ? $ / , async ( route ) => {
461470 await route . fulfill ( {
462471 status : 200 ,
463472 contentType : 'application/json' ,
464473 body : JSON . stringify ( {
465474 tracks : [
466- { id : 101 , title : 'Track A' , artist : 'Artist A' , album : 'Album A' , duration : 180 , filepath : '/music/track-a.mp3' } ,
467- { id : 102 , title : 'Track B' , artist : 'Artist B' , album : 'Album B' , duration : 200 , filepath : '/music/track-b.mp3' } ,
475+ {
476+ id : 101 ,
477+ title : 'Track A' ,
478+ artist : 'Artist A' ,
479+ album : 'Album A' ,
480+ duration : 180 ,
481+ filepath : '/music/track-a.mp3' ,
482+ } ,
483+ {
484+ id : 102 ,
485+ title : 'Track B' ,
486+ artist : 'Artist B' ,
487+ album : 'Album B' ,
488+ duration : 200 ,
489+ filepath : '/music/track-b.mp3' ,
490+ } ,
468491 ] ,
469492 total : 2 ,
470493 } ) ,
@@ -545,7 +568,9 @@ test.describe('Playlist Feature Parity (task-150)', () => {
545568
546569 test ( 'AC#6: should show drag handle in playlist view' , async ( { page } ) => {
547570 await page . evaluate ( ( ) => {
548- const libraryBrowser = window . Alpine . $data ( document . querySelector ( '[x-data="libraryBrowser"]' ) ) ;
571+ const libraryBrowser = window . Alpine . $data (
572+ document . querySelector ( '[x-data="libraryBrowser"]' ) ,
573+ ) ;
549574 libraryBrowser . currentPlaylistId = 1 ;
550575 } ) ;
551576
@@ -557,7 +582,9 @@ test.describe('Playlist Feature Parity (task-150)', () => {
557582
558583 test ( 'AC#6: should hide drag handle outside playlist view' , async ( { page } ) => {
559584 await page . evaluate ( ( ) => {
560- const libraryBrowser = window . Alpine . $data ( document . querySelector ( '[x-data="libraryBrowser"]' ) ) ;
585+ const libraryBrowser = window . Alpine . $data (
586+ document . querySelector ( '[x-data="libraryBrowser"]' ) ,
587+ ) ;
561588 libraryBrowser . currentPlaylistId = null ;
562589 } ) ;
563590
@@ -829,7 +856,7 @@ test.describe('Playlist Multi-Select and Batch Delete (task-161)', () => {
829856 await playlist1 . click ( { modifiers : [ 'Meta' ] } ) ;
830857 await playlistList . focus ( ) ;
831858
832- page . once ( 'dialog' , async dialog => {
859+ page . once ( 'dialog' , async ( dialog ) => {
833860 expect ( dialog . type ( ) ) . toBe ( 'confirm' ) ;
834861 expect ( dialog . message ( ) ) . toContain ( 'Delete playlist' ) ;
835862 await dialog . dismiss ( ) ;
@@ -845,7 +872,7 @@ test.describe('Playlist Multi-Select and Batch Delete (task-161)', () => {
845872 await playlist1 . click ( { modifiers : [ 'Meta' ] } ) ;
846873 await playlistList . focus ( ) ;
847874
848- page . once ( 'dialog' , async dialog => {
875+ page . once ( 'dialog' , async ( dialog ) => {
849876 expect ( dialog . type ( ) ) . toBe ( 'confirm' ) ;
850877 await dialog . dismiss ( ) ;
851878 } ) ;
@@ -860,7 +887,7 @@ test.describe('Playlist Multi-Select and Batch Delete (task-161)', () => {
860887 await playlist1 . click ( { modifiers : [ 'Meta' ] } ) ;
861888 await playlistList . focus ( ) ;
862889
863- page . once ( 'dialog' , async dialog => {
890+ page . once ( 'dialog' , async ( dialog ) => {
864891 await dialog . accept ( ) ;
865892 } ) ;
866893
@@ -878,7 +905,7 @@ test.describe('Playlist Multi-Select and Batch Delete (task-161)', () => {
878905 await playlist1 . click ( { modifiers : [ 'Meta' ] } ) ;
879906 await playlistList . focus ( ) ;
880907
881- page . once ( 'dialog' , async dialog => {
908+ page . once ( 'dialog' , async ( dialog ) => {
882909 await dialog . dismiss ( ) ;
883910 } ) ;
884911
@@ -942,7 +969,7 @@ test.describe('Playlist Multi-Select and Batch Delete (task-161)', () => {
942969 await playlist2 . click ( { modifiers : [ 'Meta' ] } ) ;
943970 await playlistList . focus ( ) ;
944971
945- page . once ( 'dialog' , async dialog => {
972+ page . once ( 'dialog' , async ( dialog ) => {
946973 expect ( dialog . message ( ) ) . toContain ( 'Delete selected playlists' ) ;
947974 expect ( dialog . message ( ) ) . toContain ( 'Test Playlist 1' ) ;
948975 expect ( dialog . message ( ) ) . toContain ( 'Test Playlist 2' ) ;
0 commit comments