From 879650911e03fc48a62d5cd460cf2532b602e5a6 Mon Sep 17 00:00:00 2001 From: Tiago Tavares Date: Tue, 18 Aug 2026 11:50:03 +0100 Subject: [PATCH] test(host): name the network transport in the reader's words and start every story with the user --- .../tests/functional/fixtures/settings.ts | 13 ++++++++++ .../tests/functional/host-settings.spec.ts | 11 ++++---- apps/host/tests/functional/loading.spec.ts | 26 +++++++++---------- apps/host/tests/functional/navigation.spec.ts | 24 ++++++++--------- apps/host/tests/functional/resolution.spec.ts | 6 ++--- 5 files changed, 47 insertions(+), 33 deletions(-) diff --git a/apps/host/tests/functional/fixtures/settings.ts b/apps/host/tests/functional/fixtures/settings.ts index e9979404..a2ed17d2 100644 --- a/apps/host/tests/functional/fixtures/settings.ts +++ b/apps/host/tests/functional/fixtures/settings.ts @@ -15,6 +15,19 @@ export const BACKENDS = [ export type Backend = (typeof BACKENDS)[number]; +/** + * How each network transport is named in a user story. + * + * Test titles are read by people deciding whether a behaviour is covered, so + * they name the transport the way the settings screen does rather than by its + * stored value. + */ +export const TRANSPORT_LABELS: Record = { + "smoldot-shared-worker": "shared smoldot", + "smoldot-direct": "smoldot per app", + "rpc-gateway": "trusted provider", +}; + export interface CacheSeed { skipCidCache: boolean; skipArchiveCache: boolean; diff --git a/apps/host/tests/functional/host-settings.spec.ts b/apps/host/tests/functional/host-settings.spec.ts index ea7c9d19..3f645ff8 100644 --- a/apps/host/tests/functional/host-settings.spec.ts +++ b/apps/host/tests/functional/host-settings.spec.ts @@ -36,6 +36,7 @@ import { CACHE_ENABLED, SKIP_ARCHIVE_ONLY, SKIP_CID_ONLY, + TRANSPORT_LABELS, updateCacheSettings, } from "./fixtures/settings"; import { test } from "./helpers/shared-mode-reset"; @@ -101,7 +102,7 @@ test.describe("Settings works", () => { }); for (const backend of BACKENDS) { - test(`As a user opening a link that selects ${backend}, my session runs in that mode and stays there`, async ({ + test(`As a user opening a link that selects ${TRANSPORT_LABELS[backend]}, my session runs in that mode and stays there`, async ({ page, }) => { // When @@ -238,7 +239,7 @@ test.describe("Settings works", () => { }); for (const backend of BACKENDS) { - test(`As a user on ${backend} with the dotNS cache on, revisiting a site skips looking its name up again`, async ({ + test(`As a user on ${TRANSPORT_LABELS[backend]} with the dotNS cache on, revisiting a site skips looking its name up again`, async ({ browser, }) => { // Given @@ -263,7 +264,7 @@ test.describe("Settings works", () => { } }); - test(`As a user on ${backend} who turns the dotNS cache off, every visit looks the name up again`, async ({ + test(`As a user on ${TRANSPORT_LABELS[backend]} who turns the dotNS cache off, every visit looks the name up again`, async ({ browser, }) => { // Given @@ -291,7 +292,7 @@ test.describe("Settings works", () => { } for (const backend of BACKENDS) { - test(`As a user on ${backend} with the archive cache on, revisiting a site checks my local copy first`, async ({ + test(`As a user on ${TRANSPORT_LABELS[backend]} with the archive cache on, revisiting a site checks my local copy first`, async ({ browser, }) => { // Given @@ -315,7 +316,7 @@ test.describe("Settings works", () => { } }); - test(`As a user on ${backend} who turns the archive cache off, the site is fetched fresh instead of from my local copy`, async ({ + test(`As a user on ${TRANSPORT_LABELS[backend]} who turns the archive cache off, the site is fetched fresh instead of from my local copy`, async ({ browser, }) => { // Given diff --git a/apps/host/tests/functional/loading.spec.ts b/apps/host/tests/functional/loading.spec.ts index 02c27557..362e544c 100644 --- a/apps/host/tests/functional/loading.spec.ts +++ b/apps/host/tests/functional/loading.spec.ts @@ -157,7 +157,7 @@ async function shrinkTimeout( ); } -test("As a user using smoldot directly, when the light client panics mid-resolution, I see the appropriate error and can switch backend", async ({ +test("As a user on smoldot per app, when the light client panics mid-resolution, I see the appropriate error and can switch network transport", async ({ page, }) => { // Given @@ -183,7 +183,7 @@ test("As a user using smoldot directly, when the light client panics mid-resolut ); }); -test("As a user using smoldot in shared worker, when the light client panics mid-resolution, I see the appropriate error and can switch backend", async ({ +test("As a user on shared smoldot, when the light client panics mid-resolution, I see the appropriate error and can switch network transport", async ({ page, }) => { // Given @@ -209,7 +209,7 @@ test("As a user using smoldot in shared worker, when the light client panics mid ); }); -test("As a user using smoldot in shared worker, when the browser can't create a worker, I see the appropriate error and can switch backend", async ({ +test("As a user on shared smoldot, when the browser can't create a worker, I see the appropriate error and can switch network transport", async ({ page, }) => { // Given @@ -238,7 +238,7 @@ test("As a user using smoldot in shared worker, when the browser can't create a ); }); -test("As a user using smoldot in shared worker, when the worker dies silently, I see the appropriate error and can switch backend", async ({ +test("As a user on shared smoldot, when the worker dies silently, I see the appropriate error and can switch network transport", async ({ page, }) => { // Given @@ -267,7 +267,7 @@ test("As a user using smoldot in shared worker, when the worker dies silently, I ); }); -test("As a user using smoldot directly, when loading is slow (>10s) I see a one-click gateway escape, and if it times out (>45s) I see the appropriate error and can switch backend", async ({ +test("As a user on smoldot per app, when loading is slow (>10s) I see a one-click escape to a trusted provider, and if it times out (>45s) I see the appropriate error and can switch network transport", async ({ page, }) => { // Given @@ -304,7 +304,7 @@ test("As a user using smoldot directly, when loading is slow (>10s) I see a one- ); }); -test("As a user using smoldot in shared worker, when loading is slow (>10s) I see a one-click gateway escape, and if it times out (>45s) I see the appropriate error and can switch backend", async ({ +test("As a user on shared smoldot, when loading is slow (>10s) I see a one-click escape to a trusted provider, and if it times out (>45s) I see the appropriate error and can switch network transport", async ({ page, }) => { // Given @@ -341,7 +341,7 @@ test("As a user using smoldot in shared worker, when loading is slow (>10s) I se ); }); -test("As a user using smoldot directly, when I click the gateway escape, the backend flips to rpc-gateway and the page reloads", async ({ +test("As a user on smoldot per app, when I click the escape, my network transport becomes the trusted provider and the page reloads", async ({ page, }) => { // Given @@ -391,7 +391,7 @@ test("As a user, when the app chunks fail to load mid-session, I see the appropr await expect(page.locator("#error-retry-btn")).toContainText("Reload"); }); -test("As a user using smoldot directly, when smoldot rejects the chain spec, I see the appropriate error and can switch backend", async ({ +test("As a user on smoldot per app, when smoldot rejects the chain spec, I see the appropriate error and can switch network transport", async ({ page, }) => { // Given @@ -420,7 +420,7 @@ test("As a user using smoldot directly, when smoldot rejects the chain spec, I s ); }); -test("As a user using smoldot in shared worker, when smoldot rejects the chain spec, I see the appropriate error and can switch backend", async ({ +test("As a user on shared smoldot, when smoldot rejects the chain spec, I see the appropriate error and can switch network transport", async ({ page, }) => { // Given @@ -497,7 +497,7 @@ test("As a user, when the domain's contenthash is unsupported or malformed, I se await expect(page.locator("#error-retry-btn")).toHaveCount(0); }); -test("As a user, after a resolution failure, clicking retry switches backend and the app loads successfully", async ({ +test("As a user, after a resolution failure, clicking retry switches my network transport and the app loads successfully", async ({ page, }) => { // Given @@ -524,7 +524,7 @@ test("As a user, after a resolution failure, clicking retry switches backend and expect(backendAfter).toBe("rpc-gateway"); }); -test("As a user, after a resolution failure, I can refresh instead of switching backend, and the backend stays unchanged", async ({ +test("As a user, after a resolution failure, I can refresh instead of switching network transport, and my network transport stays unchanged", async ({ page, }) => { // Given @@ -557,10 +557,10 @@ test("As a user, after a resolution failure, I can refresh instead of switching }); for (const [label, backend] of [ - ["per-product smoldot", "smoldot-direct"], + ["smoldot per app", "smoldot-direct"], ["shared smoldot", "smoldot-shared-worker"], ] as const) { - test(`As a user using ${label}, the host must only spawn one instance of the light client`, async ({ + test(`As a user on ${label}, I only ever get one light client, never one per app`, async ({ page, }) => { // Given diff --git a/apps/host/tests/functional/navigation.spec.ts b/apps/host/tests/functional/navigation.spec.ts index a27151b6..cbee0d12 100644 --- a/apps/host/tests/functional/navigation.spec.ts +++ b/apps/host/tests/functional/navigation.spec.ts @@ -35,7 +35,7 @@ async function seedBackend(page: Page): Promise { } test.describe("URL parameters are forwarded into the product", () => { - test("when I open http://