Skip to content

Commit 7e176f5

Browse files
test (e2e): update 6 stale test selectors and assertions in statistics and lastfm specs
Update statistics.spec.js selectors to match current UI classes (text-[13px] not text-sm, w-14 not w-20), fix locale-formatted number assertion, and rewrite date range test for custom dropdown. Narrow lastfm.spec.js toast filter to avoid strict mode violation from multiple matching elements. Closes TASK-305
1 parent 1b25660 commit 7e176f5

File tree

3 files changed

+39
-12
lines changed

3 files changed

+39
-12
lines changed

app/frontend/tests/lastfm.spec.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1239,7 +1239,7 @@ test.describe('Last.fm Integration', () => {
12391239
await page.click('[data-testid="lastfm-import-loved"]');
12401240
await page.waitForTimeout(1000);
12411241

1242-
const authError = page.locator('[data-testid="toast-container"] div').filter({ hasText: /failed/i });
1242+
const authError = page.locator('[data-testid="toast-container"] div').filter({ hasText: /Failed to import loved tracks/i });
12431243
await expect(authError).toBeVisible({ timeout: 3000 });
12441244
});
12451245

app/frontend/tests/statistics.spec.js

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -129,7 +129,7 @@ test.describe('Statistics Dashboard', () => {
129129
const cards = page.locator('[data-testid="stats-overview-cards"]');
130130
await expect(cards).toBeVisible();
131131

132-
await expect(page.locator('[data-testid="stats-total-plays"]')).toHaveText('1234');
132+
await expect(page.locator('[data-testid="stats-total-plays"]')).toHaveText('1,234');
133133
await expect(page.locator('[data-testid="stats-artists-played"]')).toHaveText('42');
134134
await expect(page.locator('[data-testid="stats-listening-time"]')).toContainText('4d');
135135
});
@@ -140,8 +140,8 @@ test.describe('Statistics Dashboard', () => {
140140
const artistsSection = page.locator('[data-testid="stats-top-artists"]');
141141
await expect(artistsSection).toBeVisible();
142142

143-
// Check artists are listed in order
144-
const artistNames = artistsSection.locator('.text-sm.truncate');
143+
// Check artists are listed in order (artist name spans use text-[13px] + truncate)
144+
const artistNames = artistsSection.locator('.truncate');
145145
await expect(artistNames.nth(0)).toHaveText('Radiohead');
146146
await expect(artistNames.nth(1)).toHaveText('Pink Floyd');
147147
await expect(artistNames.nth(2)).toHaveText('Tool');
@@ -154,7 +154,7 @@ test.describe('Statistics Dashboard', () => {
154154
await expect(playsSection).toBeVisible();
155155

156156
// Check year labels
157-
const labels = playsSection.locator('.tabular-nums.w-20');
157+
const labels = playsSection.locator('.tabular-nums.w-14');
158158
await expect(labels).toHaveCount(3);
159159
});
160160

@@ -165,7 +165,7 @@ test.describe('Statistics Dashboard', () => {
165165
await expect(genreSection).toBeVisible();
166166

167167
// Check genre names
168-
const genreNames = genreSection.locator('.text-sm.truncate');
168+
const genreNames = genreSection.locator('.truncate');
169169
await expect(genreNames.nth(0)).toHaveText('Rock');
170170
await expect(genreNames.nth(1)).toHaveText('Electronic');
171171
await expect(genreNames.nth(2)).toHaveText('Jazz');
@@ -174,8 +174,10 @@ test.describe('Statistics Dashboard', () => {
174174
test('date range filter invokes with correct range', async ({ page }) => {
175175
await navigateToStats(page);
176176

177-
// Change to Last 7 Days
178-
await page.locator('[data-testid="stats-date-range"]').selectOption('Last7Days');
177+
// Change to Last 7 Days (custom dropdown, not a <select>)
178+
await page.locator('[data-testid="stats-date-range"]').click();
179+
await page.waitForTimeout(300);
180+
await page.locator('button', { hasText: 'Last 7 days' }).click();
179181
await page.waitForTimeout(500);
180182

181183
// Verify the invoke was called with the correct range

backlog/tasks/task-305 - Fix-6-pre-existing-E2E-test-failures-in-statistics-and-lastfm-specs.md

Lines changed: 29 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,10 @@
11
---
22
id: TASK-305
33
title: Fix 6 pre-existing E2E test failures in statistics and lastfm specs
4-
status: To Do
4+
status: Done
55
assignee: []
66
created_date: '2026-03-31 05:38'
7+
updated_date: '2026-03-31 05:49'
78
labels:
89
- testing
910
- e2e
@@ -13,6 +14,7 @@ references:
1314
- app/frontend/tests/statistics.spec.js
1415
- app/frontend/tests/lastfm.spec.js
1516
priority: medium
17+
ordinal: 750
1618
---
1719

1820
## Description
@@ -33,7 +35,30 @@ priority: medium
3335

3436
## Acceptance Criteria
3537
<!-- AC:BEGIN -->
36-
- [ ] #1 All 5 statistics.spec.js tests pass
37-
- [ ] #2 lastfm.spec.js 'should require authentication for import' test passes
38-
- [ ] #3 No other tests regress (full suite green minus any unrelated pre-existing failures)
38+
- [x] #1 All 5 statistics.spec.js tests pass
39+
- [x] #2 lastfm.spec.js 'should require authentication for import' test passes
40+
- [x] #3 No other tests regress (full suite green minus any unrelated pre-existing failures)
3941
<!-- AC:END -->
42+
43+
## Final Summary
44+
45+
<!-- SECTION:FINAL_SUMMARY:BEGIN -->
46+
## Summary
47+
48+
Fixed all 6 pre-existing E2E test failures across `statistics.spec.js` (5 tests) and `lastfm.spec.js` (1 test). Root causes were stale CSS selectors, locale formatting mismatch, a `<select>` changed to custom dropdown, and an overly broad toast text filter.
49+
50+
### Changes
51+
52+
**`statistics.spec.js`** (5 fixes):
53+
1. `overview cards render with data`: Changed expected text from `'1234'` to `'1,234'` (UI uses `toLocaleString()`)
54+
2. `top artists list renders`: Changed selector `.text-sm.truncate``.truncate` (HTML uses `text-[13px]` not `text-sm`)
55+
3. `plays-over-time chart renders`: Changed selector `.tabular-nums.w-20``.tabular-nums.w-14` (HTML uses `w-14`)
56+
4. `genre breakdown renders`: Changed selector `.text-sm.truncate``.truncate` (same as #2)
57+
5. `date range filter invokes with correct range`: Rewrote from `selectOption('Last7Days')` (native select) to click-based interaction (custom dropdown button)
58+
59+
**`lastfm.spec.js`** (1 fix):
60+
6. `should require authentication for import`: Changed toast filter from `/failed/i` to `/Failed to import loved tracks/i` to avoid strict mode violation when multiple failure toasts are present
61+
62+
### Verification
63+
- Full E2E suite: **728 passed, 2 skipped, 0 failures**
64+
<!-- SECTION:FINAL_SUMMARY:END -->

0 commit comments

Comments
 (0)