66 lines
2.8 KiB
Swift
66 lines
2.8 KiB
Swift
import MusicAssistantCore
|
|
import XCTest
|
|
|
|
final class SongProjectPromptCompilerTests: XCTestCase {
|
|
func testCompilerUsesSelectedInstrumentsInSunoStylePrompt() throws {
|
|
let project = SongProject(
|
|
title: "Compiled Song",
|
|
idea: "Prepare Suno output",
|
|
genres: [
|
|
GenreStyle(id: "arabic-pop", name: "Arabic Pop"),
|
|
GenreStyle(id: "cinematic", name: "Cinematic")
|
|
],
|
|
moods: [MoodTag(id: "hopeful", name: "Hopeful")],
|
|
bpm: ManualAutoValue(mode: .manual, value: 96),
|
|
maqam: ManualAutoValue(mode: .manual, value: "Hijaz"),
|
|
sections: [
|
|
SongSection(id: "chorus", type: .chorus, title: "Chorus", lyrics: "Section chorus")
|
|
],
|
|
instruments: [
|
|
InstrumentTrack(
|
|
instrumentId: "oud",
|
|
selected: true,
|
|
variant: "Arabic Oud",
|
|
playingStyle: "picked",
|
|
role: "main hook",
|
|
placements: [InstrumentPlacement(sectionId: "chorus", direction: "answer the vocal")]
|
|
),
|
|
InstrumentTrack(
|
|
instrumentId: "drum-kit",
|
|
selected: false,
|
|
variant: "Drum Kit"
|
|
)
|
|
],
|
|
vocalists: [Vocalist(id: "lead", label: "Lead", voiceType: "warm tenor")],
|
|
lyrics: Lyrics(text: "Approved lyrics"),
|
|
productionDirections: [ProductionDirection(id: "lift", text: "wide chorus lift")]
|
|
)
|
|
|
|
let output = try SongProjectPromptCompiler().compile(project: project)
|
|
|
|
XCTAssertEqual(output.lyricsText, "Approved lyrics")
|
|
XCTAssertTrue(output.stylePrompt.contains("Arabic Pop + Cinematic"))
|
|
XCTAssertTrue(output.stylePrompt.contains("Arabic Oud (main hook, picked, Chorus answer the vocal)"))
|
|
XCTAssertTrue(output.stylePrompt.contains("Lead warm tenor"))
|
|
XCTAssertTrue(output.stylePrompt.contains("96 BPM"))
|
|
XCTAssertTrue(output.stylePrompt.contains("maqam Hijaz"))
|
|
XCTAssertTrue(output.stylePrompt.contains("wide chorus lift"))
|
|
XCTAssertFalse(output.stylePrompt.contains("Drum Kit"))
|
|
}
|
|
|
|
func testCompilerFallsBackToOrderedSectionLyrics() throws {
|
|
let project = SongProject(
|
|
title: "Section Lyrics",
|
|
idea: "Compile sections",
|
|
sections: [
|
|
SongSection(id: "chorus", type: .chorus, title: "Chorus", order: 1, lyrics: "Hook line"),
|
|
SongSection(id: "verse", type: .verse, title: "Verse", order: 0, lyrics: "Verse line")
|
|
]
|
|
)
|
|
|
|
let output = try SongProjectPromptCompiler().compile(project: project)
|
|
|
|
XCTAssertEqual(output.lyricsText, "[Verse]\nVerse line\n\n[Chorus]\nHook line")
|
|
}
|
|
}
|