fix: clear lyrics-review cache on job status change
renderLyricsReview was caching its job ID only in the done path, allowing stale data to persist when switching between done/running/failed jobs. Now clears the cache in the failed and not-done branches so a previously- viewed done job always re-fetches when re-selected. Regression test: test_lyrics_review_cache_clears_on_job_status_change verifies both branches clear the cache key before rendering placeholders.
This commit is contained in:
@@ -872,10 +872,12 @@ function buildLyricsReview(data) {
|
||||
async function renderLyricsReview(job) {
|
||||
const box = document.getElementById("lyrics-review");
|
||||
if (job.status === "failed") {
|
||||
delete box.dataset.jobId;
|
||||
box.replaceChildren(emptyNote("job failed — nothing to review"));
|
||||
return;
|
||||
}
|
||||
if (job.status !== "done") {
|
||||
delete box.dataset.jobId;
|
||||
box.replaceChildren(emptyNote("waiting for this song to finish…"));
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -433,6 +433,23 @@ def test_index_lyrics_review_uses_endash_for_time_ranges():
|
||||
assert "–" in body
|
||||
|
||||
|
||||
def test_lyrics_review_cache_clears_on_job_status_change():
|
||||
"""Regression: switching between done/failed/running jobs must clear the
|
||||
cache so a previously-viewed done job re-fetches when re-selected."""
|
||||
html = _index_html()
|
||||
body = _fn_body(html, "renderLyricsReview")
|
||||
# The "failed" branch must clear the cache before rendering the placeholder
|
||||
assert re.search(
|
||||
r'if\s*\(\s*job\.status\s*===\s*"failed"\s*\)\s*\{[^}]*'
|
||||
r'delete\s+box\.dataset\.jobId',
|
||||
body, re.S), "failed branch must delete cache key"
|
||||
# The "not done" (queued/running) branch must clear the cache before rendering
|
||||
assert re.search(
|
||||
r'if\s*\(\s*job\.status\s*!==\s*"done"\s*\)\s*\{[^}]*'
|
||||
r'delete\s+box\.dataset\.jobId',
|
||||
body, re.S), "not done branch must delete cache key"
|
||||
|
||||
|
||||
def test_index_has_copy_path_control():
|
||||
assert "copy-path" in _index_html()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user