Dvesign improvemments
This commit is contained in:
+104
-1
@@ -2,7 +2,12 @@ import assert from 'node:assert/strict';
|
||||
import { mkdtempSync, rmSync } from 'fs';
|
||||
import { join } from 'path';
|
||||
import { tmpdir } from 'os';
|
||||
import { createBoxSetSection, createRecentlyWatchedSection, getWatchlistLabelsForTarget } from '../src/lib/constants.js';
|
||||
import {
|
||||
applySectionStandards,
|
||||
createBoxSetSection,
|
||||
createRecentlyWatchedSection,
|
||||
getWatchlistLabelsForTarget
|
||||
} from '../src/lib/constants.js';
|
||||
import { normalizeLookupItem, rankRecommendationResults } from '../src/lib/collection-tools.js';
|
||||
import * as embyUserCache from '../src/lib/server/emby-user-cache.js';
|
||||
|
||||
@@ -152,6 +157,104 @@ test('box set section template links a created collection', () => {
|
||||
});
|
||||
});
|
||||
|
||||
test('section standards normalize up next label', () => {
|
||||
const normalized = applySectionStandards(
|
||||
{
|
||||
Name: 'Resume / Up Next',
|
||||
CustomName: 'Resume / Up Next',
|
||||
SectionType: 'resume'
|
||||
},
|
||||
{
|
||||
embyName: 'Bob',
|
||||
sections: []
|
||||
}
|
||||
);
|
||||
|
||||
assert.equal(normalized.Name, 'Up Next');
|
||||
assert.equal(normalized.CustomName, 'Up Next');
|
||||
});
|
||||
|
||||
test('section standards normalize watchlist label for target user', () => {
|
||||
const normalized = applySectionStandards(
|
||||
{
|
||||
Name: "Matt's Watchlist",
|
||||
CustomName: "Matt's Watchlist",
|
||||
SectionType: 'items',
|
||||
Query: { IsFavorite: true }
|
||||
},
|
||||
{
|
||||
embyName: 'Bob',
|
||||
sections: []
|
||||
}
|
||||
);
|
||||
|
||||
assert.equal(normalized.Name, "Bob's Watchlist");
|
||||
assert.equal(normalized.CustomName, "Bob's Watchlist");
|
||||
});
|
||||
|
||||
test('section standards keep new to emby fixed to date added descending', () => {
|
||||
const normalized = applySectionStandards(
|
||||
{
|
||||
Name: 'New To Emby',
|
||||
CustomName: 'New To Emby',
|
||||
SectionType: 'items',
|
||||
SortBy: 'ProductionYear,PremiereDate,SortName',
|
||||
SortOrder: 'Ascending'
|
||||
},
|
||||
{
|
||||
embyName: 'Bob',
|
||||
sections: []
|
||||
}
|
||||
);
|
||||
|
||||
assert.equal(normalized.Name, 'New to Emby');
|
||||
assert.equal(normalized.CustomName, 'New to Emby');
|
||||
assert.equal(normalized.SortBy, 'DateLastContentAdded,SortName');
|
||||
assert.equal(normalized.SortOrder, 'Descending');
|
||||
});
|
||||
|
||||
test('section standards randomize regular curated sections', () => {
|
||||
const normalized = applySectionStandards(
|
||||
{
|
||||
Name: 'Crime / Drama Shows',
|
||||
CustomName: 'Crime / Drama Shows',
|
||||
SectionType: 'items',
|
||||
SortBy: 'ProductionYear,PremiereDate,SortName',
|
||||
SortOrder: 'Ascending',
|
||||
Query: { GenreIds: ['4910', '62'] }
|
||||
},
|
||||
{
|
||||
embyName: 'Bob',
|
||||
sections: []
|
||||
}
|
||||
);
|
||||
|
||||
assert.equal(normalized.SortBy, 'Random');
|
||||
assert.equal(normalized.SortOrder, 'Descending');
|
||||
});
|
||||
|
||||
test('section standards preserve recently watched ordering semantics', () => {
|
||||
const normalized = applySectionStandards(
|
||||
{
|
||||
Name: 'Recently Watched - Matt',
|
||||
CustomName: 'Recently Watched - Matt',
|
||||
SectionType: 'items',
|
||||
SortBy: 'Random',
|
||||
SortOrder: 'Ascending',
|
||||
Query: { IsPlayed: true }
|
||||
},
|
||||
{
|
||||
embyName: 'Bob',
|
||||
sections: []
|
||||
}
|
||||
);
|
||||
|
||||
assert.equal(normalized.Name, 'Recently Watched - Bob');
|
||||
assert.equal(normalized.CustomName, 'Recently Watched - Bob');
|
||||
assert.equal(normalized.SortBy, 'DatePlayed');
|
||||
assert.equal(normalized.SortOrder, 'Descending');
|
||||
});
|
||||
|
||||
test('normalizeLookupItem preserves already-normalized recommendation items', () => {
|
||||
const normalized = normalizeLookupItem({
|
||||
id: 'pick-1',
|
||||
|
||||
Reference in New Issue
Block a user