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