Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions changelog.d/+roles-card-no-bis-while-running.fixed.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
On a phone, the card of a Funktion that is still running no longer shows "BIS —", so it no longer reads as ended (#668).
6 changes: 4 additions & 2 deletions src/LageBuch.App.Shared/Views/RolesView.axaml
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,10 @@
<TextBlock Text="VON" Classes="overline" FontSize="9" VerticalAlignment="Center" />
<TextBlock Text="{Binding FromDisplay}" Classes="mono" FontSize="12" />
</StackPanel>
<StackPanel Orientation="Horizontal" Spacing="6"
IsVisible="{Binding ToDisplay, Converter={x:Static ObjectConverters.IsNotNull}}">
<!-- ToDisplay is "—" while running, which the grid column wants and a card
would read as ended (#668). -->
<StackPanel x:Name="RoleCardTo" Orientation="Horizontal" Spacing="6"
IsVisible="{Binding !IsRunning}">
<TextBlock Text="BIS" Classes="overline" FontSize="9" VerticalAlignment="Center" />
<TextBlock Text="{Binding ToDisplay}" Classes="mono" FontSize="12" />
</StackPanel>
Expand Down
70 changes: 70 additions & 0 deletions tests/LageBuch.Acceptance.Tests/RolesCardTests.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,70 @@
using Avalonia.Controls;
using Avalonia.Headless;
using Avalonia.Headless.XUnit;
using Avalonia.Threading;
using Avalonia.VisualTree;
using LageBuch.App.Shared.Views;
using LageBuch.AppLogic.Services;
using LageBuch.AppLogic.ViewModels;
using LageBuch.Domain;
using LageBuch.Persistence.MasterData;

namespace LageBuch.Acceptance.Tests;

// #668: on a phone the Funktionen are cards, and a running assignment's card showed "BIS —",
// which reads as ended. The card names BIS only once the assignment has one.
public class RolesCardTests
{
[AvaloniaFact]
public void A_running_card_shows_no_bis_line_and_an_ended_card_does()
{
var clock = new FixedClock();
var session = TestSession.StartNew(
new FakeStore(),
clock,
new SessionOperator(AnonymizedExampleData.OperatorSurname, "FFB 12/1"),
"/x.fwincident",
Array.Empty<(string, bool)>(),
Array.Empty<(string, bool)>());
session.AssignRole("EL", AnonymizedExampleData.OperatorSurname, from: clock.Now.AddMinutes(-40), to: clock.Now.AddMinutes(-10));
session.AssignRole("EL", AnonymizedExampleData.OperatorSurnameAlt, from: clock.Now.AddMinutes(-10));
var vm = new IncidentWorkspaceViewModel(
session,
clock,
new NoopTicker(),
MasterDataSet.Empty,
new FakeDialogs(),
new NoopAlarmService(),
new NoopIncidentHostController());
vm.Roles.ShowAllRoles = true; // the ended one is listed only on request
var window = new Window { Content = new IncidentWorkspaceView { DataContext = vm }, Width = 412, Height = 915 };
window.Show();
Dispatcher.UIThread.RunJobs();
WorkspaceRenderHelper.SelectTab(window, "FUNKTIONEN");
Dispatcher.UIThread.RunJobs();

var bisLines = window.GetVisualDescendants().OfType<StackPanel>()
.Where(p => p.Name == "RoleCardTo")
.ToList();
Capture(window, "roles-cards.png");

var running = Assert.Single(bisLines, p => p.DataContext is RoleAssignmentRow { IsRunning: true });
var ended = Assert.Single(bisLines, p => p.DataContext is RoleAssignmentRow { IsRunning: false });
Assert.False(running.IsEffectivelyVisible);
Assert.True(ended.IsEffectivelyVisible);
}

// Opt-in PNG capture for the PR's before/after pair; a plain test run writes nothing.
private static void Capture(Window window, string name)
{
var dir = Environment.GetEnvironmentVariable("RENDER_OUT");
if (string.IsNullOrWhiteSpace(dir))
{
return;
}

Directory.CreateDirectory(dir);
using var frame = window.CaptureRenderedFrame();
frame?.SavePng(Path.Join(dir, name));
}
}
Loading