Merge feature/restart-update-modal-commit-details
@@ -19,7 +19,10 @@
19
19
20
20
### Git authoring
21
21
- When starting work on something, create a feature or fix branch
22
- When concrete, complete steps are made, create a commit in that branch
22
- When concrete, complete steps are made, create a commit in that branch as you work
23
- Don't wait until everything is finished before you commit, just commit as soon as you complete a step before moving on to the next step
24
- Keep commit subjects short and to the point (what changed)
25
- When useful, include a longer commit description body that explains the change in user-facing terms (what users will notice), not only implementation detail
23
26
- Try to commit frequently, chunking work into individual steps
24
27
- When all work is done, merge the branch into master using a non-fast-forward merge commit (`git merge --no-ff`), and then delete it so only master remains
25
28
- Ensure you don't leave old branches you've made in git and that everything is merged neatly.
@@ -19,7 +19,10 @@19
19
20
### Git authoring
20
### Git authoring
21
- When starting work on something, create a feature or fix branch
21
- When starting work on something, create a feature or fix branch
22
- When concrete, complete steps are made, create a commit in that branch
22
- When concrete, complete steps are made, create a commit in that branch as you work
23
- Don't wait until everything is finished before you commit, just commit as soon as you complete a step before moving on to the next step
24
- Keep commit subjects short and to the point (what changed)
25
- When useful, include a longer commit description body that explains the change in user-facing terms (what users will notice), not only implementation detail
23
- Try to commit frequently, chunking work into individual steps
26
- Try to commit frequently, chunking work into individual steps
24
- When all work is done, merge the branch into master using a non-fast-forward merge commit (`git merge --no-ff`), and then delete it so only master remains
27
- When all work is done, merge the branch into master using a non-fast-forward merge commit (`git merge --no-ff`), and then delete it so only master remains
25
- Ensure you don't leave old branches you've made in git and that everything is merged neatly.
28
- Ensure you don't leave old branches you've made in git and that everything is merged neatly.
@@ -57,7 +57,7 @@
57
57
- ensureUserFolders(userPath) - Ensures configured userPath exists and creates per-user subfolders for all current users.
58
58
- GET /api/admin/config - Returns admin config including userPath and userFolderSizeLimit (bytes, null for unlimited).
59
59
- PUT /api/admin/config - Persists paths plus userPath/userFolderSizeLimit and ensures per-user folders exist.
60
- GET /api/admin/update-status - Returns { underSystemd, commitsAhead[] }. Detects systemd via INVOCATION_ID env var; runs git fetch + git log to find commits ahead of HEAD. Used by the frontend to set button label (Shut down server / Restart Server / Restart & Update).
60
- GET /api/admin/update-status - Returns { underSystemd, commitsAhead[] } where commitsAhead contains non-merge commits as {hash, subject, body}; detects systemd via INVOCATION_ID env var and runs git fetch + git log against origin/HEAD for Restart & Update messaging.
61
61
62
62
## server/routes/files.js
63
63
- GET /api/files/roots - Returns readable roots with display label (alias when configured), originalName, and path.
@@ -156,8 +156,10 @@
156
156
- api(method, path, body, opts) - Central API caller; refreshes local session timestamp on successful authenticated calls.
157
157
- performLogout() - Explicit logout path that revokes server session and clears local session state.
158
158
- initAuth() - Restores prior session when valid and auto-logins without credential prompt.
159
- showConfirm(title, message, { html, okLabel }) - In-page confirm dialog; returns Promise<boolean>. `html=true` renders message as innerHTML (caller must escape user data). `okLabel` overrides the OK button text. Use instead of window.confirm().
159
- showConfirm(title, message, { html, okLabel, modalClass }) - In-page confirm dialog; returns Promise<boolean>. `html=true` renders message as innerHTML (caller must escape user data), `okLabel` overrides the OK button text, and `modalClass` temporarily widens/restyles the dialog for rich content.
160
160
- escHtml(s) - HTML-escapes a string (& < > ") for safe use with innerHTML in confirm messages.
161
- normaliseUpdateCommits(commitsAhead) - Normalises update-status commit entries from string/object formats into {hash, subject, body} for consistent UI rendering.
162
- renderUpdateCommitListHtml(commitsAhead) - Builds rich HTML for Restart & Update commit entries with bold subject headers and optional body descriptions.
161
163
- showPrompt(title, message, defaultValue) - In-page text-input dialog; returns Promise<string|null>. Use instead of window.prompt().
162
164
- showOverwrite(filename) - In-page overwrite-decision dialog for file conflicts; returns Promise<'yes'|'no'|'all'|'none'>.
163
165
- splitNameExt(name) - Client-side filename splitter used for local conflict rename suggestions.
@@ -57,7 +57,7 @@57
- ensureUserFolders(userPath) - Ensures configured userPath exists and creates per-user subfolders for all current users.
57
- ensureUserFolders(userPath) - Ensures configured userPath exists and creates per-user subfolders for all current users.
58
- GET /api/admin/config - Returns admin config including userPath and userFolderSizeLimit (bytes, null for unlimited).
58
- GET /api/admin/config - Returns admin config including userPath and userFolderSizeLimit (bytes, null for unlimited).
59
- PUT /api/admin/config - Persists paths plus userPath/userFolderSizeLimit and ensures per-user folders exist.
59
- PUT /api/admin/config - Persists paths plus userPath/userFolderSizeLimit and ensures per-user folders exist.
60
- GET /api/admin/update-status - Returns { underSystemd, commitsAhead[] }. Detects systemd via INVOCATION_ID env var; runs git fetch + git log to find commits ahead of HEAD. Used by the frontend to set button label (Shut down server / Restart Server / Restart & Update).
60
- GET /api/admin/update-status - Returns { underSystemd, commitsAhead[] } where commitsAhead contains non-merge commits as {hash, subject, body}; detects systemd via INVOCATION_ID env var and runs git fetch + git log against origin/HEAD for Restart & Update messaging.
61
61
62
## server/routes/files.js
62
## server/routes/files.js
63
- GET /api/files/roots - Returns readable roots with display label (alias when configured), originalName, and path.
63
- GET /api/files/roots - Returns readable roots with display label (alias when configured), originalName, and path.
@@ -156,8 +156,10 @@156
- api(method, path, body, opts) - Central API caller; refreshes local session timestamp on successful authenticated calls.
156
- api(method, path, body, opts) - Central API caller; refreshes local session timestamp on successful authenticated calls.
157
- performLogout() - Explicit logout path that revokes server session and clears local session state.
157
- performLogout() - Explicit logout path that revokes server session and clears local session state.
158
- initAuth() - Restores prior session when valid and auto-logins without credential prompt.
158
- initAuth() - Restores prior session when valid and auto-logins without credential prompt.
159
- showConfirm(title, message, { html, okLabel }) - In-page confirm dialog; returns Promise<boolean>. `html=true` renders message as innerHTML (caller must escape user data). `okLabel` overrides the OK button text. Use instead of window.confirm().
159
- showConfirm(title, message, { html, okLabel, modalClass }) - In-page confirm dialog; returns Promise<boolean>. `html=true` renders message as innerHTML (caller must escape user data), `okLabel` overrides the OK button text, and `modalClass` temporarily widens/restyles the dialog for rich content.
160
- escHtml(s) - HTML-escapes a string (& < > ") for safe use with innerHTML in confirm messages.
160
- escHtml(s) - HTML-escapes a string (& < > ") for safe use with innerHTML in confirm messages.
161
- normaliseUpdateCommits(commitsAhead) - Normalises update-status commit entries from string/object formats into {hash, subject, body} for consistent UI rendering.
162
- renderUpdateCommitListHtml(commitsAhead) - Builds rich HTML for Restart & Update commit entries with bold subject headers and optional body descriptions.
161
- showPrompt(title, message, defaultValue) - In-page text-input dialog; returns Promise<string|null>. Use instead of window.prompt().
163
- showPrompt(title, message, defaultValue) - In-page text-input dialog; returns Promise<string|null>. Use instead of window.prompt().
162
- showOverwrite(filename) - In-page overwrite-decision dialog for file conflicts; returns Promise<'yes'|'no'|'all'|'none'>.
164
- showOverwrite(filename) - In-page overwrite-decision dialog for file conflicts; returns Promise<'yes'|'no'|'all'|'none'>.
163
- splitNameExt(name) - Client-side filename splitter used for local conflict rename suggestions.
165
- splitNameExt(name) - Client-side filename splitter used for local conflict rename suggestions.
@@ -1340,15 +1340,18 @@ function toast (msg, type = '')
1340
1340
* @param {string} message
1341
1341
* @returns {Promise<boolean>} true = OK, false = Cancel
1342
1342
*/
1343
function showConfirm (title, message, { html = false, okLabel = null } = {})
1343
function showConfirm (title, message, { html = false, okLabel = null, modalClass = '' } = {})
1344
1344
{
1345
1345
return new Promise((resolve) =>
1346
1346
{
1347
1347
const overlay = document.getElementById('confirm-modal');
1348
const dialogEl = overlay ? overlay.querySelector('.modal') : null;
1349
const className = typeof modalClass === 'string' ? modalClass.trim() : '';
1348
1350
document.getElementById('confirm-modal-title').textContent = title;
1349
1351
const msgEl = document.getElementById('confirm-modal-message');
1350
1352
if (html) msgEl.innerHTML = message;
1351
1353
else msgEl.textContent = message;
1354
if (dialogEl && className) dialogEl.classList.add(className);
1352
1355
overlay.classList.remove('hidden');
1353
1356
1354
1357
const ok = document.getElementById('confirm-modal-ok');
@@ -1360,6 +1363,7 @@ function showConfirm (title, message, { html = false, okLabel = null } = {})
1360
1363
function finish (result)
1361
1364
{
1362
1365
overlay.classList.add('hidden');
1366
if (dialogEl && className) dialogEl.classList.remove(className);
1363
1367
ok.textContent = prevOkLabel;
1364
1368
ok.removeEventListener('click', onOk);
1365
1369
cancel.removeEventListener('click', onCancel);
@@ -1383,6 +1387,61 @@ function escHtml (s)
1383
1387
.replace(/"/g, '"');
1384
1388
}
1385
1389
1390
function normaliseUpdateCommits (commitsAhead)
1391
{
1392
if (!Array.isArray(commitsAhead)) return [];
1393
1394
const out = [];
1395
for (const raw of commitsAhead)
1396
{
1397
if (typeof raw === 'string')
1398
{
1399
const line = raw.trim();
1400
if (!line) continue;
1401
const match = line.match(/^([0-9a-f]{7,40})\s+(.+)$/i);
1402
out.push({
1403
hash: match ? match[1] : '',
1404
subject: match ? match[2].trim() : line,
1405
body: '',
1406
});
1407
continue;
1408
}
1409
1410
if (!raw || typeof raw !== 'object') continue;
1411
const subject = String(raw.subject || '').trim();
1412
if (!subject) continue;
1413
out.push({
1414
hash: String(raw.hash || '').trim(),
1415
subject,
1416
body: String(raw.body || '').trim(),
1417
});
1418
}
1419
1420
return out;
1421
}
1422
1423
function renderUpdateCommitListHtml (commitsAhead)
1424
{
1425
const commits = normaliseUpdateCommits(commitsAhead);
1426
if (!commits.length) return '';
1427
1428
const commitItems = commits.map((commit) =>
1429
{
1430
const hashLabel = commit.hash
1431
? `<span class="update-commit-hash">${escHtml(commit.hash.slice(0, 7))}</span>`
1432
: '';
1433
const subjectLabel = `<span class="update-commit-subject">${escHtml(commit.subject)}</span>`;
1434
1435
const bodyHtml = commit.body
1436
? `<p class="update-commit-body">${escHtml(commit.body).replace(/\n/g, '<br/>')}</p>`
1437
: '';
1438
1439
return `<article class="update-commit-item"><h3>${hashLabel}${hashLabel ? ' ' : ''}${subjectLabel}</h3>${bodyHtml}</article>`;
1440
}).join('');
1441
1442
return `<div class="update-commit-list">${commitItems}</div>`;
1443
}
1444
1386
1445
/**
1387
1446
* Show a text-input dialog.
1388
1447
* @param {string} title
@@ -6757,9 +6816,9 @@ function wireEvents ()
6757
6816
else
6758
6817
{
6759
6818
// Under systemd, updates available.
6760
const commitList = status.commitsAhead.map(c => escHtml(c)).join('<br/>');
6819
const commitList = renderUpdateCommitListHtml(status.commitsAhead);
6761
6820
const msg = `Updates available:<br/><br/>${commitList}<br/><br/>Update now?`;
6762
if (!await showConfirm('Restart & Update', msg, { html: true, okLabel: 'Update now' })) return;
6821
if (!await showConfirm('Restart & Update', msg, { html: true, okLabel: 'Update now', modalClass: 'confirm-modal-wide' })) return;
6763
6822
}
6764
6823
6765
6824
try
@@ -1340,15 +1340,18 @@ function toast (msg, type = '')1340
* @param {string} message1340
* @param {string} message1341
* @returns {Promise<boolean>} true = OK, false = Cancel1341
* @returns {Promise<boolean>} true = OK, false = Cancel1342
*/1342
*/1343
function showConfirm (title, message, { html = false, okLabel = null } = {})1343
function showConfirm (title, message, { html = false, okLabel = null, modalClass = '' } = {})1344
{1344
{1345
return new Promise((resolve) =>1345
return new Promise((resolve) =>1346
{1346
{1347
const overlay = document.getElementById('confirm-modal');1347
const overlay = document.getElementById('confirm-modal');1348
const dialogEl = overlay ? overlay.querySelector('.modal') : null;1349
const className = typeof modalClass === 'string' ? modalClass.trim() : '';1348
document.getElementById('confirm-modal-title').textContent = title;1350
document.getElementById('confirm-modal-title').textContent = title;1349
const msgEl = document.getElementById('confirm-modal-message');1351
const msgEl = document.getElementById('confirm-modal-message');1350
if (html) msgEl.innerHTML = message;1352
if (html) msgEl.innerHTML = message;1351
else msgEl.textContent = message;1353
else msgEl.textContent = message;1354
if (dialogEl && className) dialogEl.classList.add(className);1352
overlay.classList.remove('hidden');1355
overlay.classList.remove('hidden');1353
1356
1354
const ok = document.getElementById('confirm-modal-ok');1357
const ok = document.getElementById('confirm-modal-ok');@@ -1360,6 +1363,7 @@ function showConfirm (title, message, { html = false, okLabel = null } = {})1360
function finish (result)1363
function finish (result)1361
{1364
{1362
overlay.classList.add('hidden');1365
overlay.classList.add('hidden');1366
if (dialogEl && className) dialogEl.classList.remove(className);1363
ok.textContent = prevOkLabel;1367
ok.textContent = prevOkLabel;1364
ok.removeEventListener('click', onOk);1368
ok.removeEventListener('click', onOk);1365
cancel.removeEventListener('click', onCancel);1369
cancel.removeEventListener('click', onCancel);@@ -1383,6 +1387,61 @@ function escHtml (s)1383
.replace(/"/g, '"');1387
.replace(/"/g, '"');1384
}1388
}1385
1389
1390
function normaliseUpdateCommits (commitsAhead)1391
{1392
if (!Array.isArray(commitsAhead)) return [];1393
1394
const out = [];1395
for (const raw of commitsAhead)1396
{1397
if (typeof raw === 'string')1398
{1399
const line = raw.trim();1400
if (!line) continue;1401
const match = line.match(/^([0-9a-f]{7,40})\s+(.+)$/i);1402
out.push({1403
hash: match ? match[1] : '',1404
subject: match ? match[2].trim() : line,1405
body: '',1406
});1407
continue;1408
}1409
1410
if (!raw || typeof raw !== 'object') continue;1411
const subject = String(raw.subject || '').trim();1412
if (!subject) continue;1413
out.push({1414
hash: String(raw.hash || '').trim(),1415
subject,1416
body: String(raw.body || '').trim(),1417
});1418
}1419
1420
return out;1421
}1422
1423
function renderUpdateCommitListHtml (commitsAhead)1424
{1425
const commits = normaliseUpdateCommits(commitsAhead);1426
if (!commits.length) return '';1427
1428
const commitItems = commits.map((commit) =>1429
{1430
const hashLabel = commit.hash1431
? `<span class="update-commit-hash">${escHtml(commit.hash.slice(0, 7))}</span>`1432
: '';1433
const subjectLabel = `<span class="update-commit-subject">${escHtml(commit.subject)}</span>`;1434
1435
const bodyHtml = commit.body1436
? `<p class="update-commit-body">${escHtml(commit.body).replace(/\n/g, '<br/>')}</p>`1437
: '';1438
1439
return `<article class="update-commit-item"><h3>${hashLabel}${hashLabel ? ' ' : ''}${subjectLabel}</h3>${bodyHtml}</article>`;1440
}).join('');1441
1442
return `<div class="update-commit-list">${commitItems}</div>`;1443
}1444
1386
/**1445
/**1387
* Show a text-input dialog.1446
* Show a text-input dialog.1388
* @param {string} title1447
* @param {string} title@@ -6757,9 +6816,9 @@ function wireEvents ()6757
else6816
else6758
{6817
{6759
// Under systemd, updates available.6818
// Under systemd, updates available.6760
const commitList = status.commitsAhead.map(c => escHtml(c)).join('<br/>');6819
const commitList = renderUpdateCommitListHtml(status.commitsAhead);6761
const msg = `Updates available:<br/><br/>${commitList}<br/><br/>Update now?`;6820
const msg = `Updates available:<br/><br/>${commitList}<br/><br/>Update now?`;6762
if (!await showConfirm('Restart & Update', msg, { html: true, okLabel: 'Update now' })) return;6821
if (!await showConfirm('Restart & Update', msg, { html: true, okLabel: 'Update now', modalClass: 'confirm-modal-wide' })) return;6763
}6822
}6764
6823
6765
try6824
try@@ -811,6 +811,10 @@ button.danger.admin-update-highlight {
811
811
width: min(340px, 94vw);
812
812
}
813
813
814
#confirm-modal .modal.confirm-modal-wide {
815
width: min(760px, 94vw);
816
}
817
814
818
.modal h2 {
815
819
font-size: 1.3rem;
816
820
margin-bottom: 1.25rem;
@@ -836,6 +840,45 @@ button.danger.admin-update-highlight {
836
840
color: var(--text);
837
841
}
838
842
843
.update-commit-list {
844
max-height: min(48vh, 420px);
845
overflow: auto;
846
border: 1px solid var(--border);
847
border-radius: 10px;
848
background: var(--bg);
849
padding: 0.6rem 0.8rem;
850
}
851
852
.update-commit-item + .update-commit-item {
853
margin-top: 0.9rem;
854
padding-top: 0.9rem;
855
border-top: 1px solid var(--border);
856
}
857
858
.update-commit-item h3 {
859
margin: 0;
860
font-size: 1.06rem;
861
font-weight: 700;
862
color: var(--text);
863
}
864
865
.update-commit-hash {
866
color: var(--text-muted);
867
font-weight: 600;
868
font-size: 0.9rem;
869
}
870
871
.update-commit-subject {
872
color: var(--text);
873
}
874
875
.update-commit-body {
876
margin: 0.45rem 0 0;
877
font-size: 0.94rem;
878
color: var(--text-muted);
879
line-height: 1.45;
880
}
881
839
882
/* =========================================================
840
883
FOLDER ICON PICKER
841
884
========================================================= */
@@ -811,6 +811,10 @@ button.danger.admin-update-highlight {811
width: min(340px, 94vw);
811
width: min(340px, 94vw);
812
}
812
}
813
813
814
#confirm-modal .modal.confirm-modal-wide {
815
width: min(760px, 94vw);
816
}
817
814
.modal h2 {
818
.modal h2 {
815
font-size: 1.3rem;
819
font-size: 1.3rem;
816
margin-bottom: 1.25rem;
820
margin-bottom: 1.25rem;
@@ -836,6 +840,45 @@ button.danger.admin-update-highlight {836
color: var(--text);
840
color: var(--text);
837
}
841
}
838
842
843
.update-commit-list {
844
max-height: min(48vh, 420px);
845
overflow: auto;
846
border: 1px solid var(--border);
847
border-radius: 10px;
848
background: var(--bg);
849
padding: 0.6rem 0.8rem;
850
}
851
852
.update-commit-item + .update-commit-item {
853
margin-top: 0.9rem;
854
padding-top: 0.9rem;
855
border-top: 1px solid var(--border);
856
}
857
858
.update-commit-item h3 {
859
margin: 0;
860
font-size: 1.06rem;
861
font-weight: 700;
862
color: var(--text);
863
}
864
865
.update-commit-hash {
866
color: var(--text-muted);
867
font-weight: 600;
868
font-size: 0.9rem;
869
}
870
871
.update-commit-subject {
872
color: var(--text);
873
}
874
875
.update-commit-body {
876
margin: 0.45rem 0 0;
877
font-size: 0.94rem;
878
color: var(--text-muted);
879
line-height: 1.45;
880
}
881
839
/* =========================================================
882
/* =========================================================
840
FOLDER ICON PICKER
883
FOLDER ICON PICKER
841
========================================================= */
884
========================================================= */
@@ -384,10 +384,19 @@ router.get('/update-status', async (req, res) =>
384
384
{
385
385
await execFileAsync('git', ['fetch', '--quiet', 'origin'], { cwd: PROJECT_ROOT });
386
386
const { stdout } = await execFileAsync(
387
'git', ['log', 'HEAD..origin/HEAD', '--oneline', '--no-decorate'],
387
'git', ['log', 'HEAD..origin/HEAD', '--no-decorate', '--no-merges', '--pretty=format:%H%x1f%s%x1f%b%x1e'],
388
388
{ cwd: PROJECT_ROOT },
389
389
);
390
commitsAhead = stdout.trim().split('\n').filter(Boolean);
390
const records = String(stdout || '').split('\x1e').map(line => line.trim()).filter(Boolean);
391
commitsAhead = records.map((record) =>
392
{
393
const parts = record.split('\x1f');
394
const hash = String(parts[0] || '').trim();
395
const subject = String(parts[1] || '').trim();
396
const body = String(parts.slice(2).join('\x1f') || '').trim();
397
if (!subject) return null;
398
return { hash, subject, body };
399
}).filter(Boolean);
391
400
}
392
401
catch
393
402
{
@@ -384,10 +384,19 @@ router.get('/update-status', async (req, res) =>384
{384
{385
await execFileAsync('git', ['fetch', '--quiet', 'origin'], { cwd: PROJECT_ROOT });385
await execFileAsync('git', ['fetch', '--quiet', 'origin'], { cwd: PROJECT_ROOT });386
const { stdout } = await execFileAsync(386
const { stdout } = await execFileAsync(387
'git', ['log', 'HEAD..origin/HEAD', '--oneline', '--no-decorate'],387
'git', ['log', 'HEAD..origin/HEAD', '--no-decorate', '--no-merges', '--pretty=format:%H%x1f%s%x1f%b%x1e'],388
{ cwd: PROJECT_ROOT },388
{ cwd: PROJECT_ROOT },389
);389
);390
commitsAhead = stdout.trim().split('\n').filter(Boolean);390
const records = String(stdout || '').split('\x1e').map(line => line.trim()).filter(Boolean);391
commitsAhead = records.map((record) =>392
{393
const parts = record.split('\x1f');394
const hash = String(parts[0] || '').trim();395
const subject = String(parts[1] || '').trim();396
const body = String(parts.slice(2).join('\x1f') || '').trim();397
if (!subject) return null;398
return { hash, subject, body };399
}).filter(Boolean);391
}400
}392
catch401
catch393
{402
{@@ -475,16 +475,37 @@ describe('GET /api/admin/update-status', () =>
475
475
process.env.INVOCATION_ID = 'test-invocation-id';
476
476
// git fetch succeeds, then git log returns two commits.
477
477
let callCount = 0;
478
let logArgs = null;
478
479
mockExecFileImpl = (_cmd, _args, _opts, cb) =>
479
480
{
480
481
callCount++;
481
482
if (callCount === 1) cb(null, { stdout: '', stderr: '' }); // git fetch
482
else cb(null, { stdout: 'abc1234 Fix bug\ndef5678 Add feature\n', stderr: '' }); // git log
483
else
484
{
485
logArgs = _args;
486
cb(null, {
487
stdout: 'abc1234567890\x1fFix bug\x1fThis fixes an issue users were hitting.\x1e'
488
+ 'def5678901234\x1fAdd feature\x1fUsers can now do the new thing.\x1e',
489
stderr: '',
490
});
491
}
483
492
};
484
493
const { status, body } = await req('GET', '/api/admin/update-status');
485
494
expect(status).toBe(200);
486
495
expect(body.underSystemd).toBe(true);
487
expect(body.commitsAhead).toEqual(['abc1234 Fix bug', 'def5678 Add feature']);
496
expect(logArgs).toContain('--no-merges');
497
expect(body.commitsAhead).toEqual([
498
{
499
hash: 'abc1234567890',
500
subject: 'Fix bug',
501
body: 'This fixes an issue users were hitting.',
502
},
503
{
504
hash: 'def5678901234',
505
subject: 'Add feature',
506
body: 'Users can now do the new thing.',
507
},
508
]);
488
509
});
489
510
490
511
test('returns underSystemd=true and empty commitsAhead when git is up to date', async () =>
@@ -475,16 +475,37 @@ describe('GET /api/admin/update-status', () =>475
process.env.INVOCATION_ID = 'test-invocation-id';475
process.env.INVOCATION_ID = 'test-invocation-id';476
// git fetch succeeds, then git log returns two commits.476
// git fetch succeeds, then git log returns two commits.477
let callCount = 0;477
let callCount = 0;478
let logArgs = null;478
mockExecFileImpl = (_cmd, _args, _opts, cb) =>479
mockExecFileImpl = (_cmd, _args, _opts, cb) =>479
{480
{480
callCount++;481
callCount++;481
if (callCount === 1) cb(null, { stdout: '', stderr: '' }); // git fetch482
if (callCount === 1) cb(null, { stdout: '', stderr: '' }); // git fetch482
else cb(null, { stdout: 'abc1234 Fix bug\ndef5678 Add feature\n', stderr: '' }); // git log483
else484
{485
logArgs = _args;486
cb(null, {487
stdout: 'abc1234567890\x1fFix bug\x1fThis fixes an issue users were hitting.\x1e'488
+ 'def5678901234\x1fAdd feature\x1fUsers can now do the new thing.\x1e',489
stderr: '',490
});491
}483
};492
};484
const { status, body } = await req('GET', '/api/admin/update-status');493
const { status, body } = await req('GET', '/api/admin/update-status');485
expect(status).toBe(200);494
expect(status).toBe(200);486
expect(body.underSystemd).toBe(true);495
expect(body.underSystemd).toBe(true);487
expect(body.commitsAhead).toEqual(['abc1234 Fix bug', 'def5678 Add feature']);496
expect(logArgs).toContain('--no-merges');497
expect(body.commitsAhead).toEqual([498
{499
hash: 'abc1234567890',500
subject: 'Fix bug',501
body: 'This fixes an issue users were hitting.',502
},503
{504
hash: 'def5678901234',505
subject: 'Add feature',506
body: 'Users can now do the new thing.',507
},508
]);488
});509
});489
510
490
test('returns underSystemd=true and empty commitsAhead when git is up to date', async () =>511
test('returns underSystemd=true and empty commitsAhead when git is up to date', async () =>@@ -1154,7 +1154,10 @@ describe('page load smoke test', () =>
1154
1154
meFixture = { username: 'admin', isAdmin: true, permissions: {} };
1155
1155
updateStatusFixture = {
1156
1156
underSystemd: true,
1157
commitsAhead: ['a1b2c3 Update one', 'd4e5f6 Update two'],
1157
commitsAhead: [
1158
{ hash: 'a1b2c3d4e5f6', subject: 'Update one', body: '' },
1159
{ hash: 'd4e5f6a1b2c3', subject: 'Update two', body: '' },
1160
],
1158
1161
};
1159
1162
1160
1163
const { dom, runtimeErrors } = await bootClient();
@@ -1174,7 +1177,9 @@ describe('page load smoke test', () =>
1174
1177
meFixture = { username: 'admin', isAdmin: true, permissions: {} };
1175
1178
updateStatusFixture = {
1176
1179
underSystemd: true,
1177
commitsAhead: ['a1b2c3 Update one'],
1180
commitsAhead: [
1181
{ hash: 'a1b2c3d4e5f6', subject: 'Update one', body: '' },
1182
],
1178
1183
};
1179
1184
1180
1185
const { dom, runtimeErrors } = await bootClient();
@@ -1197,6 +1202,51 @@ describe('page load smoke test', () =>
1197
1202
dom.window.close();
1198
1203
});
1199
1204
1205
test('restart and update confirmation shows readable commit titles and descriptions', async () =>
1206
{
1207
meFixture = { username: 'admin', isAdmin: true, permissions: {} };
1208
updateStatusFixture = {
1209
underSystemd: true,
1210
commitsAhead: [
1211
{
1212
hash: 'a1b2c3d4e5f6',
1213
subject: 'Improve subtitle experience',
1214
body: 'Subtitles are now easier to read during fullscreen playback.',
1215
},
1216
],
1217
};
1218
1219
const { dom, runtimeErrors } = await bootClient();
1220
expect(runtimeErrors).toEqual([]);
1221
1222
dom.window.document.getElementById('btn-admin').dispatchEvent(new dom.window.MouseEvent('click', { bubbles: true }));
1223
await waitFor(dom, () =>
1224
{
1225
const shutdownBtn = dom.window.document.getElementById('admin-shutdown-btn');
1226
return shutdownBtn && shutdownBtn.textContent === 'Restart & Update';
1227
});
1228
1229
dom.window.document.getElementById('admin-shutdown-btn').dispatchEvent(new dom.window.MouseEvent('click', { bubbles: true }));
1230
await waitFor(dom, () => !dom.window.document.getElementById('confirm-modal').classList.contains('hidden'));
1231
1232
const confirmTitle = dom.window.document.getElementById('confirm-modal-title');
1233
const confirmMessage = dom.window.document.getElementById('confirm-modal-message');
1234
const confirmDialog = dom.window.document.querySelector('#confirm-modal .modal');
1235
1236
expect(confirmTitle.textContent).toBe('Restart & Update');
1237
expect(confirmDialog.classList.contains('confirm-modal-wide')).toBe(true);
1238
expect(confirmMessage.querySelectorAll('.update-commit-item').length).toBe(1);
1239
expect(confirmMessage.querySelector('.update-commit-item h3').textContent).toContain('Improve subtitle experience');
1240
expect(confirmMessage.textContent).toContain('Subtitles are now easier to read during fullscreen playback.');
1241
1242
dom.window.document.getElementById('confirm-modal-cancel').dispatchEvent(new dom.window.MouseEvent('click', { bubbles: true }));
1243
await waitFor(dom, () => dom.window.document.getElementById('confirm-modal').classList.contains('hidden'));
1244
1245
await new Promise(resolve => dom.window.setTimeout(resolve, 120));
1246
1247
dom.window.close();
1248
});
1249
1200
1250
test('uses direct svg thumbnail when svg file is under 1MB', async () =>
1201
1251
{
1202
1252
listFixture = {
@@ -1154,7 +1154,10 @@ describe('page load smoke test', () =>1154
meFixture = { username: 'admin', isAdmin: true, permissions: {} };
1154
meFixture = { username: 'admin', isAdmin: true, permissions: {} };
1155
updateStatusFixture = {
1155
updateStatusFixture = {
1156
underSystemd: true,
1156
underSystemd: true,
1157
commitsAhead: ['a1b2c3 Update one', 'd4e5f6 Update two'],
1157
commitsAhead: [
1158
{ hash: 'a1b2c3d4e5f6', subject: 'Update one', body: '' },
1159
{ hash: 'd4e5f6a1b2c3', subject: 'Update two', body: '' },
1160
],
1158
};
1161
};
1159
1162
1160
const { dom, runtimeErrors } = await bootClient();
1163
const { dom, runtimeErrors } = await bootClient();
@@ -1174,7 +1177,9 @@ describe('page load smoke test', () =>1174
meFixture = { username: 'admin', isAdmin: true, permissions: {} };
1177
meFixture = { username: 'admin', isAdmin: true, permissions: {} };
1175
updateStatusFixture = {
1178
updateStatusFixture = {
1176
underSystemd: true,
1179
underSystemd: true,
1177
commitsAhead: ['a1b2c3 Update one'],
1180
commitsAhead: [
1181
{ hash: 'a1b2c3d4e5f6', subject: 'Update one', body: '' },
1182
],
1178
};
1183
};
1179
1184
1180
const { dom, runtimeErrors } = await bootClient();
1185
const { dom, runtimeErrors } = await bootClient();
@@ -1197,6 +1202,51 @@ describe('page load smoke test', () =>1197
dom.window.close();
1202
dom.window.close();
1198
});
1203
});
1199
1204
1205
test('restart and update confirmation shows readable commit titles and descriptions', async () =>
1206
{
1207
meFixture = { username: 'admin', isAdmin: true, permissions: {} };
1208
updateStatusFixture = {
1209
underSystemd: true,
1210
commitsAhead: [
1211
{
1212
hash: 'a1b2c3d4e5f6',
1213
subject: 'Improve subtitle experience',
1214
body: 'Subtitles are now easier to read during fullscreen playback.',
1215
},
1216
],
1217
};
1218
1219
const { dom, runtimeErrors } = await bootClient();
1220
expect(runtimeErrors).toEqual([]);
1221
1222
dom.window.document.getElementById('btn-admin').dispatchEvent(new dom.window.MouseEvent('click', { bubbles: true }));
1223
await waitFor(dom, () =>
1224
{
1225
const shutdownBtn = dom.window.document.getElementById('admin-shutdown-btn');
1226
return shutdownBtn && shutdownBtn.textContent === 'Restart & Update';
1227
});
1228
1229
dom.window.document.getElementById('admin-shutdown-btn').dispatchEvent(new dom.window.MouseEvent('click', { bubbles: true }));
1230
await waitFor(dom, () => !dom.window.document.getElementById('confirm-modal').classList.contains('hidden'));
1231
1232
const confirmTitle = dom.window.document.getElementById('confirm-modal-title');
1233
const confirmMessage = dom.window.document.getElementById('confirm-modal-message');
1234
const confirmDialog = dom.window.document.querySelector('#confirm-modal .modal');
1235
1236
expect(confirmTitle.textContent).toBe('Restart & Update');
1237
expect(confirmDialog.classList.contains('confirm-modal-wide')).toBe(true);
1238
expect(confirmMessage.querySelectorAll('.update-commit-item').length).toBe(1);
1239
expect(confirmMessage.querySelector('.update-commit-item h3').textContent).toContain('Improve subtitle experience');
1240
expect(confirmMessage.textContent).toContain('Subtitles are now easier to read during fullscreen playback.');
1241
1242
dom.window.document.getElementById('confirm-modal-cancel').dispatchEvent(new dom.window.MouseEvent('click', { bubbles: true }));
1243
await waitFor(dom, () => dom.window.document.getElementById('confirm-modal').classList.contains('hidden'));
1244
1245
await new Promise(resolve => dom.window.setTimeout(resolve, 120));
1246
1247
dom.window.close();
1248
});
1249
1200
test('uses direct svg thumbnail when svg file is under 1MB', async () =>
1250
test('uses direct svg thumbnail when svg file is under 1MB', async () =>
1201
{
1251
{
1202
listFixture = {
1252
listFixture = {