Changeset 1485933 in Klonkt for test/feed-pagination.test.js


Ignore:
Timestamp:
07/20/2026 07:35:55 AM (7 weeks ago)
Author:
Robin <roboburr@…>
Branches:
main
Children:
520e477
Parents:
7b04d3b
git-author:
Robin <roboburr@…> (07/20/2026 07:18:02 AM)
git-committer:
Robin <roboburr@…> (07/20/2026 07:35:55 AM)
Message:

Feature: Load more on Messages, page 72 (klonkt-demo-r9u, slice 2/4)

Messages now pages in 72s with the shared Load-more button instead of a
hard 80-item cap. getMessages gains an offset arg and pages the merged,
grouped stream by recomputing top-down and slicing [offset, offset+72]
(stable across pages); getNotifications' per-source caps scale with the
requested limit so deep paging can reach older items. The item markup
moved to partials/msg-item.ejs so the page and the append fragment
render identically. The client-side filter/search re-indexes appended
rows on htmx:afterSettle and re-applies the active chip, so search keeps
working across pages. Seen-watermark is only stamped on the first page,
not on appends.

Tests: getMessages offset paging (no overlap, PAGE+1 probe). Browser:
72 -> 144 -> 150 then the button drops; searching a term only present on
page 2 matches after append.

Co-Authored-By: Claude Opus 4.8 <noreply@…>

File:
1 edited

Legend:

Unmodified
Added
Removed
  • test/feed-pagination.test.js

    r7b04d3b r1485933  
    4141  assert.equal(AP.getTimeline('me', 72, 300).length, 0);
    4242});
     43
     44// getMessages pages the merged stream by offset (recompute-top-down + slice).
     45const fins = db.prepare('INSERT OR IGNORE INTO ap_followers (slug, actor_uri, created_at) VALUES (?,?,?)');
     46for (let i = 0; i < 150; i++) {
     47  const n = String(i).padStart(3, '0');
     48  const hh = String(23 - Math.floor(i / 60)).padStart(2, '0');
     49  const mm = String(59 - (i % 60)).padStart(2, '0');
     50  fins.run('me', 'https://r.test/u/f' + n, `2026-02-01 ${hh}:${mm}:00`);
     51}
     52
     53test('getMessages pages the stream by offset without overlap', () => {
     54  const p1 = AP.getMessages('me', 72, 0);
     55  const p2 = AP.getMessages('me', 72, 72);
     56  assert.equal(p1.length, 72);
     57  assert.equal(p2.length, 72);
     58  const k = (m) => m.type + '|' + (m.url || m.handle || m.outboxId || '');
     59  const set1 = new Set(p1.map(k));
     60  assert.equal(p2.filter((m) => set1.has(k(m))).length, 0, 'no overlap between pages');
     61});
     62
     63test('getMessages probe of PAGE+1 signals the last page', () => {
     64  assert.equal(AP.getMessages('me', 73, 0).length, 73);      // more remain
     65  assert.equal(AP.getMessages('me', 73, 144).length, 6);     // 150 follows → 6 left
     66});
Note: See TracChangeset for help on using the changeset viewer.