mirror of
https://github.com/4gray/iptvnator.git
synced 2026-10-16 06:06:18 -08:00
- Unconfirmed writes and early edits are kept in the tab's own sessionStorage, so tabs never clear each other's; a shared registry of unconfirmed entries (one record per tab, ignored after ten minutes) keeps a re-read in one tab from replacing another tab's values. - A cache value too big for localStorage stays readable from memory, so later edits are diffed against what the app reads. - Typing legacy Xtream ids keeps each snapshot's bare key as an alias, so a reference not yet rewritten still resolves and a retry can type it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
70 lines
2.5 KiB
TypeScript
70 lines
2.5 KiB
TypeScript
import { combineUserData } from './server-migration-merge';
|
|
import { typeLegacyXtreamRefs } from './server-migration-xtream';
|
|
|
|
describe('typeLegacyXtreamRefs', () => {
|
|
it('types bare ids from the same copy snapshots', () => {
|
|
expect(
|
|
typeLegacyXtreamRefs({
|
|
'xtream-favorites': [42, 'movie:7', 99],
|
|
'xtream-recent-items': [{ id: 42, viewedAt: 't' }],
|
|
'xtream-collection-items': {
|
|
'42': { xtream_id: 42, type: 'live', title: 'News' },
|
|
'movie:7': { xtream_id: 7, type: 'movie' },
|
|
},
|
|
})
|
|
).toEqual({
|
|
'xtream-favorites': ['live:42', 'movie:7', 99],
|
|
'xtream-recent-items': [{ id: 'live:42', viewedAt: 't' }],
|
|
'xtream-collection-items': {
|
|
'42': { xtream_id: 42, type: 'live', title: 'News' },
|
|
'live:42': { xtream_id: 42, type: 'live', title: 'News' },
|
|
'movie:7': { xtream_id: 7, type: 'movie' },
|
|
},
|
|
});
|
|
});
|
|
|
|
it('keeps a live and a movie favorite that share an id apart', () => {
|
|
const browser = typeLegacyXtreamRefs({
|
|
'xtream-favorites': [42],
|
|
'xtream-collection-items': {
|
|
'42': { xtream_id: 42, type: 'live' },
|
|
},
|
|
});
|
|
const server = typeLegacyXtreamRefs({
|
|
'xtream-favorites': [42],
|
|
'xtream-collection-items': {
|
|
'42': { xtream_id: 42, type: 'movie' },
|
|
},
|
|
});
|
|
|
|
expect(
|
|
combineUserData([
|
|
server['xtream-favorites'],
|
|
browser['xtream-favorites'],
|
|
])
|
|
).toEqual(['movie:42', 'live:42']);
|
|
expect(
|
|
combineUserData([
|
|
server['xtream-collection-items'],
|
|
browser['xtream-collection-items'],
|
|
])
|
|
).toEqual({
|
|
// The server's own bare alias wins its key; both typed keys stay.
|
|
'42': { xtream_id: 42, type: 'movie' },
|
|
'movie:42': { xtream_id: 42, type: 'movie' },
|
|
'live:42': { xtream_id: 42, type: 'live' },
|
|
});
|
|
});
|
|
|
|
it('types numeric-string ids too', () => {
|
|
expect(
|
|
typeLegacyXtreamRefs({
|
|
'xtream-favorites': ['42'],
|
|
'xtream-collection-items': {
|
|
'42': { xtream_id: 42, type: 'movie' },
|
|
},
|
|
})['xtream-favorites']
|
|
).toEqual(['movie:42']);
|
|
});
|
|
});
|