Skip to content
Back to skills

Testing Ui

ASecurity

Category-D component-level acceptance tests for OwlMeans Common UI packages (web-panel, web-client, web-consent, web-router, mui-panel, client-panel, client-wl, web-flow, web-wl, client, client-i18n) and shadcn UI + Tailwind v4 packages. Run under bun test, drive a real chromium via Playwright as a library — not the Playwright runner. Auto-invoked when writing tests in those packages.

  • 3 stars
  • 0 votes
  • 0 copies
  • 3 views
  • Added September 22, 2026
developmentrustgoreactnodetestinggitapibackend

Works with

  • cli
  • api

Security analysis

A100/100

Scanned November 14, 2026

npx -y skills add owlmeans/common --skill testing-ui --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Testing Ui?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Testing Ui
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/owlmeans-testing-ui-common/badge)](https://www.skillsdirectory.com/skills/owlmeans-testing-ui-common)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
name: testing-ui
description: Category-D component-level acceptance tests for OwlMeans Common UI packages (web-panel, web-client, web-consent, web-router, mui-panel, client-panel, client-wl, web-flow, web-wl, client, client-i18n) and shadcn UI + Tailwind v4 packages. Run under bun test, drive a real chromium via Playwright as a library — not the Playwright runner. Auto-invoked when writing tests in those packages.
---
<!-- AUTO-GENERATED — do not edit. Regenerate via sync-agent-meta. -->

# UI Acceptance Tests — Category D (bun test + Playwright as a library)

**Install:** `"@owlmeans/test-ui": "^0.2.0-alpha.0"` in `devDependencies`

`@owlmeans/test-ui` depends on `playwright`, so the browser library arrives with it; add
`playwright` to `devDependencies` as well when a spec imports a launcher itself. The Vite harness
below is the consuming package's own, so a package that builds one also declares `vite` and
`@vitejs/plugin-react`, plus `@tailwindcss/vite` and `tailwindcss` for a shadcn package. A
smoke-only package that serves a `data:` URL needs none of those.

Category D applies to packages that ship a rendered surface: `client`, `client-i18n`, `client-panel`, `client-wl`, `mui-panel`, `web-client`, `web-consent`, `web-flow`, `web-oauth`, `web-panel`, `web-router`, `web-wl`. Tests are **component-level acceptance** — they mount one component in a real browser and assert against rendered DOM. They are **not** end-to-end tests (no live backend).

The runner is **`bun test`** — same as categories A/B/C — kept consistent so contributors only learn one harness. Playwright is consumed as a **library** (`playwright` package, not `@playwright/test`). The `playwright` library exposes `chromium`, `firefox`, `webkit` browser launchers; specs drive them directly from inside `bun:test` blocks.

A client-side package that ships no component belongs to category A, however browser-flavoured its
name — `client-config`, `client-context`, `client-entrypoint`, `client-flow`, `client-job`,
`client-resource`, `client-route`, `client-socket`, `web-db` and
`web-router-react-router` are all services, models and adapters. `@owlmeans/web-router` is the one
that is not: it drives the real History API, so its routing behaviour is only observable in a
browser and its specs mount a full harness here.

Auth-related UI packages (`web-oidc-rp`, `web-oidc-provider`, `client-auth`, `client-payment`) belong to category B and use `bun test` + `@owlmeans/test-auth`, not the chromium harness.

## Layout

```
<your-package>/
├── src/...
└── tests/
    ├── harness/              # per-package: the app the specs drive
    │   ├── index.html        # copy of @owlmeans/test-ui/harness/index.html
    │   └── mount.tsx         # boots the package's real surface into #root
    ├── context.ts            # one place that boots the harness server, exports HARNESS_URL
    └── <area>.spec.ts        # *.spec.ts only
```

## One-time setup (per developer machine)

```sh
bunx playwright install chromium
```

Downloads the chromium binary the `playwright` library drives. CI installs it in a workflow step.

## Helpers from `@owlmeans/test-ui`

| Helper | Purpose |
|---|---|
| `browserHelper.launchBrowser(opts?)` | Return the shared chromium for this `bun test` process. Idempotent. |
| `browserHelper.closeBrowser()` | Tear it down. Call from `afterAll`. |
| `browserHelper.withPage(fn)` | Lease a fresh context+page for the duration of `fn`, dispose context on completion. |
| `mountComponent(opts)` | Open a fresh context, navigate to `opts.url`, return `Mounted` = `{ page, close }`. `component` and `props`, when given, are appended as `?component=` and `?props=`; omit them when the harness mounts a fixed root, which is what every harness here does. |
| `MountOptions` | `{ url, component?, props?, waitUntil?, timeout? }` — `waitUntil` defaults to `domcontentloaded`, see below. |
| `makePageHelper(page).acceptConsent({ timeout? })` | Wait up to `timeout` (default 5s) for the consent store to SETTLE — `[data-consent-dialog]` up (bar or window), or `<html data-consent="decided">` — then accept all and wait for it to detach. Returns whether it answered one; a decision made without UI returns `false` at once. |
| `consentGeoTestHelper.mockConsentGeo(pageOrContext, geo)` / `.traceCalls(page)` | Pin where the visitor is: an init script answering the same-origin `/cdn-cgi/trace` (`'US'`, or `{ country?, fail?: true \| 'hang', delayMs?, gpc? }`), installed for the NEXT navigation; counts the calls in the page. `mountComponent({ …, consentGeo })` installs it before the first one. |
| `makePageHelper(page).saveScreenshot(dir, name)` | Full-page PNG to `<dir>/<name>.png`, creating `dir`. Returns the absolute path. |
| Re-exports: `Browser`, `BrowserContext`, `Page`, `Locator` | Playwright types — no direct `playwright` import needed. |

### Authenticated specs

`@owlmeans/test-ui` also carries the supervisor-login helpers, so a spec can reach a screen that
sits behind auth without hand-rolling a token:

| Helper | Purpose |
|---|---|
| `supervisorAuthHelper.pregenerateAuthToken(opts)` | Mint an `ED25519-BASIC-TOKEN …` bearer offline from a trusted private key — no browser, no round trip. Options: `{ userId, pk, scopes?, role?, entityId?, profileId?, source? }`. |
| `supervisorAuthHelper.authenticateViaSupervisorApi(opts)` | Drive the live PK supervisor flow over the backend API (init → sign → authenticate → dispatch), registering the user on first use. Options: `{ apiBaseUrl, userId, pk, paths?, fetchImpl? }`. |
| `makePageHelper(page).loginViaDispatcher(baseUrl, token, opts?)` | Inject a bearer through the standard `/dispatcher?token=…` route, wait for the app to navigate away, then answer marketing consent (see below). Options: `{ dispatcherPath?, waitUntil?, marketingConsent? }`. |
| `makePageHelper(page).loginViaSupervisorForm(opts)` | Drive the real login form end-to-end — navigate, answer consent, fill user id + key, submit, wait for the landing, then answer marketing consent (see below). Options: `{ baseUrl, userId, pk, path?, expectPath?, timeout?, waitUntil?, consent?, screenshotDir?, marketingConsent? }`. |
| `makePageHelper(page).answerMarketingConsent(opts?)` | Answer the `@owlmeans/web-marketing-consent` full-page step if it is shown right after login. Options: `{ accept?: 'all' \| 'none' \| 'skip', terms?: 'accept' \| 'leave', timeout? }`, default `accept: 'all'`, `terms: 'accept'`, `timeout: 30_000`. Returns whether the step was actually shown and answered — `false` means it never appeared. Throws if a Terms box could not be confirmed. |

| `makePageHelper(page).loginViaEmailForm(opts)` | Drive the real e-mail card of `@owlmeans/web-auth-email` (below). Options: `{ baseUrl, email, rewritePin, password?, waiver?, start?: 'email' \| 'dispatcher', path?, dispatcherPath?, apiPath?, offer?: 'skip' \| 'ignore' \| { password }, marketingConsent?, expectPath?, landedSelector?, timeout?, waitUntil?, consent?, screenshotDir? }`. Resolves `{ mode, device, pins, offer, marketingConsent }`. |
| `makePageHelper(page).routeEmailWaiver(waiver, opts?)` | Send a developer waiver in `x-owlmeans-email-waiver` on this page's `<apiPath>/` requests only (default `/auth/email/`); resolves the function that stops it. |
| `makeEmailTechClient({ apiUrl, privateKey, credentialId?, path?, fetchImpl? })` | The e-mail developer routes, signed as a trusted record (`signBasicEd25519Request`): `.waiver()` and `.rewritePin(challenge, pin?)` → the PIN now valid (6 random digits by default). `credentialId` defaults to the key's address. |

These need a project whose backend trusts the private key they sign with, so they belong to specs
that run against a real app rather than a mounted component. See `[[supervisor-auth]]` for the
server and web wiring they assume.

### E-mail sign-in without a mailbox

`loginViaEmailForm` opens the e-mail card (`/authentication/login/email`, or the chooser and its
`[data-login-method="email"]` with `start: 'dispatcher'`, ticking a Terms box first when one is
shown), answers the cookie dialog, types the address and sends for a PIN. It reads the challenge
from the send-PIN ANSWER on the network and hands it to `rewritePin` for the PIN to type — normally
`makeEmailTechClient(…).rewritePin`, which rewrites that pending PIN on the server. With `password`
it tries the password first; a device answer (`reason: 'device'`) is finished with a PIN the same
way. After the sign-in it answers, in whatever order they come, the password offer (`'skip'` by
default) and the marketing-consent step, then waits for the landing (`expectPath`, else
`landedSelector`, default `#app-prompt` — pass the app's own marker, or the wait costs the full
timeout).

- **The waiver rides on the e-mail routes only**, and only while the login runs: `routeEmailWaiver`
  is a `page.route` with a path predicate. Routing turns Playwright's HTTP cache off for the page
  while installed — never route every request, a vite-served app stalls on its unbundled modules.
- The tech routes exist only where the deployment enabled them for the signing record; elsewhere
  `waiver()` and `rewritePin()` throw. A spec that must prove the real captcha signs in without
  `waiver`.
- A refused step throws with the HTTP status and the card's `data-refusal`, never a bare timeout.

## Spec shape

```ts
import { afterAll, describe, expect, test } from 'bun:test'
import { browserHelper, mountComponent } from '@owlmeans/test-ui'
import { HARNESS_URL } from './context.js'

// Browser work does not fit bun's 5s default: a cold harness compiles the app on first request,
// and the first test to run pays for the Vite boot happening in the same process.
const TIMEOUT = 30_000

afterAll(async () => { await browserHelper.closeBrowser() })

// The harness is a real app, so a spec picks its case by opening a path on it.
const open = async (path: string) =>
  mountComponent({ url: `${HARNESS_URL.replace(/\/$/, '')}${path}` })

describe('<package> — <component>', () => {
  test('renders the SKILL.md happy-path example', async () => {
    const { page, close } = await open('/login')
    try {
      expect(await page.locator('h1').textContent()).toBe('Sign in')
      expect(await page.getByRole('button', { name: /sign in/i }).isVisible()).toBe(true)
    } finally {
      await close()
    }
  }, TIMEOUT)
})
```

**Every chromium test carries its own timeout** — the third argument to `test`. Bun's default is
5s, which a cold harness blows through before the first assertion, and `bunfig.toml`'s
`[test] timeout` does not raise it (bun 1.4.0 reads the section but ignores that key). 30s covers a
mounted component against a Vite harness; a suite that drives a login form or a consent gate needs
60s. `bun test --timeout=<ms>` raises a whole run from the command line.

Use `bun:test`'s `expect` against awaited Playwright DOM queries (`textContent()`, `isVisible()`, `getAttribute()`). Don't import `expect` from `@playwright/test` — that would pull in the full runner and create two parallel test toolchains.

## Per-package `tests/context.ts`

The harness needs a real HTTP server because module-style React components can't run from a `data:` URL. Boot it once per `bun test` process:

```ts
import { createServer } from 'vite'
import react from '@vitejs/plugin-react'
import { fileURLToPath } from 'node:url'
import { dirname, resolve } from 'node:path'

const here = dirname(fileURLToPath(import.meta.url))

let url: string | null = null

export const getHarnessUrl = async (): Promise<string> => {
  if (url != null) return url
  const server = await createServer({
    configFile: false,
    root: resolve(here, './harness'),
    plugins: [react()],
    // Pre-bundle the third-party runtime deps the mounted components pull in. A dependency
    // discovered mid-transform makes Vite re-optimize and reload the page underneath the
    // navigation, and the first `goto` of a cold run pays for that as a timeout.
    optimizeDeps: { include: ['<runtime dep the components import>'] },
    server: { port: 0 },
    logLevel: 'warn',
  })
  await server.listen()
  const local = server.resolvedUrls?.local?.[0]
  if (local == null) throw new Error('vite did not expose a local URL')
  url = local
  return url
}

export const HARNESS_URL = await getHarnessUrl()
```

List in `optimizeDeps.include` every non-`@owlmeans` runtime package the components reach — the
toast library, the icon set, a form library. It is the difference between a cold run that passes
and one that times out on its first navigation for no visible reason.

The per-package `tests/harness/mount.tsx` statically imports what the package ships and renders it
via `react-dom/client` into the `<div id="root">` that `index.html` provides. It builds a real
application — `@owlmeans/web-panel` wires a context, the framework entrypoints and a `NavLayout`
over its screens; `@owlmeans/web-router` compiles a route tree behind the browser router plugin —
so a spec selects its case by the path it opens rather than by naming a component. A harness that
needs variants of one surface reads its own query string for them, the way `@owlmeans/web-consent`
picks a locale, a category set or the policy view. `mountComponent`'s `component` and `props`
options are the ready-made form of that convention, for a harness written to read them.
Each consuming UI package wires its own providers (a theme provider for the `mui-*` packages, or Tailwind CSS + the `@` alias for shadcn packages; plus i18n, router) the way the real app does — that's why mount.tsx is per-package, not in `@owlmeans/test-ui`.

## Smoke-only baseline

For a package that only needs to prove the bun-test + chromium pipeline works, skip the Vite harness and serve a `data:text/html` URL inline. Use this for a first spec in a package that has no harness yet — `web-panel` keeps one alongside a full Vite + chromium harness (`tests/harness/` plus a `tests/context.ts` wiring the Tailwind plugin, the `@` alias and a react dedupe), and that harness is the reference to copy for any package rendering real components:

```ts
import { afterAll, describe, expect, test } from 'bun:test'
import { browserHelper, mountComponent } from '@owlmeans/test-ui'

const harness = `data:text/html,${encodeURIComponent('<h1 id="t">hello</h1>')}`

afterAll(async () => { await browserHelper.closeBrowser() })

describe('chromium smoke', () => {
  test('reads a heading from a data: URL', async () => {
    const { page, close } = await mountComponent({ url: harness })
    try { expect(await page.locator('#t').textContent()).toBe('hello') }
    finally { await close() }
  }, 30_000)
})
```

A smoke spec needs the same explicit timeout as any other: bun runs every spec file of a package
in one process, so the first test to start pays for whatever harness the sibling files boot.

## Wiring `bun test`

Per-package `package.json`:

```json
"scripts": {
  "test": "bun test ./tests"
}
```

Same line as categories A/B/C. No `playwright.config.ts`, no `bun x playwright test`.

## Tailwind + shadcn packages

For shadcn-based OwlMeans packages the `tests/context.ts` Vite config needs three additions beyond the standard setup:

```ts
import tailwindcss from '@tailwindcss/vite'
import { resolve } from 'node:path'

const server = await createServer({
  configFile: false,
  root: resolve(here, './harness'),
  plugins: [react(), tailwindcss()],               // add Tailwind v4 Vite plugin
  resolve: {
    alias: { '@': resolve(here, '../src/@') },     // resolve @/ to the package's local copy
    dedupe: ['react', 'react-dom'],                // one React across the workspace links
  },
  optimizeDeps: { include: ['sonner'] },           // pre-bundle, never discover mid-navigation
  server: { port: 0 },
  logLevel: 'warn',
})
```

`dedupe` is not optional in a workspace: symlinked sibling packages otherwise resolve their own React copy and every hook throws.

`tests/harness/mount.tsx` imports the package CSS so components render with Tailwind styles:

```tsx
import '../../src/@/globals.css'
// ... dynamic component mounting ...
```

### Testing routed UI (navigation, layouts)

A spec that exercises navigation opens a **path** on the harness origin instead of a `?component=` query, and `mount.tsx` builds a real context with real entrypoints — the OwlMeans router drives the History API, so nothing about the routing may be faked. Two shapes the harness must get right, because a spec that trips them fails obscurely:

- **Leave the context un-initialized** (`ready` false). The Router compiles the entrypoint tree into routes only while the context is un-initialized; a pre-readied context renders a blank page.
- **Give every entrypoint that has children one child declared `default: true`**, or the parent's own path renders blank.

Spread the framework's own `entrypoints` (exported by the panel package) into the harness list: the panel context registers the api-config middleware, which resolves one of them during init and throws before any route is compiled if they are missing.

Shadcn components are plain React — no theme provider needed. Assert via `getByRole` / text as usual. To verify that Tailwind classes took visual effect, read computed styles:

```ts
const bg = await page.locator('button').evaluate(el =>
  window.getComputedStyle(el).backgroundColor
)
expect(bg).not.toBe('')
```

See `[[shadcn-web]]` for the full `@` alias contract and `tests/context.ts` pattern.

## Rules

- **No mocks.** Render the real component with real client-context wiring (state, i18n, router) the way the app does. For network calls, use Playwright's `page.route(...)` to a static fixture — never point at a live backend.
- **Cover SKILL.md and README.md cases first.** Each component the package documents gets at least one acceptance spec for its happy path.
- **Max 3-4 tests per component**: render, primary interaction, one edge case.
- **Always pass a timeout as `test`'s third argument.** 30s for a mounted component, 60s for a
  suite that drives a login or a consent gate. Bun's 5s default is for in-process work, and
  `bunfig.toml`'s `[test] timeout` is not a way to change it.
- **Always `close()` the page and `browserHelper.closeBrowser()` in `afterAll`.** A leaked context blocks the bun process from exiting.
- **A phone context needs the page's viewport meta.** `newContext({ isMobile: true, hasTouch: true,
  viewport: { width: 375, … } })` lays a page without `<meta name="viewport" content="width=device-width,
  initial-scale=1">` out at 980px and zooms it, so no `max-md:` rule and no `matchMedia('(min-width:
  768px)')` branch ever sees 375. The harness `index.html` carries the meta; `isMobile` + `hasTouch`
  also make `(pointer: coarse)` match.
- **Focus comes back a tick after a Radix surface closes.** Its focus scope restores focus in a
  timeout after unmount — wait for it (`page.waitForFunction(() => document.activeElement …)`), never
  assert it right after `waitFor({ state: 'detached' })`.
- **Chromium only by default.** Add `firefox` or `webkit` per package only when the feature has documented cross-browser concerns — call `chromium.launch` / `firefox.launch` explicitly in that case.

## `mountComponent` waits for `domcontentloaded`, not `load`

Playwright's own default is `load`, and it is wrong for any page that is a real application:
`load` waits for EVERY subresource, so one analytics beacon, long-poll or third-party pixel that
never settles holds the navigation open until it times out — with the page fully rendered and
working the whole time. The failure reads as "the site is down", and the first instinct is to go
looking at the server.

`mountComponent` therefore navigates with `domcontentloaded` and lets the spec wait for the
selector it actually needs. That wait IS the assertion; the load event never was. Pass
`waitUntil` explicitly for the rare case that wants otherwise.

The rule is not `mountComponent`'s alone — **every** navigation helper here follows it, including
`makePageHelper(page).loginViaSupervisorForm`, `.loginViaEmailForm` and `.loginViaDispatcher`. A helper that navigates on playwright's default
turns "someone added a tag manager" into "the whole login-driven suite times out", with the browser
showing a working login form the entire time. Any new helper that calls `page.goto` passes
`domcontentloaded` and takes a `waitUntil` override.

`makePageHelper(page).saveScreenshot(dir, name)` is the fastest way to see what the browser actually had on
screen when an assertion timed out; `.loginViaSupervisorForm` takes a `screenshotDir` that captures
the filled form just before submit.

## An unanswered consent gates the login form, and the failure blames the button

An OwlMeans app asks for cookie consent **before** it will start an authentication flow. The first
ask is the bar, which blocks nothing — the page is usable and the bar simply stays — so a spec that
never answers it clicks a login control and meets the gate instead: the sign-in precondition
(`@owlmeans/client-iam`) refuses the click and raises the preferences WINDOW, a modal over a
dimmed overlay that offers no dismissal. From then on the overlay intercepts pointer events, so a
login form renders, resolves, reports itself `visible, enabled and stable`, and still cannot be
clicked. Playwright retries for the full timeout and then reports `click: Timeout … waiting for
getByTestId('supervisor-submit')`, naming the button. Nothing is wrong with the button; read the
`subtree intercepts pointer events` line, which names `[data-consent-dialog]`. (A bar that is still
up is not in the way of anything — and a window that was not asked for is a sign the spec skipped
the answer.)

`makePageHelper(page).loginViaSupervisorForm` and `.loginViaEmailForm` therefore call `.acceptConsent()` after navigating. `.acceptConsent` is
public for specs that drive their own login: it waits for the consent store to SETTLE — never while
the visitor is still being located, when the transparent overlay is up and would take the click —
then clicks `[data-consent-accept-all]` on whichever surface asks, waits for it to detach, and
reports whether it answered one. It accepts **all** categories deliberately — a spec asserting a
narrower decision must make that decision itself rather than inherit a silent minimum.

**Where the app asks depends on where the runner is.** With the geo gate on, a Cloudflare-proxied
app asks only visitors located in a consent country — and the trace answers with the RUNNER's
country. A spec whose assertions need the surface pins it: `mountComponent({ url, consentGeo: 'PL' })`
or `consentGeoTestHelper.mockConsentGeo(context, 'PL')` before the navigation; a spec about the
automatic decision pins `'US'`. Never `page.route` for it — interception disables the cache for
every request, and a vite-served application stalls on its hundreds of unbundled modules.

**A `false` is cheap when the app says so, and costs the full wait when it cannot.** An app on a
consent package that marks `<html data-consent>` settles at once on a stored or automatic
decision. One older than that marker — or one that ships no consent widget — only ever settles by
showing a dialog, so a page with none pays the timeout: 5s by `.acceptConsent`'s own default, but
`.loginViaSupervisorForm` passes its `timeout` straight through and that defaults to `60_000`.
Drive an app with no widget with `consent: 'ignore'`, which skips the call entirely; that is also
the switch a spec flips when it wants to answer the dialog itself.

## `makePageHelper(page).answerMarketingConsent` — cheap absence detection, unlike the cookie dialog

`makePageHelper(page).loginViaSupervisorForm` and `.loginViaDispatcher` both call `.answerMarketingConsent({ accept:
'all', timeout })` right after they confirm the app has navigated away from login/dispatch, passing
their **own** `timeout` through explicitly rather than relying on this helper's internal default —
both of them already budget more than one round trip (login + terms + items) into the value they
pick. Both also default `marketingConsent` (their own option, not `.answerMarketingConsent`'s) to
`'save'` — pass `'ignore'` to skip the call in a spec that drives the step itself.
`@owlmeans/web-marketing-consent` renders a full-page step, when shown, with `[data-marketing-consent]`
(root, carrying `data-state="loading"` while its status read is outstanding and `"ready"` once it can
render), `[data-marketing-consent-terms]` (the Terms checkbox, Terms mode only, with `data-version`),
`[data-marketing-consent-terms-error]` (Terms record failed — the person stays and retries),
`[data-marketing-consent-all]` (select-all — exactly one per page; the step's closing copy above the
buttons is `[data-marketing-consent-all-end]` — and in Terms mode it ticks the Terms box with the
consents, in required-only mode only the Terms box), `[data-marketing-consent-item="<key>"]`
(per-consent), `[data-marketing-consent-save]`, `[data-marketing-consent-skip]` (shown whenever the
step is optional-only — i.e. `!loading && !terms.needed` — not only after a failed save),
`[data-marketing-consent-skip-note]`, `[data-marketing-consent-signout]` (shown while a Terms box or
the loading state is up) and `[data-marketing-consent-error]`.

Unlike `makePageHelper(page).acceptConsent`, whose `false` return deliberately costs the full wait (see above),
`.answerMarketingConsent` does NOT pay the full `timeout` (default `30_000`) when the step is absent.
The screen is opt-in per app and most applications and environments don't have it wired in yet, and this helper
is called unconditionally by both login helpers — a full-timeout tax on every login, on every app,
whether or not the screen exists, would be an unacceptable regression to every existing suite. It
instead races `[data-marketing-consent]` against the generic "the app has already landed" /
"still on the login screen" markers the login helpers themselves already rely on (`#app-prompt`,
`[data-login-method]`) via the same `locator('a, b, c').first().waitFor({ state: 'visible' })` idiom
`.loginViaSupervisorForm` uses for its own dialog-vs-form race. By the time a login helper calls this,
one of those markers has typically already rendered, so on an app without the screen the race
resolves as soon as it does — no fixed sleep, and no meaningful added latency over what the login
helper already paid to get there.

Once the step's root is present, it may still be `data-state="loading"` (its own status read is
outstanding) — the helper races that attribute clearing against the whole root detaching on its own
(nothing was pending, so it auto-continued while this waited), via two `page.waitForSelector` calls
rather than an in-page `waitForFunction`/`evaluate` (this package's `tsconfig` has no `lib: dom`, so
no TS runs inside the browser context here). An older `web-marketing-consent` that predates
`data-state` entirely satisfies the "not loading" selector immediately, so this costs nothing there.

When a Terms box is present, `opts.terms` (default `'accept'`) ticks it before saving; `'leave'`
keeps it unticked, for a spec that means to exercise the blocked state itself — the confirm click
still fires (with `{ force: true }`, since the control is never natively `disabled`), and the helper
then *expects* the box to still be up afterward. `opts.accept` (default `'all'`) additionally clicks
select-all when present, `'none'` saves with every item unchecked, and `'skip'` clicks
`[data-marketing-consent-skip]` instead of saving — valid only when no Terms box is on screen.

Returns `false` when the step never appeared. Otherwise it **throws** in two cases rather than
silently swallowing them: a `[data-marketing-consent-terms-error]` after attempting to confirm
Terms, and a Terms box still on screen after a failed/blocked confirm (Skip is never offered there
on purpose, so there is no fallback and no honest way to report success). Short of those, it returns
`true` whether the save succeeded outright or fell back to clicking
`[data-marketing-consent-skip]` after a save error on an optional-only screen (logged as a console
warning, never thrown) — the step is "answered" either way, so a spec is never permanently blocked
behind a flaky save.

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in development →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.