diff options
Diffstat (limited to 'tools/feed-when-test.js')
| -rw-r--r-- | tools/feed-when-test.js | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/tools/feed-when-test.js b/tools/feed-when-test.js index d9baa50..38be4ef 100644 --- a/tools/feed-when-test.js +++ b/tools/feed-when-test.js @@ -119,11 +119,16 @@ try { }); const ev = shown && seeded.find((e) => e.id === shown.key); check('the chip shows while scrolling, under the top bar', !!shown && shown.y >= shown.head, JSON.stringify(shown)); - const want = ev && await page.evaluate((s) => new Date(s * 1000).toLocaleTimeString(undefined, { hour: '2-digit', minute: '2-digit' }), ev.created_at); - check('...with the time of the post at the top of the screen', !!want && shown.text.includes(want), shown?.text + ' / ' + want); + // seeded posts are two hours apart: the chip's minute is one of those between this post and the next + const between = ev && await page.evaluate((s) => Array.from({ length: 121 }, (_, m) => new Date((s - m * 60) * 1000).toLocaleTimeString(undefined, { hour: '2-digit', minute: '2-digit' })), ev.created_at); + check('...with a time between the top post and the next', !!between && between.some((x) => shown.text.includes(x)), shown?.text); check('...and how long ago', /ago|yesterday/i.test(shown?.text || ''), shown?.text); if (process.env.SHOT) await page.screenshot({ path: process.env.SHOT }); - await sleep(1700); + // the clock rolls between posts: a few px down the same post moves it on + const at = (y) => page.evaluate(async (y) => { scrollBy(0, y); await new Promise((r) => setTimeout(r, 60)); return document.querySelector('.feed-when')?.textContent; }, y); + const a = await at(1), b = await at(60); + check('the time blends between posts as you scroll', !!a && !!b && a !== b, a + ' → ' + b); + await sleep(450); check('it fades once the scrolling stops', !(await page.$('.feed-when.on'))); check('no page errors', !errors.length, errors.join('; ')); } finally { |
