diff options
Diffstat (limited to 'tools/feed-mention-tap-test.js')
| -rw-r--r-- | tools/feed-mention-tap-test.js | 22 |
1 files changed, 20 insertions, 2 deletions
diff --git a/tools/feed-mention-tap-test.js b/tools/feed-mention-tap-test.js index d381288..fde2ddb 100644 --- a/tools/feed-mention-tap-test.js +++ b/tools/feed-mention-tap-test.js @@ -14,6 +14,8 @@ const key = () => { const sk = generateSecretKey(); return { sk, pk: getPublicKe const AUTHOR = key(), FRIEND = key(); const now = Math.floor(Date.now() / 1000); const POST = finalizeEvent({ kind: 1, created_at: now - 100, tags: [['p', FRIEND.pk]], content: 'say hello to nostr:' + npubEncode(FRIEND.pk) + ' today' }, AUTHOR.sk); +// a name typed out as plain text: no key in it, no p tag +const PLAIN = finalizeEvent({ kind: 1, created_at: now - 50, tags: [], content: 'big thanks to @poster and @somebody for testing' }, FRIEND.sk); const html = await buildHtml({ minify: true, pwa: false }); const server = Bun.serve({ port: 5319, fetch: (req) => { const p = new URL(req.url).pathname; if (p === '/verify-worker.js' || p.startsWith('/punks')) return new Response(Bun.file('dist' + p)); return new Response(html, { headers: { 'content-type': 'text/html' } }); } }); const browser = await puppeteer.launch({ executablePath: '/usr/bin/google-chrome', headless: 'new', args: ['--no-sandbox'] }); @@ -39,11 +41,11 @@ try { await waitText('Receive', 20000); const base = cacheKeyFor(mn + '\n'); await page.evaluate(([k, a, f, ns]) => { - localStorage.setItem(k + ':follows', JSON.stringify({ tags: [['p', a]], c: '', at: Math.floor(Date.now() / 1000) })); + localStorage.setItem(k + ':follows', JSON.stringify({ tags: [['p', a], ['p', f]], c: '', at: Math.floor(Date.now() / 1000) })); localStorage.setItem(k + ':feedNotes', JSON.stringify(ns)); localStorage.setItem(k + ':profiles', JSON.stringify({ [a]: { name: 'Poster', t: Date.now() }, [f]: { name: 'Friendly', t: Date.now() } })); localStorage.setItem('btc-wallet-feed:' + k, 'following'); - }, [base, AUTHOR.pk, FRIEND.pk, [POST]]); + }, [base, AUTHOR.pk, FRIEND.pk, [PLAIN, POST]]); await page.reload({ waitUntil: 'domcontentloaded' }); await waitText('Receive', 20000); await page.evaluate(() => document.querySelector('.app-nav-button[aria-label="Feed"]')?.click()); @@ -52,6 +54,22 @@ try { await sleep(1200); const where = await page.evaluate(() => location.pathname); check('the tap opens Friendly\'s profile, not the post', where.startsWith('/npub1') && !where.includes('nevent'), where); + // a typed-out name: the one follow who goes by it opens, anyone else is a search + const tapPlain = async (name) => { + await page.reload({ waitUntil: 'domcontentloaded' }); + await waitText('Receive', 20000); + await page.evaluate(() => document.querySelector('.app-nav-button[aria-label="Feed"]')?.click()); + await waitText('big thanks to', 15000); + await page.evaluate((n) => [...document.querySelectorAll('[data-zap-post] a')].find((a) => a.textContent === n).click(), name); + await sleep(1200); + }; + await tapPlain('@poster'); + const where2 = await page.evaluate(() => location.pathname); + check('"@poster" typed as plain text opens the follow named Poster', where2 === '/' + npubEncode(AUTHOR.pk) || where2.startsWith('/npub1'), where2); + check('...and it is Poster\'s page', await waitText('Poster', 5000) && !(await page.evaluate(() => !!document.querySelector('.user-search, [data-key="user-search"]')))); + await tapPlain('@somebody'); + const where3 = await page.evaluate(() => location.pathname); + check('"@somebody", whom you do not follow, is still a search', !where3.startsWith('/npub1'), where3); check('no page errors', errs.length === 0, errs.slice(0, 2).join(' | ')); } finally { await browser.close(); server.stop(true); } console.log(ok ? '\nā
a mention opens the person' : '\nā failed'); |
