Change default download filenames to anonymised hash
This commit is contained in:
@@ -1,12 +1,18 @@
|
||||
import { describe, it, expect } from 'vitest'
|
||||
import { Asset, AssetType, KeyType } from '@ipp/core'
|
||||
import { dateSortComparator } from '../src/gallery/builder'
|
||||
import { describe, it, expect, afterEach } from 'vitest'
|
||||
import { Asset, AssetType, KeyType, loadConfig } from '@ipp/core'
|
||||
import { dateSortComparator, displayOrder } from '../src/gallery/order'
|
||||
|
||||
/*
|
||||
The date-grouping sort must follow the album's own order while
|
||||
keeping undated assets last in BOTH directions.
|
||||
keeping undated assets last in BOTH directions. displayOrder applies it,
|
||||
after the album's own sort, when `gallery.groupByDate` is on.
|
||||
*/
|
||||
|
||||
afterEach(() => {
|
||||
delete process.env.CONFIG
|
||||
loadConfig()
|
||||
})
|
||||
|
||||
const asset = (localDateTime?: string): Asset => ({
|
||||
id: localDateTime || 'undated',
|
||||
key: 'k',
|
||||
@@ -57,3 +63,37 @@ describe('dateSortComparator', () => {
|
||||
expect(sorted[1]).toBe(a)
|
||||
})
|
||||
})
|
||||
|
||||
describe('displayOrder', () => {
|
||||
const dated = (id: string, fileCreatedAt: string, localDateTime?: string): Asset =>
|
||||
({ ...asset(localDateTime), id, fileCreatedAt })
|
||||
// Capture order c, a, b; local time disagrees for b (shot late at night)
|
||||
const album = () => [
|
||||
dated('a', '2024-02-01T10:00:00.000Z'),
|
||||
dated('b', '2024-03-01T01:00:00.000Z', '2024-01-31T23:00:00.000Z'),
|
||||
dated('c', '2024-01-01T10:00:00.000Z')
|
||||
]
|
||||
const ids = (assets: Asset[]) => assets.map(a => a.id)
|
||||
|
||||
it('leaves an orderless share as Immich returned it', () => {
|
||||
expect(ids(displayOrder(album()))).toEqual(['a', 'b', 'c'])
|
||||
})
|
||||
|
||||
it('sorts an album by capture time in its own direction', () => {
|
||||
expect(ids(displayOrder(album(), 'asc'))).toEqual(['c', 'a', 'b'])
|
||||
expect(ids(displayOrder(album(), 'desc'))).toEqual(['b', 'a', 'c'])
|
||||
})
|
||||
|
||||
it('sorts by local time when date grouping is on, so buckets stay contiguous', () => {
|
||||
process.env.CONFIG = JSON.stringify({ ipp: { gallery: { groupByDate: 'day' } } })
|
||||
loadConfig()
|
||||
expect(ids(displayOrder(album(), 'asc'))).toEqual(['c', 'b', 'a'])
|
||||
// Newest-first without an album order
|
||||
expect(ids(displayOrder(album()))).toEqual(['a', 'b', 'c'])
|
||||
})
|
||||
|
||||
it('sorts in place and returns the same array', () => {
|
||||
const assets = album()
|
||||
expect(displayOrder(assets, 'asc')).toBe(assets)
|
||||
})
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user