tv-anarchy/Tests/TVAnarchyCoreTests/LibraryDisplayNamesTests.swift
Natalie 4a2ceb9781 feat(offline): inline star-to-keep and trash-to-cull on cache rows
Surface the existing pin (keep-from-cull) and per-file delete actions as
visible inline buttons on each offline cache row instead of context-menu-only:
a star toggles protection from auto-cull (and restore-if-missing), a trash
culls that file early. Aligns wording/icons to the star metaphor.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-06-30 00:12:41 -04:00

57 lines
No EOL
2.4 KiB
Swift

import XCTest
@testable import TVAnarchyCore
final class LibraryDisplayNamesTests: XCTestCase {
private var tmp: URL!
private var store: TitleLibraryStore!
override func setUp() {
tmp = FileManager.default.temporaryDirectory
.appendingPathComponent("tv-anarchy-display-\(UUID().uuidString)", isDirectory: true)
try? FileManager.default.createDirectory(at: tmp, withIntermediateDirectories: true)
setenv("TV_ANARCHY_STATE_DIR", tmp.path, 1)
store = TitleLibraryStore()
TitleLibrary.store = store
}
override func tearDown() {
unsetenv("TV_ANARCHY_STATE_DIR")
try? FileManager.default.removeItem(at: tmp)
TitleLibrary.store = TitleLibraryStore()
}
func testPsychReleaseFilenameUsesCodeNotDots() {
let path = "/media/tv/Psych/Psych.S01E04.720p.WEB-DL.x264-GROUP.mkv"
let resolved = LibraryDisplayNames.resolve(showName: "Psych", path: path, titleLibrary: store)
XCTAssertEqual(resolved.displayName, "S01E04")
XCTAssertNil(resolved.episodeTitle)
}
func testTitleAfterSxxEyyInFilename() {
let path = "/m/cartoons/Futurama/Futurama S03E01 The Honking.mp4"
let resolved = LibraryDisplayNames.resolve(showName: "Futurama", path: path, titleLibrary: store)
XCTAssertEqual(resolved.displayName, "S03E01 · The Honking")
XCTAssertEqual(resolved.episodeTitle, "The Honking")
}
func testLibraryHitSkipsRegexWrite() {
let key = ContentID.canonical(work: "Psych", season: 1, episode: 4)
store.observe(TitleObservation(contentKey: key, showName: "Psych",
season: 1, episode: 4,
episodeTitle: "Shawn vs. the Red Phantom",
provenance: .tvmaze))
let path = "/media/tv/Psych/Psych.S01E04.720p.WEB-DL.x264-GROUP.mkv"
let resolved = LibraryDisplayNames.resolve(showName: "Psych", path: path, titleLibrary: store)
XCTAssertEqual(resolved.displayName, "S01E04 · Shawn vs. the Red Phantom")
XCTAssertEqual(resolved.episodeTitle, "Shawn vs. the Red Phantom")
}
func testTitleAfterSxxEyyHelper() {
XCTAssertEqual(
LibraryDisplayNames.titleAfterSxxEyy(
"Dharma & Greg S01E03 Shower the People You Love With Love.mkv"
),
"Shower the People You Love With Love"
)
}
}