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..f4b8a42f 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 @@ -130,7 +131,10 @@ test.describe("Settings works", () => { // Then const state = await readChainBackendState(page, "smoldot-direct"); expect(state.chainBackend).toBe("smoldot-direct"); - expect(state.url).toContain("chainBackend=smoldot-direct"); + // The link asked for the default mode, and a default axis is stripped from + // the address bar, so landing in it leaves a clean URL rather than one + // that still names it. See the contract in `packages/config/url-settings`. + expect(state.url).not.toContain("chainBackend="); }); test("As a user who arrived through such a link, reloading without it keeps me in the mode I landed in", async ({ @@ -234,11 +238,13 @@ test.describe("Settings works", () => { expect(cache.skipWorkerCache).toBe(false); expect(state.url).toContain("skipCidCache=1"); expect(state.url).toContain("skipArchiveCache=1"); - expect(state.url).toContain("skipWorkerCache=0"); + // The worker cache was left at its default, so it is stripped rather than + // written back as `=0`. Only the axes I actually changed travel in the link. + expect(state.url).not.toContain("skipWorkerCache="); }); 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 +269,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 @@ -283,7 +289,10 @@ test.describe("Settings works", () => { // Then await waitForResolutionOutcome(page, TIMEOUT_MS, backend); expect(await hostResolveStarted(page)).toBe(true); - expect(await hasCachedCid(page, DOMAIN)).toBe(true); + // Changing a cache setting wipes this origin, so the entry saved on the + // first visit is gone rather than merely ignored, and with the cache off + // nothing writes a new one. See the wipe in `applyUrlSettings`. + expect(await hasCachedCid(page, DOMAIN)).toBe(false); } finally { await context.close(); } @@ -291,7 +300,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 +324,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://