Merge feature/subtitle-cropped-frame-payload
@@ -11,7 +11,7 @@
11
11
12
12
## server/image-subtitles.js
13
13
- parseRenderOptions(options) - Normalises subtitle-frame request options and validates filePath/streamIndex/time/canvas dimensions; stream index `0` is valid and must not be treated as missing; canvas is scaled down within a 1280x720 ceiling while preserving requested aspect ratio to keep subtitle placement stable in fullscreen.
14
- renderImageSubtitleFrame({ filePath, streamIndex, timeSeconds, canvasWidth, canvasHeight }) - Extracts bitmap subtitle streams to cached `.sup`, parses PGS display sets, and returns cached/composited PNG subtitle frames for a requested timestamp; returns null when no subtitle is active.
14
- renderImageSubtitleFrame({ filePath, streamIndex, timeSeconds, canvasWidth, canvasHeight }) - Extracts bitmap subtitle streams to cached `.sup`, parses PGS display sets, and returns cached/scaled PNG subtitle bitmaps (without full-frame transparent compositing) for a requested timestamp; returns null when no subtitle is active.
15
15
- clearCachesForFile(filePath) - Removes all event and frame cache entries for a given file path using path-prefixed cache keys and byte-accounted eviction; called when video stream sessions end to prevent memory accumulation.
16
16
- pruneOldImageSubtitleCaches(filePath, slowestViewerTimeSeconds) - Drops subtitle frame caches for events that have passed their retention threshold of end time + event duration + 5 seconds (e.g., event ending at 30s with 10s duration is dropped after slowest viewer reaches 45s); used during segment pruning to keep memory usage bounded on long videos, especially on resource-limited hardware like Raspberry Pi.
17
17
@@ -194,7 +194,7 @@
194
194
- setThumbnailPending(iconEl, pending) - Toggles per-icon pending spinner state while a cached image thumbnail is not ready yet.
195
195
- buildThumbnailSource(item, blob, kind) - Produces thumbnail image source (data/blob URL) for icon injection.
196
196
- buildAuthHeaders() - Builds the authenticated fetch headers used by preview-side API calls that need the bearer token plus fingerprint header.
197
- bindImageSubtitleOverlay(player, videojs, prefs, session, item) - Adds the fullscreen-safe image-subtitle button, menu, and bottom overlay used to fetch and display subtitle frames for image-based tracks; highlights the currently selected IM menu option; persists per-user image subtitle stream index + track name; restores by saved track name first (then stream index); disables the track after the first failed frame request to avoid repeated polling.
197
- bindImageSubtitleOverlay(player, videojs, prefs, session, item) - Adds the fullscreen-safe image-subtitle button, menu, and bottom overlay used to fetch and display subtitle frames for image-based tracks; keeps subtitle bitmaps horizontally centred at the bottom, highlights the currently selected IM menu option, persists per-user image subtitle stream index + track name, restores by saved track name first (then stream index), and disables the track after the first failed frame request to avoid repeated polling.
198
198
- renderStreamedVideoPreview(item, targetEl) - Creates the Video.js player with HLS source/track config, enforces non-live playback UI for file streams, uses container-fill sizing to keep previews within bounds, restores per-user video prefs (volume + subtitle/audio track names when present), wires the image-subtitle overlay controller, forces caption overrides on each open (text background opacity transparent + text edge style uniform), reports watch progress, warns when subtitle streams exist but none are web-compatible, and releases the backend stream session on close/unload.
199
199
- modelPreviewType(name) - Classifies direct client-side 3D preview support for `.stl` and `.obj`.
200
200
- loadThreePreviewModules() - Lazy-loads Three.js plus OrbitControls/STLLoader/OBJLoader via import map aliases.
@@ -11,7 +11,7 @@11
11
12
## server/image-subtitles.js
12
## server/image-subtitles.js
13
- parseRenderOptions(options) - Normalises subtitle-frame request options and validates filePath/streamIndex/time/canvas dimensions; stream index `0` is valid and must not be treated as missing; canvas is scaled down within a 1280x720 ceiling while preserving requested aspect ratio to keep subtitle placement stable in fullscreen.
13
- parseRenderOptions(options) - Normalises subtitle-frame request options and validates filePath/streamIndex/time/canvas dimensions; stream index `0` is valid and must not be treated as missing; canvas is scaled down within a 1280x720 ceiling while preserving requested aspect ratio to keep subtitle placement stable in fullscreen.
14
- renderImageSubtitleFrame({ filePath, streamIndex, timeSeconds, canvasWidth, canvasHeight }) - Extracts bitmap subtitle streams to cached `.sup`, parses PGS display sets, and returns cached/composited PNG subtitle frames for a requested timestamp; returns null when no subtitle is active.
14
- renderImageSubtitleFrame({ filePath, streamIndex, timeSeconds, canvasWidth, canvasHeight }) - Extracts bitmap subtitle streams to cached `.sup`, parses PGS display sets, and returns cached/scaled PNG subtitle bitmaps (without full-frame transparent compositing) for a requested timestamp; returns null when no subtitle is active.
15
- clearCachesForFile(filePath) - Removes all event and frame cache entries for a given file path using path-prefixed cache keys and byte-accounted eviction; called when video stream sessions end to prevent memory accumulation.
15
- clearCachesForFile(filePath) - Removes all event and frame cache entries for a given file path using path-prefixed cache keys and byte-accounted eviction; called when video stream sessions end to prevent memory accumulation.
16
- pruneOldImageSubtitleCaches(filePath, slowestViewerTimeSeconds) - Drops subtitle frame caches for events that have passed their retention threshold of end time + event duration + 5 seconds (e.g., event ending at 30s with 10s duration is dropped after slowest viewer reaches 45s); used during segment pruning to keep memory usage bounded on long videos, especially on resource-limited hardware like Raspberry Pi.
16
- pruneOldImageSubtitleCaches(filePath, slowestViewerTimeSeconds) - Drops subtitle frame caches for events that have passed their retention threshold of end time + event duration + 5 seconds (e.g., event ending at 30s with 10s duration is dropped after slowest viewer reaches 45s); used during segment pruning to keep memory usage bounded on long videos, especially on resource-limited hardware like Raspberry Pi.
17
17
@@ -194,7 +194,7 @@194
- setThumbnailPending(iconEl, pending) - Toggles per-icon pending spinner state while a cached image thumbnail is not ready yet.
194
- setThumbnailPending(iconEl, pending) - Toggles per-icon pending spinner state while a cached image thumbnail is not ready yet.
195
- buildThumbnailSource(item, blob, kind) - Produces thumbnail image source (data/blob URL) for icon injection.
195
- buildThumbnailSource(item, blob, kind) - Produces thumbnail image source (data/blob URL) for icon injection.
196
- buildAuthHeaders() - Builds the authenticated fetch headers used by preview-side API calls that need the bearer token plus fingerprint header.
196
- buildAuthHeaders() - Builds the authenticated fetch headers used by preview-side API calls that need the bearer token plus fingerprint header.
197
- bindImageSubtitleOverlay(player, videojs, prefs, session, item) - Adds the fullscreen-safe image-subtitle button, menu, and bottom overlay used to fetch and display subtitle frames for image-based tracks; highlights the currently selected IM menu option; persists per-user image subtitle stream index + track name; restores by saved track name first (then stream index); disables the track after the first failed frame request to avoid repeated polling.
197
- bindImageSubtitleOverlay(player, videojs, prefs, session, item) - Adds the fullscreen-safe image-subtitle button, menu, and bottom overlay used to fetch and display subtitle frames for image-based tracks; keeps subtitle bitmaps horizontally centred at the bottom, highlights the currently selected IM menu option, persists per-user image subtitle stream index + track name, restores by saved track name first (then stream index), and disables the track after the first failed frame request to avoid repeated polling.
198
- renderStreamedVideoPreview(item, targetEl) - Creates the Video.js player with HLS source/track config, enforces non-live playback UI for file streams, uses container-fill sizing to keep previews within bounds, restores per-user video prefs (volume + subtitle/audio track names when present), wires the image-subtitle overlay controller, forces caption overrides on each open (text background opacity transparent + text edge style uniform), reports watch progress, warns when subtitle streams exist but none are web-compatible, and releases the backend stream session on close/unload.
198
- renderStreamedVideoPreview(item, targetEl) - Creates the Video.js player with HLS source/track config, enforces non-live playback UI for file streams, uses container-fill sizing to keep previews within bounds, restores per-user video prefs (volume + subtitle/audio track names when present), wires the image-subtitle overlay controller, forces caption overrides on each open (text background opacity transparent + text edge style uniform), reports watch progress, warns when subtitle streams exist but none are web-compatible, and releases the backend stream session on close/unload.
199
- modelPreviewType(name) - Classifies direct client-side 3D preview support for `.stl` and `.obj`.
199
- modelPreviewType(name) - Classifies direct client-side 3D preview support for `.stl` and `.obj`.
200
- loadThreePreviewModules() - Lazy-loads Three.js plus OrbitControls/STLLoader/OBJLoader via import map aliases.
200
- loadThreePreviewModules() - Lazy-loads Three.js plus OrbitControls/STLLoader/OBJLoader via import map aliases.
@@ -742,6 +742,7 @@ function bindImageSubtitleOverlay (player, videojs, prefs, session, item)
742
742
overlayImgEl.style.display = 'none';
743
743
overlayImgEl.style.maxWidth = '100%';
744
744
overlayImgEl.style.maxHeight = '35%';
745
overlayImgEl.style.margin = '0 auto';
745
746
overlayImgEl.style.objectFit = 'contain';
746
747
overlayImgEl.style.filter = 'drop-shadow(0 2px 2px rgba(0, 0, 0, 0.7))';
747
748
overlayEl.appendChild(overlayImgEl);
@@ -742,6 +742,7 @@ function bindImageSubtitleOverlay (player, videojs, prefs, session, item)742
overlayImgEl.style.display = 'none';742
overlayImgEl.style.display = 'none';743
overlayImgEl.style.maxWidth = '100%';743
overlayImgEl.style.maxWidth = '100%';744
overlayImgEl.style.maxHeight = '35%';744
overlayImgEl.style.maxHeight = '35%';745
overlayImgEl.style.margin = '0 auto';745
overlayImgEl.style.objectFit = 'contain';746
overlayImgEl.style.objectFit = 'contain';746
overlayImgEl.style.filter = 'drop-shadow(0 2px 2px rgba(0, 0, 0, 0.7))';747
overlayImgEl.style.filter = 'drop-shadow(0 2px 2px rgba(0, 0, 0, 0.7))';747
overlayEl.appendChild(overlayImgEl);748
overlayEl.appendChild(overlayImgEl);@@ -421,39 +421,41 @@ async function renderEventFrame (event, canvasWidth, canvasHeight)
421
421
422
422
const targetWidth = Math.max(1, Math.round(event.imageWidth * scaleX));
423
423
const targetHeight = Math.max(1, Math.round(event.imageHeight * scaleY));
424
const left = Math.max(0, Math.round(event.left * scaleX));
425
const top = Math.max(0, Math.round(event.top * scaleY));
426
427
if (left >= canvasWidth || top >= canvasHeight)
424
const left = Math.round(event.left * scaleX);
425
const top = Math.round(event.top * scaleY);
426
const right = left + targetWidth;
427
const bottom = top + targetHeight;
428
429
const visibleLeft = Math.max(0, left);
430
const visibleTop = Math.max(0, top);
431
const visibleRight = Math.min(canvasWidth, right);
432
const visibleBottom = Math.min(canvasHeight, bottom);
433
const visibleWidth = Math.max(0, visibleRight - visibleLeft);
434
const visibleHeight = Math.max(0, visibleBottom - visibleTop);
435
436
if (visibleWidth <= 0 || visibleHeight <= 0)
428
437
{
429
return sharp({
430
create: {
431
width: canvasWidth,
432
height: canvasHeight,
433
channels: 4,
434
background: { r: 0, g: 0, b: 0, alpha: 0 },
435
},
436
}).png().toBuffer();
438
return null;
437
439
}
438
440
439
const imageBuffer = (targetWidth === event.imageWidth && targetHeight === event.imageHeight)
441
let imageBuffer = (targetWidth === event.imageWidth && targetHeight === event.imageHeight)
440
442
? event.imagePng
441
443
: await sharp(event.imagePng).resize({ width: targetWidth, height: targetHeight, fit: 'fill' }).png().toBuffer();
442
444
443
return sharp({
444
create: {
445
width: canvasWidth,
446
height: canvasHeight,
447
channels: 4,
448
background: { r: 0, g: 0, b: 0, alpha: 0 },
449
},
450
}).composite([
451
{
452
input: imageBuffer,
453
left,
454
top,
455
},
456
]).png().toBuffer();
445
if (visibleWidth < targetWidth || visibleHeight < targetHeight)
446
{
447
imageBuffer = await sharp(imageBuffer)
448
.extract({
449
left: Math.max(0, visibleLeft - left),
450
top: Math.max(0, visibleTop - top),
451
width: visibleWidth,
452
height: visibleHeight,
453
})
454
.png()
455
.toBuffer();
456
}
457
458
return imageBuffer;
457
459
}
458
460
459
461
function parseRenderOptions (options)
@@ -421,39 +421,41 @@ async function renderEventFrame (event, canvasWidth, canvasHeight)421
421
422
const targetWidth = Math.max(1, Math.round(event.imageWidth * scaleX));422
const targetWidth = Math.max(1, Math.round(event.imageWidth * scaleX));423
const targetHeight = Math.max(1, Math.round(event.imageHeight * scaleY));423
const targetHeight = Math.max(1, Math.round(event.imageHeight * scaleY));424
const left = Math.max(0, Math.round(event.left * scaleX));424
const left = Math.round(event.left * scaleX);425
const top = Math.max(0, Math.round(event.top * scaleY));425
const top = Math.round(event.top * scaleY);426
426
const right = left + targetWidth;427
if (left >= canvasWidth || top >= canvasHeight)427
const bottom = top + targetHeight;428
429
const visibleLeft = Math.max(0, left);430
const visibleTop = Math.max(0, top);431
const visibleRight = Math.min(canvasWidth, right);432
const visibleBottom = Math.min(canvasHeight, bottom);433
const visibleWidth = Math.max(0, visibleRight - visibleLeft);434
const visibleHeight = Math.max(0, visibleBottom - visibleTop);435
436
if (visibleWidth <= 0 || visibleHeight <= 0)428
{437
{429
return sharp({438
return null;430
create: {431
width: canvasWidth,432
height: canvasHeight,433
channels: 4,434
background: { r: 0, g: 0, b: 0, alpha: 0 },435
},436
}).png().toBuffer();437
}439
}438
440
439
const imageBuffer = (targetWidth === event.imageWidth && targetHeight === event.imageHeight)441
let imageBuffer = (targetWidth === event.imageWidth && targetHeight === event.imageHeight)440
? event.imagePng442
? event.imagePng441
: await sharp(event.imagePng).resize({ width: targetWidth, height: targetHeight, fit: 'fill' }).png().toBuffer();443
: await sharp(event.imagePng).resize({ width: targetWidth, height: targetHeight, fit: 'fill' }).png().toBuffer();442
444
443
return sharp({445
if (visibleWidth < targetWidth || visibleHeight < targetHeight)444
create: {446
{445
width: canvasWidth,447
imageBuffer = await sharp(imageBuffer)446
height: canvasHeight,448
.extract({447
channels: 4,449
left: Math.max(0, visibleLeft - left),448
background: { r: 0, g: 0, b: 0, alpha: 0 },450
top: Math.max(0, visibleTop - top),449
},451
width: visibleWidth,450
}).composite([452
height: visibleHeight,451
{453
})452
input: imageBuffer,454
.png()453
left,455
.toBuffer();454
top,456
}455
},457
456
]).png().toBuffer();458
return imageBuffer;457
}459
}458
460
459
function parseRenderOptions (options)461
function parseRenderOptions (options)@@ -692,10 +692,10 @@ function uploadedAtFromStat (stat)
692
692
const chosenMs = (Number.isFinite(birthtimeMs) && birthtimeMs > 0)
693
693
? birthtimeMs
694
694
: (Number.isFinite(ctimeMs) && ctimeMs > 0)
695
? ctimeMs
696
: (Number.isFinite(mtimeMs) && mtimeMs > 0)
697
? mtimeMs
698
: null;
695
? ctimeMs
696
: (Number.isFinite(mtimeMs) && mtimeMs > 0)
697
? mtimeMs
698
: null;
699
699
700
700
if (!Number.isFinite(chosenMs) || chosenMs <= 0) return null;
701
701
return new Date(chosenMs).toISOString();
@@ -1548,7 +1548,7 @@ router.delete('/video-stream/:sessionId', requireAuth, (req, res) =>
1548
1548
1549
1549
// ---------------------------------------------------------------------------
1550
1550
// GET /api/files/video-stream-subtitle-frame
1551
// Authenticated. Returns a composited PNG subtitle frame at a given timestamp.
1551
// Authenticated. Returns a rendered PNG subtitle bitmap at a given timestamp.
1552
1552
// Query params: filePath, streamIndex, timeSeconds
1553
1553
// ---------------------------------------------------------------------------
1554
1554
router.get('/video-stream-subtitle-frame', requireAuth, async (req, res, next) =>
@@ -692,10 +692,10 @@ function uploadedAtFromStat (stat)692
const chosenMs = (Number.isFinite(birthtimeMs) && birthtimeMs > 0)692
const chosenMs = (Number.isFinite(birthtimeMs) && birthtimeMs > 0)693
? birthtimeMs693
? birthtimeMs694
: (Number.isFinite(ctimeMs) && ctimeMs > 0)694
: (Number.isFinite(ctimeMs) && ctimeMs > 0)695
? ctimeMs695
? ctimeMs696
: (Number.isFinite(mtimeMs) && mtimeMs > 0)696
: (Number.isFinite(mtimeMs) && mtimeMs > 0)697
? mtimeMs697
? mtimeMs698
: null;698
: null;699
699
700
if (!Number.isFinite(chosenMs) || chosenMs <= 0) return null;700
if (!Number.isFinite(chosenMs) || chosenMs <= 0) return null;701
return new Date(chosenMs).toISOString();701
return new Date(chosenMs).toISOString();@@ -1548,7 +1548,7 @@ router.delete('/video-stream/:sessionId', requireAuth, (req, res) =>1548
1548
1549
// ---------------------------------------------------------------------------1549
// ---------------------------------------------------------------------------1550
// GET /api/files/video-stream-subtitle-frame1550
// GET /api/files/video-stream-subtitle-frame1551
// Authenticated. Returns a composited PNG subtitle frame at a given timestamp.1551
// Authenticated. Returns a rendered PNG subtitle bitmap at a given timestamp.1552
// Query params: filePath, streamIndex, timeSeconds1552
// Query params: filePath, streamIndex, timeSeconds1553
// ---------------------------------------------------------------------------1553
// ---------------------------------------------------------------------------1554
router.get('/video-stream-subtitle-frame', requireAuth, async (req, res, next) =>1554
router.get('/video-stream-subtitle-frame', requireAuth, async (req, res, next) =>@@ -704,101 +704,101 @@ describe('page load smoke test', () =>
704
704
dom.window.close();
705
705
});
706
706
707
test('folder sidebar view options apply grouping/sorting and persist per folder', async () =>
708
{
709
listFixture = {
710
'/data': [
711
{
712
name: 'sub',
713
path: '/data/sub',
714
isDir: true,
715
size: 0,
716
mtime: '2026-05-10T08:00:00.000Z',
717
uploadedAt: '2026-05-09T08:00:00.000Z',
718
},
719
{
720
name: 'small.txt',
721
path: '/data/small.txt',
722
isDir: false,
723
size: 20,
724
mtime: '2026-05-15T10:00:00.000Z',
725
uploadedAt: '2026-05-15T10:00:00.000Z',
726
},
727
{
728
name: 'big.txt',
729
path: '/data/big.txt',
730
isDir: false,
731
size: 100,
732
mtime: '2026-05-11T10:00:00.000Z',
733
uploadedAt: '2026-05-11T10:00:00.000Z',
734
},
735
{
736
name: 'clip.mp4',
737
path: '/data/clip.mp4',
738
isDir: false,
739
size: 50,
740
mtime: '2026-05-12T10:00:00.000Z',
741
uploadedAt: '2026-05-12T10:00:00.000Z',
742
},
743
],
744
'/data/sub': [
745
{
746
name: 'inside.txt',
747
path: '/data/sub/inside.txt',
748
isDir: false,
749
size: 1,
750
mtime: '2026-05-01T00:00:00.000Z',
751
uploadedAt: '2026-05-01T00:00:00.000Z',
752
},
753
],
754
};
707
test('folder sidebar view options apply grouping/sorting and persist per folder', async () =>
708
{
709
listFixture = {
710
'/data': [
711
{
712
name: 'sub',
713
path: '/data/sub',
714
isDir: true,
715
size: 0,
716
mtime: '2026-05-10T08:00:00.000Z',
717
uploadedAt: '2026-05-09T08:00:00.000Z',
718
},
719
{
720
name: 'small.txt',
721
path: '/data/small.txt',
722
isDir: false,
723
size: 20,
724
mtime: '2026-05-15T10:00:00.000Z',
725
uploadedAt: '2026-05-15T10:00:00.000Z',
726
},
727
{
728
name: 'big.txt',
729
path: '/data/big.txt',
730
isDir: false,
731
size: 100,
732
mtime: '2026-05-11T10:00:00.000Z',
733
uploadedAt: '2026-05-11T10:00:00.000Z',
734
},
735
{
736
name: 'clip.mp4',
737
path: '/data/clip.mp4',
738
isDir: false,
739
size: 50,
740
mtime: '2026-05-12T10:00:00.000Z',
741
uploadedAt: '2026-05-12T10:00:00.000Z',
742
},
743
],
744
'/data/sub': [
745
{
746
name: 'inside.txt',
747
path: '/data/sub/inside.txt',
748
isDir: false,
749
size: 1,
750
mtime: '2026-05-01T00:00:00.000Z',
751
uploadedAt: '2026-05-01T00:00:00.000Z',
752
},
753
],
754
};
755
755
756
const { dom, runtimeErrors } = await bootClient();
757
expect(runtimeErrors).toEqual([]);
756
const { dom, runtimeErrors } = await bootClient();
757
expect(runtimeErrors).toEqual([]);
758
758
759
await waitFor(dom, () => dom.window.document.querySelectorAll('.file-item').length === 4);
760
await waitFor(dom, () => !!dom.window.document.querySelector('select[data-view-option="sort"]'));
761
const sortSelect = dom.window.document.querySelector('select[data-view-option="sort"]');
762
const groupSelect = dom.window.document.querySelector('select[data-view-option="group"]');
763
const ascInput = dom.window.document.querySelector('input[data-view-option="ascending"]');
764
expect(sortSelect).toBeTruthy();
765
expect(groupSelect).toBeTruthy();
766
expect(ascInput).toBeTruthy();
759
await waitFor(dom, () => dom.window.document.querySelectorAll('.file-item').length === 4);
760
await waitFor(dom, () => !!dom.window.document.querySelector('select[data-view-option="sort"]'));
761
const sortSelect = dom.window.document.querySelector('select[data-view-option="sort"]');
762
const groupSelect = dom.window.document.querySelector('select[data-view-option="group"]');
763
const ascInput = dom.window.document.querySelector('input[data-view-option="ascending"]');
764
expect(sortSelect).toBeTruthy();
765
expect(groupSelect).toBeTruthy();
766
expect(ascInput).toBeTruthy();
767
767
768
sortSelect.value = 'size';
769
sortSelect.dispatchEvent(new dom.window.Event('change', { bubbles: true }));
770
ascInput.checked = false;
771
ascInput.dispatchEvent(new dom.window.Event('change', { bubbles: true }));
768
sortSelect.value = 'size';
769
sortSelect.dispatchEvent(new dom.window.Event('change', { bubbles: true }));
770
ascInput.checked = false;
771
ascInput.dispatchEvent(new dom.window.Event('change', { bubbles: true }));
772
772
773
await waitFor(dom, () =>
774
{
775
const names = Array.from(dom.window.document.querySelectorAll('.file-item .name')).map((el) => el.textContent);
776
const bigIdx = names.indexOf('big.txt');
777
const clipIdx = names.indexOf('clip.mp4');
778
const smallIdx = names.indexOf('small.txt');
779
return names[0] === 'sub' && bigIdx > -1 && clipIdx > -1 && smallIdx > -1 && bigIdx < clipIdx && clipIdx < smallIdx;
780
});
781
782
groupSelect.value = 'fileType';
783
groupSelect.dispatchEvent(new dom.window.Event('change', { bubbles: true }));
784
await waitFor(dom, () => dom.window.document.querySelectorAll('.file-group-separator').length >= 2);
785
786
const subTile = dom.window.document.querySelector('.file-item[data-path="/data/sub"]');
787
subTile.dispatchEvent(new dom.window.MouseEvent('dblclick', { bubbles: true }));
788
await waitFor(dom, () => !!dom.window.document.querySelector('.file-item[data-path="/data/sub/inside.txt"]'));
789
790
const homeCrumb = dom.window.document.querySelector('#breadcrumb .crumb');
791
homeCrumb.dispatchEvent(new dom.window.MouseEvent('click', { bubbles: true }));
792
793
await waitFor(dom, () => !!dom.window.document.querySelector('.file-item[data-path="/data/sub"]'));
794
await waitFor(dom, () => !!dom.window.document.querySelector('select[data-view-option="group"]'));
795
expect(dom.window.document.querySelector('select[data-view-option="sort"]').value).toBe('size');
796
expect(dom.window.document.querySelector('select[data-view-option="group"]').value).toBe('fileType');
797
expect(dom.window.document.querySelectorAll('.file-group-separator').length).toBeGreaterThanOrEqual(2);
798
799
dom.window.close();
773
await waitFor(dom, () =>
774
{
775
const names = Array.from(dom.window.document.querySelectorAll('.file-item .name')).map((el) => el.textContent);
776
const bigIdx = names.indexOf('big.txt');
777
const clipIdx = names.indexOf('clip.mp4');
778
const smallIdx = names.indexOf('small.txt');
779
return names[0] === 'sub' && bigIdx > -1 && clipIdx > -1 && smallIdx > -1 && bigIdx < clipIdx && clipIdx < smallIdx;
800
780
});
801
781
782
groupSelect.value = 'fileType';
783
groupSelect.dispatchEvent(new dom.window.Event('change', { bubbles: true }));
784
await waitFor(dom, () => dom.window.document.querySelectorAll('.file-group-separator').length >= 2);
785
786
const subTile = dom.window.document.querySelector('.file-item[data-path="/data/sub"]');
787
subTile.dispatchEvent(new dom.window.MouseEvent('dblclick', { bubbles: true }));
788
await waitFor(dom, () => !!dom.window.document.querySelector('.file-item[data-path="/data/sub/inside.txt"]'));
789
790
const homeCrumb = dom.window.document.querySelector('#breadcrumb .crumb');
791
homeCrumb.dispatchEvent(new dom.window.MouseEvent('click', { bubbles: true }));
792
793
await waitFor(dom, () => !!dom.window.document.querySelector('.file-item[data-path="/data/sub"]'));
794
await waitFor(dom, () => !!dom.window.document.querySelector('select[data-view-option="group"]'));
795
expect(dom.window.document.querySelector('select[data-view-option="sort"]').value).toBe('size');
796
expect(dom.window.document.querySelector('select[data-view-option="group"]').value).toBe('fileType');
797
expect(dom.window.document.querySelectorAll('.file-group-separator').length).toBeGreaterThanOrEqual(2);
798
799
dom.window.close();
800
});
801
802
802
test('date grouping uses relative written labels for recent days', async () =>
803
803
{
804
804
const now = new Date();
@@ -704,101 +704,101 @@ describe('page load smoke test', () =>704
dom.window.close();
704
dom.window.close();
705
});
705
});
706
706
707
test('folder sidebar view options apply grouping/sorting and persist per folder', async () =>
707
test('folder sidebar view options apply grouping/sorting and persist per folder', async () =>
708
{
708
{
709
listFixture = {
709
listFixture = {
710
'/data': [
710
'/data': [
711
{
711
{
712
name: 'sub',
712
name: 'sub',
713
path: '/data/sub',
713
path: '/data/sub',
714
isDir: true,
714
isDir: true,
715
size: 0,
715
size: 0,
716
mtime: '2026-05-10T08:00:00.000Z',
716
mtime: '2026-05-10T08:00:00.000Z',
717
uploadedAt: '2026-05-09T08:00:00.000Z',
717
uploadedAt: '2026-05-09T08:00:00.000Z',
718
},
718
},
719
{
719
{
720
name: 'small.txt',
720
name: 'small.txt',
721
path: '/data/small.txt',
721
path: '/data/small.txt',
722
isDir: false,
722
isDir: false,
723
size: 20,
723
size: 20,
724
mtime: '2026-05-15T10:00:00.000Z',
724
mtime: '2026-05-15T10:00:00.000Z',
725
uploadedAt: '2026-05-15T10:00:00.000Z',
725
uploadedAt: '2026-05-15T10:00:00.000Z',
726
},
726
},
727
{
727
{
728
name: 'big.txt',
728
name: 'big.txt',
729
path: '/data/big.txt',
729
path: '/data/big.txt',
730
isDir: false,
730
isDir: false,
731
size: 100,
731
size: 100,
732
mtime: '2026-05-11T10:00:00.000Z',
732
mtime: '2026-05-11T10:00:00.000Z',
733
uploadedAt: '2026-05-11T10:00:00.000Z',
733
uploadedAt: '2026-05-11T10:00:00.000Z',
734
},
734
},
735
{
735
{
736
name: 'clip.mp4',
736
name: 'clip.mp4',
737
path: '/data/clip.mp4',
737
path: '/data/clip.mp4',
738
isDir: false,
738
isDir: false,
739
size: 50,
739
size: 50,
740
mtime: '2026-05-12T10:00:00.000Z',
740
mtime: '2026-05-12T10:00:00.000Z',
741
uploadedAt: '2026-05-12T10:00:00.000Z',
741
uploadedAt: '2026-05-12T10:00:00.000Z',
742
},
742
},
743
],
743
],
744
'/data/sub': [
744
'/data/sub': [
745
{
745
{
746
name: 'inside.txt',
746
name: 'inside.txt',
747
path: '/data/sub/inside.txt',
747
path: '/data/sub/inside.txt',
748
isDir: false,
748
isDir: false,
749
size: 1,
749
size: 1,
750
mtime: '2026-05-01T00:00:00.000Z',
750
mtime: '2026-05-01T00:00:00.000Z',
751
uploadedAt: '2026-05-01T00:00:00.000Z',
751
uploadedAt: '2026-05-01T00:00:00.000Z',
752
},
752
},
753
],
753
],
754
};
754
};
755
755
756
const { dom, runtimeErrors } = await bootClient();
756
const { dom, runtimeErrors } = await bootClient();
757
expect(runtimeErrors).toEqual([]);
757
expect(runtimeErrors).toEqual([]);
758
758
759
await waitFor(dom, () => dom.window.document.querySelectorAll('.file-item').length === 4);
759
await waitFor(dom, () => dom.window.document.querySelectorAll('.file-item').length === 4);
760
await waitFor(dom, () => !!dom.window.document.querySelector('select[data-view-option="sort"]'));
760
await waitFor(dom, () => !!dom.window.document.querySelector('select[data-view-option="sort"]'));
761
const sortSelect = dom.window.document.querySelector('select[data-view-option="sort"]');
761
const sortSelect = dom.window.document.querySelector('select[data-view-option="sort"]');
762
const groupSelect = dom.window.document.querySelector('select[data-view-option="group"]');
762
const groupSelect = dom.window.document.querySelector('select[data-view-option="group"]');
763
const ascInput = dom.window.document.querySelector('input[data-view-option="ascending"]');
763
const ascInput = dom.window.document.querySelector('input[data-view-option="ascending"]');
764
expect(sortSelect).toBeTruthy();
764
expect(sortSelect).toBeTruthy();
765
expect(groupSelect).toBeTruthy();
765
expect(groupSelect).toBeTruthy();
766
expect(ascInput).toBeTruthy();
766
expect(ascInput).toBeTruthy();
767
767
768
sortSelect.value = 'size';
768
sortSelect.value = 'size';
769
sortSelect.dispatchEvent(new dom.window.Event('change', { bubbles: true }));
769
sortSelect.dispatchEvent(new dom.window.Event('change', { bubbles: true }));
770
ascInput.checked = false;
770
ascInput.checked = false;
771
ascInput.dispatchEvent(new dom.window.Event('change', { bubbles: true }));
771
ascInput.dispatchEvent(new dom.window.Event('change', { bubbles: true }));
772
772
773
await waitFor(dom, () =>
773
await waitFor(dom, () =>
774
{
774
{
775
const names = Array.from(dom.window.document.querySelectorAll('.file-item .name')).map((el) => el.textContent);
775
const names = Array.from(dom.window.document.querySelectorAll('.file-item .name')).map((el) => el.textContent);
776
const bigIdx = names.indexOf('big.txt');
776
const bigIdx = names.indexOf('big.txt');
777
const clipIdx = names.indexOf('clip.mp4');
777
const clipIdx = names.indexOf('clip.mp4');
778
const smallIdx = names.indexOf('small.txt');
778
const smallIdx = names.indexOf('small.txt');
779
return names[0] === 'sub' && bigIdx > -1 && clipIdx > -1 && smallIdx > -1 && bigIdx < clipIdx && clipIdx < smallIdx;
779
return names[0] === 'sub' && bigIdx > -1 && clipIdx > -1 && smallIdx > -1 && bigIdx < clipIdx && clipIdx < smallIdx;
780
});
781
782
groupSelect.value = 'fileType';
783
groupSelect.dispatchEvent(new dom.window.Event('change', { bubbles: true }));
784
await waitFor(dom, () => dom.window.document.querySelectorAll('.file-group-separator').length >= 2);
785
786
const subTile = dom.window.document.querySelector('.file-item[data-path="/data/sub"]');
787
subTile.dispatchEvent(new dom.window.MouseEvent('dblclick', { bubbles: true }));
788
await waitFor(dom, () => !!dom.window.document.querySelector('.file-item[data-path="/data/sub/inside.txt"]'));
789
790
const homeCrumb = dom.window.document.querySelector('#breadcrumb .crumb');
791
homeCrumb.dispatchEvent(new dom.window.MouseEvent('click', { bubbles: true }));
792
793
await waitFor(dom, () => !!dom.window.document.querySelector('.file-item[data-path="/data/sub"]'));
794
await waitFor(dom, () => !!dom.window.document.querySelector('select[data-view-option="group"]'));
795
expect(dom.window.document.querySelector('select[data-view-option="sort"]').value).toBe('size');
796
expect(dom.window.document.querySelector('select[data-view-option="group"]').value).toBe('fileType');
797
expect(dom.window.document.querySelectorAll('.file-group-separator').length).toBeGreaterThanOrEqual(2);
798
799
dom.window.close();
800
});
780
});
801
781
782
groupSelect.value = 'fileType';
783
groupSelect.dispatchEvent(new dom.window.Event('change', { bubbles: true }));
784
await waitFor(dom, () => dom.window.document.querySelectorAll('.file-group-separator').length >= 2);
785
786
const subTile = dom.window.document.querySelector('.file-item[data-path="/data/sub"]');
787
subTile.dispatchEvent(new dom.window.MouseEvent('dblclick', { bubbles: true }));
788
await waitFor(dom, () => !!dom.window.document.querySelector('.file-item[data-path="/data/sub/inside.txt"]'));
789
790
const homeCrumb = dom.window.document.querySelector('#breadcrumb .crumb');
791
homeCrumb.dispatchEvent(new dom.window.MouseEvent('click', { bubbles: true }));
792
793
await waitFor(dom, () => !!dom.window.document.querySelector('.file-item[data-path="/data/sub"]'));
794
await waitFor(dom, () => !!dom.window.document.querySelector('select[data-view-option="group"]'));
795
expect(dom.window.document.querySelector('select[data-view-option="sort"]').value).toBe('size');
796
expect(dom.window.document.querySelector('select[data-view-option="group"]').value).toBe('fileType');
797
expect(dom.window.document.querySelectorAll('.file-group-separator').length).toBeGreaterThanOrEqual(2);
798
799
dom.window.close();
800
});
801
802
test('date grouping uses relative written labels for recent days', async () =>
802
test('date grouping uses relative written labels for recent days', async () =>
803
{
803
{
804
const now = new Date();
804
const now = new Date();