aboutsummaryrefslogtreecommitdiffstats
path: root/tools/gift-from-test.js
diff options
context:
space:
mode:
Diffstat (limited to 'tools/gift-from-test.js')
-rw-r--r--tools/gift-from-test.js17
1 files changed, 13 insertions, 4 deletions
diff --git a/tools/gift-from-test.js b/tools/gift-from-test.js
index a0ffaf8..e82926d 100644
--- a/tools/gift-from-test.js
+++ b/tools/gift-from-test.js
@@ -1,6 +1,6 @@
// A gift link can name its sender: #f=<base32 pubkey|created_at|sig>, a
// nostr signature over the gift's code. The claim screen shows who it's
-// from (and that claiming follows them); a link whose signature doesn't
+// from; a link whose signature doesn't
// match its code — passed on as someone else's gift — shows no sender.
// Run: bun run build && bun tools/gift-from-test.js
import puppeteer from './puppeteer.js';
@@ -52,16 +52,25 @@ try {
const code = giftCode();
let page = await open(`ag/${code}#m=hi&f=${fromFrag(code)}`);
let tx = await text(page);
- check('a signed link names its sender', /\bFrom\b/.test(tx) && /Claiming it follows them/.test(tx), tx.slice(0, 300).replace(/\n/g, ' | '));
+ const chip = () => page.evaluate(() => !!document.querySelector('.zap-chip'));
+ check('a signed link names its sender', /\bFrom\b/.test(tx) && await chip(), tx.slice(0, 300).replace(/\n/g, ' | '));
+ check('no "claiming follows them" line', !/follows them/i.test(tx));
+ // the sender's face waits for their profile, never punk art first
+ check("the sender's face waits for their profile", await page.evaluate(() => !!document.querySelector('.zap-chip .wait-face')));
+ // a hat sits above the chip: the chip's name clipping must not cut it off
+ check('a hat on the sender is not clipped', await page.evaluate(() => {
+ const c = document.querySelector('.zap-chip'); const w = document.createElement('span'); w.className = 'hat-wrap';
+ c.prepend(w); const o = getComputedStyle(w).overflow; w.remove(); return o === 'visible';
+ }));
check('the note still shows', /\bhi\b/.test(tx));
await page.close();
// an upper-case key, as a scanner may hand it over
page = await open(`ag/${code}#F=${fromFrag(code)}`);
- { const tx = await text(page); check("an upper-cased link still names its sender", /Claiming it follows them/.test(tx), tx.slice(0, 200).replace(/\n/g, " | ")); }
+ { const tx = await text(page); check("an upper-cased link still names its sender", /\bFrom\b/.test(tx) && await page.evaluate(() => !!document.querySelector('.zap-chip')), tx.slice(0, 200).replace(/\n/g, " | ")); }
await page.close();
// the same signature on a different gift: no sender
page = await open(`ag/${giftCode()}#f=${fromFrag(code)}`);
- check('a signature over another code names nobody', !/Claiming it follows them/.test(await text(page)));
+ check('a signature over another code names nobody', !/\bFrom\b/.test(await text(page)) && !(await page.evaluate(() => !!document.querySelector('.zap-chip'))));
await page.close();
} finally {
await browser.close();