aboutsummaryrefslogtreecommitdiffstats
path: root/tools/feed-follow-test.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-10-07 08:34:45 -0700
committerAdam Soltys <[email protected]>2026-10-07 08:34:45 -0700
commit8dfc629d129c6c1a8a3ed38a935e659eee9f67c7 (patch)
treee85c955e7014e1cf4b22166077d41e3d5c2bc4bd /tools/feed-follow-test.js
parent1d6786265f4d86b2260b30060df473a51774fb72 (diff)
downloadcoinosv3-8dfc629d129c6c1a8a3ed38a935e659eee9f67c7.tar.gz
coinosv3-8dfc629d129c6c1a8a3ed38a935e659eee9f67c7.zip
Feed tests: open the Feed from the bottom nav, on Following
The feed left the chat home for a bottom-nav tab, and a wallet with no feed remembered opens on Popular, so these tests click the Feed tab and seed Following as the wallet's last feed. Also brought up to date: - feed-live: the pill lands on the oldest new post; arrivals at the top go in above the first post (held still), not behind the pill; scroll up a screen at a time (one jump lands before the windowed rows are back) - feed-custom: only the feeds' chips are counted (not All/Images/…); the follows box is not the first checkbox any more; the last feed is remembered across a reload; the pack shows in the feed's editor (the chat home no longer lists the feed) - feed-follow: Feed tab + Following chip instead of the messages-home row; the feed opens at ten posts (tall ones, so a page doesn't fill the screen) - moderation: nos.lol is a local stand-in (a relay that won't connect held the mute list back past the checks) Co-Authored-By: Claude Opus 5.5 <[email protected]>
Diffstat (limited to 'tools/feed-follow-test.js')
-rw-r--r--tools/feed-follow-test.js43
1 files changed, 20 insertions, 23 deletions
diff --git a/tools/feed-follow-test.js b/tools/feed-follow-test.js
index 50a572b..bae06a9 100644
--- a/tools/feed-follow-test.js
+++ b/tools/feed-follow-test.js
@@ -20,7 +20,9 @@ const server = Bun.serve({ port: 5237, fetch: () => new Response(html, { headers
const browser = await puppeteer.launch({ executablePath: '/usr/bin/google-chrome', headless: 'new', args: ['--no-sandbox'] });
const page = await browser.newPage();
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);
-const clickItem = (t) => page.evaluate((x) => { const e = [...document.querySelectorAll('.item, button')].find((n) => n.textContent.trim().toLowerCase().includes(x)); if (e) { e.click(); return true; } return false; }, t);
+// the Feed is a tab in the bottom nav (it used to be offered on the messages home)
+const openFeed = () => page.evaluate(() => { const b = [...document.querySelectorAll('.app-nav-button')].find((e) => e.getAttribute('aria-label') === 'Feed'); if (b) b.click(); return !!b; });
+const chip = (name) => page.evaluate((n) => { const e = [...document.querySelectorAll('.feed-chips > .feed-chip')].find((b) => b.textContent.trim() === n); if (e) e.click(); return !!e; }, name);
const text = () => page.evaluate(() => document.body.innerText);
const waitText = async (x, ms = 25000) => { for (let i = 0; i < ms / 250; i++) { if ((await text()).toLowerCase().includes(x)) return true; await sleep(250); } return false; };
const FOLLOWED = 'e'.repeat(63) + '1';
@@ -40,12 +42,10 @@ try {
await waitText('receive', 20000);
const base = cacheKeyFor(mnemonic + '\n');
- // chat → the feed is offered before the conversations
- await page.evaluate(() => { const b = [...document.querySelectorAll('button')].find((e) => /message/i.test(e.getAttribute('aria-label') || '')); if (b) b.click(); });
- await sleep(1200);
- check('the feed is on the messages home', /follow people to fill this/i.test(await text()), (await text()).split('\n').slice(0, 6).join(' | '));
-
- await clickItem('feed');
+ check('the bottom nav has a Feed tab', await openFeed());
+ await sleep(1000);
+ // a new wallet opens on Popular; Following is the people you follow
+ check('...whose chips include Following', await chip('Following'));
await sleep(1000);
check('a wallet that follows nobody is told so', /don't follow anyone yet/i.test(await text()));
check('...and offered somewhere to start', /find people/i.test(await text()));
@@ -56,9 +56,11 @@ try {
}, [base, FOLLOWED]);
await page.reload({ waitUntil: 'domcontentloaded' });
await waitText('receive', 20000);
- await page.evaluate(() => { const b = [...document.querySelectorAll('button')].find((e) => /message/i.test(e.getAttribute('aria-label') || '')); if (b) b.click(); });
+ await openFeed();
await sleep(1200);
- check('the follow count shows on the messages home', /posts from the one person you follow/i.test(await text()), (await text()).match(/Posts from[^\n]*/)?.[0] || 'no line');
+ // (the feed you were on, Following, is remembered)
+ check('Following no longer says you follow nobody', /\bFollowing\b/.test(await page.evaluate(() => document.querySelector('.feed-chips > .feed-chip.on')?.textContent || ''))
+ && !/don't follow anyone yet/i.test(await text()));
// and their own profile page knows we follow them
await page.goto('http://localhost:5237/' + npubEncode(FOLLOWED), { waitUntil: 'domcontentloaded' });
@@ -89,9 +91,7 @@ try {
}, [base, FOLLOWED, OTHER]);
await page.reload({ waitUntil: 'domcontentloaded' });
await waitText('receive', 20000);
- await page.evaluate(() => { const b = [...document.querySelectorAll('button')].find((e) => /message/i.test(e.getAttribute('aria-label') || '')); if (b) b.click(); });
- await sleep(1000);
- await clickItem('feed');
+ await openFeed();
await sleep(6000);
const dialled = await page.evaluate(() => window.__dialled || []);
check('each author is read on their own write relay',
@@ -114,35 +114,32 @@ try {
}, [base, FOLLOWED]);
await page.reload({ waitUntil: 'domcontentloaded' });
await waitText('receive', 20000);
- await page.evaluate(() => { const b = [...document.querySelectorAll('button')].find((e) => /message/i.test(e.getAttribute('aria-label') || '')); if (b) b.click(); });
- await sleep(1000);
- await clickItem('feed');
+ await openFeed();
await sleep(6000);
const wide = await page.evaluate(() => window.__dialled || []);
const hit = [1, 2, 3, 4, 5, 6].filter((n) => wide.some((u) => u.includes('r' + n + '.example.invalid')));
check('an author who publishes to six relays is read on all six',
hit.length === 6, 'reached ' + (hit.join(',') || 'none'));
- // The feed opens at twenty posts and grows as you reach the bottom, however
- // many it is holding.
+ // The feed opens at ten posts and grows as you reach the bottom, however
+ // many it is holding. (Tall posts: a page of short ones doesn't reach the
+ // distance from the bottom where the next page is read.)
await page.evaluate((k) => {
const notes = [];
const now = Math.floor(Date.now() / 1000);
- for (let i = 0; i < 60; i++) notes.push({ id: String(i).padStart(64, '0'), pubkey: 'f'.repeat(64), kind: 1, created_at: now - i * 60, content: 'post ' + i, tags: [] });
+ for (let i = 0; i < 60; i++) notes.push({ id: String(i).padStart(64, '0'), pubkey: 'f'.repeat(64), kind: 1, created_at: now - i * 60, content: 'post ' + i + ' ' + 'with enough words to stand tall '.repeat(30), tags: [] });
localStorage.setItem(k + ':feedNotes', JSON.stringify(notes));
}, base);
await page.reload({ waitUntil: 'domcontentloaded' });
await waitText('receive', 20000);
- await page.evaluate(() => { const b = [...document.querySelectorAll('button')].find((e) => /message/i.test(e.getAttribute('aria-label') || '')); if (b) b.click(); });
- await sleep(1000);
- await clickItem('feed');
+ await openFeed();
await sleep(1500);
const first = await page.evaluate(() => document.querySelectorAll('.notes-feed > .row').length);
- check('the feed opens at twenty posts, not sixty', first === 20, first + ' rows');
+ check('the feed opens at ten posts, not sixty', first === 10, first + ' rows');
await page.evaluate(() => window.scrollTo(0, document.documentElement.scrollHeight));
await sleep(1200);
const second = await page.evaluate(() => document.querySelectorAll('.notes-feed > .row').length);
- check('reaching the bottom shows twenty more', second === 40, second + ' rows');
+ check('reaching the bottom shows ten more', second === 20, second + ' rows');
} finally { await browser.close(); server.stop(true); }
console.log(ok ? '\n✅ follows and feed' : '\n❌ failed');
process.exit(ok ? 0 : 1);