Lds.Web.Components.Testing 0.111.0

Lds.Web.Components.Testing

Lds is Datalogik LDS' framework for .NET web applications: the parts every one of its applications would otherwise write again — a shell and components for Blazor pages, the Result an operation answers with, permissions and who holds them, an audit trail and the store it writes to — shipped as seven packages that share one version. It prescribes no application architecture: an application keeps its own structure and takes the parts it wants.

Package What it is
Lds.Application The technology-blind core: Result and the failure text that words it, permissions and the current user, granted access, the audit trail and the ports its store implements
Lds.Application.FormattedText The formatted-text sanitiser and its rules, apart from the core on weight
Lds.Application.IpAccess The operations that keep the rules of Lds.IpAccess, Datalogik's IP access package — authorized and recorded in the audit trail, apart from the core on weight
Lds.Infrastructure.MongoDb The MongoDB store for the core's ports: the audit trail and granted access
Lds.Web.Components The Blazor components and their SCSS, with Font Awesome Free and the editors they use
Lds.Web.Components.Testing bUnit/xUnit support for testing pages built on the components
Lds.Web.IpAccess The IP access screens over those operations, apart from the components on weight

The packages are on Datalogik's feed, https://components.datalogik.dk/v3/index.json.

This package

What a test project needs to test pages built on Lds.Web.Components with bUnit and xUnit:

  • ComponentTest — a base class that sets up rendering inside the shell: logging, localization, the colour mode, and a JavaScript runtime in loose mode, since a bUnit test has no browser. A solution derives from it and adds its own languages and failure text.
  • Presses — Press, which waits for an element and presses it, Act, which does the same for any other event, and Answer, which answers one of Lds' questions and closes it where it still stands. Why, below.
  • TranslationCompleteness — checks that every language a resource family ships says everything the others say, and leaves no entry blank.

It carries bUnit and xUnit, so it belongs in test projects only.

Getting started

public abstract class PageTest : ComponentTest
{
    protected PageTest()
    {
        Services.AddInterfaceLanguages([new("en-GB", "English"), new("da-DK", "Dansk")]);
        Services.AddFailureText<MyFailures>();
    }
}

See Adopting the framework §3.7.

Tests that hold on a busy runner

A page test that passes on a developer's machine can fail on a slow or busy CI runner, a different test each time, and look like noise. The races below are the ones found by running a solution's page tests forty times beside a busy loop on every core; each failed about one run in forty.

  • A wait asserts; it never acts. No click, change, input or submit inside WaitForAssertion. bUnit reports an event on a handler the renderer has replaced as unhandled, and that ends every running wait at once, so the wait is no retry. Under load bUnit's markup can also keep a replaced handler until the component renders again. Press and Act wait for the element, raise the event apart from the wait, and on a replaced handler render again and raise it again.

    // Fails one run in forty under load
    page.WaitForAssertion(() => page.Find("input[name=Title]").Input("Lead tester"));
    page.WaitForAssertion(() => page.FindAll("button").First(b => b.TextContent.Trim() == "Save").Click());
    
    // Holds
    page.Act(() => page.Find("input[name=Title]"), field => field.Input("Lead tester"));
    page.Press(() => page.FindAll("button").First(b => b.TextContent.Trim() == "Save"));
    
  • An act that depends on what the page shows is decided inside Act, on the element it found, and its result is waited for after. A wait that clicks a fold if it is closed clicks again on the next try, before the first click's render has arrived, and folds it shut.

    IElement Fold() => page.Find("button.panel__fold");
    page.Act(Fold, fold => { if (fold.GetAttribute("aria-expanded") != "true") fold.Click(); });
    page.WaitForAssertion(() => Assert.Equal("true", Fold().GetAttribute("aria-expanded")));
    
  • Answer one of Lds' questions with Answer; never wait for the question to still stand. A confirming answer performs its act at once, while the browser closes the element. Where the question stood inside what the act takes away (a deleted record's row) it is gone, and a test waiting for it to send the browser's close waits for nothing. page.Answer("Delete the record") sends the close only where the question still stands. A question asked over a DialogueForm stands inside the form's own dialog.lds-dialogue: name it, page.Answer("…", "dialog.lds-dialogue:not(.lds-dialogue--form)").

  • A read the page starts again must not be overtaken by an older one. A page that starts a read on a parameter, an event or a navigation, and can start it again before the first returns, keeps the answer only if it is still for what is shown. Under load the older read returns last.

  • A read still running is shown as busy, not as empty. A test that waits for the page to finish reading can only tell the two apart by what the page shows.

  • A check cached for the whole test process must not cache a timeout. A "can we reach the database?" check with a two-second timeout, cached on first use, answered no once under load and failed every test after it in that run.

Finding them. Lds' repository has tools/load-test/load-test.ps1, which runs a test project several times at once beside a busy loop on every core and counts how often each test failed, with its first error. Forty runs find a test that fails one run in forty about two times in three; run it before and after a fix. A search for WaitForAssertion( whose lambda calls .Click(, .Change(, .Input( or .Submit( finds the first kind.

Documentation, issues and changes

The source, the documents and the issues are on GitHub, at datalogiklds/webframework. The repository is private: if you have access, report a fault or ask for a change there; if you don't, ask Datalogik LDS for it.

  • Adopting the framework — everything a solution supplies to the packages, with the decision behind each item
  • Architecture — how Lds is built and where an application's code meets its types
  • Using the components — how a page is put together from the components
  • Design manual — what the interface looks like and how it behaves
  • Glossary — the words the source and the documents use
  • Changelog — what changed in each version, and what a solution has to change to take it

No packages depend on Lds.Web.Components.Testing.

.NET 10.0

Version Downloads Last updated
0.146.0 2 2026-11-17
0.145.0 1 2026-11-17
0.144.0 2 2026-11-16
0.143.1 1 2026-11-16
0.143.0 2 2026-11-16
0.142.0 3 2026-11-15
0.141.1 6 2026-11-15
0.141.0 2 2026-11-15
0.140.0 1 2026-11-15
0.139.1 10 2026-11-15
0.139.0 2 2026-11-15
0.138.0 5 2026-11-15
0.137.0 3 2026-11-15
0.136.1 2 2026-11-15
0.136.0 2 2026-11-15
0.135.0 2 2026-11-15
0.134.1 6 2026-11-15
0.134.0 2 2026-11-15
0.133.0 2 2026-11-15
0.132.0 1 2026-11-15
0.131.0 3 2026-11-15
0.130.0 3 2026-11-15
0.129.0 3 2026-11-14
0.128.0 4 2026-11-14
0.127.0 2 2026-11-14
0.126.0 3 2026-11-14
0.125.1 1 2026-11-14
0.125.0 2 2026-11-14
0.124.0 3 2026-11-14
0.123.0 1 2026-11-14
0.122.0 2 2026-11-14
0.121.0 12 2026-11-12
0.120.0 24 2026-11-12
0.119.0 1 2026-11-12
0.118.0 0 2026-11-12
0.117.0 1 2026-11-12
0.116.0 3 2026-11-11
0.115.0 7 2026-11-11
0.113.0 2 2026-11-11
0.112.0 8 2026-11-11
0.111.1 6 2026-11-10
0.111.0 7 2026-11-10
0.110.0 1 2026-11-09
0.109.0 4 2026-11-09
0.108.1 3 2026-11-09
0.108.0 9 2026-11-09
0.107.0 6 2026-11-09
0.106.1 5 2026-11-09
0.106.0 4 2026-11-08
0.105.0 4 2026-11-08
0.104.0 3 2026-11-08
0.103.0 5 2026-11-08
0.102.0 3 2026-11-08
0.101.0 4 2026-11-08
0.100.0 4 2026-11-08
0.99.0 2 2026-11-08
0.98.1 4 2026-11-08
0.98.0 8 2026-11-08
0.97.1 6 2026-11-08
0.97.0 2 2026-11-08
0.96.0 6 2026-11-08