Open-source platform for 3D AI agents. Turn text or a photo into a rigged, animated GLB avatar, give it an LLM brain, memory and a wallet, and embed it anywhere with one web component. Remote MCP server, x402 payments, Three.js, browser-native.
JavaScript 3d-generationai-agentsanimationavatardigital-humangenerative-aiglbgltfimage-to-3dllmmcpmcp-servermodel-context-protocolsolanatext-to-3dthreejsweb-componentswebglwebxrx402
test(hood-desk): pin the desk's panels, ladder collapse and trade ticket in the browser
nirholasb7cb2d5344a3
diff --git a/STRUCTURE.md b/STRUCTURE.mdindex a2cba7800..3496c5adf 100644--- a/STRUCTURE.md+++ b/STRUCTURE.md@@ -244,7 +244,7 @@ bottom.| Market surfaces III (protocol/chain/stablecoin detail + fees, DEX volumes, hacks, trending) | Detail pages `→ /protocol/:slug /chain/:name /stablecoin/:id` over [api/defi/protocol.js](api/defi/protocol.js), [api/defi/chain.js](api/defi/chain.js), [api/defi/stablecoin.js](api/defi/stablecoin.js); surfaces `→ /fees /dex-volumes /hacks` over [api/defi/](api/defi) (fees, dex-volumes, hacks over DeFiLlama) + `→ /markets/trending` over [api/coin/trending.js](api/coin/trending.js) (CoinGecko /search/trending); list rows in [src/defi.js](src/defi.js), [src/chains.js](src/chains.js), [src/stablecoins.js](src/stablecoins.js) now deep-link into the detail pages | In-repo | Turns the DeFiLlama list pages into full detail experiences: a protocol page (TVL history + hallmark markers, per-chain breakdown, fees/revenue, funding rounds, methodology), a chain page (TVL + stablecoin + DEX-volume charts, top protocols), a stablecoin page (supply history, per-chain distribution, peg-deviation badge). Plus three new market surfaces — protocol fees & revenue, the DEX-volume leaderboard, and a searchable DeFi hacks database ($16.7B all-time) — and a CoinGecko trending page (most-searched coins/categories/NFTs). All real key-free data, cross-linked. Docs: [docs/coin-pages.md](docs/coin-pages.md) || Market detail pages (exchange, category) + DeFi yields | [pages/exchange.html](pages/exchange.html) + [src/exchange-page.js](src/exchange-page.js) `→ /exchange/:id` over [api/coin/exchange.js](api/coin/exchange.js), [pages/category.html](pages/category.html) + [src/category-page.js](src/category-page.js) `→ /category/:id` over [api/coin/category.js](api/coin/category.js) + [api/coin/markets.js](api/coin/markets.js) (`?category=`), [pages/yields.html](pages/yields.html) + [src/yields.js](src/yields.js) `→ /yields` over [api/defi/yields.js](api/defi/yields.js) | In-repo | Rich detail pages that turn list rows into full profiles. Exchange: trust badge, normalized-volume stat, BTC-volume history chart, and a per-pair markets table (spot + derivatives fallback), reached from `/exchanges` and the new Derivatives Exchanges table. Category: rank, sector stats, the full sortable coins table for that sector, and related categories, reached from `/categories`. Yields: an explorer over ~15k live DeFiLlama pools with chain/project/stablecoin/min-TVL filters, APY/TVL sort, URL-synced state, and a per-pool APY+TVL history chart on row expand. Docs: [docs/coin-pages.md](docs/coin-pages.md) || Crypto news + archive + markets hub | [pages/markets.html](pages/markets.html) + [src/markets-page.js](src/markets-page.js) `→ /markets`, [pages/markets-news.html](pages/markets-news.html) + [src/markets-news.js](src/markets-news.js) `→ /markets/news`, [pages/news-article.html](pages/news-article.html) + [src/news-article.js](src/news-article.js) `→ /markets/news/article`, [pages/news-archive.html](pages/news-archive.html) + [src/news-archive.js](src/news-archive.js) `→ /markets/archive`, [pages/news-digest.html](pages/news-digest.html) + [src/news-digest.js](src/news-digest.js) `→ /markets/digest`; backend [api/news/](api/news) (feed, article, knowledge, archive, digest, rss, image) over [api/_lib/article-extract.js](api/_lib/article-extract.js) (page→reader→feed→preview ladder) and [api/_lib/news-rights.js](api/_lib/news-rights.js) (publisher rights layer, enforced at every read path), [api/_lib/news-coins.js](api/_lib/news-coins.js) (ticker→live market snapshot), [api/_lib/news-knowledge-store.js](api/_lib/news-knowledge-store.js) (durable `news_knowledge` corpus) + hourly archiver [api/cron/news-archive-append.js](api/cron/news-archive-append.js) over [api/_lib/news.js](api/_lib/news.js) + [api/_lib/news-sources.js](api/_lib/news-sources.js), corpus on `gs://three-ws-news-archive`, purge tooling [scripts/news-takedown-purge.mjs](scripts/news-takedown-purge.mjs) | In-repo | The Markets news wing + front door: /markets/news is “Your briefing”: live news aggregated natively from 197 publisher feeds (Featured/Trending/Saved tabs, breaking ticker, AI briefing card, top-stories hero + rail, search, sentiment, ticker chips, og:image preview resolution for imageless feeds), a rich article reader that shows a bounded lead excerpt plus our own summary/key points/entities/market context and sends the reader to the publisher for the rest (the excerpt cap and any rightsholder takedowns are enforced server-side across the reader, RSS mirror, archive search, and agent knowledge corpus, never just hidden client-side), and renders **live coin cards** (price/24h/7d/sparkline→/coin/:id) for detected tickers, and related coverage. Every read story is recorded to a durable **news knowledge base** (`GET /api/news/knowledge`) that grounds the 3D agents, itself subject to the same excerpt limit. Plus the largest open crypto-news archive (662,047 enriched articles, Sept 2017 → today, EN+中文, GCS-hosted) and the /markets hub aggregating global stats, the top-100 table, breaking news, and every market surface as a hero card. Docs: [docs/coin-pages.md](docs/coin-pages.md), [docs/api-reference.md](docs/api-reference.md), [docs/news-rights.md](docs/news-rights.md) (publisher takedown path) |-| Robinhood Chain markets + buy flow | Hub + detail pages [pages/markets-robinhood.html](pages/markets-robinhood.html) + [src/markets-robinhood.js](src/markets-robinhood.js) `→ /markets/robinhood`, [pages/robinhood-stock.html](pages/robinhood-stock.html) + [src/robinhood-stock.js](src/robinhood-stock.js) `→ /markets/robinhood/stock/:symbol`, [pages/robinhood-coin.html](pages/robinhood-coin.html) + [src/robinhood-coin.js](src/robinhood-coin.js) `→ /markets/robinhood/coin/:address`, buy flow [src/robinhood-purchase.js](src/robinhood-purchase.js), wallet desk [pages/hood-desk.html](pages/hood-desk.html) + [src/hood-desk.js](src/hood-desk.js) + [src/hood-desk.css](src/hood-desk.css) `→ /markets/robinhood/desk`; backend [api/_lib/robinhood.js](api/_lib/robinhood.js) + `api/v1/robinhood/{chain,stocks,stocks-detail,coins,coins-detail,launches,desk,wallet}.js` (free, the last two composed for the desk over [api/_lib/robinhood-desk.js](api/_lib/robinhood-desk.js)) + [api/x402/robinhood-portfolio.js](api/x402/robinhood-portfolio.js) (x402 paid) | In-repo | The 24/7 tokenized-equity board for Robinhood Chain (4663): live Chainlink NAV vs. Uniswap DEX premium for every Stock Token (one multicall, never 95 RPC calls), a memecoin screener across NOXA/The Odyssey launchpads (CoinGecko categories + on-chain launch logs via Blockscout), and chain TVL/gas/block stats. Detail pages add NAV history, holders, transfers, and contract links. Coin pages carry a real buy panel: injected-wallet connect, chain-switch to 4663, live Uniswap v3 `QuoterV2` quote + `SwapRouter02` swap with slippage, LI.FI bridge deep-link; Stock Tokens are display-only (tokenized securities, not offered to US persons) with an eligibility-gated outbound DEX link instead. Paid `portfolio` endpoint returns ERC-8056 `uiMultiplier`-correct holdings. The Hood Desk (`/markets/robinhood/desk`) is the wallet-first view of the same chain: paste or connect any address and it loads that wallet's book (native + priced ERC-20 positions), its native balance curve rebuilt from Blockscout's daily and per-transaction feeds (the public RPC is not an archive node), an activity tape that folds token transfers onto the transaction that emitted them, the NAV premium ridge layered by liquidity floor, counterparty flow, and memecoin movers. Read-only and signature-free; the trade ticket reuses the coin pages' swap panel and the Stock Token eligibility gate. Tests: [tests/robinhood-desk.test.js](tests/robinhood-desk.test.js). Docs: [docs/robinhood-chain-markets.md](docs/robinhood-chain-markets.md) |+| Robinhood Chain markets + buy flow | Hub + detail pages [pages/markets-robinhood.html](pages/markets-robinhood.html) + [src/markets-robinhood.js](src/markets-robinhood.js) `→ /markets/robinhood`, [pages/robinhood-stock.html](pages/robinhood-stock.html) + [src/robinhood-stock.js](src/robinhood-stock.js) `→ /markets/robinhood/stock/:symbol`, [pages/robinhood-coin.html](pages/robinhood-coin.html) + [src/robinhood-coin.js](src/robinhood-coin.js) `→ /markets/robinhood/coin/:address`, buy flow [src/robinhood-purchase.js](src/robinhood-purchase.js), wallet desk [pages/hood-desk.html](pages/hood-desk.html) + [src/hood-desk.js](src/hood-desk.js) + [src/hood-desk.css](src/hood-desk.css) `→ /markets/robinhood/desk`; backend [api/_lib/robinhood.js](api/_lib/robinhood.js) + `api/v1/robinhood/{chain,stocks,stocks-detail,coins,coins-detail,launches,desk,wallet}.js` (free, the last two composed for the desk over [api/_lib/robinhood-desk.js](api/_lib/robinhood-desk.js)) + [api/x402/robinhood-portfolio.js](api/x402/robinhood-portfolio.js) (x402 paid) | In-repo | The 24/7 tokenized-equity board for Robinhood Chain (4663): live Chainlink NAV vs. Uniswap DEX premium for every Stock Token (one multicall, never 95 RPC calls), a memecoin screener across NOXA/The Odyssey launchpads (CoinGecko categories + on-chain launch logs via Blockscout), and chain TVL/gas/block stats. Detail pages add NAV history, holders, transfers, and contract links. Coin pages carry a real buy panel: injected-wallet connect, chain-switch to 4663, live Uniswap v3 `QuoterV2` quote + `SwapRouter02` swap with slippage, LI.FI bridge deep-link; Stock Tokens are display-only (tokenized securities, not offered to US persons) with an eligibility-gated outbound DEX link instead. Paid `portfolio` endpoint returns ERC-8056 `uiMultiplier`-correct holdings. The Hood Desk (`/markets/robinhood/desk`) is the wallet-first view of the same chain: paste or connect any address and it loads that wallet's book (native + priced ERC-20 positions), its native balance curve rebuilt from Blockscout's daily and per-transaction feeds (the public RPC is not an archive node), an activity tape that folds token transfers onto the transaction that emitted them, the NAV premium ridge layered by liquidity floor, counterparty flow, and memecoin movers. Read-only and signature-free; the trade ticket reuses the coin pages' swap panel and the Stock Token eligibility gate. Tests: [tests/robinhood-desk.test.js](tests/robinhood-desk.test.js) (the derivations) and [tests/e2e/hood-desk.spec.js](tests/e2e/hood-desk.spec.js) (the panels, the empty states, the ladder collapse and the trade ticket). Docs: [docs/robinhood-chain-markets.md](docs/robinhood-chain-markets.md) || Robinhood Portfolios (generated index portfolios) | Generator [pages/hood-portfolios.html](pages/hood-portfolios.html) + [src/hood-portfolios.js](src/hood-portfolios.js) + [src/hood-portfolios.css](src/hood-portfolios.css) `→ /markets/robinhood/portfolios`, universe board [pages/hood-portfolios-universe.html](pages/hood-portfolios-universe.html) + [src/hood-portfolios-universe.js](src/hood-portfolios-universe.js) `→ /markets/robinhood/portfolios/universe`; backend [api/_lib/hood-portfolios.js](api/_lib/hood-portfolios.js) + `api/v1/hood-portfolios/{universe,generate,health}.js` (free, keyless); universe snapshot [data/hood-portfolios-universe.json](data/hood-portfolios-universe.json) built by [scripts/build-hood-portfolios-universe.mjs](scripts/build-hood-portfolios-universe.mjs) (`npm run hood:universe`); contracts [contracts/hood-portfolios/](contracts/hood-portfolios) | In-repo · contracts code-complete and fork-proven against live chain 4663, mainnet deploy owner-gated | Describe a portfolio in a sentence and get a real basket of Robinhood Chain assets. The screen ranks the whole holdable universe (727 assets: 167 tokenized equities, majors, and the chain-native long tail) through the platform free-first LLM chain, and every token it returns is validated back against that universe before it is shown. The result is committed as an immutable content-addressed manifest (`PortfolioRegistry`), held in kind by an ERC-20 share vault (`Portfolio`) whose backing is derived from balances rather than tracked, and rebalanced to published targets by a descending-price auction any address can fill: there is no function that lets a manager trade the fund. Needs no price oracle on any code path, which is what makes it work on a chain where only 34 of 95 registry equities have a Chainlink feed. Halt-aware: a paused tokenized equity stops issuance, redemption and rebalancing, and the UI says so. Ticker impersonation is resolved by contract address at build time (12 contracts on this chain call themselves USDG), so an impostor can never be selected. 38 offline tests incl. fuzz + 4 stateful invariants, plus 5 against a fork of live chain 4663. Docs: [docs/robinhood-portfolios.md](docs/robinhood-portfolios.md), [contracts/hood-portfolios/README.md](contracts/hood-portfolios/README.md) || Premium Data API pass | [api/premium/](api/premium) + [api/_lib/premium.js](api/_lib/premium.js), dashboards [src/dashboard-next/pages/data-api.js](src/dashboard-next/pages/data-api.js) `→ /dashboard/data-api` + [src/dashboard-next/pages/billing.js](src/dashboard-next/pages/billing.js) `→ /dashboard/billing` | In-repo | Monthly pass in three tiers (Developer $19.99, Pro $99, Enterprise $499 per 30d, tiered rate limits) paid on Solana in $THREE (20% off), SOL, or USDC — replaces per-call x402 on the news archive with an `x402_live_` API key (existing access-control lane) + SIWX browser grants. Quote→sign→verify flow with on-chain balance-delta verification; tables `premium_passes`/`premium_quotes`. Docs: [docs/premium.md](docs/premium.md) || Liquidations pulse (/coins) | Collector [services/liquidation-collector/](services/liquidation-collector) (standalone always-on Node service, ported from SperaxOS), proxy [api/coin/liquidations.js](api/coin/liquidations.js) `→ GET /api/coin/liquidations`, UI strip in [src/coins-index.js](src/coins-index.js) `→ /coins` | Live — collector on Cloud Run (`liquidation-collector`, min-instances 1, unthrottled CPU) since 2026-07-10 | Real-time long/short liquidation pain across Binance, Bybit, and OKX public futures WebSocket streams: dominant-side badge (LONG PAIN / SHORT SQUEEZE / BALANCED), 1h long-vs-short bars, and the 3 largest recent liquidations, polled every 30s (pauses on hidden tab). The collector holds long-lived WebSockets so it can't run as a Vercel function — deploy it separately and point `LIQUIDATION_COLLECTOR_URL` at it. No fallback data: the proxy 503s `collector_offline` (never fabricated numbers) when unset or unreachable, and the strip degrades to a quiet single-line offline state. Docs: [docs/api-reference.md#liquidations](docs/api-reference.md#liquidations) |diff --git a/tests/e2e/hood-desk.spec.js b/tests/e2e/hood-desk.spec.jsnew file mode 100644index 000000000..763062aa8--- /dev/null+++ b/tests/e2e/hood-desk.spec.js@@ -0,0 +1,361 @@+// /markets/robinhood/desk - the Hood Desk.+//+// The desk composes two reads (/api/v1/robinhood/desk for the market side,+// /api/v1/robinhood/wallet for a book) and renders seven panels off them. Both+// are stubbed here with payloads shaped exactly like the live responses,+// because the assertions are about what the page DOES with a payload, and a+// spec that depended on one live wallet's balances would fail every time that+// wallet traded. The upstream shapes themselves are pinned separately by+// tests/robinhood-desk.test.js against the real field names.+//+// What this locks down, all of it found by hand first:+// • every panel has a designed empty state before a wallet is loaded, with a+// way forward, not a blank card+// • a bad address is refused with a readable message instead of a dead form+// • an unpriced token is shown as unpriced and never counted into the book+// • a dusted wallet's 200-token ladder collapses to the deepest twelve, and+// the count never lies about what is there+// • the trade ticket opens the swap panel for a coin and the eligibility+// gate (never a swap) for a Stock Token++import { test, expect } from '@playwright/test';+import { collectPageErrors, installEvmWallet } from './_support.js';++const LOAD = { waitUntil: 'domcontentloaded', timeout: 120_000 };+const ADDRESS = '0x1111111111111111111111111111111111111111';+const COIN = '0xaaaa000000000000000000000000000000000001';+const STOCK = '0xbbbb000000000000000000000000000000000002';++const BINS = 9;+const bins = Array.from({ length: BINS }, (_, i) => {+ const from = -2 + i * (4 / BINS);+ return { from, to: from + 4 / BINS, center: from + 2 / BINS };+});++function deskPayload() {+ return {+ data: {+ chain: {+ name: 'Robinhood Chain',+ chainId: 4663,+ blockHeight: 57_138_464,+ averageBlockTimeMs: 101,+ totalTransactions: '643348295',+ gas: { slow: 0.27, average: 0.32, fast: 0.64, unit: 'gwei' },+ ethPriceUsd: 2494.79,+ tvlUsd: 908_173_602,+ explorer: 'https://robinhoodchain.blockscout.com',+ },+ ridge: {+ bins,+ layers: Array.from({ length: 4 }, (_, layer) => ({+ minLiquidityUsd: layer * 250_000,+ count: 8 - layer * 2,+ density: bins.map((_, i) => (i === 4 || i === 5 ? 4 - layer : i === 6 ? 1 : 0)),+ })),+ symbols: bins.map((_, i) => (i === 4 ? ['MU', 'AMD'] : [])),+ stats: { priced: 8, total: 95, min: -0.33, max: 1.7, median: 0.69, p10: 0.12, p90: 1.6, spanPct: 2 },+ },+ arb: [+ {+ symbol: 'MU',+ name: 'Micron Technology',+ address: STOCK,+ premiumPct: 1.7,+ navPriceUsd: 1014.79,+ dexPriceUsd: 1032.05,+ liquidityUsd: 1_632_162,+ volume24hUsd: 1_381_494,+ side: 'dex-rich',+ },+ ],+ movers: [+ {+ id: 'test-mover',+ symbol: 'MOVER',+ name: 'Mover',+ image: null,+ priceUsd: 0.004138,+ marketCapUsd: 4_096_877,+ volume24hUsd: 4_124_066,+ change24hPct: 303.74,+ sparkline7d: [0.001, 0.002, 0.0015, 0.004],+ },+ ],+ launches: [],+ stockCount: 95,+ disclosure: 'Stock Tokens are tokenized debt securities.',+ source: 'test',+ asOf: new Date().toISOString(),+ },+ };+}++// 14 positions: two that carry the book, one deliberately unpriced, and eleven+// dust rows so the ladder has something to collapse.+function positions() {+ const rows = [+ {+ address: COIN,+ symbol: 'MEME',+ name: 'Meme',+ icon: null,+ decimals: 18,+ rawBalance: '5000000000000000000',+ amount: 5,+ kind: 'coin',+ priceUsd: 2,+ priceSource: 'dex',+ navPriceUsd: null,+ dexPriceUsd: 2,+ change24hPct: 78.55,+ liquidityUsd: 86_804,+ valueUsd: 10,+ pairUrl: 'https://dexscreener.com/robinhood/0xpair',+ holders: 306_239,+ sharePct: 25,+ },+ {+ address: STOCK,+ symbol: 'MU',+ name: 'Micron Technology',+ icon: null,+ decimals: 18,+ rawBalance: '1000000000000000000',+ amount: 1,+ kind: 'stock',+ priceUsd: 1014.79,+ priceSource: 'chainlink-nav',+ navPriceUsd: 1014.79,+ dexPriceUsd: 1032.05,+ change24hPct: -1.2,+ liquidityUsd: 1_632_162,+ valueUsd: 1014.79,+ pairUrl: null,+ holders: 12,+ sharePct: 70,+ },+ {+ address: '0xcccc000000000000000000000000000000000003',+ symbol: 'NOPRICE',+ name: 'No pool yet',+ icon: null,+ decimals: 18,+ rawBalance: '908330000000000000000000',+ amount: 908_330,+ kind: 'coin',+ priceUsd: null,+ priceSource: null,+ navPriceUsd: null,+ dexPriceUsd: null,+ change24hPct: null,+ liquidityUsd: null,+ valueUsd: null,+ pairUrl: null,+ holders: 3,+ sharePct: null,+ },+ ];+ for (let i = 0; i < 11; i++) {+ rows.push({+ address: `0xdddd00000000000000000000000000000000${String(i).padStart(4, '0')}`,+ symbol: `DUST${i}`,+ name: `Dust ${i}`,+ icon: null,+ decimals: 18,+ rawBalance: '1000000000000000000',+ amount: 1,+ kind: 'coin',+ priceUsd: 0.0001,+ priceSource: 'dex',+ navPriceUsd: null,+ dexPriceUsd: 0.0001,+ change24hPct: 0.5,+ liquidityUsd: 10,+ valueUsd: 0.0001,+ pairUrl: null,+ holders: 2,+ sharePct: 0.00001,+ });+ }+ return rows;+}++function walletPayload(address = ADDRESS) {+ const now = Date.now();+ const series = Array.from({ length: 6 }, (_, i) => ({+ t: now - (5 - i) * 600_000,+ eth: 0.05 + i * 0.01,+ usd: (0.05 + i * 0.01) * 2494.79,+ block: 57_138_000 + i,+ }));+ return {+ data: {+ address,+ native: { symbol: 'ETH', balance: 0.1, balanceWei: '100000000000000000', valueUsd: 249.47 },+ book: {+ // native + MEME + MU. The unpriced token is deliberately absent from+ // the total; the desk must not invent a value for it.+ valueUsd: 249.47 + 10 + 1014.79,+ nativeUsd: 249.47,+ tokensUsd: 1024.79,+ nativeSharePct: 19.6,+ positionCount: 220,+ pricedCount: 13,+ },+ positions: positions(),+ positionsTruncated: true,+ history: {+ series,+ intraday: series,+ daily: [],+ change: { startEth: 0.05, endEth: 0.1, deltaEth: 0.05, pct: 100, fromT: series[0].t, toT: series[5].t },+ sessionChange: { startEth: 0.05, endEth: 0.1, deltaEth: 0.05, pct: 100, fromT: series[0].t, toT: series[5].t },+ usdBasis: { ethPriceUsd: 2494.79, mode: 'current-price' },+ },+ activity: [+ {+ hash: '0xswap',+ timestamp: new Date(now - 60_000).toISOString(),+ kind: 'swap',+ method: 'swapExactETHForTokens',+ direction: 'out',+ counterparty: '0x2222222222222222222222222222222222222222',+ counterpartyName: null,+ valueEth: 0.05,+ feeEth: 0.00002,+ status: 'ok',+ block: 57_138_005,+ tokens: [{ symbol: 'MEME', address: COIN, amount: 27, direction: 'in' }],+ },+ {+ hash: '0xrecv',+ timestamp: new Date(now - 900_000).toISOString(),+ kind: 'receive',+ method: 'transfer',+ direction: 'in',+ counterparty: '0x3333333333333333333333333333333333333333',+ counterpartyName: null,+ valueEth: 0.02,+ feeEth: null,+ status: 'ok',+ block: 57_138_001,+ tokens: [],+ },+ ],+ counterparties: [+ { address: '0x2222222222222222222222222222222222222222', name: null, inCount: 0, outCount: 12, kinds: { swap: 12 }, total: 12 },+ { address: '0x3333333333333333333333333333333333333333', name: null, inCount: 3, outCount: 0, kinds: { receive: 3 }, total: 3 },+ ],+ ethPriceUsd: 2494.79,+ source: 'test',+ asOf: new Date().toISOString(),+ },+ };+}++async function stubDesk(page, { wallet = true } = {}) {+ await page.route('**/api/v1/robinhood/desk*', (route) =>+ route.fulfill({ contentType: 'application/json', body: JSON.stringify(deskPayload()) }),+ );+ if (!wallet) return;+ await page.route('**/api/v1/robinhood/wallet*', (route) => {+ const address = new URL(route.request().url()).searchParams.get('address') || ADDRESS;+ return route.fulfill({ contentType: 'application/json', body: JSON.stringify(walletPayload(address)) });+ });+}++test('every panel is designed before a wallet is loaded, and the market side still renders', async ({ page }) => {+ const errors = collectPageErrors(page);+ await stubDesk(page);+ await page.goto('/markets/robinhood/desk', LOAD);++ // Wallet panels: a heading, guidance, and a way forward. Never a blank card.+ for (const id of ['#hd-balance', '#hd-tape-card', '#hd-book', '#hd-flow']) {+ const empty = page.locator(`${id} .hd-empty`);+ await expect(empty).toBeVisible();+ await expect(empty.locator('strong')).not.toBeEmpty();+ await expect(empty.locator('[data-action="focus-address"]')).toBeVisible();+ }++ // Market panels do not need a wallet, so they carry data immediately.+ await expect(page.locator('#hd-ridge .hd-ridge-svg')).toBeVisible();+ await expect(page.locator('#hd-movers .hd-mover')).toHaveCount(1);+ await expect(page.locator('#hd-stats .hd-stat')).toHaveCount(4);+ await expect(page.locator('#hd-stats')).toContainText('Chain TVL');++ // The empty-state action reaches the one control that unblocks the page.+ await page.locator('#hd-balance [data-action="focus-address"]').click();+ await expect(page.locator('#hd-address')).toBeFocused();+ expect(errors).toEqual([]);+});++test('a bad address is refused in words, a real one loads the whole book', async ({ page }) => {+ const errors = collectPageErrors(page);+ await stubDesk(page);+ await page.goto('/markets/robinhood/desk', LOAD);++ await page.fill('#hd-address', 'not-an-address');+ await page.click('#hd-wallet-form button[type=submit]');+ await expect(page.locator('#hd-alert')).toContainText('Robinhood Chain address');+ await expect(page.locator('#hd-book .hd-empty')).toBeVisible();++ await page.fill('#hd-address', ADDRESS);+ await page.click('#hd-wallet-form button[type=submit]');++ await expect(page.locator('#hd-brand-sub')).toContainText('0x1111');+ expect(new URL(page.url()).searchParams.get('address')).toBe(ADDRESS);+ await expect(page.locator('#hd-stats')).toContainText('Book value');+ await expect(page.locator('#hd-balance svg.hd-chart')).toBeVisible();+ await expect(page.locator('#hd-tape .hd-tape-row')).toHaveCount(2);+ await expect(page.locator('#hd-tape .hd-kind.swap')).toBeVisible();+ await expect(page.locator('#hd-flow .hd-flow-arc')).toHaveCount(2);+ expect(errors).toEqual([]);+});++test('an unpriced token stays unpriced, and the ladder collapses without lying about the count', async ({ page }) => {+ await stubDesk(page);+ await page.goto(`/markets/robinhood/desk?address=${ADDRESS}`, LOAD);++ // 220 held, 100 returned, 12 rendered: each number appears where it belongs.+ await expect(page.locator('#hd-book .hd-card-meta')).toContainText('220 positions');+ await expect(page.locator('#hd-book tbody tr')).toHaveCount(12);+ const expander = page.locator('[data-action="expand-positions"]');+ await expect(expander).toContainText('Show 2 smaller positions');+ await expander.click();+ await expect(page.locator('#hd-book tbody tr')).toHaveCount(14);+ await expect(page.locator('#hd-book .hd-note')).toContainText('deepest 14 of 220');++ // The token with no pool is named as unpriced rather than valued at zero, and+ // the book total is native + the two priced positions only.+ const unpriced = page.locator('#hd-book tbody tr', { hasText: 'NOPRICE' });+ await expect(unpriced).toContainText('unpriced');+ await expect(page.locator('#hd-stats .hd-stat-value').first()).toHaveText('$1.27K');+});++test('the trade ticket swaps a coin and gates a Stock Token', async ({ page }) => {+ await stubDesk(page);+ await page.goto(`/markets/robinhood/desk?address=${ADDRESS}`, LOAD);++ await page.locator('#hd-book tbody tr', { hasText: 'MEME' }).getByRole('button', { name: 'Trade' }).click();+ await expect(page.locator('#hd-trade-title')).toHaveText('Trade MEME');+ await expect(page.locator('#hd-trade-body #rh-buy-amount')).toBeVisible();+ await page.click('#hd-trade-close');+ await expect(page.locator('#hd-trade-body #rh-buy-amount')).toBeHidden();++ // A Stock Token is a tokenized security: the desk shows the disclosure and an+ // outbound link, never an in-house swap.+ await page.locator('#hd-ridge tbody tr', { hasText: 'MU' }).getByRole('button', { name: 'Trade' }).click();+ await expect(page.locator('#hd-trade-body')).toContainText('may not be offered, sold, or delivered to US persons');+ await expect(page.locator('#hd-trade-body #rh-buy-amount')).toHaveCount(0);+});++test('connecting an injected wallet loads that address', async ({ page }) => {+ await installEvmWallet(page, { address: ADDRESS, chainIdHex: '0x1237' });+ await stubDesk(page);+ await page.goto('/markets/robinhood/desk', LOAD);++ await page.click('#hd-connect');+ await expect(page.locator('#hd-brand-sub')).toContainText('0x1111');+ await expect(page.locator('#hd-book tbody tr').first()).toBeVisible();+});