BlueGit

timfa filemanager

feat(admin): show update badge and focus update action

timfa Tim Falken · pushed by timfa

Authored 2026-05-16 · 6 months ago

Hash
f9ded20891bcd625a2d3e7b712fb8688e33cfe0c
Parent
a2656d30
5 files changed +164 −3
.github/technical-reference.md +8 −0
@@ -126,6 +126,7 @@
126 126 ## public/index.html
127 127 - Auth form - Login/setup form uses username plus mode-specific password autocomplete tokens so browser password managers behave correctly.
128 128 - Admin modal - Includes User Folders controls (user path + per-user size limit) and a dedicated save action for that config.
129 - Admin topbar button - Includes the `#admin-update-badge` element that displays pending update commit count for admins.
129 130 - Import map - Maps `three` and `three/addons/` to local vendored modules for client-side STL/OBJ previews.
130 131
131 132 ## public/app.js
@@ -149,6 +150,8 @@
149 150 - showFileConflictChoice(filename, renameTo, mode) - Dialog for single upload/move conflicts; returns overwrite/rename/cancel.
150 151 - parseHumanSize(input) - Parses human-readable sizes like `25 MB`/`1gb` into bytes for admin user-folder limits.
151 152 - updateAdminSizeFeedback(rawValue) - Validates size input and updates admin hint text/classes with parsed byte preview.
153 - setAdminUpdateBadge(count) - Shows/hides the admin topbar update badge and clamps display to `99+` for large update counts.
154 - pulseAdminUpdateButton() - Scrolls the admin modal to the shutdown/update CTA and applies a short pulse highlight animation.
152 155 - relativePathFromRoot(targetPath, rootPath) - Produces a root-relative path string for sidebar folder context display.
153 156 - displayPathWithRootLabel(targetPath, rootPath, rootLabel) - Produces Linux-style root-relative display paths like `/Downloads/A/B` for folder context UI.
154 157 - openShareModal(item) - Opens the Delen (share) popup, calls POST /api/share/create, shows the 24-hour URL with a copy button and OK to dismiss.
@@ -176,6 +179,7 @@
176 179 - buildModelObjectFromBlob(blob, type, modules) - Parses STL/OBJ blobs and produces a geometry-only model using the standard blue material.
177 180 - renderModelPreview(item, blob, targetEl) - Renders interactive STL/OBJ previews (drag rotate + scroll zoom) with WebGL fallback messaging when unavailable.
178 181 - closePreview(opts) - Closes expanded previews; video previews ignore backdrop close and require explicit close action.
182 - refreshAdminUpdateStatus(opts) - Fetches `/api/admin/update-status`, updates CTA label, updates topbar badge, and optionally triggers update-button pulse/scroll in the admin modal.
179 183
180 184 ## tests/thumbnail-cache.test.js
181 185 - thumbnail cache worker / creates cached thumbnail with dimensions smaller than 100px - Verifies cached image generation and manifest write.
@@ -251,6 +255,8 @@
251 255 ## public/style.css
252 256 - #sidebar-duplicates + related classes - Sidebar duplicate-file list styling with truncation and hover feedback.
253 257 - .admin-size-feedback(.ok/.err) - Validation feedback styling for admin user-folder size-limit input.
258 - .topbar-badge - Red count badge attached to the admin topbar button for available updates.
259 - .admin-update-highlight / @keyframes admin-update-pulse - Temporary pulse animation class used to highlight the Restart & Update CTA.
254 260
255 261 ## tests/auth.routes.test.js
256 262 - session lifecycle / POST /api/auth/logout revokes active session - Verifies explicit logout invalidates token immediately.
@@ -258,6 +264,8 @@
258 264
259 265 ## tests/page.load.test.js
260 266 - bootClient() - Boots the app in jsdom and waits until app shell is visible or timeout before assertions.
267 - admin topbar shows update badge after login when updates are available - Verifies admins see the pending-update count badge immediately after boot/login restore.
268 - opening admin panel with updates scrolls to and highlights the update button - Verifies modal open triggers scroll-to-CTA and pulse highlight when updates exist.
261 269 - waitFor(dom, predicate, timeoutMs) - Poll helper used by interaction tests to wait for rendered tiles.
262 270 - login overlay uses username and current-password autocomplete tokens - Verifies normal sign-in mode exposes browser-friendly login autocomplete attributes.
263 271 - first-run setup uses new-password autocomplete token - Verifies setup mode switches the password field to the browser-friendly new-password token.
@@ -126,6 +126,7 @@
126## public/index.html
126## public/index.html
127- Auth form - Login/setup form uses username plus mode-specific password autocomplete tokens so browser password managers behave correctly.
127- Auth form - Login/setup form uses username plus mode-specific password autocomplete tokens so browser password managers behave correctly.
128- Admin modal - Includes User Folders controls (user path + per-user size limit) and a dedicated save action for that config.
128- Admin modal - Includes User Folders controls (user path + per-user size limit) and a dedicated save action for that config.
129- Admin topbar button - Includes the `#admin-update-badge` element that displays pending update commit count for admins.
129- Import map - Maps `three` and `three/addons/` to local vendored modules for client-side STL/OBJ previews.
130- Import map - Maps `three` and `three/addons/` to local vendored modules for client-side STL/OBJ previews.
130
131
131## public/app.js
132## public/app.js
@@ -149,6 +150,8 @@
149- showFileConflictChoice(filename, renameTo, mode) - Dialog for single upload/move conflicts; returns overwrite/rename/cancel.
150- showFileConflictChoice(filename, renameTo, mode) - Dialog for single upload/move conflicts; returns overwrite/rename/cancel.
150- parseHumanSize(input) - Parses human-readable sizes like `25 MB`/`1gb` into bytes for admin user-folder limits.
151- parseHumanSize(input) - Parses human-readable sizes like `25 MB`/`1gb` into bytes for admin user-folder limits.
151- updateAdminSizeFeedback(rawValue) - Validates size input and updates admin hint text/classes with parsed byte preview.
152- updateAdminSizeFeedback(rawValue) - Validates size input and updates admin hint text/classes with parsed byte preview.
153- setAdminUpdateBadge(count) - Shows/hides the admin topbar update badge and clamps display to `99+` for large update counts.
154- pulseAdminUpdateButton() - Scrolls the admin modal to the shutdown/update CTA and applies a short pulse highlight animation.
152- relativePathFromRoot(targetPath, rootPath) - Produces a root-relative path string for sidebar folder context display.
155- relativePathFromRoot(targetPath, rootPath) - Produces a root-relative path string for sidebar folder context display.
153- displayPathWithRootLabel(targetPath, rootPath, rootLabel) - Produces Linux-style root-relative display paths like `/Downloads/A/B` for folder context UI.
156- displayPathWithRootLabel(targetPath, rootPath, rootLabel) - Produces Linux-style root-relative display paths like `/Downloads/A/B` for folder context UI.
154- openShareModal(item) - Opens the Delen (share) popup, calls POST /api/share/create, shows the 24-hour URL with a copy button and OK to dismiss.
157- openShareModal(item) - Opens the Delen (share) popup, calls POST /api/share/create, shows the 24-hour URL with a copy button and OK to dismiss.
@@ -176,6 +179,7 @@
176- buildModelObjectFromBlob(blob, type, modules) - Parses STL/OBJ blobs and produces a geometry-only model using the standard blue material.
179- buildModelObjectFromBlob(blob, type, modules) - Parses STL/OBJ blobs and produces a geometry-only model using the standard blue material.
177- renderModelPreview(item, blob, targetEl) - Renders interactive STL/OBJ previews (drag rotate + scroll zoom) with WebGL fallback messaging when unavailable.
180- renderModelPreview(item, blob, targetEl) - Renders interactive STL/OBJ previews (drag rotate + scroll zoom) with WebGL fallback messaging when unavailable.
178- closePreview(opts) - Closes expanded previews; video previews ignore backdrop close and require explicit close action.
181- closePreview(opts) - Closes expanded previews; video previews ignore backdrop close and require explicit close action.
182- refreshAdminUpdateStatus(opts) - Fetches `/api/admin/update-status`, updates CTA label, updates topbar badge, and optionally triggers update-button pulse/scroll in the admin modal.
179
183
180## tests/thumbnail-cache.test.js
184## tests/thumbnail-cache.test.js
181- thumbnail cache worker / creates cached thumbnail with dimensions smaller than 100px - Verifies cached image generation and manifest write.
185- thumbnail cache worker / creates cached thumbnail with dimensions smaller than 100px - Verifies cached image generation and manifest write.
@@ -251,6 +255,8 @@
251## public/style.css
255## public/style.css
252- #sidebar-duplicates + related classes - Sidebar duplicate-file list styling with truncation and hover feedback.
256- #sidebar-duplicates + related classes - Sidebar duplicate-file list styling with truncation and hover feedback.
253- .admin-size-feedback(.ok/.err) - Validation feedback styling for admin user-folder size-limit input.
257- .admin-size-feedback(.ok/.err) - Validation feedback styling for admin user-folder size-limit input.
258- .topbar-badge - Red count badge attached to the admin topbar button for available updates.
259- .admin-update-highlight / @keyframes admin-update-pulse - Temporary pulse animation class used to highlight the Restart & Update CTA.
254
260
255## tests/auth.routes.test.js
261## tests/auth.routes.test.js
256- session lifecycle / POST /api/auth/logout revokes active session - Verifies explicit logout invalidates token immediately.
262- session lifecycle / POST /api/auth/logout revokes active session - Verifies explicit logout invalidates token immediately.
@@ -258,6 +264,8 @@
258
264
259## tests/page.load.test.js
265## tests/page.load.test.js
260- bootClient() - Boots the app in jsdom and waits until app shell is visible or timeout before assertions.
266- bootClient() - Boots the app in jsdom and waits until app shell is visible or timeout before assertions.
267- admin topbar shows update badge after login when updates are available - Verifies admins see the pending-update count badge immediately after boot/login restore.
268- opening admin panel with updates scrolls to and highlights the update button - Verifies modal open triggers scroll-to-CTA and pulse highlight when updates exist.
261- waitFor(dom, predicate, timeoutMs) - Poll helper used by interaction tests to wait for rendered tiles.
269- waitFor(dom, predicate, timeoutMs) - Poll helper used by interaction tests to wait for rendered tiles.
262- login overlay uses username and current-password autocomplete tokens - Verifies normal sign-in mode exposes browser-friendly login autocomplete attributes.
270- login overlay uses username and current-password autocomplete tokens - Verifies normal sign-in mode exposes browser-friendly login autocomplete attributes.
263- first-run setup uses new-password autocomplete token - Verifies setup mode switches the password field to the browser-friendly new-password token.
271- first-run setup uses new-password autocomplete token - Verifies setup mode switches the password field to the browser-friendly new-password token.
public/app.js +62 −2
@@ -1536,6 +1536,14 @@ function showApp ()
1536 1536 openFolderSidebar();
1537 1537 }
1538 1538 document.getElementById('btn-admin').classList.toggle('hidden', !STATE.isAdmin);
1539 if (STATE.isAdmin)
1540 {
1541 void refreshAdminUpdateStatus();
1542 }
1543 else
1544 {
1545 setAdminUpdateBadge(0);
1546 }
1539 1547 startAutoRefresh();
1540 1548 }
1541 1549
@@ -1659,6 +1667,8 @@ async function performLogout ()
1659 1667 STATE.restoreDir = null;
1660 1668 STATE.restoreRootPath = null;
1661 1669 STATE.lastOperationAt = null;
1670 _adminUpdateStatus = null;
1671 setAdminUpdateBadge(0);
1662 1672 clearSessionState();
1663 1673 closePreview({ force: true });
1664 1674 closeSidebar();
@@ -4573,12 +4583,54 @@ async function deleteItem (item)
4573 4583
4574 4584 let _adminUpdateStatus = null;
4575 4585
4586 function setAdminUpdateBadge (count)
4587 {
4588 const badge = document.getElementById('admin-update-badge');
4589 const adminBtn = document.getElementById('btn-admin');
4590 if (!badge || !adminBtn) return;
4591
4592 if (!STATE.isAdmin || !Number.isFinite(count) || count <= 0)
4593 {
4594 badge.classList.add('hidden');
4595 badge.textContent = '';
4596 adminBtn.removeAttribute('data-update-count');
4597 return;
4598 }
4599
4600 const whole = Math.floor(count);
4601 const capped = Math.min(whole, 99);
4602 badge.textContent = capped >= 99 ? '99+' : String(capped);
4603 badge.classList.remove('hidden');
4604 adminBtn.dataset.updateCount = String(whole);
4605 }
4606
4607 function pulseAdminUpdateButton ()
4608 {
4609 const btn = document.getElementById('admin-shutdown-btn');
4610 if (!btn) return;
4611
4612 if (typeof btn.scrollIntoView === 'function')
4613 {
4614 btn.scrollIntoView({ behavior: 'smooth', block: 'center' });
4615 }
4616
4617 btn.classList.remove('admin-update-highlight');
4618 // Force reflow so repeated openings can replay the pulse animation.
4619 void btn.offsetWidth;
4620 btn.classList.add('admin-update-highlight');
4621
4622 setTimeout(() =>
4623 {
4624 btn.classList.remove('admin-update-highlight');
4625 }, 1800);
4626 }
4627
4576 4628 async function openAdminModal ()
4577 4629 {
4578 4630 document.getElementById('admin-modal').classList.remove('hidden');
4579 4631 await refreshAdminConfig();
4580 4632 await refreshAdminUsers();
4581 void refreshAdminUpdateStatus();
4633 await refreshAdminUpdateStatus({ pulseIfUpdateAvailable: true });
4582 4634 }
4583 4635
4584 4636 async function refreshAdminConfig ()
@@ -4648,11 +4700,13 @@ async function refreshAdminUsers ()
4648 4700 }
4649 4701 }
4650 4702
4651 async function refreshAdminUpdateStatus ()
4703 async function refreshAdminUpdateStatus (opts = {})
4652 4704 {
4705 const pulseIfUpdateAvailable = !!opts.pulseIfUpdateAvailable;
4653 4706 const btn = document.getElementById('admin-shutdown-btn');
4654 4707 _adminUpdateStatus = null;
4655 4708 btn.textContent = 'Shut down server';
4709 setAdminUpdateBadge(0);
4656 4710
4657 4711 try
4658 4712 {
@@ -4660,6 +4714,11 @@ async function refreshAdminUpdateStatus ()
4660 4714 if (!data) return;
4661 4715 _adminUpdateStatus = data;
4662 4716
4717 const updateCount = (data.underSystemd && Array.isArray(data.commitsAhead))
4718 ? data.commitsAhead.length
4719 : 0;
4720 setAdminUpdateBadge(updateCount);
4721
4663 4722 if (!data.underSystemd)
4664 4723 {
4665 4724 btn.textContent = 'Shut down server';
@@ -4671,6 +4730,7 @@ async function refreshAdminUpdateStatus ()
4671 4730 else
4672 4731 {
4673 4732 btn.textContent = 'Restart & Update';
4733 if (pulseIfUpdateAvailable) pulseAdminUpdateButton();
4674 4734 }
4675 4735 }
4676 4736 catch
@@ -1536,6 +1536,14 @@ function showApp ()
1536 openFolderSidebar();
1536 openFolderSidebar();
1537 }
1537 }
1538 document.getElementById('btn-admin').classList.toggle('hidden', !STATE.isAdmin);
1538 document.getElementById('btn-admin').classList.toggle('hidden', !STATE.isAdmin);
1539 if (STATE.isAdmin)
1540 {
1541 void refreshAdminUpdateStatus();
1542 }
1543 else
1544 {
1545 setAdminUpdateBadge(0);
1546 }
1539 startAutoRefresh();
1547 startAutoRefresh();
1540}
1548}
1541
1549
@@ -1659,6 +1667,8 @@ async function performLogout ()
1659 STATE.restoreDir = null;
1667 STATE.restoreDir = null;
1660 STATE.restoreRootPath = null;
1668 STATE.restoreRootPath = null;
1661 STATE.lastOperationAt = null;
1669 STATE.lastOperationAt = null;
1670 _adminUpdateStatus = null;
1671 setAdminUpdateBadge(0);
1662 clearSessionState();
1672 clearSessionState();
1663 closePreview({ force: true });
1673 closePreview({ force: true });
1664 closeSidebar();
1674 closeSidebar();
@@ -4573,12 +4583,54 @@ async function deleteItem (item)
4573
4583
4574let _adminUpdateStatus = null;
4584let _adminUpdateStatus = null;
4575
4585
4586function setAdminUpdateBadge (count)
4587{
4588 const badge = document.getElementById('admin-update-badge');
4589 const adminBtn = document.getElementById('btn-admin');
4590 if (!badge || !adminBtn) return;
4591
4592 if (!STATE.isAdmin || !Number.isFinite(count) || count <= 0)
4593 {
4594 badge.classList.add('hidden');
4595 badge.textContent = '';
4596 adminBtn.removeAttribute('data-update-count');
4597 return;
4598 }
4599
4600 const whole = Math.floor(count);
4601 const capped = Math.min(whole, 99);
4602 badge.textContent = capped >= 99 ? '99+' : String(capped);
4603 badge.classList.remove('hidden');
4604 adminBtn.dataset.updateCount = String(whole);
4605}
4606
4607function pulseAdminUpdateButton ()
4608{
4609 const btn = document.getElementById('admin-shutdown-btn');
4610 if (!btn) return;
4611
4612 if (typeof btn.scrollIntoView === 'function')
4613 {
4614 btn.scrollIntoView({ behavior: 'smooth', block: 'center' });
4615 }
4616
4617 btn.classList.remove('admin-update-highlight');
4618 // Force reflow so repeated openings can replay the pulse animation.
4619 void btn.offsetWidth;
4620 btn.classList.add('admin-update-highlight');
4621
4622 setTimeout(() =>
4623 {
4624 btn.classList.remove('admin-update-highlight');
4625 }, 1800);
4626}
4627
4576async function openAdminModal ()
4628async function openAdminModal ()
4577{
4629{
4578 document.getElementById('admin-modal').classList.remove('hidden');
4630 document.getElementById('admin-modal').classList.remove('hidden');
4579 await refreshAdminConfig();
4631 await refreshAdminConfig();
4580 await refreshAdminUsers();
4632 await refreshAdminUsers();
4581 void refreshAdminUpdateStatus();
4633 await refreshAdminUpdateStatus({ pulseIfUpdateAvailable: true });
4582}
4634}
4583
4635
4584async function refreshAdminConfig ()
4636async function refreshAdminConfig ()
@@ -4648,11 +4700,13 @@ async function refreshAdminUsers ()
4648 }
4700 }
4649}
4701}
4650
4702
4651async function refreshAdminUpdateStatus ()
4703async function refreshAdminUpdateStatus (opts = {})
4652{
4704{
4705 const pulseIfUpdateAvailable = !!opts.pulseIfUpdateAvailable;
4653 const btn = document.getElementById('admin-shutdown-btn');
4706 const btn = document.getElementById('admin-shutdown-btn');
4654 _adminUpdateStatus = null;
4707 _adminUpdateStatus = null;
4655 btn.textContent = 'Shut down server';
4708 btn.textContent = 'Shut down server';
4709 setAdminUpdateBadge(0);
4656
4710
4657 try
4711 try
4658 {
4712 {
@@ -4660,6 +4714,11 @@ async function refreshAdminUpdateStatus ()
4660 if (!data) return;
4714 if (!data) return;
4661 _adminUpdateStatus = data;
4715 _adminUpdateStatus = data;
4662
4716
4717 const updateCount = (data.underSystemd && Array.isArray(data.commitsAhead))
4718 ? data.commitsAhead.length
4719 : 0;
4720 setAdminUpdateBadge(updateCount);
4721
4663 if (!data.underSystemd)
4722 if (!data.underSystemd)
4664 {
4723 {
4665 btn.textContent = 'Shut down server';
4724 btn.textContent = 'Shut down server';
@@ -4671,6 +4730,7 @@ async function refreshAdminUpdateStatus ()
4671 else
4730 else
4672 {
4731 {
4673 btn.textContent = 'Restart & Update';
4732 btn.textContent = 'Restart & Update';
4733 if (pulseIfUpdateAvailable) pulseAdminUpdateButton();
4674 }
4734 }
4675 }
4735 }
4676 catch
4736 catch
public/index.html +2 −1
@@ -93,7 +93,8 @@
93 93 <circle cx="12" cy="8" r="4" />
94 94 <path d="M6 20v-2a6 6 0 0 1 12 0v2" />
95 95 </svg>
96 Admin
96 <span class="icon-btn-label">Admin</span>
97 <span id="admin-update-badge" class="topbar-badge hidden" aria-hidden="true"></span>
97 98 </button>
98 99
99 100 <button id="btn-logout" class="icon-btn" title="Sign out" aria-label="Sign out">
@@ -93,7 +93,8 @@
93 <circle cx="12" cy="8" r="4" />
93 <circle cx="12" cy="8" r="4" />
94 <path d="M6 20v-2a6 6 0 0 1 12 0v2" />
94 <path d="M6 20v-2a6 6 0 0 1 12 0v2" />
95 </svg>
95 </svg>
96 Admin
96 <span class="icon-btn-label">Admin</span>
97 <span id="admin-update-badge" class="topbar-badge hidden" aria-hidden="true"></span>
97 </button>
98 </button>
98
99
99 <button id="btn-logout" class="icon-btn" title="Sign out" aria-label="Sign out">
100 <button id="btn-logout" class="icon-btn" title="Sign out" aria-label="Sign out">
public/style.css +37 −0
@@ -127,6 +127,7 @@ button {
127 127 color: var(--text-muted);
128 128 padding: 0.4rem 0.7rem;
129 129 border-radius: 6px;
130 position: relative;
130 131 }
131 132
132 133 .icon-btn:hover {
@@ -139,6 +140,23 @@ button {
139 140 height: 18px;
140 141 }
141 142
143 .topbar-badge {
144 position: absolute;
145 top: -0.25rem;
146 right: -0.3rem;
147 min-width: 1.1rem;
148 height: 1.1rem;
149 padding: 0 0.28rem;
150 border-radius: 999px;
151 background: #d33131;
152 color: #fff;
153 font-size: 0.68rem;
154 font-weight: 700;
155 line-height: 1.1rem;
156 text-align: center;
157 border: 1px solid var(--surface);
158 }
159
142 160 button[type="submit"],
143 161 .primary {
144 162 background: var(--accent);
@@ -166,6 +184,25 @@ button.danger:hover {
166 184 background: var(--border);
167 185 }
168 186
187 button.danger.admin-update-highlight {
188 animation: admin-update-pulse 0.9s ease-in-out 2;
189 }
190
191 @keyframes admin-update-pulse {
192 0% {
193 box-shadow: 0 0 0 0 rgba(211, 49, 49, 0.55);
194 transform: scale(1);
195 }
196 50% {
197 box-shadow: 0 0 0 10px rgba(211, 49, 49, 0);
198 transform: scale(1.02);
199 }
200 100% {
201 box-shadow: 0 0 0 0 rgba(211, 49, 49, 0);
202 transform: scale(1);
203 }
204 }
205
169 206 /* =========================================================
170 207 TOP BAR
171 208 ========================================================= */
@@ -127,6 +127,7 @@ button {
127 color: var(--text-muted);
127 color: var(--text-muted);
128 padding: 0.4rem 0.7rem;
128 padding: 0.4rem 0.7rem;
129 border-radius: 6px;
129 border-radius: 6px;
130 position: relative;
130}
131}
131
132
132.icon-btn:hover {
133.icon-btn:hover {
@@ -139,6 +140,23 @@ button {
139 height: 18px;
140 height: 18px;
140}
141}
141
142
143.topbar-badge {
144 position: absolute;
145 top: -0.25rem;
146 right: -0.3rem;
147 min-width: 1.1rem;
148 height: 1.1rem;
149 padding: 0 0.28rem;
150 border-radius: 999px;
151 background: #d33131;
152 color: #fff;
153 font-size: 0.68rem;
154 font-weight: 700;
155 line-height: 1.1rem;
156 text-align: center;
157 border: 1px solid var(--surface);
158}
159
142button[type="submit"],
160button[type="submit"],
143.primary {
161.primary {
144 background: var(--accent);
162 background: var(--accent);
@@ -166,6 +184,25 @@ button.danger:hover {
166 background: var(--border);
184 background: var(--border);
167}
185}
168
186
187button.danger.admin-update-highlight {
188 animation: admin-update-pulse 0.9s ease-in-out 2;
189}
190
191@keyframes admin-update-pulse {
192 0% {
193 box-shadow: 0 0 0 0 rgba(211, 49, 49, 0.55);
194 transform: scale(1);
195 }
196 50% {
197 box-shadow: 0 0 0 10px rgba(211, 49, 49, 0);
198 transform: scale(1.02);
199 }
200 100% {
201 box-shadow: 0 0 0 0 rgba(211, 49, 49, 0);
202 transform: scale(1);
203 }
204}
205
169/* =========================================================
206/* =========================================================
170 TOP BAR
207 TOP BAR
171 ========================================================= */
208 ========================================================= */
tests/page.load.test.js +55 −0
@@ -26,6 +26,7 @@ describe('page load smoke test', () =>
26 26 let folderIconFixture;
27 27 let adminUsersFixture;
28 28 let adminConfigFixture;
29 let updateStatusFixture;
29 30 let downloadFixture;
30 31 let videoStreamFixture;
31 32 let metaDelayMsFixture;
@@ -57,6 +58,7 @@ describe('page load smoke test', () =>
57 58 folderIconFixture = {};
58 59 adminUsersFixture = { users: [] };
59 60 adminConfigFixture = { port: 3000, paths: ['/data'], effectivePaths: ['/data'] };
61 updateStatusFixture = { underSystemd: false, commitsAhead: [] };
60 62 downloadFixture = {};
61 63 videoStreamFixture = {};
62 64 metaDelayMsFixture = {};
@@ -193,6 +195,7 @@ describe('page load smoke test', () =>
193 195 });
194 196 app.get('/api/admin/config', (req, res) => res.json(adminConfigFixture));
195 197 app.get('/api/admin/users', (req, res) => res.json(adminUsersFixture));
198 app.get('/api/admin/update-status', (req, res) => res.json(updateStatusFixture));
196 199 app.post('/api/auth/logout', (req, res) => res.json({ ok: true }));
197 200 app.get('*', (req, res) => res.sendFile(path.join(publicDir, 'index.html')));
198 201
@@ -237,6 +240,10 @@ describe('page load smoke test', () =>
237 240 return fetch(new URL(url, baseUrl).toString(), init);
238 241 };
239 242 window.HTMLElement.prototype.focus = function focus () { };
243 window.HTMLElement.prototype.scrollIntoView = function scrollIntoView ()
244 {
245 window.__lastScrollIntoViewId = this.id || null;
246 };
240 247 window.HTMLCanvasElement.prototype.getContext = () => null;
241 248 window.matchMedia = () => ({ matches: mobile, addListener () { }, removeListener () { }, addEventListener () { }, removeEventListener () { } });
242 249 window.scrollTo = () => { };
@@ -877,6 +884,54 @@ describe('page load smoke test', () =>
877 884 dom.window.close();
878 885 });
879 886
887 test('admin topbar shows update badge after login when updates are available', async () =>
888 {
889 meFixture = { username: 'admin', isAdmin: true, permissions: {} };
890 updateStatusFixture = {
891 underSystemd: true,
892 commitsAhead: ['a1b2c3 Update one', 'd4e5f6 Update two'],
893 };
894
895 const { dom, runtimeErrors } = await bootClient();
896 expect(runtimeErrors).toEqual([]);
897
898 await waitFor(dom, () => dom.window.document.getElementById('admin-update-badge').textContent === '2');
899
900 const badge = dom.window.document.getElementById('admin-update-badge');
901 expect(badge.classList.contains('hidden')).toBe(false);
902 expect(badge.textContent).toBe('2');
903
904 dom.window.close();
905 });
906
907 test('opening admin panel with updates scrolls to and highlights the update button', async () =>
908 {
909 meFixture = { username: 'admin', isAdmin: true, permissions: {} };
910 updateStatusFixture = {
911 underSystemd: true,
912 commitsAhead: ['a1b2c3 Update one'],
913 };
914
915 const { dom, runtimeErrors } = await bootClient();
916 expect(runtimeErrors).toEqual([]);
917
918 const adminBtn = dom.window.document.getElementById('btn-admin');
919 adminBtn.dispatchEvent(new dom.window.MouseEvent('click', { bubbles: true }));
920
921 await waitFor(dom, () =>
922 {
923 const shutdownBtn = dom.window.document.getElementById('admin-shutdown-btn');
924 return shutdownBtn && shutdownBtn.classList.contains('admin-update-highlight');
925 });
926
927 const shutdownBtn = dom.window.document.getElementById('admin-shutdown-btn');
928 expect(shutdownBtn.textContent).toBe('Restart & Update');
929 expect(shutdownBtn.classList.contains('admin-update-highlight')).toBe(true);
930 expect(dom.window.__lastScrollIntoViewId).toBe('admin-shutdown-btn');
931
932 dom.window.close();
933 });
934
880 935 test('uses direct svg thumbnail when svg file is under 1MB', async () =>
881 936 {
882 937 listFixture = {
@@ -26,6 +26,7 @@ describe('page load smoke test', () =>
26 let folderIconFixture;
26 let folderIconFixture;
27 let adminUsersFixture;
27 let adminUsersFixture;
28 let adminConfigFixture;
28 let adminConfigFixture;
29 let updateStatusFixture;
29 let downloadFixture;
30 let downloadFixture;
30 let videoStreamFixture;
31 let videoStreamFixture;
31 let metaDelayMsFixture;
32 let metaDelayMsFixture;
@@ -57,6 +58,7 @@ describe('page load smoke test', () =>
57 folderIconFixture = {};
58 folderIconFixture = {};
58 adminUsersFixture = { users: [] };
59 adminUsersFixture = { users: [] };
59 adminConfigFixture = { port: 3000, paths: ['/data'], effectivePaths: ['/data'] };
60 adminConfigFixture = { port: 3000, paths: ['/data'], effectivePaths: ['/data'] };
61 updateStatusFixture = { underSystemd: false, commitsAhead: [] };
60 downloadFixture = {};
62 downloadFixture = {};
61 videoStreamFixture = {};
63 videoStreamFixture = {};
62 metaDelayMsFixture = {};
64 metaDelayMsFixture = {};
@@ -193,6 +195,7 @@ describe('page load smoke test', () =>
193 });
195 });
194 app.get('/api/admin/config', (req, res) => res.json(adminConfigFixture));
196 app.get('/api/admin/config', (req, res) => res.json(adminConfigFixture));
195 app.get('/api/admin/users', (req, res) => res.json(adminUsersFixture));
197 app.get('/api/admin/users', (req, res) => res.json(adminUsersFixture));
198 app.get('/api/admin/update-status', (req, res) => res.json(updateStatusFixture));
196 app.post('/api/auth/logout', (req, res) => res.json({ ok: true }));
199 app.post('/api/auth/logout', (req, res) => res.json({ ok: true }));
197 app.get('*', (req, res) => res.sendFile(path.join(publicDir, 'index.html')));
200 app.get('*', (req, res) => res.sendFile(path.join(publicDir, 'index.html')));
198
201
@@ -237,6 +240,10 @@ describe('page load smoke test', () =>
237 return fetch(new URL(url, baseUrl).toString(), init);
240 return fetch(new URL(url, baseUrl).toString(), init);
238 };
241 };
239 window.HTMLElement.prototype.focus = function focus () { };
242 window.HTMLElement.prototype.focus = function focus () { };
243 window.HTMLElement.prototype.scrollIntoView = function scrollIntoView ()
244 {
245 window.__lastScrollIntoViewId = this.id || null;
246 };
240 window.HTMLCanvasElement.prototype.getContext = () => null;
247 window.HTMLCanvasElement.prototype.getContext = () => null;
241 window.matchMedia = () => ({ matches: mobile, addListener () { }, removeListener () { }, addEventListener () { }, removeEventListener () { } });
248 window.matchMedia = () => ({ matches: mobile, addListener () { }, removeListener () { }, addEventListener () { }, removeEventListener () { } });
242 window.scrollTo = () => { };
249 window.scrollTo = () => { };
@@ -877,6 +884,54 @@ describe('page load smoke test', () =>
877 dom.window.close();
884 dom.window.close();
878 });
885 });
879
886
887 test('admin topbar shows update badge after login when updates are available', async () =>
888 {
889 meFixture = { username: 'admin', isAdmin: true, permissions: {} };
890 updateStatusFixture = {
891 underSystemd: true,
892 commitsAhead: ['a1b2c3 Update one', 'd4e5f6 Update two'],
893 };
894
895 const { dom, runtimeErrors } = await bootClient();
896 expect(runtimeErrors).toEqual([]);
897
898 await waitFor(dom, () => dom.window.document.getElementById('admin-update-badge').textContent === '2');
899
900 const badge = dom.window.document.getElementById('admin-update-badge');
901 expect(badge.classList.contains('hidden')).toBe(false);
902 expect(badge.textContent).toBe('2');
903
904 dom.window.close();
905 });
906
907 test('opening admin panel with updates scrolls to and highlights the update button', async () =>
908 {
909 meFixture = { username: 'admin', isAdmin: true, permissions: {} };
910 updateStatusFixture = {
911 underSystemd: true,
912 commitsAhead: ['a1b2c3 Update one'],
913 };
914
915 const { dom, runtimeErrors } = await bootClient();
916 expect(runtimeErrors).toEqual([]);
917
918 const adminBtn = dom.window.document.getElementById('btn-admin');
919 adminBtn.dispatchEvent(new dom.window.MouseEvent('click', { bubbles: true }));
920
921 await waitFor(dom, () =>
922 {
923 const shutdownBtn = dom.window.document.getElementById('admin-shutdown-btn');
924 return shutdownBtn && shutdownBtn.classList.contains('admin-update-highlight');
925 });
926
927 const shutdownBtn = dom.window.document.getElementById('admin-shutdown-btn');
928 expect(shutdownBtn.textContent).toBe('Restart & Update');
929 expect(shutdownBtn.classList.contains('admin-update-highlight')).toBe(true);
930 expect(dom.window.__lastScrollIntoViewId).toBe('admin-shutdown-btn');
931
932 dom.window.close();
933 });
934
880 test('uses direct svg thumbnail when svg file is under 1MB', async () =>
935 test('uses direct svg thumbnail when svg file is under 1MB', async () =>
881 {
936 {
882 listFixture = {
937 listFixture = {