Files
LlamaCasty/ytLive.Tests/EditWhileLiveTests.cs
T
gramps d46e84562f feat(settings): editing during a session is the creator's call (default: allowed)
Creator ruling 2026-11-12: "we don't care if a creator wants to edit their scene: move stuff around,
shrink/grow a webcam view, etc. Why not?" Correct — the app was only ever *forcing* EDIT off at
go-live, never enforcing it, so the gun-safety was a habit rather than a rule.

App.LockEditWhileLive ships off: a show no longer takes EDIT away. Turning it on restores the old
behaviour exactly — go-live flips EDIT off and stop flips it back, and only because the lock took it,
so a creator who had already turned EDIT off does not get it handed back on stop.

MainViewModel.ApplyEditLockForSession holds the rule so it is testable without starting a broadcast;
EditWhileLiveTests covers both settings, the round trip, and the "don't hand it back" case. Settings →
Editing carries the checkbox.

This is the first slice of TASK 68 (editing while live).

678 pass, 0 warnings. Scope justification: Assets/starting-background.jpg is outside this unit — the
creator's replacement art, still awaiting their visual check.
2026-11-12 14:45:58 -08:00

65 lines
2.2 KiB
C#

using System;
using System.IO;
using Xunit;
using ytLive.ViewModels;
namespace ytLive.Tests;
/// <summary>
/// Editing during a session is the creator's call (ruling 2026-11-12: moving a layer or resizing a
/// webcam mid-show is theirs to do). The setting decides whether go-live still flips EDIT off.
/// </summary>
[Collection("MainViewModelLayoutPath")]
public class EditWhileLiveTests
{
private static MainViewModel NewVm(string db, out Action cleanup)
{
MainViewModel.LayoutPathOverride = db;
cleanup = () =>
{
MainViewModel.LayoutPathOverride = null;
try { File.Delete(db); } catch (IOException) { }
};
return new MainViewModel();
}
[Fact]
public void Editing_stays_available_during_a_session_unless_the_creator_locked_it()
{
var db = Path.Combine(Path.GetTempPath(), $"llamacasty-editlock-{Guid.NewGuid():N}.db");
var vm = NewVm(db, out var cleanup);
try
{
Assert.False(vm.LockEditWhileLive); // unlocked ships as the default
Assert.True(vm.IsEditMode);
// Unlocked: a session neither takes EDIT away nor gives it back.
vm.EditingActive = false;
vm.ApplyEditLockForSession(starting: true);
Assert.False(vm.EditingActive);
vm.EditingActive = true;
vm.ApplyEditLockForSession(starting: true);
Assert.True(vm.EditingActive);
// Locked: go-live turns EDIT off…
vm.LockEditWhileLive = true;
vm.ApplyEditLockForSession(starting: true);
Assert.False(vm.EditingActive);
Assert.False(vm.IsEditMode);
// …and stopping restores it, but only because the lock took it away.
vm.ApplyEditLockForSession(starting: false);
Assert.True(vm.EditingActive);
Assert.True(vm.IsEditMode);
// The choice survives a restart: a second view model on the same profile reads it back.
var reloaded = new MainViewModel();
Assert.True(reloaded.LockEditWhileLive);
}
finally
{
cleanup();
}
}
}