The browser fixture opens phones from Playwright's own device presets (360x800, iPhone SE 375x667, Pixel 7 412x839, and the Pixel 7 held sideways), with touch, a coarse pointer and reduced motion, and a phone session fails at once if the page doesn't see a touch screen. Mobile/fit.js measures a page one screen at a time down its main scroller: sideways scroll, boxes past the screen's sides, open menus and dialogs cut or outside the screen, targets without a 44px hit area (hit-tested at their centre and 21px around it, so a crowding neighbour fails them too) and control text under 12px. RouteSweepTests runs every feed tab, threads of each kind the town holds, profiles, search, Explore, lists, groups, filters, scheduled posts, settings and administration (every section opened) and the login page on the three portrait phones, as client.mobile.fit.* and client.mobile.touch.* cells; screenshots, findings and a contact sheet go to tests/e2e/out/mobile/. DesktopUnchangedTests holds desktop's control sizes. Category=Mobile. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01LsXgEaXee4GCU1hwYgPJXw
44 lines
1.7 KiB
C#
44 lines
1.7 KiB
C#
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 = """
|
|
() => Object.fromEntries(["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 [classes, 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<bool>("() => matchMedia('(pointer: coarse)').matches"), "the desktop session has a coarse pointer");
|
|
var heights = await page.EvaluateAsync<Dictionary<string, double>>(Probe);
|
|
Assert.Equal(40, heights["btn"], 0.5);
|
|
Assert.Equal(32, heights["btn btn-sm"], 0.5);
|
|
Assert.Equal(24, heights["btn btn-xs"], 0.5);
|
|
Assert.Equal(40, heights["input"], 0.5);
|
|
Assert.Equal(32, heights["input input-sm"], 0.5);
|
|
await Assertions.Expect(page.Locator("nav a.btn").First).ToBeVisibleAsync();
|
|
await session.AssertGuards();
|
|
}, page);
|
|
}
|
|
}
|
|
}
|