Skip to content

Commit fd2e474

Browse files
fix(tests): correct import paths in error-states Playwright tests
Change relative import paths to absolute paths in page.evaluate() context. In Playwright's browser context, dynamic imports need absolute paths starting with '/' to resolve correctly. Before: const { api } = await import('./js/api.js'); After: const { api } = await import('/js/api.js'); This fixes 26 failing tests in error-states.spec.js that were attempting to test API error handling but failing due to module resolution issues. All 32 tests in error-states.spec.js now pass locally. Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
1 parent 4ff1d00 commit fd2e474

1 file changed

Lines changed: 14 additions & 14 deletions

File tree

app/frontend/tests/error-states.spec.js

Lines changed: 14 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -119,7 +119,7 @@ test.describe('API Error Responses', () => {
119119
// Attempt to access non-existent track via store method
120120
const result = await page.evaluate(async () => {
121121
try {
122-
const { api } = await import('./js/api.js');
122+
const { api } = await import('/js/api.js');
123123
await api.library.getTrack(9999);
124124
return { success: true };
125125
} catch (e) {
@@ -143,7 +143,7 @@ test.describe('API Error Responses', () => {
143143
// Attempt to get stats
144144
const result = await page.evaluate(async () => {
145145
try {
146-
const { api } = await import('./js/api.js');
146+
const { api } = await import('/js/api.js');
147147
await api.library.getStats();
148148
return { success: true };
149149
} catch (e) {
@@ -166,7 +166,7 @@ test.describe('API Error Responses', () => {
166166
// Empty responses should be handled as null
167167
const result = await page.evaluate(async () => {
168168
try {
169-
const { api } = await import('./js/api.js');
169+
const { api } = await import('/js/api.js');
170170
const stats = await api.library.getStats();
171171
return { success: true, result: stats };
172172
} catch (e) {
@@ -365,7 +365,7 @@ test.describe('Playlist API Error Handling', () => {
365365
// Attempt to create playlist
366366
const result = await page.evaluate(async () => {
367367
try {
368-
const { api } = await import('./js/api.js');
368+
const { api } = await import('/js/api.js');
369369
await api.playlists.create('Test Playlist');
370370
return { success: true };
371371
} catch (e) {
@@ -392,7 +392,7 @@ test.describe('Playlist API Error Handling', () => {
392392

393393
const result = await page.evaluate(async () => {
394394
try {
395-
const { api } = await import('./js/api.js');
395+
const { api } = await import('/js/api.js');
396396
await api.playlists.delete(1);
397397
return { success: true };
398398
} catch (e) {
@@ -423,7 +423,7 @@ test.describe('Queue API Error Handling', () => {
423423

424424
const result = await page.evaluate(async () => {
425425
try {
426-
const { api } = await import('./js/api.js');
426+
const { api } = await import('/js/api.js');
427427
await api.queue.add([1, 2, 3]);
428428
return { success: true };
429429
} catch (e) {
@@ -446,7 +446,7 @@ test.describe('Queue API Error Handling', () => {
446446

447447
const result = await page.evaluate(async () => {
448448
try {
449-
const { api } = await import('./js/api.js');
449+
const { api } = await import('/js/api.js');
450450
await api.queue.clear();
451451
return { success: true };
452452
} catch (e) {
@@ -590,7 +590,7 @@ test.describe('Settings Error Handling', () => {
590590
// Attempt to get settings
591591
const result = await page.evaluate(async () => {
592592
try {
593-
const { api } = await import('./js/api.js');
593+
const { api } = await import('/js/api.js');
594594
await api.settings.getAll();
595595
return { success: true };
596596
} catch (e) {
@@ -632,7 +632,7 @@ test.describe('Last.fm API Error Handling', () => {
632632

633633
const result = await page.evaluate(async () => {
634634
try {
635-
const { api } = await import('./js/api.js');
635+
const { api } = await import('/js/api.js');
636636
await api.lastfm.scrobble({
637637
artist: 'Test Artist',
638638
track: 'Test Track',
@@ -660,7 +660,7 @@ test.describe('Last.fm API Error Handling', () => {
660660

661661
const result = await page.evaluate(async () => {
662662
try {
663-
const { api } = await import('./js/api.js');
663+
const { api } = await import('/js/api.js');
664664
await api.lastfm.getAuthUrl();
665665
return { success: true };
666666
} catch (e) {
@@ -696,7 +696,7 @@ test.describe('Favorites API Error Handling', () => {
696696

697697
const result = await page.evaluate(async () => {
698698
try {
699-
const { api } = await import('./js/api.js');
699+
const { api } = await import('/js/api.js');
700700
await api.favorites.add(1);
701701
return { success: true };
702702
} catch (e) {
@@ -723,7 +723,7 @@ test.describe('Favorites API Error Handling', () => {
723723

724724
const result = await page.evaluate(async () => {
725725
try {
726-
const { api } = await import('./js/api.js');
726+
const { api } = await import('/js/api.js');
727727
await api.favorites.remove(9999);
728728
return { success: true };
729729
} catch (e) {
@@ -755,7 +755,7 @@ test.describe('Watched Folders API Error Handling', () => {
755755

756756
const result = await page.evaluate(async () => {
757757
try {
758-
const { api } = await import('./js/api.js');
758+
const { api } = await import('/js/api.js');
759759
await api.watchedFolders.list();
760760
return { success: true };
761761
} catch (e) {
@@ -782,7 +782,7 @@ test.describe('Watched Folders API Error Handling', () => {
782782

783783
const result = await page.evaluate(async () => {
784784
try {
785-
const { api } = await import('./js/api.js');
785+
const { api } = await import('/js/api.js');
786786
await api.watchedFolders.add('/nonexistent/path');
787787
return { success: true };
788788
} catch (e) {

0 commit comments

Comments
 (0)