using Avalonia.Controls;
using Avalonia.Headless.XUnit;
using Avalonia.VisualTree;
using PostIt.ViewModels;
using PostIt.Views;
namespace PostIt.Tests;
///
/// UI tests for . Mounted inside
/// a real via the headless Avalonia
/// platform declared in TestApp.cs.
///
/// The pattern is the one that UnitTest1.MainPage_Should_Load
/// established: a test attribute [AvaloniaFact] (from
/// Avalonia.Headless.XUnit) instead of plain [Fact],
/// new MainWindow(), window.Show(). The AvaloniaFact
/// attribute schedules the test body inside a dispatcher, which
/// is the precondition for the headless Window's
/// PlatformManager.CreateWindow() to find a registered
/// service. A plain [Fact] test that calls
/// new Window().Show() throws because the harness has not
/// been initialised for that thread.
///
/// These tests set the DataContext directly on the banner
/// mounted in the window. The production code path is exercised
/// end-to-end by the manual launch, not here.
///
public class SessionStatusBannerTests : IDisposable
{
private MainWindow? _window;
[AvaloniaFact]
public void Banner_renders_four_buttons_in_the_visual_tree()
{
SessionStatusBanner banner = CreateBanner();
var buttons = banner.GetVisualDescendants()
.OfType