aboutsummaryrefslogtreecommitdiffstats
path: root/tools/thread-reply-test.js
diff options
context:
space:
mode:
authorAdam Soltys <[email protected]>2026-09-24 08:33:46 -0700
committerAdam Soltys <[email protected]>2026-09-24 08:33:46 -0700
commit189c1a3d24b859d3ebf351cff24bbec788a0251a (patch)
tree13e52ea66f136ccf753114f98b297acd64981d4f /tools/thread-reply-test.js
parentcdca3fa061c856f9063aadfabf1c1e713f512123 (diff)
downloadcoinosv3-189c1a3d24b859d3ebf351cff24bbec788a0251a.tar.gz
coinosv3-189c1a3d24b859d3ebf351cff24bbec788a0251a.zip
Preserve restored thread state across rapid refreshes
Diffstat (limited to 'tools/thread-reply-test.js')
-rw-r--r--tools/thread-reply-test.js17
1 files changed, 14 insertions, 3 deletions
diff --git a/tools/thread-reply-test.js b/tools/thread-reply-test.js
index 3dba87f..37c22b4 100644
--- a/tools/thread-reply-test.js
+++ b/tools/thread-reply-test.js
@@ -22,9 +22,11 @@ function render() {
if (!feature) return;
document.querySelector('#app').replaceChildren(feature.screenView() || feature.row(author, reply, 'Someone'));
}
-feature = messagesFeature({ h, wallet, ui, render, toast() {}, brandHeader: () => null,
+feature = messagesFeature({ h, wallet, ui, render, toast() {}, brandHeader: () => window.test?.showNav
+ ? h('div', { style: 'height:60px' }) : null,
hook: k => k === 'nostrLoginIdentity' ? { pubkey: mine, signer } : null });
-window.test = { ui, reply, other, root, render, waiting,
+window.test = { ui, reply, other, root, render, waiting, showNav: false,
+ stable: () => feature.testStable(),
seedFace: () => createThreadStore().save({ root, replies: [reply] }, reply.id, {
[author]: { name: 'Nostrich', picture: 'https://example.com/nostrich.webp', eventAt: 10, t: Date.now(),
thumbFor: 'https://example.com/nostrich.webp', thumb: 'data:image/png;base64,iVBORw0KGgo=', thumbPx: 144 },
@@ -46,7 +48,7 @@ const bundle = await Bun.build({ entrypoints: ['thread-test-entry'], target: 'br
build.onResolve({ filter: /^thread-test-entry$/ }, () => ({ path: 'entry', namespace: 'thread-test' }));
build.onLoad({ filter: /.*/, namespace: 'thread-test' }, () => ({ contents: entry, loader: 'js', resolveDir: process.cwd() }));
build.onLoad({ filter: /src\/features\/messages\.js$/ }, async ({ path }) => ({ loader: 'js', contents: (await Bun.file(path).text())
- .replace("id: 'messages',", "id: 'messages', row: noteRow, actions: noteActions,") }));
+ .replace("id: 'messages',", "id: 'messages', row: noteRow, actions: noteActions, testStable: renderThreadStable,") }));
build.onLoad({ filter: /src\/nostr\.js$/ }, async ({ path }) => ({ loader: 'js', contents: (await Bun.file(path).text())
.replace('export async function queryOn(relays, filter, maxWait = 1500) {', 'export async function queryOn(relays, filter, maxWait = 1500) { return window.query(filter);')
.replace('export async function publishOn(relays, evt) {', 'export async function publishOn(relays, evt) { window.sent.push(evt); return true;')
@@ -114,6 +116,15 @@ try {
const buttons = row?.querySelectorAll('.note-acts > button');
return buttons?.[1].textContent === '7' && buttons?.[3].textContent === '29' && buttons?.[4].textContent === '210';
}));
+ await page.evaluate(() => {
+ document.querySelector('#outside').style.height = '2000px';
+ window.scrollTo(0, 0);
+ test.showNav = true;
+ test.stable();
+ });
+ await new Promise((r) => setTimeout(r, 80));
+ check('adding header controls while at the top does not scroll to the first post',
+ await page.evaluate(() => window.scrollY === 0));
assert.deepEqual(errors, []);
console.log('✓ no browser errors');
} finally { await browser.close(); server.stop(true); }