11import { expect , test } from 'vite-plus/test' ;
22import { page , userEvent } from 'vite-plus/test/browser' ;
33
4- import { beforeEachSetup } from './test-helpers' ;
4+ import { beforeEachSetup , goToLibrary , scanLibrary } from './test-helpers' ;
55
66beforeEachSetup ( ) ;
77
88test ( 'The library tab should display all tracks' , async ( ) => {
9- // Fake the import of tracks
10- await page . getByTestId ( 'footer-settings-link' ) . click ( ) ;
11- await page . getByTestId ( 'scan-library-button' ) . click ( ) ;
12- await page . getByTestId ( 'footer-library-link' ) . click ( ) ;
9+ await scanLibrary ( ) ;
10+ await goToLibrary ( ) ;
1311
1412 // Ensure we have the 3 test-tracks, but no more
1513 await expect . element ( page . getByTestId ( 'track-row-0' ) ) . toBeInTheDocument ( ) ;
@@ -29,10 +27,8 @@ test('The library tab should display all tracks', async () => {
2927} ) ;
3028
3129test ( 'Tracks should selectable via click + modifiers' , async ( ) => {
32- // Fake the import of tracks
33- await page . getByTestId ( 'footer-settings-link' ) . click ( ) ;
34- await page . getByTestId ( 'scan-library-button' ) . click ( ) ;
35- await page . getByTestId ( 'footer-library-link' ) . click ( ) ;
30+ await scanLibrary ( ) ;
31+ await goToLibrary ( ) ;
3632
3733 const firstTrack = page . getByTestId ( / t r a c k - r o w - / ) . first ( ) ;
3834 const secondTrack = page . getByTestId ( / t r a c k - r o w - / ) . nth ( 1 ) ;
@@ -72,10 +68,8 @@ test('Tracks should selectable via click + modifiers', async () => {
7268} ) ;
7369
7470test ( 'Tracks should be selectable via keyboard only (after a single selection)' , async ( ) => {
75- // Fake the import of tracks
76- await page . getByTestId ( 'footer-settings-link' ) . click ( ) ;
77- await page . getByTestId ( 'scan-library-button' ) . click ( ) ;
78- await page . getByTestId ( 'footer-library-link' ) . click ( ) ;
71+ await scanLibrary ( ) ;
72+ await goToLibrary ( ) ;
7973
8074 const firstTrack = page . getByTestId ( / t r a c k - r o w - / ) . first ( ) ;
8175 const secondTrack = page . getByTestId ( / t r a c k - r o w - / ) . nth ( 1 ) ;
@@ -131,10 +125,8 @@ test('Tracks should be selectable via keyboard only (after a single selection)',
131125} ) ;
132126
133127test ( 'Search should filter tracks in the library' , async ( ) => {
134- // Fake the import of tracks
135- await page . getByTestId ( 'footer-settings-link' ) . click ( ) ;
136- await page . getByTestId ( 'scan-library-button' ) . click ( ) ;
137- await page . getByTestId ( 'footer-library-link' ) . click ( ) ;
128+ await scanLibrary ( ) ;
129+ await goToLibrary ( ) ;
138130
139131 const search = page . getByTestId ( 'library-search' ) ;
140132 const searchClear = page . getByTestId ( 'library-search-clear' ) ;
@@ -174,10 +166,8 @@ test('Search should filter tracks in the library', async () => {
174166} ) ;
175167
176168test ( 'Column headers should sort tracks in the library' , async ( ) => {
177- // Fake the import of tracks
178- await page . getByTestId ( 'footer-settings-link' ) . click ( ) ;
179- await page . getByTestId ( 'scan-library-button' ) . click ( ) ;
180- await page . getByTestId ( 'footer-library-link' ) . click ( ) ;
169+ await scanLibrary ( ) ;
170+ await goToLibrary ( ) ;
181171
182172 const firstTrack = page . getByTestId ( / t r a c k - r o w - / ) . first ( ) ;
183173 const secondTrack = page . getByTestId ( / t r a c k - r o w - / ) . nth ( 1 ) ;
0 commit comments