Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion static/local-js/modules/processingMode.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@ export function validateProcessingMode (value) {
if (Number.isSafeInteger(seconds) && seconds <= Date.now() / 1000 + 62135596800) return value
throw new Error('Added duration is too large.')
}
const index = value.match(/^index\(([a-z])(?:-([a-z])(#)?)?\)$/i)
// The keyword must be lowercase (server and Kometa schema); range letters may be either case.
const index = value.match(/^index\(([A-Za-z])(?:-([A-Za-z])(#)?)?\)$/)
if (index) {
if (index[1].toLowerCase() <= (index[2] || index[1]).toLowerCase()) return value
throw new Error('Alphabetical range must be ascending, such as A-F.')
Expand Down
15 changes: 13 additions & 2 deletions tests/js/libraryScheduling.test.js
Original file line number Diff line number Diff line change
Expand Up @@ -32,16 +32,27 @@ function change (input, value) {
beforeEach(() => document.body.replaceChildren())

describe('processing mode contract', () => {
it.each(['full', 'diff', 'added(7)', 'added(30m)', 'added(1h)', 'added(12d)', 'index(A-F#)', 'index(A)', 'items(imdb:tt0133093|plex:42)'])('restores and validates %s', mode => {
it.each(['full', 'diff', 'added(7)', 'added(30m)', 'added(1h)', 'added(12d)', 'index(A-F#)', 'index(A)', 'index(A-F)', 'items(imdb:tt0133093|plex:42)'])('restores and validates %s', mode => {
document.body.innerHTML = modeMarkup
const root = document.querySelector('[data-processing-mode]')
initProcessingMode(root, mode)
expect(processingModeValue(root)).toBe(mode)
expect(validateProcessingMode(mode)).toBe(mode)
})
it.each(['added(0)', 'added(-1)', 'added(1w)', 'added(999999999999)', 'index(Z-A)', 'items(42)', 'items(plex:0)', 'items(imdb:123)', 'full; ls'])('rejects %s', mode => {
it.each(['index(a-f)', 'index(a)', 'index(A-f#)'])('accepts lowercase range letters in %s', mode => {
expect(validateProcessingMode(mode)).toBe(mode)
})
it.each(['added(0)', 'added(-1)', 'added(1w)', 'added(999999999999)', 'index(Z-A)', 'INDEX(A-F)', 'Index(a)', 'items(42)', 'items(plex:0)', 'items(imdb:123)', 'full; ls'])('rejects %s', mode => {
expect(() => validateProcessingMode(mode)).toThrow()
})
it.each(['INDEX(A-F)', 'INDEX(a-f#)', 'Index(b)'])('still restores a saved %s into the dropdowns and rebuilds it as index(...)', saved => {
document.body.innerHTML = modeMarkup
const root = document.querySelector('[data-processing-mode]')
initProcessingMode(root, saved)
expect(root.querySelector('[data-processing-kind]').value).toBe('index')
expect(processingModeValue(root)).toMatch(/^index\([A-Z](-[A-Z]#?)?\)$/)
expect(() => validateProcessingMode(processingModeValue(root))).not.toThrow()
})
it('accepts comma and newline separated provider IDs', () => {
document.body.innerHTML = modeMarkup
const root = document.querySelector('[data-processing-mode]')
Expand Down
1 change: 1 addition & 0 deletions tests/test_library_scheduling.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@ def test_finalized_processing_modes(mode):
"added(1w)",
"added(999999999999999999999)",
"index(Z-A)",
"INDEX(A-F)",
"index(A#)",
"index(1-9)",
"items(42)",
Expand Down
Loading