aboutsummaryrefslogtreecommitdiffstats
path: root/tools/post-search-test.js
diff options
context:
space:
mode:
Diffstat (limited to 'tools/post-search-test.js')
-rw-r--r--tools/post-search-test.js8
1 files changed, 7 insertions, 1 deletions
diff --git a/tools/post-search-test.js b/tools/post-search-test.js
index 2f32812..81e5b62 100644
--- a/tools/post-search-test.js
+++ b/tools/post-search-test.js
@@ -13,6 +13,9 @@ const SK = generateSecretKey();
const now = Math.floor(Date.now() / 1000);
const post = finalizeEvent({ kind: 1, created_at: now - 300, tags: [], content: 'talked to fiatjaf about relays today' }, SK);
const parent = 'a'.repeat(64);
+// one newsletter, posted by bot keys with a word or emoji changed each time
+const NL = 'In this week\'s issue: The Quiet Coup: Fiatjaf Wipes Authorship From 57 NIPs. In a 12-hour window, the documentation layer was rewritten without consent. https://nostrmag.com/article/w45';
+const copies = ['📰 ' + NL, '🗞️ BREAKING ' + NL, NL + ' 👤 NM team'].map((content, i) => finalizeEvent({ kind: 1, created_at: now - 100 - i, tags: [], content }, generateSecretKey()));
const reply = finalizeEvent({ kind: 1, created_at: now - 200, tags: [['e', parent, '', 'reply']], content: 'fiatjaf would say just use a relay' }, SK);
const html = await buildHtml({ minify: true, pwa: false });
@@ -41,7 +44,7 @@ await page.evaluateOnNewDocument((hits) => {
};
window.WebSocket.prototype = Real.prototype;
Object.assign(window.WebSocket, Real);
-}, [post, reply]);
+}, [post, reply, ...copies]);
const errs = [];
page.on('pageerror', (e) => errs.push(String(e)));
const click = (t) => page.evaluate((x) => { const e = [...document.querySelectorAll('button')].find((n) => n.textContent.trim().toLowerCase().includes(x)); if (e) { e.click(); return true; } return false; }, t);
@@ -65,6 +68,9 @@ try {
await page.keyboard.press('Enter');
check('Enter opens a feed of posts that say it', await waitText('talked to fiatjaf about relays', 10000));
check('...replies too', await waitText('fiatjaf would say just use a relay', 3000));
+ await waitText('quiet coup', 10000); await sleep(1500);
+ const nl = await page.evaluate(() => (document.body.innerText.match(/Quiet Coup/g) || []).length);
+ check('a newsletter posted by three bot keys shows once', nl === 1, nl + ' copies');
const s = await page.evaluate(() => window.__searches.filter((x) => x.f.search === 'fiatjaf' && !(x.f.kinds || []).includes(0)));
check('asked NIP-50 relays for kind 1 with the words', s.length > 0 && s.every((x) => JSON.stringify(x.f.kinds) === '[1]'), JSON.stringify(s.map((x) => x.url)));
check('the feed is named for the search', await page.evaluate(() => [...document.querySelectorAll('.feed-chip')].some((c) => c.classList.contains('on') && c.textContent.includes('fiatjaf'))),