43 lines
2.4 KiB
C#
43 lines
2.4 KiB
C#
using Bunit;
|
|
using Duempelkas.App.Components;
|
|
using Duempelkas.App.Services;
|
|
using Duempelkas.Domain.Enums;
|
|
using Microsoft.AspNetCore.Components;
|
|
using Xunit;
|
|
|
|
namespace Duempelkas.Tests;
|
|
|
|
public class LayoutControlTests
|
|
{
|
|
[Fact]
|
|
public async Task TextScaleControl_ChangesPresentationWithoutChangingLedger()
|
|
{
|
|
using var f = new LedgerUiFixture();
|
|
var entries = f.Service<IEntryService>();
|
|
await entries.CreateEntryAsync(1, EntryType.Expense, DateTime.Today, "Porto mit sehr langer Beschreibung und Umlauten äöü", 4.20m);
|
|
f.Service<NavigationManager>().NavigateTo("/accounts/1");
|
|
var page = f.Context.Render<Routes>();
|
|
page.WaitForElement("#text-scale").Change("200");
|
|
Assert.Contains(f.Context.JSInterop.Invocations, i => i.Identifier == "duempelkasReading.set" && Equals(i.Arguments[0], 200));
|
|
Assert.Equal(95.80m, (await f.Service<IBalanceQueryService>().GetAccountBalanceAsync(1)).TotalBalance);
|
|
Capture("account", page.Markup);
|
|
page.FindAll("button").Single(b => b.TextContent.Contains("Einnahme oder Ausgabe")).Click();
|
|
page.WaitForElement("#entry-title");
|
|
Capture("booking", page.Markup);
|
|
}
|
|
|
|
private static void Capture(string name, string markup)
|
|
{
|
|
var output = Environment.GetEnvironmentVariable("DUEMPELKAS_LAYOUT_EVIDENCE");
|
|
if (output == null) return;
|
|
Directory.CreateDirectory(output);
|
|
var root = new DirectoryInfo(AppContext.BaseDirectory);
|
|
while (root != null && !File.Exists(Path.Combine(root.FullName, "src", "Duempelkas.Desktop", "Duempelkas.Desktop.csproj"))) root = root.Parent;
|
|
var web = new Uri(Path.Combine(root!.FullName, "src", "Duempelkas.Desktop", "wwwroot") + Path.DirectorySeparatorChar).AbsoluteUri;
|
|
File.WriteAllText(Path.Combine(output, name + ".html"), "<!doctype html><html lang='de'><head><meta charset='utf-8'><meta name='viewport' content='width=device-width, initial-scale=1'>" +
|
|
$"<link rel='stylesheet' href='{web}vendor/bootstrap/bootstrap.min.css'><link rel='stylesheet' href='{web}vendor/bootstrap-icons/bootstrap-icons.min.css'><link rel='stylesheet' href='{web}css/app.css'>" +
|
|
"</head><body>" + markup + $"<script src='{web}js/app.js'></script>" +
|
|
"<script>document.querySelectorAll('dialog').forEach(d=>d.showModal());</script></body></html>");
|
|
}
|
|
}
|