fix(settings): keep full refresh busy across phases
Centralize persisted full-refresh phase detection so the Settings rebuild button stays in its refreshing state during Laya, projection, writing, and EPG phases. Refs #44 Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@ -1,6 +1,16 @@
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const { layaFallbackMessage, present } = require('../public/js/services/liveAnalysisPresentation.js');
|
||||
const { isFullRefreshPhase, layaFallbackMessage, present } = require('../public/js/services/liveAnalysisPresentation.js');
|
||||
|
||||
test('classifies every persisted full refresh phase centrally', () => {
|
||||
const phases = [
|
||||
'refreshing_live_sources', 'laya_identity', 'laya_language', 'projecting', 'writing',
|
||||
'refreshing_epg_sources', 'matching_epg', 'laya_epg_matching', 'writing_epg_matches'
|
||||
];
|
||||
assert.ok(phases.every(isFullRefreshPhase));
|
||||
assert.equal(isFullRefreshPhase('complete'), false);
|
||||
assert.equal(isFullRefreshPhase(''), false);
|
||||
});
|
||||
|
||||
test('presents determinate channel analysis progress', () => {
|
||||
const view = present({ status: 'building', phase: 'projecting', processed: 25, total: 100 });
|
||||
|
||||
57
test/t44FullRefreshLiveRegression.test.js
Normal file
57
test/t44FullRefreshLiveRegression.test.js
Normal file
@ -0,0 +1,57 @@
|
||||
const test = require('node:test');
|
||||
const assert = require('node:assert/strict');
|
||||
const fs = require('node:fs');
|
||||
const path = require('node:path');
|
||||
const { JSDOM } = require('jsdom');
|
||||
|
||||
const root = path.resolve(__dirname, '..');
|
||||
const readPublicScript = relativePath => fs.readFileSync(path.join(root, 'public', relativePath), 'utf8');
|
||||
|
||||
function createSettingsDom() {
|
||||
const dom = new JSDOM(`<!doctype html>
|
||||
<button type="button" id="live-check-new-button">Check for new streams</button>
|
||||
<button type="button" id="live-rebuild-catalog-button">Run full refresh</button>
|
||||
<button type="button" id="live-analysis-button">Analyze channels</button>
|
||||
<div id="live-analysis-status" role="status"></div>
|
||||
<div id="live-analysis-progress" hidden>
|
||||
<div id="live-analysis-progress-track"><span id="live-analysis-progress-bar"></span></div>
|
||||
<div id="live-analysis-progress-text"></div>
|
||||
</div>
|
||||
<div id="live-analysis-fallback"></div>
|
||||
<button type="button" id="live-analysis-details-toggle" hidden></button>
|
||||
<pre id="live-analysis-error-details" hidden></pre>
|
||||
`, { url: 'http://nodecast.test/', runScripts: 'outside-only' });
|
||||
const { window } = dom;
|
||||
window.eval(readPublicScript('js/services/liveAnalysisPresentation.js'));
|
||||
window.eval(`${readPublicScript('js/pages/Settings.js')}\nwindow.SettingsPage = SettingsPage;`);
|
||||
return { dom, window };
|
||||
}
|
||||
|
||||
test('full refresh keeps the rebuild action visibly busy during Laya language detection from persisted status', () => {
|
||||
const { dom, window } = createSettingsDom();
|
||||
const settingsPage = Object.create(window.SettingsPage.prototype);
|
||||
settingsPage.app = { player: { settings: { languageDetectionMode: 'laya' } } };
|
||||
settingsPage.layaStatus = { modelPresent: true, runtimeAvailable: true };
|
||||
settingsPage.currentLiveAnalysisAction = '';
|
||||
|
||||
try {
|
||||
settingsPage.renderLiveAnalysisStatus({
|
||||
status: 'building',
|
||||
phase: 'laya_language',
|
||||
phaseProcessed: 2,
|
||||
phaseTotal: 4,
|
||||
processed: 0,
|
||||
total: 128
|
||||
});
|
||||
|
||||
assert.equal(window.document.getElementById('live-analysis-status').textContent, 'Detecting stream languages…');
|
||||
assert.equal(window.document.getElementById('live-analysis-progress-text').textContent, 'Language batch 2 of 4 · 50%');
|
||||
assert.equal(
|
||||
window.document.getElementById('live-rebuild-catalog-button').textContent,
|
||||
'Refreshing…',
|
||||
'full refresh should remain visibly active while the backend publishes laya_language'
|
||||
);
|
||||
} finally {
|
||||
dom.window.close();
|
||||
}
|
||||
});
|
||||
Reference in New Issue
Block a user