using decePubClient.E2E.Support; using Microsoft.Playwright; namespace decePubClient.E2E.Mobile { // What phones get stays on phones: at 1440x900 with a mouse the controls keep daisyUI's sizes, measured on probes made // with the app's own classes, and the nav menu stays open beside the feed. [Trait("Category", "Mobile")] public sealed class DesktopUnchangedTests(Browser browser) { const string Probe = """ () => ["btn", "btn btn-sm", "btn btn-xs", "input", "input input-sm"].map(classes => { const el = document.createElement(classes.startsWith("input") ? "input" : "button") el.className = classes document.body.append(el) const height = el.getBoundingClientRect().height el.remove() return height }) """; [Fact] public async Task Desktop_keeps_its_sizes() { var persona = Pasture.Personas().GroupBy(p => p.Root).OrderByDescending(g => g.Count()).First().First(); await using var session = await SignIn.As(browser, persona); var page = session.Page; await Results.Cell("client.mobile.desktop", "privapub", "desktop", async () => { Assert.False(await page.EvaluateAsync("() => matchMedia('(pointer: coarse)').matches"), "the desktop session has a coarse pointer"); // btn, btn btn-sm, btn btn-xs, input, input input-sm var heights = await page.EvaluateAsync(Probe); Assert.Equal([40, 32, 24, 40, 32], heights.Select(h => Math.Round(h)).ToArray()); await Assertions.Expect(page.Locator("nav a.btn").First).ToBeVisibleAsync(); await session.AssertGuards(); }, page); } } }