BlueGit

timfa filemanager

Merge branch 'fix/bulk-watched-status-loading'

timfa Tim Falken · pushed by timfa

Authored 2026-05-15 · 6 months ago

Hash
d06c67dc382853d9a9141d632ea9c7978d30bf0b
5 files changed +145 −18
.github/technical-reference.md +2 −1
@@ -75,6 +75,7 @@
75 75 - POST /api/files/copy - Copies a file to a destination folder with conflict strategies (`error`, `overwrite`, `rename`) and user-folder size-limit checks.
76 76 - POST /api/files/video-stream - Creates a short-lived HLS session for a video and returns playlistUrl, durationSeconds, subtitleTracks, and subtitleSummary ({total, converted, skipped}).
77 77 - DELETE /api/files/video-stream/:sessionId - Explicitly releases an active short-lived video stream session and stops backend processing.
78 - POST /api/files/watched-statuses - Returns fast per-user watched statuses for up to 500 file paths without triggering expensive metadata/hash work; response is { statuses: { [filePath]: 'fully'|'partway' } }.
78 79 - POST /api/files/watch-progress - Records per-user watch status (`partway` >=10%, `fully` >=70%) for sidebar "Watched by" display.
79 80
80 81 ## server/routes/share.js
@@ -193,7 +194,7 @@
193 194 - isInlinePreviewableBlob(blob, name) - Determines if a blob can be previewed inline by MIME/extension.
194 195 - makeFileItem(item) - Builds a .file-item element; roots in Home now use folder-like interaction (single-click focus, double-click open), roots are non-draggable, and mobile long-press contextmenu suppression remains.
195 196 - makeFileItem(item) - Renders tile icons first, then applies any cached watched overlay state (`fully` filled eye, `partway` outlined eye).
196 - loadWatchedStatusesForCurrentDir() - Fetches /files/meta for video files in the current directory, derives the logged-in user's watched state, caches it per path, and updates tile overlays after metadata arrives.
197 - loadWatchedStatusesForCurrentDir() - Fetches watched states in one bulk POST /files/watched-statuses request per directory (with legacy /files/meta fallback), caches statuses per path, and updates tile overlays quickly.
197 198 - attachMobileLongPress(el, item) - Adds mobile long-press detection on file/folder tiles to open the item sidebar without desktop side effects.
198 199 - beginSidebarLoad() - Aborts in-flight sidebar requests and increments a load token so stale async responses cannot mutate the current sidebar state.
199 200 - openSidebar(item) - Renders item details/actions in sidebar; roots show alias + original name + usage stats, hide Move To/Delete, keep Rename.
@@ -75,6 +75,7 @@
75- POST /api/files/copy - Copies a file to a destination folder with conflict strategies (`error`, `overwrite`, `rename`) and user-folder size-limit checks.
75- POST /api/files/copy - Copies a file to a destination folder with conflict strategies (`error`, `overwrite`, `rename`) and user-folder size-limit checks.
76- POST /api/files/video-stream - Creates a short-lived HLS session for a video and returns playlistUrl, durationSeconds, subtitleTracks, and subtitleSummary ({total, converted, skipped}).
76- POST /api/files/video-stream - Creates a short-lived HLS session for a video and returns playlistUrl, durationSeconds, subtitleTracks, and subtitleSummary ({total, converted, skipped}).
77- DELETE /api/files/video-stream/:sessionId - Explicitly releases an active short-lived video stream session and stops backend processing.
77- DELETE /api/files/video-stream/:sessionId - Explicitly releases an active short-lived video stream session and stops backend processing.
78- POST /api/files/watched-statuses - Returns fast per-user watched statuses for up to 500 file paths without triggering expensive metadata/hash work; response is { statuses: { [filePath]: 'fully'|'partway' } }.
78- POST /api/files/watch-progress - Records per-user watch status (`partway` >=10%, `fully` >=70%) for sidebar "Watched by" display.
79- POST /api/files/watch-progress - Records per-user watch status (`partway` >=10%, `fully` >=70%) for sidebar "Watched by" display.
79
80
80## server/routes/share.js
81## server/routes/share.js
@@ -193,7 +194,7 @@
193- isInlinePreviewableBlob(blob, name) - Determines if a blob can be previewed inline by MIME/extension.
194- isInlinePreviewableBlob(blob, name) - Determines if a blob can be previewed inline by MIME/extension.
194- makeFileItem(item) - Builds a .file-item element; roots in Home now use folder-like interaction (single-click focus, double-click open), roots are non-draggable, and mobile long-press contextmenu suppression remains.
195- makeFileItem(item) - Builds a .file-item element; roots in Home now use folder-like interaction (single-click focus, double-click open), roots are non-draggable, and mobile long-press contextmenu suppression remains.
195- makeFileItem(item) - Renders tile icons first, then applies any cached watched overlay state (`fully` filled eye, `partway` outlined eye).
196- makeFileItem(item) - Renders tile icons first, then applies any cached watched overlay state (`fully` filled eye, `partway` outlined eye).
196- loadWatchedStatusesForCurrentDir() - Fetches /files/meta for video files in the current directory, derives the logged-in user's watched state, caches it per path, and updates tile overlays after metadata arrives.
197- loadWatchedStatusesForCurrentDir() - Fetches watched states in one bulk POST /files/watched-statuses request per directory (with legacy /files/meta fallback), caches statuses per path, and updates tile overlays quickly.
197- attachMobileLongPress(el, item) - Adds mobile long-press detection on file/folder tiles to open the item sidebar without desktop side effects.
198- attachMobileLongPress(el, item) - Adds mobile long-press detection on file/folder tiles to open the item sidebar without desktop side effects.
198- beginSidebarLoad() - Aborts in-flight sidebar requests and increments a load token so stale async responses cannot mutate the current sidebar state.
199- beginSidebarLoad() - Aborts in-flight sidebar requests and increments a load token so stale async responses cannot mutate the current sidebar state.
199- openSidebar(item) - Renders item details/actions in sidebar; roots show alias + original name + usage stats, hide Move To/Delete, keep Rename.
200- openSidebar(item) - Renders item details/actions in sidebar; roots show alias + original name + usage stats, hide Move To/Delete, keep Rename.
public/app.js +38 −12
@@ -1708,6 +1708,7 @@ function isSidebarLoadStale (item, sidebarLoadId)
1708 1708 */
1709 1709 function renderSidebarDuplicates (item, duplicates)
1710 1710 {
1711 if (typeof document === 'undefined' || typeof document.getElementById !== 'function') return;
1711 1712 const panel = document.getElementById('sidebar-duplicates');
1712 1713 if (!panel) return;
1713 1714
@@ -4247,26 +4248,51 @@ async function loadWatchedStatusesForCurrentDir ()
4247 4248
4248 4249 const loadId = ++STATE.watchedLoadId;
4249 4250
4250 const statuses = await Promise.all(videoItems.map(async (item) =>
4251 let statusMap = null;
4252 const filePaths = videoItems.map((item) => item.path);
4253
4254 const bulk = await api('POST', '/files/watched-statuses', { filePaths }).catch(() => null);
4255 if (bulk && bulk.statuses && typeof bulk.statuses === 'object')
4251 4256 {
4252 const meta = await api('GET', `/files/meta?file=${encodeURIComponent(item.path)}`).catch(() => null);
4253 return {
4254 path: item.path,
4255 status: watchStatusFromWatchedBy(meta && meta.watchedBy),
4256 };
4257 }));
4257 statusMap = {};
4258 for (const item of videoItems)
4259 {
4260 const status = String(bulk.statuses[item.path] || '').toLowerCase();
4261 statusMap[item.path] = status === 'fully' || status === 'partway' ? status : null;
4262 }
4263 }
4264
4265 // Compatibility fallback for older servers that do not expose bulk statuses yet.
4266 if (!statusMap)
4267 {
4268 statusMap = {};
4269 const statuses = await Promise.all(videoItems.map(async (item) =>
4270 {
4271 const meta = await api('GET', `/files/meta?file=${encodeURIComponent(item.path)}`).catch(() => null);
4272 return {
4273 path: item.path,
4274 status: watchStatusFromWatchedBy(meta && meta.watchedBy),
4275 };
4276 }));
4277
4278 for (const entry of statuses)
4279 {
4280 statusMap[entry.path] = entry.status;
4281 }
4282 }
4258 4283
4259 4284 if (loadId !== STATE.watchedLoadId) return;
4260 4285 if (!samePath(STATE.currentDir, dirAtStart)) return;
4261 4286 if (typeof document === 'undefined' || typeof document.querySelectorAll !== 'function') return;
4262 4287
4263 for (const entry of statuses)
4288 for (const item of videoItems)
4264 4289 {
4265 if (entry.status) STATE.watchedStatusByPath[entry.path] = entry.status;
4266 else delete STATE.watchedStatusByPath[entry.path];
4290 const status = statusMap[item.path] || null;
4291 if (status) STATE.watchedStatusByPath[item.path] = status;
4292 else delete STATE.watchedStatusByPath[item.path];
4267 4293
4268 const iconEl = findTileIconByPath(entry.path);
4269 renderWatchedOverlayOnIcon(iconEl, entry.status);
4294 const iconEl = findTileIconByPath(item.path);
4295 renderWatchedOverlayOnIcon(iconEl, status);
4270 4296 }
4271 4297 }
4272 4298
@@ -1708,6 +1708,7 @@ function isSidebarLoadStale (item, sidebarLoadId)
1708 */
1708 */
1709function renderSidebarDuplicates (item, duplicates)
1709function renderSidebarDuplicates (item, duplicates)
1710{
1710{
1711 if (typeof document === 'undefined' || typeof document.getElementById !== 'function') return;
1711 const panel = document.getElementById('sidebar-duplicates');
1712 const panel = document.getElementById('sidebar-duplicates');
1712 if (!panel) return;
1713 if (!panel) return;
1713
1714
@@ -4247,26 +4248,51 @@ async function loadWatchedStatusesForCurrentDir ()
4247
4248
4248 const loadId = ++STATE.watchedLoadId;
4249 const loadId = ++STATE.watchedLoadId;
4249
4250
4250 const statuses = await Promise.all(videoItems.map(async (item) =>
4251 let statusMap = null;
4252 const filePaths = videoItems.map((item) => item.path);
4253
4254 const bulk = await api('POST', '/files/watched-statuses', { filePaths }).catch(() => null);
4255 if (bulk && bulk.statuses && typeof bulk.statuses === 'object')
4251 {
4256 {
4252 const meta = await api('GET', `/files/meta?file=${encodeURIComponent(item.path)}`).catch(() => null);
4257 statusMap = {};
4253 return {
4258 for (const item of videoItems)
4254 path: item.path,
4259 {
4255 status: watchStatusFromWatchedBy(meta && meta.watchedBy),
4260 const status = String(bulk.statuses[item.path] || '').toLowerCase();
4256 };
4261 statusMap[item.path] = status === 'fully' || status === 'partway' ? status : null;
4257 }));
4262 }
4263 }
4264
4265 // Compatibility fallback for older servers that do not expose bulk statuses yet.
4266 if (!statusMap)
4267 {
4268 statusMap = {};
4269 const statuses = await Promise.all(videoItems.map(async (item) =>
4270 {
4271 const meta = await api('GET', `/files/meta?file=${encodeURIComponent(item.path)}`).catch(() => null);
4272 return {
4273 path: item.path,
4274 status: watchStatusFromWatchedBy(meta && meta.watchedBy),
4275 };
4276 }));
4277
4278 for (const entry of statuses)
4279 {
4280 statusMap[entry.path] = entry.status;
4281 }
4282 }
4258
4283
4259 if (loadId !== STATE.watchedLoadId) return;
4284 if (loadId !== STATE.watchedLoadId) return;
4260 if (!samePath(STATE.currentDir, dirAtStart)) return;
4285 if (!samePath(STATE.currentDir, dirAtStart)) return;
4261 if (typeof document === 'undefined' || typeof document.querySelectorAll !== 'function') return;
4286 if (typeof document === 'undefined' || typeof document.querySelectorAll !== 'function') return;
4262
4287
4263 for (const entry of statuses)
4288 for (const item of videoItems)
4264 {
4289 {
4265 if (entry.status) STATE.watchedStatusByPath[entry.path] = entry.status;
4290 const status = statusMap[item.path] || null;
4266 else delete STATE.watchedStatusByPath[entry.path];
4291 if (status) STATE.watchedStatusByPath[item.path] = status;
4292 else delete STATE.watchedStatusByPath[item.path];
4267
4293
4268 const iconEl = findTileIconByPath(entry.path);
4294 const iconEl = findTileIconByPath(item.path);
4269 renderWatchedOverlayOnIcon(iconEl, entry.status);
4295 renderWatchedOverlayOnIcon(iconEl, status);
4270 }
4296 }
4271}
4297}
4272
4298
server/routes/files.js +53 −0
@@ -468,6 +468,12 @@ function watchStatusForProgress (progress)
468 468 return null;
469 469 }
470 470
471 function normalisedWatchedStatus (value)
472 {
473 const status = String(value || '').toLowerCase();
474 return status === 'fully' || status === 'partway' ? status : null;
475 }
476
471 477 function splitNameExt (name)
472 478 {
473 479 const dot = String(name || '').lastIndexOf('.');
@@ -941,6 +947,53 @@ router.get('/download', requireAuth, (req, res) =>
941 947 res.download(file, path.basename(file));
942 948 });
943 949
950 // ---------------------------------------------------------------------------
951 // POST /api/files/watched-statuses
952 // Body: { filePaths: [<absolute-path>, ...] }
953 // Returns per-path watched status for the authenticated user.
954 // ---------------------------------------------------------------------------
955 router.post('/watched-statuses', requireAuth, (req, res) =>
956 {
957 const rawPaths = req.body && Array.isArray(req.body.filePaths) ? req.body.filePaths : null;
958 if (!rawPaths)
959 {
960 return res.status(400).json({ error: 'filePaths array is required.' });
961 }
962
963 const paths = rawPaths
964 .map((p) => String(p || '').trim())
965 .filter(Boolean)
966 .slice(0, 500);
967
968 const { config, roots } = loadConfigAndRoots();
969 const db = getDb();
970 const statuses = {};
971 const selectMeta = db.prepare('SELECT watched_by FROM file_meta WHERE file_path = ?');
972
973 for (const filePath of paths)
974 {
975 const info = resolveRootForUser(filePath, roots, req.user, config);
976 if (!info || !canReadInfo(req.user, info)) continue;
977
978 let stat;
979 try
980 {
981 stat = fs.statSync(filePath);
982 } catch
983 {
984 continue;
985 }
986 if (stat.isDirectory()) continue;
987
988 const row = selectMeta.get([filePath]);
989 const watchedBy = parseJsonObject(row && row.watched_by);
990 const status = normalisedWatchedStatus(watchedBy[req.user.username]);
991 if (status) statuses[filePath] = status;
992 }
993
994 res.json({ statuses });
995 });
996
944 997 // ---------------------------------------------------------------------------
945 998 // POST /api/files/watch-progress
946 999 // Body: { filePath: <absolute-path>, progress: <0..1> }
@@ -468,6 +468,12 @@ function watchStatusForProgress (progress)
468 return null;
468 return null;
469}
469}
470
470
471function normalisedWatchedStatus (value)
472{
473 const status = String(value || '').toLowerCase();
474 return status === 'fully' || status === 'partway' ? status : null;
475}
476
471function splitNameExt (name)
477function splitNameExt (name)
472{
478{
473 const dot = String(name || '').lastIndexOf('.');
479 const dot = String(name || '').lastIndexOf('.');
@@ -941,6 +947,53 @@ router.get('/download', requireAuth, (req, res) =>
941 res.download(file, path.basename(file));
947 res.download(file, path.basename(file));
942});
948});
943
949
950// ---------------------------------------------------------------------------
951// POST /api/files/watched-statuses
952// Body: { filePaths: [<absolute-path>, ...] }
953// Returns per-path watched status for the authenticated user.
954// ---------------------------------------------------------------------------
955router.post('/watched-statuses', requireAuth, (req, res) =>
956{
957 const rawPaths = req.body && Array.isArray(req.body.filePaths) ? req.body.filePaths : null;
958 if (!rawPaths)
959 {
960 return res.status(400).json({ error: 'filePaths array is required.' });
961 }
962
963 const paths = rawPaths
964 .map((p) => String(p || '').trim())
965 .filter(Boolean)
966 .slice(0, 500);
967
968 const { config, roots } = loadConfigAndRoots();
969 const db = getDb();
970 const statuses = {};
971 const selectMeta = db.prepare('SELECT watched_by FROM file_meta WHERE file_path = ?');
972
973 for (const filePath of paths)
974 {
975 const info = resolveRootForUser(filePath, roots, req.user, config);
976 if (!info || !canReadInfo(req.user, info)) continue;
977
978 let stat;
979 try
980 {
981 stat = fs.statSync(filePath);
982 } catch
983 {
984 continue;
985 }
986 if (stat.isDirectory()) continue;
987
988 const row = selectMeta.get([filePath]);
989 const watchedBy = parseJsonObject(row && row.watched_by);
990 const status = normalisedWatchedStatus(watchedBy[req.user.username]);
991 if (status) statuses[filePath] = status;
992 }
993
994 res.json({ statuses });
995});
996
944// ---------------------------------------------------------------------------
997// ---------------------------------------------------------------------------
945// POST /api/files/watch-progress
998// POST /api/files/watch-progress
946// Body: { filePath: <absolute-path>, progress: <0..1> }
999// Body: { filePath: <absolute-path>, progress: <0..1> }
tests/files.routes.test.js +35 −0
@@ -823,6 +823,41 @@ describe('video streaming routes', () =>
823 823 expect(result.status).toBe(200);
824 824 expect(result.body.watchedBy).toEqual({ admin: 'fully' });
825 825 });
826
827 test('POST /api/files/watched-statuses returns bulk watched statuses for accessible files', async () =>
828 {
829 const clipA = path.join(rootDir, 'clip-a.mkv');
830 const clipB = path.join(rootDir, 'clip-b.mkv');
831 const clipC = path.join(rootDir, 'clip-c.mkv');
832 fs.writeFileSync(clipA, 'a');
833 fs.writeFileSync(clipB, 'b');
834 fs.writeFileSync(clipC, 'c');
835
836 const db = getDb();
837 db.prepare('INSERT INTO file_meta (file_path, uploader, downloaders, watched_by) VALUES (?, ?, ?, ?)')
838 .run([clipA, '', '[]', JSON.stringify({ admin: 'fully' })]);
839 db.prepare('INSERT INTO file_meta (file_path, uploader, downloaders, watched_by) VALUES (?, ?, ?, ?)')
840 .run([clipB, '', '[]', JSON.stringify({ admin: 'partway' })]);
841 db.prepare('INSERT INTO file_meta (file_path, uploader, downloaders, watched_by) VALUES (?, ?, ?, ?)')
842 .run([clipC, '', '[]', JSON.stringify({ admin: 'none' })]);
843
844 const { status, body } = await req('POST', '/api/files/watched-statuses', {
845 filePaths: [clipA, clipB, clipC],
846 });
847
848 expect(status).toBe(200);
849 expect(body.statuses).toEqual({
850 [clipA]: 'fully',
851 [clipB]: 'partway',
852 });
853 });
854
855 test('POST /api/files/watched-statuses validates filePaths input', async () =>
856 {
857 const { status, body } = await req('POST', '/api/files/watched-statuses', { filePaths: 'nope' });
858 expect(status).toBe(400);
859 expect(body.error).toMatch(/filePaths array is required/i);
860 });
826 861 });
827 862
828 863 describe('SHA-256 hashing and duplicate detection', () =>
@@ -823,6 +823,41 @@ describe('video streaming routes', () =>
823 expect(result.status).toBe(200);
823 expect(result.status).toBe(200);
824 expect(result.body.watchedBy).toEqual({ admin: 'fully' });
824 expect(result.body.watchedBy).toEqual({ admin: 'fully' });
825 });
825 });
826
827 test('POST /api/files/watched-statuses returns bulk watched statuses for accessible files', async () =>
828 {
829 const clipA = path.join(rootDir, 'clip-a.mkv');
830 const clipB = path.join(rootDir, 'clip-b.mkv');
831 const clipC = path.join(rootDir, 'clip-c.mkv');
832 fs.writeFileSync(clipA, 'a');
833 fs.writeFileSync(clipB, 'b');
834 fs.writeFileSync(clipC, 'c');
835
836 const db = getDb();
837 db.prepare('INSERT INTO file_meta (file_path, uploader, downloaders, watched_by) VALUES (?, ?, ?, ?)')
838 .run([clipA, '', '[]', JSON.stringify({ admin: 'fully' })]);
839 db.prepare('INSERT INTO file_meta (file_path, uploader, downloaders, watched_by) VALUES (?, ?, ?, ?)')
840 .run([clipB, '', '[]', JSON.stringify({ admin: 'partway' })]);
841 db.prepare('INSERT INTO file_meta (file_path, uploader, downloaders, watched_by) VALUES (?, ?, ?, ?)')
842 .run([clipC, '', '[]', JSON.stringify({ admin: 'none' })]);
843
844 const { status, body } = await req('POST', '/api/files/watched-statuses', {
845 filePaths: [clipA, clipB, clipC],
846 });
847
848 expect(status).toBe(200);
849 expect(body.statuses).toEqual({
850 [clipA]: 'fully',
851 [clipB]: 'partway',
852 });
853 });
854
855 test('POST /api/files/watched-statuses validates filePaths input', async () =>
856 {
857 const { status, body } = await req('POST', '/api/files/watched-statuses', { filePaths: 'nope' });
858 expect(status).toBe(400);
859 expect(body.error).toMatch(/filePaths array is required/i);
860 });
826});
861});
827
862
828describe('SHA-256 hashing and duplicate detection', () =>
863describe('SHA-256 hashing and duplicate detection', () =>
tests/page.load.test.js +17 −5
@@ -159,6 +159,23 @@ describe('page load smoke test', () =>
159 159 {
160 160 res.json({ ok: true, updated: true });
161 161 });
162 app.post('/api/files/watched-statuses', (req, res) =>
163 {
164 const requested = Array.isArray(req.body?.filePaths) ? req.body.filePaths : [];
165 const statuses = {};
166
167 for (const rawPath of requested)
168 {
169 const filePath = String(rawPath || '');
170 const allItems = Object.values(listFixture).flat();
171 const item = allItems.find((it) => it.path === filePath);
172 const watchedBy = metaWatchedByFixture[filePath] || (item && item.watchedBy) || {};
173 const status = String(watchedBy.tester || '').toLowerCase();
174 if (status === 'fully' || status === 'partway') statuses[filePath] = status;
175 }
176
177 res.json({ statuses });
178 });
162 179 app.get('/api/files/root-access', (req, res) =>
163 180 {
164 181 const rootPath = String(req.query.rootPath || '');
@@ -768,15 +785,10 @@ describe('page load smoke test', () =>
768 785 };
769 786 metaWatchedByFixture['/data/watched-full.mkv'] = { tester: 'fully' };
770 787 metaWatchedByFixture['/data/watched-part.mkv'] = { tester: 'partway' };
771 metaDelayMsFixture['/data/watched-full.mkv'] = 80;
772 metaDelayMsFixture['/data/watched-part.mkv'] = 80;
773 788
774 789 const { dom, runtimeErrors } = await bootClient();
775 790 expect(runtimeErrors).toEqual([]);
776 791
777 await waitFor(dom, () => !!dom.window.document.querySelector('.file-item[data-path="/data/watched-full.mkv"]'));
778 expect(dom.window.document.querySelector('.file-item[data-path="/data/watched-full.mkv"] .watched-overlay')).toBeFalsy();
779
780 792 await waitFor(dom, () => !!dom.window.document.querySelector('.file-item[data-path="/data/watched-full.mkv"] .watched-overlay--fully'));
781 793
782 794 const fullOverlayPath = dom.window.document.querySelector('.file-item[data-path="/data/watched-full.mkv"] .watched-overlay--fully path');
@@ -159,6 +159,23 @@ describe('page load smoke test', () =>
159 {
159 {
160 res.json({ ok: true, updated: true });
160 res.json({ ok: true, updated: true });
161 });
161 });
162 app.post('/api/files/watched-statuses', (req, res) =>
163 {
164 const requested = Array.isArray(req.body?.filePaths) ? req.body.filePaths : [];
165 const statuses = {};
166
167 for (const rawPath of requested)
168 {
169 const filePath = String(rawPath || '');
170 const allItems = Object.values(listFixture).flat();
171 const item = allItems.find((it) => it.path === filePath);
172 const watchedBy = metaWatchedByFixture[filePath] || (item && item.watchedBy) || {};
173 const status = String(watchedBy.tester || '').toLowerCase();
174 if (status === 'fully' || status === 'partway') statuses[filePath] = status;
175 }
176
177 res.json({ statuses });
178 });
162 app.get('/api/files/root-access', (req, res) =>
179 app.get('/api/files/root-access', (req, res) =>
163 {
180 {
164 const rootPath = String(req.query.rootPath || '');
181 const rootPath = String(req.query.rootPath || '');
@@ -768,15 +785,10 @@ describe('page load smoke test', () =>
768 };
785 };
769 metaWatchedByFixture['/data/watched-full.mkv'] = { tester: 'fully' };
786 metaWatchedByFixture['/data/watched-full.mkv'] = { tester: 'fully' };
770 metaWatchedByFixture['/data/watched-part.mkv'] = { tester: 'partway' };
787 metaWatchedByFixture['/data/watched-part.mkv'] = { tester: 'partway' };
771 metaDelayMsFixture['/data/watched-full.mkv'] = 80;
772 metaDelayMsFixture['/data/watched-part.mkv'] = 80;
773
788
774 const { dom, runtimeErrors } = await bootClient();
789 const { dom, runtimeErrors } = await bootClient();
775 expect(runtimeErrors).toEqual([]);
790 expect(runtimeErrors).toEqual([]);
776
791
777 await waitFor(dom, () => !!dom.window.document.querySelector('.file-item[data-path="/data/watched-full.mkv"]'));
778 expect(dom.window.document.querySelector('.file-item[data-path="/data/watched-full.mkv"] .watched-overlay')).toBeFalsy();
779
780 await waitFor(dom, () => !!dom.window.document.querySelector('.file-item[data-path="/data/watched-full.mkv"] .watched-overlay--fully'));
792 await waitFor(dom, () => !!dom.window.document.querySelector('.file-item[data-path="/data/watched-full.mkv"] .watched-overlay--fully'));
781
793
782 const fullOverlayPath = dom.window.document.querySelector('.file-item[data-path="/data/watched-full.mkv"] .watched-overlay--fully path');
794 const fullOverlayPath = dom.window.document.querySelector('.file-item[data-path="/data/watched-full.mkv"] .watched-overlay--fully path');