fix(ui): render Fair Draw's envelope card icon correctly
This commit is contained in:
1 parent
b6f5b93d6e
commit
6461b783b0
5 files changed
+330
-3
No files matched your search
+32
@@ -0,0 +1,32 @@
|
||||
{
|
||||
"task": "17. Fix Fair Draw's broken icon glyph",
|
||||
"qa": "failure/flow-unaffected",
|
||||
"description": "Confirms the icon-glyph swap did not regress the rest of the real Fair Draw commit-reveal flow: Start Draw -> Reveal -> Verified -> Winner, driven end-to-end on the real '/miniapp/fair-draw' route using its existing reveal-draw-* data-testid family.",
|
||||
"tool": "Playwright (chromium), real Vite dev server, real app UI ('/miniapp/fair-draw' -> RevealDraw)",
|
||||
"run_command": "node e2e/fairDrawEnvelopeIcon.e2e.mjs",
|
||||
"selectors_used": [
|
||||
"reveal-draw-commit-hash",
|
||||
"reveal-draw-revealed",
|
||||
"reveal-draw-badge",
|
||||
"reveal-draw-winner"
|
||||
],
|
||||
"timestamp": "2026-11-18T08:31:38.616Z",
|
||||
"result": {
|
||||
"scenario": "flow-unaffected",
|
||||
"steps": {
|
||||
"startDraw": {
|
||||
"commitHashText": "0d3a217235a6fae70cc1a92b7661552a38bf0ced7f11f90b554ee6846a5f01a3",
|
||||
"isHex64": true
|
||||
},
|
||||
"reveal": {
|
||||
"badgeState": "verified"
|
||||
},
|
||||
"winner": {
|
||||
"winnerText": "Winner: Resident D",
|
||||
"hasWinner": true
|
||||
}
|
||||
},
|
||||
"pass": true
|
||||
},
|
||||
"pass": true
|
||||
}
|
||||
@@ -0,0 +1,25 @@
|
||||
{
|
||||
"task": "17. Fix Fair Draw's broken icon glyph",
|
||||
"qa": "happy",
|
||||
"description": "On the real '/miniapp/fair-draw' route, the envelope reveal card's icon glyph is asserted via a real Playwright locator to be a visible inline <svg> element from the shared src/shell/icons.tsx set, rather than the previous raw emoji code point that rendered as a blank/tofu box - no screenshot or human judgment used.",
|
||||
"tool": "Playwright (chromium), real Vite dev server, real app UI ('/miniapp/fair-draw' -> RevealDraw envelope card)",
|
||||
"run_command": "node e2e/fairDrawEnvelopeIcon.e2e.mjs",
|
||||
"selectors_used": [
|
||||
"reveal-draw-envelope",
|
||||
"svg (inline-SVG icon element)"
|
||||
],
|
||||
"timestamp": "2026-11-18T08:31:38.616Z",
|
||||
"result": {
|
||||
"scenario": "happy",
|
||||
"steps": {
|
||||
"envelopeIconIsInlineSvg": {
|
||||
"tagName": "svg",
|
||||
"isVisible": true,
|
||||
"envelopeCardText": "Fair Draw\n\nCommit-reveal verifiable draw, provably not rigged.",
|
||||
"noLeftoverEmojiGlyph": true
|
||||
}
|
||||
},
|
||||
"pass": true
|
||||
},
|
||||
"pass": true
|
||||
}
|
||||
@@ -0,0 +1,265 @@
|
||||
// Fair Draw envelope card icon-glyph fix acceptance test (plan todo 17).
|
||||
// Self-contained Playwright runner, same shape as
|
||||
// e2e/fairDrawWalletCredit.e2e.mjs: starts a real Vite dev server, opens a
|
||||
// real browser page, and drives the real app UI through its real route -
|
||||
// no mocks of the draw/ledger/eventlog.
|
||||
//
|
||||
// HAPPY: on the real `/miniapp/fair-draw` route, the envelope reveal
|
||||
// card's icon glyph is asserted to be a real, visible inline <svg> element
|
||||
// (the shared `src/shell/icons.tsx` set) rather than a blank/tofu emoji
|
||||
// box - a Playwright locator assertion per the plan's acceptance
|
||||
// criteria, not a screenshot/human judgment.
|
||||
//
|
||||
// FAILURE/flow-unaffected: the rest of the real commit-reveal draw flow
|
||||
// (Start Draw -> Reveal -> Verified -> Winner) is run to completion on the
|
||||
// same route afterward, using its existing `reveal-draw-*` data-testid
|
||||
// family, to confirm the icon swap did not regress the draw itself.
|
||||
import { chromium } from "playwright";
|
||||
import { createServer as createViteServer } from "vite";
|
||||
import * as ed from "@noble/ed25519";
|
||||
import { mkdirSync, writeFileSync } from "node:fs";
|
||||
import { dirname, resolve } from "node:path";
|
||||
import { fileURLToPath } from "node:url";
|
||||
|
||||
const __dirname = dirname(fileURLToPath(import.meta.url));
|
||||
const ROOT = resolve(__dirname, "..");
|
||||
const VITE_PORT = 47000 + Math.floor(Math.random() * 10000);
|
||||
const APP_URL = `http://127.0.0.1:${VITE_PORT}`;
|
||||
|
||||
/**
|
||||
* Pre-seeds the real local-identity record directly into IndexedDB (same
|
||||
* schema `src/lib/db.ts` defines) via `page.addInitScript` BEFORE the
|
||||
* page's own React tree ever mounts - sidesteps the same known,
|
||||
* pre-existing, out-of-scope StrictMode double-invoke race documented in
|
||||
* transactionHistorySignature.e2e.mjs, not touched here.
|
||||
*/
|
||||
async function seedIdentity(context) {
|
||||
const { secretKey, publicKey } = await ed.keygenAsync();
|
||||
await context.addInitScript(
|
||||
({ secretKey, publicKey }) => {
|
||||
const openReq = indexedDB.open("the-commons-hollow", 4);
|
||||
openReq.onupgradeneeded = () => {
|
||||
const db = openReq.result;
|
||||
if (!db.objectStoreNames.contains("identity")) db.createObjectStore("identity", { keyPath: "id" });
|
||||
if (!db.objectStoreNames.contains("eventLog")) {
|
||||
const store = db.createObjectStore("eventLog", { keyPath: "id", autoIncrement: true });
|
||||
store.createIndex("lamportTs", "lamportTs", { unique: false });
|
||||
}
|
||||
if (!db.objectStoreNames.contains("miniappPackages")) {
|
||||
const store = db.createObjectStore("miniappPackages", { keyPath: "id" });
|
||||
store.createIndex("sourceBlobId", "sourceBlobId", { unique: true });
|
||||
}
|
||||
};
|
||||
openReq.onsuccess = () => {
|
||||
const db = openReq.result;
|
||||
const tx = db.transaction("identity", "readwrite");
|
||||
tx.objectStore("identity").put({
|
||||
id: "local",
|
||||
publicKey: new Uint8Array(publicKey),
|
||||
secretKey: new Uint8Array(secretKey),
|
||||
createdAt: Date.now(),
|
||||
});
|
||||
};
|
||||
},
|
||||
{ secretKey: Array.from(secretKey), publicKey: Array.from(publicKey) },
|
||||
);
|
||||
}
|
||||
|
||||
async function runEnvelopeIconCheck(browser) {
|
||||
const context = await browser.newContext();
|
||||
const evidence = { scenario: "happy", steps: {} };
|
||||
try {
|
||||
await seedIdentity(context);
|
||||
const page = await context.newPage();
|
||||
|
||||
await page.goto(`${APP_URL}/miniapp/fair-draw`);
|
||||
const envelopeCard = page.getByTestId("reveal-draw-envelope");
|
||||
await envelopeCard.waitFor();
|
||||
|
||||
const icon = envelopeCard.locator("svg");
|
||||
await icon.waitFor({ state: "visible" });
|
||||
const isVisible = await icon.isVisible();
|
||||
const tagName = await icon.evaluate((el) => el.tagName.toLowerCase());
|
||||
const glyphText = await envelopeCard.innerText();
|
||||
|
||||
evidence.steps.envelopeIconIsInlineSvg = {
|
||||
tagName,
|
||||
isVisible,
|
||||
envelopeCardText: glyphText,
|
||||
// The previous bug rendered a raw emoji code point as text content
|
||||
// (a tofu box in fonts lacking it); confirm no such glyph character
|
||||
// remains alongside the real svg element.
|
||||
noLeftoverEmojiGlyph: !glyphText.includes("\u{1F9E7}"),
|
||||
};
|
||||
|
||||
if (tagName !== "svg" || !isVisible) {
|
||||
throw new Error(
|
||||
`expected the envelope card's icon to be a visible <svg> element, got tagName="${tagName}" isVisible=${isVisible}`,
|
||||
);
|
||||
}
|
||||
if (!evidence.steps.envelopeIconIsInlineSvg.noLeftoverEmojiGlyph) {
|
||||
throw new Error("expected no leftover raw emoji glyph character in the envelope card");
|
||||
}
|
||||
|
||||
evidence.pass = true;
|
||||
return evidence;
|
||||
} catch (err) {
|
||||
evidence.pass = false;
|
||||
evidence.error = String(err && err.message ? err.message : err);
|
||||
throw Object.assign(err, { evidence });
|
||||
} finally {
|
||||
await context.close();
|
||||
}
|
||||
}
|
||||
|
||||
async function runFullDrawFlowUnaffected(browser) {
|
||||
const context = await browser.newContext();
|
||||
const evidence = { scenario: "flow-unaffected", steps: {} };
|
||||
try {
|
||||
await seedIdentity(context);
|
||||
const page = await context.newPage();
|
||||
|
||||
await page.goto(`${APP_URL}/miniapp/fair-draw`);
|
||||
|
||||
const startButton = page.getByRole("button", { name: "Start Draw" });
|
||||
await startButton.waitFor();
|
||||
await startButton.click();
|
||||
|
||||
const commitHash = page.getByTestId("reveal-draw-commit-hash");
|
||||
await commitHash.waitFor();
|
||||
const commitHashText = await commitHash.innerText();
|
||||
evidence.steps.startDraw = { commitHashText, isHex64: /^[0-9a-f]{64}$/.test(commitHashText) };
|
||||
if (!evidence.steps.startDraw.isHex64) {
|
||||
throw new Error(`expected a 64-char hex commit hash, got "${commitHashText}"`);
|
||||
}
|
||||
|
||||
const revealButton = page.getByRole("button", { name: "Reveal" });
|
||||
await revealButton.waitFor();
|
||||
await revealButton.click();
|
||||
|
||||
const revealed = page.getByTestId("reveal-draw-revealed");
|
||||
await revealed.waitFor();
|
||||
|
||||
const badge = page.getByTestId("reveal-draw-badge");
|
||||
const badgeState = await badge.getAttribute("data-state");
|
||||
evidence.steps.reveal = { badgeState };
|
||||
if (badgeState !== "verified") {
|
||||
throw new Error(`expected a verified draw on an untampered reveal, got badge state "${badgeState}"`);
|
||||
}
|
||||
|
||||
const winner = page.getByTestId("reveal-draw-winner");
|
||||
await winner.waitFor();
|
||||
const winnerText = await winner.innerText();
|
||||
evidence.steps.winner = { winnerText, hasWinner: winnerText.startsWith("Winner: ") };
|
||||
if (!evidence.steps.winner.hasWinner) {
|
||||
throw new Error(`expected a "Winner: ..." row, got "${winnerText}"`);
|
||||
}
|
||||
|
||||
evidence.pass = true;
|
||||
return evidence;
|
||||
} catch (err) {
|
||||
evidence.pass = false;
|
||||
evidence.error = String(err && err.message ? err.message : err);
|
||||
throw Object.assign(err, { evidence });
|
||||
} finally {
|
||||
await context.close();
|
||||
}
|
||||
}
|
||||
|
||||
async function main() {
|
||||
const vite = await createViteServer({
|
||||
root: ROOT,
|
||||
configFile: resolve(ROOT, "vite.config.ts"),
|
||||
logLevel: "warn",
|
||||
server: { host: "127.0.0.1", port: VITE_PORT, strictPort: true },
|
||||
});
|
||||
await vite.listen();
|
||||
|
||||
const browser = await chromium.launch({ headless: true, args: ["--no-sandbox"] });
|
||||
|
||||
const results = {};
|
||||
let failed = false;
|
||||
try {
|
||||
try {
|
||||
results.icon = await runEnvelopeIconCheck(browser);
|
||||
} catch (e) {
|
||||
failed = true;
|
||||
results.icon = e.evidence ?? { scenario: "happy", pass: false, error: String(e) };
|
||||
}
|
||||
|
||||
try {
|
||||
results.flow = await runFullDrawFlowUnaffected(browser);
|
||||
} catch (e) {
|
||||
failed = true;
|
||||
results.flow = e.evidence ?? { scenario: "flow-unaffected", pass: false, error: String(e) };
|
||||
}
|
||||
} finally {
|
||||
await browser.close();
|
||||
await vite.close();
|
||||
}
|
||||
|
||||
const evDir = resolve(ROOT, ".omo/evidence/the-commons-hollow-polish");
|
||||
mkdirSync(evDir, { recursive: true });
|
||||
const now = new Date().toISOString();
|
||||
|
||||
writeFileSync(
|
||||
resolve(evDir, "task-17-the-commons-hollow-polish.json"),
|
||||
JSON.stringify(
|
||||
{
|
||||
task: "17. Fix Fair Draw's broken icon glyph",
|
||||
qa: "happy",
|
||||
description:
|
||||
"On the real '/miniapp/fair-draw' route, the envelope reveal card's icon glyph is asserted via a real Playwright locator to be a visible inline <svg> element from the shared src/shell/icons.tsx set, rather than the previous raw emoji code point that rendered as a blank/tofu box - no screenshot or human judgment used.",
|
||||
tool: "Playwright (chromium), real Vite dev server, real app UI ('/miniapp/fair-draw' -> RevealDraw envelope card)",
|
||||
run_command: "node e2e/fairDrawEnvelopeIcon.e2e.mjs",
|
||||
selectors_used: ["reveal-draw-envelope", "svg (inline-SVG icon element)"],
|
||||
timestamp: now,
|
||||
result: results.icon,
|
||||
pass: Boolean(results.icon && results.icon.pass),
|
||||
},
|
||||
null,
|
||||
2,
|
||||
),
|
||||
);
|
||||
|
||||
writeFileSync(
|
||||
resolve(evDir, "task-17-the-commons-hollow-polish-flow-unaffected.json"),
|
||||
JSON.stringify(
|
||||
{
|
||||
task: "17. Fix Fair Draw's broken icon glyph",
|
||||
qa: "failure/flow-unaffected",
|
||||
description:
|
||||
"Confirms the icon-glyph swap did not regress the rest of the real Fair Draw commit-reveal flow: Start Draw -> Reveal -> Verified -> Winner, driven end-to-end on the real '/miniapp/fair-draw' route using its existing reveal-draw-* data-testid family.",
|
||||
tool: "Playwright (chromium), real Vite dev server, real app UI ('/miniapp/fair-draw' -> RevealDraw)",
|
||||
run_command: "node e2e/fairDrawEnvelopeIcon.e2e.mjs",
|
||||
selectors_used: [
|
||||
"reveal-draw-commit-hash",
|
||||
"reveal-draw-revealed",
|
||||
"reveal-draw-badge",
|
||||
"reveal-draw-winner",
|
||||
],
|
||||
timestamp: now,
|
||||
result: results.flow,
|
||||
pass: Boolean(results.flow && results.flow.pass),
|
||||
},
|
||||
null,
|
||||
2,
|
||||
),
|
||||
);
|
||||
|
||||
console.log("\n===== e2e RESULTS =====");
|
||||
console.log(JSON.stringify(results, null, 2));
|
||||
console.log(
|
||||
`\nSUMMARY: icon=${results.icon && results.icon.pass ? "PASS" : "FAIL"} flow=${
|
||||
results.flow && results.flow.pass ? "PASS" : "FAIL"
|
||||
}`,
|
||||
);
|
||||
if (failed || !(results.icon && results.icon.pass) || !(results.flow && results.flow.pass)) {
|
||||
process.exitCode = 1;
|
||||
}
|
||||
}
|
||||
|
||||
main().catch((e) => {
|
||||
console.error("FATAL", e);
|
||||
process.exitCode = 1;
|
||||
});
|
||||
@@ -22,11 +22,15 @@
|
||||
}
|
||||
|
||||
.envelopeIcon {
|
||||
font-size: 2.5rem;
|
||||
line-height: 1;
|
||||
display: flex;
|
||||
transition: transform 0.3s ease;
|
||||
}
|
||||
|
||||
.envelopeIconSvg {
|
||||
width: 2.5rem;
|
||||
height: 2.5rem;
|
||||
}
|
||||
|
||||
.envelope[data-phase="revealed"] .envelopeIcon {
|
||||
transform: rotate(-8deg) scale(1.1);
|
||||
}
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
import { useCallback, useState } from "react";
|
||||
import { append } from "../../lib/eventlog";
|
||||
import { commit, drawOutcome, reveal, verify, type Revealed } from "../../lib/fairdraw";
|
||||
import { Icon } from "../../shell/icons";
|
||||
import { useActiveAccountId } from "../../shell/useActiveAccountId";
|
||||
import styles from "./RevealDraw.module.css";
|
||||
|
||||
@@ -151,7 +152,7 @@ export function RevealDraw({
|
||||
<section className={styles.screen} aria-label="Fair Draw">
|
||||
<div className={styles.envelope} data-testid="reveal-draw-envelope" data-phase={phase.step}>
|
||||
<div className={styles.envelopeIcon} aria-hidden="true">
|
||||
{phase.step === "revealed" ? "\u{1F9E7}" : "\u{1F9E7}"}
|
||||
<Icon id="fair-draw" className={styles.envelopeIconSvg} />
|
||||
</div>
|
||||
<h2 className={styles.title}>Fair Draw</h2>
|
||||
<p className={styles.subtitle}>Commit-reveal verifiable draw, provably not rigged.</p>
|
||||
|
||||
Reference in new issue
Block a user