BlueGit

timfa filemanager

formatting

timfa Tim Falken · pushed by timfa

Authored 2026-05-14 · 6 months ago

Hash
abe013c02c68b315667f7706580f34b3ee08f867
Parent
7c87f490
6 files changed +115 −109
public/app.js +13 −13
@@ -1797,16 +1797,16 @@ async function openSidebar (item)
1797 1797 renderSidebarDuplicates(item, null); // show loading state
1798 1798 const selectedPathAtRequest = item.path;
1799 1799 api('GET', `/files/duplicates?file=${encodeURIComponent(item.path)}`)
1800 .then((data) =>
1801 {
1802 if (!STATE.selectedItem || STATE.selectedItem.path !== selectedPathAtRequest) return;
1803 renderSidebarDuplicates(item, data ? data.duplicates : []);
1804 })
1805 .catch(() =>
1806 {
1807 if (!STATE.selectedItem || STATE.selectedItem.path !== selectedPathAtRequest) return;
1808 renderSidebarDuplicates(item, []);
1809 });
1800 .then((data) =>
1801 {
1802 if (!STATE.selectedItem || STATE.selectedItem.path !== selectedPathAtRequest) return;
1803 renderSidebarDuplicates(item, data ? data.duplicates : []);
1804 })
1805 .catch(() =>
1806 {
1807 if (!STATE.selectedItem || STATE.selectedItem.path !== selectedPathAtRequest) return;
1808 renderSidebarDuplicates(item, []);
1809 });
1810 1810
1811 1811 // View / download button
1812 1812 const btnDl = document.createElement('button');
@@ -2532,7 +2532,7 @@ async function openFolderIconPicker (item)
2532 2532 const blob = await r.blob();
2533 2533 const url = URL.createObjectURL(blob);
2534 2534 imgEl.src = url;
2535 }).catch(() => {});
2535 }).catch(() => { });
2536 2536 }
2537 2537 }
2538 2538
@@ -2800,8 +2800,8 @@ async function ensureVideoJsLoaded ()
2800 2800
2801 2801 function configureVideoJsBuffering (videojs)
2802 2802 {
2803 if (! VIDEO_FORWARD_BUFFER_OVERRIDE_ENABLED)
2804 return;
2803 if (!VIDEO_FORWARD_BUFFER_OVERRIDE_ENABLED)
2804 return;
2805 2805
2806 2806 if (!videojs || !videojs.Vhs || videojs.__filemanagerBufferingConfigured) return;
2807 2807 videojs.__filemanagerBufferingConfigured = true;
@@ -1797,16 +1797,16 @@ async function openSidebar (item)
1797 renderSidebarDuplicates(item, null); // show loading state
1797 renderSidebarDuplicates(item, null); // show loading state
1798 const selectedPathAtRequest = item.path;
1798 const selectedPathAtRequest = item.path;
1799 api('GET', `/files/duplicates?file=${encodeURIComponent(item.path)}`)
1799 api('GET', `/files/duplicates?file=${encodeURIComponent(item.path)}`)
1800 .then((data) =>
1800 .then((data) =>
1801 {
1801 {
1802 if (!STATE.selectedItem || STATE.selectedItem.path !== selectedPathAtRequest) return;
1802 if (!STATE.selectedItem || STATE.selectedItem.path !== selectedPathAtRequest) return;
1803 renderSidebarDuplicates(item, data ? data.duplicates : []);
1803 renderSidebarDuplicates(item, data ? data.duplicates : []);
1804 })
1804 })
1805 .catch(() =>
1805 .catch(() =>
1806 {
1806 {
1807 if (!STATE.selectedItem || STATE.selectedItem.path !== selectedPathAtRequest) return;
1807 if (!STATE.selectedItem || STATE.selectedItem.path !== selectedPathAtRequest) return;
1808 renderSidebarDuplicates(item, []);
1808 renderSidebarDuplicates(item, []);
1809 });
1809 });
1810
1810
1811 // View / download button
1811 // View / download button
1812 const btnDl = document.createElement('button');
1812 const btnDl = document.createElement('button');
@@ -2532,7 +2532,7 @@ async function openFolderIconPicker (item)
2532 const blob = await r.blob();
2532 const blob = await r.blob();
2533 const url = URL.createObjectURL(blob);
2533 const url = URL.createObjectURL(blob);
2534 imgEl.src = url;
2534 imgEl.src = url;
2535 }).catch(() => {});
2535 }).catch(() => { });
2536 }
2536 }
2537}
2537}
2538
2538
@@ -2800,8 +2800,8 @@ async function ensureVideoJsLoaded ()
2800
2800
2801function configureVideoJsBuffering (videojs)
2801function configureVideoJsBuffering (videojs)
2802{
2802{
2803 if (! VIDEO_FORWARD_BUFFER_OVERRIDE_ENABLED)
2803 if (!VIDEO_FORWARD_BUFFER_OVERRIDE_ENABLED)
2804return;
2804 return;
2805
2805
2806 if (!videojs || !videojs.Vhs || videojs.__filemanagerBufferingConfigured) return;
2806 if (!videojs || !videojs.Vhs || videojs.__filemanagerBufferingConfigured) return;
2807 videojs.__filemanagerBufferingConfigured = true;
2807 videojs.__filemanagerBufferingConfigured = true;
public/style.css +7 −2
@@ -327,8 +327,13 @@ button.danger:hover {
327 327 }
328 328
329 329 @keyframes icon-thumb-spin {
330 from { transform: translate(-50%, -50%) rotate(0deg); }
331 to { transform: translate(-50%, -50%) rotate(360deg); }
330 from {
331 transform: translate(-50%, -50%) rotate(0deg);
332 }
333
334 to {
335 transform: translate(-50%, -50%) rotate(360deg);
336 }
332 337 }
333 338
334 339 .file-item .icon svg {
@@ -327,8 +327,13 @@ button.danger:hover {
327}
327}
328
328
329@keyframes icon-thumb-spin {
329@keyframes icon-thumb-spin {
330 from { transform: translate(-50%, -50%) rotate(0deg); }
330 from {
331 to { transform: translate(-50%, -50%) rotate(360deg); }
331 transform: translate(-50%, -50%) rotate(0deg);
332 }
333
334 to {
335 transform: translate(-50%, -50%) rotate(360deg);
336 }
332}
337}
333
338
334.file-item .icon svg {
339.file-item .icon svg {
server/routes/share.js +9 −9
@@ -428,28 +428,28 @@ function buildShareOpenGraphPage (token, req)
428 428 if (!row)
429 429 {
430 430 pageTitle = 'Link Not Found';
431 ogTitle = 'Link Not Found';
432 ogDesc = 'This shared file link does not exist.';
431 ogTitle = 'Link Not Found';
432 ogDesc = 'This shared file link does not exist.';
433 433 twitterCard = 'summary';
434 434 }
435 435 else
436 436 {
437 const name = path.basename(row.file_path);
437 const name = path.basename(row.file_path);
438 438 const expired = Date.now() > row.expires_at;
439 439
440 440 if (expired)
441 441 {
442 pageTitle = `Link Expired \u2014 ${name}`;
443 ogTitle = 'Link Expired';
444 ogDesc = `This shared link for \u201C${name}\u201D has expired.`;
442 pageTitle = `Link Expired \u2014 ${name}`;
443 ogTitle = 'Link Expired';
444 ogDesc = `This shared link for \u201C${name}\u201D has expired.`;
445 445 twitterCard = 'summary';
446 446 }
447 447 else
448 448 {
449 449 pageTitle = name;
450 ogTitle = name;
450 ogTitle = name;
451 451
452 const validity = formatOgValidity(row.expires_at);
452 const validity = formatOgValidity(row.expires_at);
453 453 const typeLabel = row.is_dir ? 'folder' : 'file';
454 454 ogDesc = validity
455 455 ? `Shared ${typeLabel} \u00B7 Valid for ${validity}`
@@ -457,7 +457,7 @@ function buildShareOpenGraphPage (token, req)
457 457
458 458 if (!row.is_dir && OG_IMAGE_EXTS.has(fileExtLower(name)))
459 459 {
460 ogImageUrl = `${baseUrl}/api/share/preview/${encodeURIComponent(token)}`;
460 ogImageUrl = `${baseUrl}/api/share/preview/${encodeURIComponent(token)}`;
461 461 twitterCard = 'summary_large_image';
462 462 }
463 463 else
@@ -428,28 +428,28 @@ function buildShareOpenGraphPage (token, req)
428 if (!row)
428 if (!row)
429 {
429 {
430 pageTitle = 'Link Not Found';
430 pageTitle = 'Link Not Found';
431 ogTitle = 'Link Not Found';
431 ogTitle = 'Link Not Found';
432 ogDesc = 'This shared file link does not exist.';
432 ogDesc = 'This shared file link does not exist.';
433 twitterCard = 'summary';
433 twitterCard = 'summary';
434 }
434 }
435 else
435 else
436 {
436 {
437 const name = path.basename(row.file_path);
437 const name = path.basename(row.file_path);
438 const expired = Date.now() > row.expires_at;
438 const expired = Date.now() > row.expires_at;
439
439
440 if (expired)
440 if (expired)
441 {
441 {
442 pageTitle = `Link Expired \u2014 ${name}`;
442 pageTitle = `Link Expired \u2014 ${name}`;
443 ogTitle = 'Link Expired';
443 ogTitle = 'Link Expired';
444 ogDesc = `This shared link for \u201C${name}\u201D has expired.`;
444 ogDesc = `This shared link for \u201C${name}\u201D has expired.`;
445 twitterCard = 'summary';
445 twitterCard = 'summary';
446 }
446 }
447 else
447 else
448 {
448 {
449 pageTitle = name;
449 pageTitle = name;
450 ogTitle = name;
450 ogTitle = name;
451
451
452 const validity = formatOgValidity(row.expires_at);
452 const validity = formatOgValidity(row.expires_at);
453 const typeLabel = row.is_dir ? 'folder' : 'file';
453 const typeLabel = row.is_dir ? 'folder' : 'file';
454 ogDesc = validity
454 ogDesc = validity
455 ? `Shared ${typeLabel} \u00B7 Valid for ${validity}`
455 ? `Shared ${typeLabel} \u00B7 Valid for ${validity}`
@@ -457,7 +457,7 @@ function buildShareOpenGraphPage (token, req)
457
457
458 if (!row.is_dir && OG_IMAGE_EXTS.has(fileExtLower(name)))
458 if (!row.is_dir && OG_IMAGE_EXTS.has(fileExtLower(name)))
459 {
459 {
460 ogImageUrl = `${baseUrl}/api/share/preview/${encodeURIComponent(token)}`;
460 ogImageUrl = `${baseUrl}/api/share/preview/${encodeURIComponent(token)}`;
461 twitterCard = 'summary_large_image';
461 twitterCard = 'summary_large_image';
462 }
462 }
463 else
463 else
tests/files.routes.test.js +74 −74
@@ -284,7 +284,7 @@ function abortMultipartUpload (routePath, file)
284 284 });
285 285 }
286 286
287 async function waitFor(predicate, timeoutMs = 500)
287 async function waitFor (predicate, timeoutMs = 500)
288 288 {
289 289 const start = Date.now();
290 290 while (Date.now() - start < timeoutMs)
@@ -389,88 +389,88 @@ describe('POST /api/files/move', () =>
389 389 expect(body.error).toMatch(/folder into itself/i);
390 390 });
391 391
392 test('overwrites an existing destination when conflict strategy is overwrite', async () =>
393 {
394 const sourceFile = path.join(rootDir, 'source.txt');
395 const destinationDir = path.join(rootDir, 'dest');
396 fs.mkdirSync(destinationDir);
397 fs.writeFileSync(sourceFile, 'new-content');
398 fs.writeFileSync(path.join(destinationDir, 'source.txt'), 'old-content');
399
400 const { status, body } = await req('POST', '/api/files/move', {
401 from: sourceFile,
402 toDir: destinationDir,
403 conflict: 'overwrite',
404 });
392 test('overwrites an existing destination when conflict strategy is overwrite', async () =>
393 {
394 const sourceFile = path.join(rootDir, 'source.txt');
395 const destinationDir = path.join(rootDir, 'dest');
396 fs.mkdirSync(destinationDir);
397 fs.writeFileSync(sourceFile, 'new-content');
398 fs.writeFileSync(path.join(destinationDir, 'source.txt'), 'old-content');
405 399
406 expect(status).toBe(200);
407 expect(body.conflictResolution).toBe('overwrite');
408 expect(fs.existsSync(sourceFile)).toBe(false);
409 expect(fs.readFileSync(path.join(destinationDir, 'source.txt'), 'utf8')).toBe('new-content');
400 const { status, body } = await req('POST', '/api/files/move', {
401 from: sourceFile,
402 toDir: destinationDir,
403 conflict: 'overwrite',
410 404 });
411 405
412 test('renames destination when conflict strategy is rename', async () =>
413 {
414 const sourceFile = path.join(rootDir, 'report.txt');
415 const destinationDir = path.join(rootDir, 'dest');
416 fs.mkdirSync(destinationDir);
417 fs.writeFileSync(sourceFile, 'latest');
418 fs.writeFileSync(path.join(destinationDir, 'report.txt'), 'existing');
419
420 const { status, body } = await req('POST', '/api/files/move', {
421 from: sourceFile,
422 toDir: destinationDir,
423 conflict: 'rename',
424 });
406 expect(status).toBe(200);
407 expect(body.conflictResolution).toBe('overwrite');
408 expect(fs.existsSync(sourceFile)).toBe(false);
409 expect(fs.readFileSync(path.join(destinationDir, 'source.txt'), 'utf8')).toBe('new-content');
410 });
425 411
426 expect(status).toBe(200);
427 expect(body.conflictResolution).toBe('rename');
428 expect(path.basename(body.path)).toBe('report (1).txt');
429 expect(fs.readFileSync(body.path, 'utf8')).toBe('latest');
430 expect(fs.readFileSync(path.join(destinationDir, 'report.txt'), 'utf8')).toBe('existing');
412 test('renames destination when conflict strategy is rename', async () =>
413 {
414 const sourceFile = path.join(rootDir, 'report.txt');
415 const destinationDir = path.join(rootDir, 'dest');
416 fs.mkdirSync(destinationDir);
417 fs.writeFileSync(sourceFile, 'latest');
418 fs.writeFileSync(path.join(destinationDir, 'report.txt'), 'existing');
419
420 const { status, body } = await req('POST', '/api/files/move', {
421 from: sourceFile,
422 toDir: destinationDir,
423 conflict: 'rename',
431 424 });
432 425
433 test('moves a file into My Folder when rename falls back across filesystems', async () =>
426 expect(status).toBe(200);
427 expect(body.conflictResolution).toBe('rename');
428 expect(path.basename(body.path)).toBe('report (1).txt');
429 expect(fs.readFileSync(body.path, 'utf8')).toBe('latest');
430 expect(fs.readFileSync(path.join(destinationDir, 'report.txt'), 'utf8')).toBe('existing');
431 });
432
433 test('moves a file into My Folder when rename falls back across filesystems', async () =>
434 {
435 const sourceFile = path.join(rootDir, 'cross-root.txt');
436 const userFolderBase = fs.mkdtempSync(path.join(os.tmpdir(), 'filemanager-userfolders-'));
437 const userFolder = path.join(userFolderBase, 'alice');
438
439 mockPaths = [rootDir];
440 mockUserPath = userFolderBase;
441 mockUser = {
442 username: 'alice',
443 isAdmin: false,
444 permissions: {
445 [path.basename(rootDir)]: { read: true, write: true },
446 },
447 };
448
449 fs.writeFileSync(sourceFile, 'hello');
450 fs.mkdirSync(userFolder, { recursive: true });
451
452 const originalRenameSync = fs.renameSync;
453 fs.renameSync = (from, to) =>
434 454 {
435 const sourceFile = path.join(rootDir, 'cross-root.txt');
436 const userFolderBase = fs.mkdtempSync(path.join(os.tmpdir(), 'filemanager-userfolders-'));
437 const userFolder = path.join(userFolderBase, 'alice');
438
439 mockPaths = [rootDir];
440 mockUserPath = userFolderBase;
441 mockUser = {
442 username: 'alice',
443 isAdmin: false,
444 permissions: {
445 [path.basename(rootDir)]: { read: true, write: true },
446 },
447 };
448
449 fs.writeFileSync(sourceFile, 'hello');
450 fs.mkdirSync(userFolder, { recursive: true });
451
452 const originalRenameSync = fs.renameSync;
453 fs.renameSync = (from, to) =>
454 {
455 const err = new Error('cross-device move');
456 err.code = 'EXDEV';
457 throw err;
458 };
455 const err = new Error('cross-device move');
456 err.code = 'EXDEV';
457 throw err;
458 };
459 459
460 try
461 {
462 const { status, body } = await req('POST', '/api/files/move', { from: sourceFile, toDir: userFolder });
460 try
461 {
462 const { status, body } = await req('POST', '/api/files/move', { from: sourceFile, toDir: userFolder });
463 463
464 expect(status).toBe(200);
465 expect(body.path).toBe(path.join(userFolder, 'cross-root.txt'));
466 expect(fs.existsSync(sourceFile)).toBe(false);
467 expect(fs.readFileSync(path.join(userFolder, 'cross-root.txt'), 'utf8')).toBe('hello');
468 } finally
469 {
470 fs.renameSync = originalRenameSync;
471 fs.rmSync(userFolderBase, { recursive: true, force: true });
472 }
473 });
464 expect(status).toBe(200);
465 expect(body.path).toBe(path.join(userFolder, 'cross-root.txt'));
466 expect(fs.existsSync(sourceFile)).toBe(false);
467 expect(fs.readFileSync(path.join(userFolder, 'cross-root.txt'), 'utf8')).toBe('hello');
468 } finally
469 {
470 fs.renameSync = originalRenameSync;
471 fs.rmSync(userFolderBase, { recursive: true, force: true });
472 }
473 });
474 474 });
475 475
476 476 describe('root alias endpoints', () =>
@@ -284,7 +284,7 @@ function abortMultipartUpload (routePath, file)
284 });
284 });
285}
285}
286
286
287async function waitFor(predicate, timeoutMs = 500)
287async function waitFor (predicate, timeoutMs = 500)
288{
288{
289 const start = Date.now();
289 const start = Date.now();
290 while (Date.now() - start < timeoutMs)
290 while (Date.now() - start < timeoutMs)
@@ -389,88 +389,88 @@ describe('POST /api/files/move', () =>
389 expect(body.error).toMatch(/folder into itself/i);
389 expect(body.error).toMatch(/folder into itself/i);
390 });
390 });
391
391
392 test('overwrites an existing destination when conflict strategy is overwrite', async () =>
392 test('overwrites an existing destination when conflict strategy is overwrite', async () =>
393 {
393 {
394 const sourceFile = path.join(rootDir, 'source.txt');
394 const sourceFile = path.join(rootDir, 'source.txt');
395 const destinationDir = path.join(rootDir, 'dest');
395 const destinationDir = path.join(rootDir, 'dest');
396 fs.mkdirSync(destinationDir);
396 fs.mkdirSync(destinationDir);
397 fs.writeFileSync(sourceFile, 'new-content');
397 fs.writeFileSync(sourceFile, 'new-content');
398 fs.writeFileSync(path.join(destinationDir, 'source.txt'), 'old-content');
398 fs.writeFileSync(path.join(destinationDir, 'source.txt'), 'old-content');
399
400 const { status, body } = await req('POST', '/api/files/move', {
401 from: sourceFile,
402 toDir: destinationDir,
403 conflict: 'overwrite',
404 });
405
399
406 expect(status).toBe(200);
400 const { status, body } = await req('POST', '/api/files/move', {
407 expect(body.conflictResolution).toBe('overwrite');
401 from: sourceFile,
408 expect(fs.existsSync(sourceFile)).toBe(false);
402 toDir: destinationDir,
409 expect(fs.readFileSync(path.join(destinationDir, 'source.txt'), 'utf8')).toBe('new-content');
403 conflict: 'overwrite',
410 });
404 });
411
405
412 test('renames destination when conflict strategy is rename', async () =>
406 expect(status).toBe(200);
413 {
407 expect(body.conflictResolution).toBe('overwrite');
414 const sourceFile = path.join(rootDir, 'report.txt');
408 expect(fs.existsSync(sourceFile)).toBe(false);
415 const destinationDir = path.join(rootDir, 'dest');
409 expect(fs.readFileSync(path.join(destinationDir, 'source.txt'), 'utf8')).toBe('new-content');
416 fs.mkdirSync(destinationDir);
410 });
417 fs.writeFileSync(sourceFile, 'latest');
418 fs.writeFileSync(path.join(destinationDir, 'report.txt'), 'existing');
419
420 const { status, body } = await req('POST', '/api/files/move', {
421 from: sourceFile,
422 toDir: destinationDir,
423 conflict: 'rename',
424 });
425
411
426 expect(status).toBe(200);
412 test('renames destination when conflict strategy is rename', async () =>
427 expect(body.conflictResolution).toBe('rename');
413 {
428 expect(path.basename(body.path)).toBe('report (1).txt');
414 const sourceFile = path.join(rootDir, 'report.txt');
429 expect(fs.readFileSync(body.path, 'utf8')).toBe('latest');
415 const destinationDir = path.join(rootDir, 'dest');
430 expect(fs.readFileSync(path.join(destinationDir, 'report.txt'), 'utf8')).toBe('existing');
416 fs.mkdirSync(destinationDir);
417 fs.writeFileSync(sourceFile, 'latest');
418 fs.writeFileSync(path.join(destinationDir, 'report.txt'), 'existing');
419
420 const { status, body } = await req('POST', '/api/files/move', {
421 from: sourceFile,
422 toDir: destinationDir,
423 conflict: 'rename',
431 });
424 });
432
425
433 test('moves a file into My Folder when rename falls back across filesystems', async () =>
426 expect(status).toBe(200);
427 expect(body.conflictResolution).toBe('rename');
428 expect(path.basename(body.path)).toBe('report (1).txt');
429 expect(fs.readFileSync(body.path, 'utf8')).toBe('latest');
430 expect(fs.readFileSync(path.join(destinationDir, 'report.txt'), 'utf8')).toBe('existing');
431 });
432
433 test('moves a file into My Folder when rename falls back across filesystems', async () =>
434 {
435 const sourceFile = path.join(rootDir, 'cross-root.txt');
436 const userFolderBase = fs.mkdtempSync(path.join(os.tmpdir(), 'filemanager-userfolders-'));
437 const userFolder = path.join(userFolderBase, 'alice');
438
439 mockPaths = [rootDir];
440 mockUserPath = userFolderBase;
441 mockUser = {
442 username: 'alice',
443 isAdmin: false,
444 permissions: {
445 [path.basename(rootDir)]: { read: true, write: true },
446 },
447 };
448
449 fs.writeFileSync(sourceFile, 'hello');
450 fs.mkdirSync(userFolder, { recursive: true });
451
452 const originalRenameSync = fs.renameSync;
453 fs.renameSync = (from, to) =>
434 {
454 {
435 const sourceFile = path.join(rootDir, 'cross-root.txt');
455 const err = new Error('cross-device move');
436 const userFolderBase = fs.mkdtempSync(path.join(os.tmpdir(), 'filemanager-userfolders-'));
456 err.code = 'EXDEV';
437 const userFolder = path.join(userFolderBase, 'alice');
457 throw err;
438
458 };
439 mockPaths = [rootDir];
440 mockUserPath = userFolderBase;
441 mockUser = {
442 username: 'alice',
443 isAdmin: false,
444 permissions: {
445 [path.basename(rootDir)]: { read: true, write: true },
446 },
447 };
448
449 fs.writeFileSync(sourceFile, 'hello');
450 fs.mkdirSync(userFolder, { recursive: true });
451
452 const originalRenameSync = fs.renameSync;
453 fs.renameSync = (from, to) =>
454 {
455 const err = new Error('cross-device move');
456 err.code = 'EXDEV';
457 throw err;
458 };
459
459
460 try
460 try
461 {
461 {
462 const { status, body } = await req('POST', '/api/files/move', { from: sourceFile, toDir: userFolder });
462 const { status, body } = await req('POST', '/api/files/move', { from: sourceFile, toDir: userFolder });
463
463
464 expect(status).toBe(200);
464 expect(status).toBe(200);
465 expect(body.path).toBe(path.join(userFolder, 'cross-root.txt'));
465 expect(body.path).toBe(path.join(userFolder, 'cross-root.txt'));
466 expect(fs.existsSync(sourceFile)).toBe(false);
466 expect(fs.existsSync(sourceFile)).toBe(false);
467 expect(fs.readFileSync(path.join(userFolder, 'cross-root.txt'), 'utf8')).toBe('hello');
467 expect(fs.readFileSync(path.join(userFolder, 'cross-root.txt'), 'utf8')).toBe('hello');
468 } finally
468 } finally
469 {
469 {
470 fs.renameSync = originalRenameSync;
470 fs.renameSync = originalRenameSync;
471 fs.rmSync(userFolderBase, { recursive: true, force: true });
471 fs.rmSync(userFolderBase, { recursive: true, force: true });
472 }
472 }
473 });
473 });
474});
474});
475
475
476describe('root alias endpoints', () =>
476describe('root alias endpoints', () =>
tests/page.load.test.js +10 −10
@@ -503,16 +503,16 @@ describe('page load smoke test', () =>
503 503 expect(dom.window.document.getElementById('sidebar-meta').textContent).toContain('Used');
504 504 expect(dom.window.document.getElementById('sidebar-meta').textContent).toContain('Remaining');
505 505
506 let rootIconImage = null;
507 for (let i = 0; i < 10; i++)
508 {
509 const rootIconSvg = rootTile.querySelector('.icon svg');
510 rootIconImage = rootIconSvg ? rootIconSvg.querySelector('image') : null;
511 if (rootIconImage) break;
512 await new Promise(resolve => dom.window.setTimeout(resolve, 25));
513 }
514 // Root tiles should load folder icon thumbnails in Home view.
515 expect(rootIconImage).toBeTruthy();
506 let rootIconImage = null;
507 for (let i = 0; i < 10; i++)
508 {
509 const rootIconSvg = rootTile.querySelector('.icon svg');
510 rootIconImage = rootIconSvg ? rootIconSvg.querySelector('image') : null;
511 if (rootIconImage) break;
512 await new Promise(resolve => dom.window.setTimeout(resolve, 25));
513 }
514 // Root tiles should load folder icon thumbnails in Home view.
515 expect(rootIconImage).toBeTruthy();
516 516
517 517 rootTile.dispatchEvent(new dom.window.MouseEvent('dblclick', { bubbles: true }));
518 518 await new Promise(resolve => dom.window.setTimeout(resolve, 80));
@@ -503,16 +503,16 @@ describe('page load smoke test', () =>
503 expect(dom.window.document.getElementById('sidebar-meta').textContent).toContain('Used');
503 expect(dom.window.document.getElementById('sidebar-meta').textContent).toContain('Used');
504 expect(dom.window.document.getElementById('sidebar-meta').textContent).toContain('Remaining');
504 expect(dom.window.document.getElementById('sidebar-meta').textContent).toContain('Remaining');
505
505
506 let rootIconImage = null;
506 let rootIconImage = null;
507 for (let i = 0; i < 10; i++)
507 for (let i = 0; i < 10; i++)
508 {
508 {
509 const rootIconSvg = rootTile.querySelector('.icon svg');
509 const rootIconSvg = rootTile.querySelector('.icon svg');
510 rootIconImage = rootIconSvg ? rootIconSvg.querySelector('image') : null;
510 rootIconImage = rootIconSvg ? rootIconSvg.querySelector('image') : null;
511 if (rootIconImage) break;
511 if (rootIconImage) break;
512 await new Promise(resolve => dom.window.setTimeout(resolve, 25));
512 await new Promise(resolve => dom.window.setTimeout(resolve, 25));
513 }
513 }
514 // Root tiles should load folder icon thumbnails in Home view.
514 // Root tiles should load folder icon thumbnails in Home view.
515 expect(rootIconImage).toBeTruthy();
515 expect(rootIconImage).toBeTruthy();
516
516
517 rootTile.dispatchEvent(new dom.window.MouseEvent('dblclick', { bubbles: true }));
517 rootTile.dispatchEvent(new dom.window.MouseEvent('dblclick', { bubbles: true }));
518 await new Promise(resolve => dom.window.setTimeout(resolve, 80));
518 await new Promise(resolve => dom.window.setTimeout(resolve, 80));
tests/share.routes.test.js +2 −1
@@ -83,7 +83,8 @@ let baseUrl;
83 83 let rootDir;
84 84
85 85 function get (p) { return fetch(baseUrl + p); }
86 function post (p, body) {
86 function post (p, body)
87 {
87 88 return fetch(baseUrl + p, {
88 89 method: 'POST',
89 90 headers: { 'Content-Type': 'application/json' },
@@ -83,7 +83,8 @@ let baseUrl;
83let rootDir;
83let rootDir;
84
84
85function get (p) { return fetch(baseUrl + p); }
85function get (p) { return fetch(baseUrl + p); }
86function post (p, body) {
86function post (p, body)
87{
87 return fetch(baseUrl + p, {
88 return fetch(baseUrl + p, {
88 method: 'POST',
89 method: 'POST',
89 headers: { 'Content-Type': 'application/json' },
90 headers: { 'Content-Type': 'application/json' },