Add Prompt Builder sets/framing and harden mobile draft look settings.
Sets and beats filter by shot size; scenes reorder/delete; portrait links Prompt Builder; landscape queue collapses; per-engine look settings and prompt Clear persist across iOS resumes.
This commit is contained in:
+109
-88
@@ -22,88 +22,104 @@ const {
|
||||
emptyScene,
|
||||
emptyCharacter,
|
||||
emptyOutfit,
|
||||
emptySet,
|
||||
emptyBeat,
|
||||
cloneSceneForNext,
|
||||
normalizePromptSequence,
|
||||
ensureSceneStatesForCharacters
|
||||
ensureSceneStatesForCharacters,
|
||||
beatMatchesShotSize
|
||||
} = await import(pathToFileURL(tmp).href)
|
||||
unlinkSync(tmp)
|
||||
|
||||
test('formatCharacterLine covers name/description and outfit', () => {
|
||||
assert.equal(formatCharacterLine({ name: 'Ada', description: 'tall' }), 'Ada: tall')
|
||||
assert.equal(formatCharacterLine({ name: 'Ada', description: '' }), 'Ada')
|
||||
assert.equal(formatCharacterLine({ name: '', description: 'tall' }), 'tall')
|
||||
assert.equal(formatCharacterLine({ name: '', description: '' }), '')
|
||||
assert.equal(
|
||||
formatCharacterLine({ name: 'Ada', description: 'tall' }, { name: 'Work', description: 'blue jacket' }),
|
||||
'Ada: tall. Outfit: blue jacket'
|
||||
)
|
||||
})
|
||||
|
||||
test('assembleSceneText joins non-empty boxes with a single blank line', () => {
|
||||
const text = assembleSceneText({
|
||||
style: 'oil paint',
|
||||
settings: 'night',
|
||||
characters: [
|
||||
{ name: 'Ada', description: 'tall' },
|
||||
{ name: '', description: '' },
|
||||
{ name: 'Bo', description: 'hat' }
|
||||
],
|
||||
prompt: 'walks'
|
||||
})
|
||||
assert.equal(text, 'oil paint\n\nnight\n\nAda: tall\nBo: hat\n\nwalks')
|
||||
test('shot size filters beats; untagged always included; tags never copied', () => {
|
||||
const set = {
|
||||
...emptySet(),
|
||||
id: 's1',
|
||||
name: 'BadgeSet',
|
||||
description: 'studio backdrop',
|
||||
beats: [
|
||||
{ ...emptyBeat(), id: 'b1', name: 'WideBeat', text: 'wide only line', framings: ['wide'] },
|
||||
{ ...emptyBeat(), id: 'b2', name: 'WideMed', text: 'wide and medium', framings: ['wide', 'medium'] },
|
||||
{ ...emptyBeat(), id: 'b3', name: 'Always', text: 'untagged beat', framings: [] },
|
||||
{ ...emptyBeat(), id: 'b4', name: 'CU', text: 'close only', framings: ['close-up'] }
|
||||
]
|
||||
}
|
||||
const sceneMedium = {
|
||||
style: 'style',
|
||||
settings: 'settings',
|
||||
shotSize: 'medium',
|
||||
setStates: [{ setId: 's1', on: true }],
|
||||
characterStates: [],
|
||||
prompt: 'prompt'
|
||||
}
|
||||
const mediumText = assembleSceneText(sceneMedium, [], [set])
|
||||
assert.equal(
|
||||
mediumText,
|
||||
'style\n\nsettings\n\nstudio backdrop\nwide and medium\nuntagged beat\n\nprompt'
|
||||
)
|
||||
assert.ok(!mediumText.includes('wide only'))
|
||||
assert.ok(!mediumText.includes('close only'))
|
||||
assert.ok(!mediumText.includes('BadgeSet'))
|
||||
assert.ok(!mediumText.includes('WideBeat'))
|
||||
assert.ok(!mediumText.includes('close-up'))
|
||||
assert.ok(!/\bwide\b/.test(mediumText.replace('wide and medium', '')))
|
||||
|
||||
const sceneClose = { ...sceneMedium, shotSize: 'close-up' }
|
||||
const closeText = assembleSceneText(sceneClose, [], [set])
|
||||
assert.equal(
|
||||
closeText,
|
||||
'style\n\nsettings\n\nstudio backdrop\nuntagged beat\nclose only\n\nprompt'
|
||||
)
|
||||
|
||||
const sceneAny = { ...sceneMedium, shotSize: '' }
|
||||
const anyText = assembleSceneText(sceneAny, [], [set])
|
||||
assert.ok(anyText.includes('wide only line'))
|
||||
assert.ok(anyText.includes('wide and medium'))
|
||||
assert.ok(anyText.includes('untagged beat'))
|
||||
assert.ok(anyText.includes('close only'))
|
||||
|
||||
assert.equal(beatMatchesShotSize({ framings: ['wide'] }, 'medium'), false)
|
||||
assert.equal(beatMatchesShotSize({ framings: [] }, 'medium'), true)
|
||||
})
|
||||
|
||||
test('off characters and active outfits affect assembly', () => {
|
||||
const ada = { ...emptyCharacter(), id: 'c1', name: 'Ada', description: 'tall', outfits: [
|
||||
{ ...emptyOutfit(), id: 'o1', name: 'Day', description: 'red dress' },
|
||||
{ ...emptyOutfit(), id: 'o2', name: 'Night', description: 'black coat' }
|
||||
] }
|
||||
const bo = { ...emptyCharacter(), id: 'c2', name: 'Bo', description: 'hat', outfits: [] }
|
||||
test('off set omitted; copy scene is one scene; sequence join is double blank', () => {
|
||||
const set = {
|
||||
...emptySet(),
|
||||
id: 's1',
|
||||
description: 'set desc',
|
||||
beats: [{ ...emptyBeat(), text: 'beat', framings: [] }]
|
||||
}
|
||||
const scene1 = {
|
||||
style: 's1',
|
||||
style: 'a',
|
||||
settings: '',
|
||||
prompt: 'p1',
|
||||
characterStates: [
|
||||
{ characterId: 'c1', on: true, outfitId: 'o1' },
|
||||
{ characterId: 'c2', on: true, outfitId: null }
|
||||
]
|
||||
shotSize: '',
|
||||
setStates: [{ setId: 's1', on: true }],
|
||||
characterStates: [],
|
||||
prompt: 'p1'
|
||||
}
|
||||
const scene2 = {
|
||||
style: 's2',
|
||||
style: 'b',
|
||||
settings: '',
|
||||
prompt: 'p2',
|
||||
characterStates: [
|
||||
{ characterId: 'c1', on: false, outfitId: 'o1' },
|
||||
{ characterId: 'c2', on: true, outfitId: null }
|
||||
]
|
||||
shotSize: '',
|
||||
setStates: [{ setId: 's1', on: false }],
|
||||
characterStates: [],
|
||||
prompt: 'p2'
|
||||
}
|
||||
assert.equal(
|
||||
assembleSceneText(scene1, [ada, bo]),
|
||||
's1\n\nAda: tall. Outfit: red dress\nBo: hat\n\np1'
|
||||
)
|
||||
assert.equal(
|
||||
assembleSceneText(scene2, [ada, bo]),
|
||||
's2\n\nBo: hat\n\np2'
|
||||
)
|
||||
const full = assembleSequenceText({ characters: [ada, bo], scenes: [scene1, scene2] })
|
||||
assert.equal(full, 's1\n\nAda: tall. Outfit: red dress\nBo: hat\n\np1\n\n\ns2\n\nBo: hat\n\np2')
|
||||
assert.ok(!full.includes('not present'))
|
||||
assert.equal(assembleSceneText(scene2, [], [set]), 'b\n\np2')
|
||||
const full = assembleSequenceText({ sets: [set], scenes: [scene1, scene2] })
|
||||
assert.equal(full, 'a\n\nset desc\nbeat\n\np1\n\n\nb\n\np2')
|
||||
assert.equal(assembleSceneText(scene1, [], [set]), 'a\n\nset desc\nbeat\n\np1')
|
||||
})
|
||||
|
||||
test('assembleSequenceText uses double blank line between scenes and skips empties', () => {
|
||||
const text = assembleSequenceText({
|
||||
name: 'ignored',
|
||||
scenes: [
|
||||
{ style: 's1', settings: '', characters: [], prompt: 'p1' },
|
||||
{ style: '', settings: '', characters: [{ name: '', description: '' }], prompt: '' },
|
||||
{ style: 's2', settings: 'set2', characters: [{ name: 'C', description: 'd' }], prompt: 'p2' }
|
||||
]
|
||||
})
|
||||
assert.equal(text, 's1\n\np1\n\n\ns2\n\nset2\n\nC: d\n\np2')
|
||||
assert.ok(!text.includes('ignored'))
|
||||
})
|
||||
|
||||
test('legacy sequences migrate to sequence characters all on with no outfits', () => {
|
||||
test('legacy sequence without sets still assembles', () => {
|
||||
const legacy = normalizePromptSequence({
|
||||
id: 'seq1',
|
||||
name: 'Old',
|
||||
@@ -111,51 +127,56 @@ test('legacy sequences migrate to sequence characters all on with no outfits', (
|
||||
{
|
||||
id: 'sc1',
|
||||
title: 'Scene 1',
|
||||
style: 'a',
|
||||
style: 'oil',
|
||||
settings: '',
|
||||
prompt: 'p',
|
||||
characters: [{ id: 'x', name: 'Ada', description: 'tall' }]
|
||||
},
|
||||
{
|
||||
id: 'sc2',
|
||||
title: 'Scene 2',
|
||||
style: 'b',
|
||||
settings: '',
|
||||
prompt: 'q',
|
||||
prompt: 'walk',
|
||||
characters: [{ id: 'x', name: 'Ada', description: 'tall' }]
|
||||
}
|
||||
],
|
||||
createdAt: 1,
|
||||
updatedAt: 1
|
||||
})
|
||||
assert.equal(legacy.characters.length, 1)
|
||||
assert.equal(legacy.characters[0].name, 'Ada')
|
||||
assert.deepEqual(legacy.characters[0].outfits, [])
|
||||
assert.equal(legacy.scenes[0].characterStates[0].on, true)
|
||||
assert.equal(legacy.scenes[0].characterStates[0].outfitId, null)
|
||||
assert.equal(legacy.scenes[1].characterStates[0].on, true)
|
||||
assert.deepEqual(legacy.sets, [])
|
||||
assert.equal(legacy.scenes[0].shotSize, '')
|
||||
const text = assembleSequenceText(legacy)
|
||||
assert.equal(text, 'oil\n\nAda: tall\n\nwalk')
|
||||
})
|
||||
|
||||
test('cloneSceneForNext copies toggles and outfit choices', () => {
|
||||
const chars = [emptyCharacter()]
|
||||
const first = emptyScene(1, chars)
|
||||
first.style = 'a'
|
||||
first.characterStates[0].on = false
|
||||
first.characterStates[0].outfitId = 'o9'
|
||||
test('cloneSceneForNext copies shotSize and setStates', () => {
|
||||
const sets = [emptySet()]
|
||||
const first = emptyScene(1, [], sets)
|
||||
first.shotSize = 'close-up'
|
||||
first.setStates[0].on = false
|
||||
const next = cloneSceneForNext(first, 2)
|
||||
assert.equal(next.title, 'Scene 2')
|
||||
assert.equal(next.style, 'a')
|
||||
assert.equal(next.characterStates[0].on, false)
|
||||
assert.equal(next.characterStates[0].outfitId, 'o9')
|
||||
assert.notEqual(next.id, first.id)
|
||||
assert.equal(next.shotSize, 'close-up')
|
||||
assert.equal(next.setStates[0].on, false)
|
||||
assert.equal(next.setStates[0].setId, sets[0].id)
|
||||
})
|
||||
|
||||
test('character outfit and off still work with sets', () => {
|
||||
const ada = {
|
||||
...emptyCharacter(),
|
||||
id: 'c1',
|
||||
name: 'Ada',
|
||||
description: 'tall',
|
||||
outfits: [{ ...emptyOutfit(), id: 'o1', description: 'red dress' }]
|
||||
}
|
||||
const text = assembleSceneText({
|
||||
style: '',
|
||||
settings: '',
|
||||
shotSize: '',
|
||||
setStates: [],
|
||||
characterStates: [{ characterId: 'c1', on: true, outfitId: 'o1' }],
|
||||
prompt: 'hi'
|
||||
}, [ada], [])
|
||||
assert.equal(text, 'Ada: tall. Outfit: red dress\n\nhi')
|
||||
})
|
||||
|
||||
test('ensureSceneStatesForCharacters turns new character on only for current scene', () => {
|
||||
const a = emptyCharacter()
|
||||
const scenes = [emptyScene(1, [a]), emptyScene(2, [a])]
|
||||
const b = emptyCharacter()
|
||||
const list = [a, b]
|
||||
ensureSceneStatesForCharacters(scenes, list, { newCharacterId: b.id, turnOnSceneIndex: 1 })
|
||||
ensureSceneStatesForCharacters(scenes, [a, b], { newCharacterId: b.id, turnOnSceneIndex: 1 })
|
||||
assert.equal(scenes[0].characterStates.find(s => s.characterId === b.id).on, false)
|
||||
assert.equal(scenes[1].characterStates.find(s => s.characterId === b.id).on, true)
|
||||
})
|
||||
|
||||
Reference in New Issue
Block a user