mirror of
https://github.com/ksyasuda/SubMiner.git
synced 2026-07-27 04:49:49 -07:00
fix(sync-ui): clarify remote merge target
This commit is contained in:
@@ -1,6 +1,11 @@
|
||||
import test from 'node:test';
|
||||
import assert from 'node:assert/strict';
|
||||
import { formatBytes, formatRelativeTime, summarizeMergeCounts } from './syncui-format';
|
||||
import {
|
||||
formatBytes,
|
||||
formatMergeTargetHeading,
|
||||
formatRelativeTime,
|
||||
summarizeMergeCounts,
|
||||
} from './syncui-format';
|
||||
|
||||
test('formatBytes renders human readable sizes', () => {
|
||||
assert.equal(formatBytes(0), '0 B');
|
||||
@@ -19,6 +24,11 @@ test('formatRelativeTime renders past timestamps', () => {
|
||||
assert.equal(formatRelativeTime(now - 2 * 86_400_000, now), '2 d ago');
|
||||
});
|
||||
|
||||
test('formatMergeTargetHeading names the local and remote machines', () => {
|
||||
assert.equal(formatMergeTargetHeading('local'), 'Merged into this machine');
|
||||
assert.equal(formatMergeTargetHeading('remote'), 'Merged into remote machine');
|
||||
});
|
||||
|
||||
test('summarizeMergeCounts lists only non-zero counts', () => {
|
||||
const summary = {
|
||||
sessionsMerged: 3,
|
||||
|
||||
@@ -1,5 +1,9 @@
|
||||
import type { SyncMergeSummary } from '../shared/sync/sync-events';
|
||||
|
||||
export function formatMergeTargetHeading(target: 'local' | 'remote'): string {
|
||||
return target === 'local' ? 'Merged into this machine' : 'Merged into remote machine';
|
||||
}
|
||||
|
||||
export function formatBytes(bytes: number): string {
|
||||
if (bytes < 1024) return `${Math.round(bytes)} B`;
|
||||
const units = ['KB', 'MB', 'GB', 'TB'];
|
||||
|
||||
@@ -7,7 +7,12 @@ import type {
|
||||
SyncUiSnapshot,
|
||||
SyncUiStartResult,
|
||||
} from '../types/sync-ui';
|
||||
import { formatBytes, formatRelativeTime, summarizeMergeCounts } from './syncui-format';
|
||||
import {
|
||||
formatBytes,
|
||||
formatMergeTargetHeading,
|
||||
formatRelativeTime,
|
||||
summarizeMergeCounts,
|
||||
} from './syncui-format';
|
||||
|
||||
declare global {
|
||||
interface Window {
|
||||
@@ -134,7 +139,7 @@ function appendMergeSummary(
|
||||
resultCard.classList.remove('hidden');
|
||||
const heading = document.createElement('div');
|
||||
heading.className = 'result-title';
|
||||
heading.textContent = target === 'local' ? 'Merged into this machine' : 'Merged into the device';
|
||||
heading.textContent = formatMergeTargetHeading(target);
|
||||
const grid = document.createElement('div');
|
||||
grid.className = 'count-grid';
|
||||
for (const line of lines) {
|
||||
|
||||
Reference in New Issue
Block a user