Merge pull request 'Live updates keep the rows brought in with Load More' (#80) from keep-loaded-rows into main
CI / UI screenshots (before/after) (push) Skipped
CI / Test (jest) (push) Failing after 46s
CI / Lint (eslint) (push) Successful in 49s
CI / Security (npm audit) (push) Successful in 37s
CI / Scan (secrets, workflows, shell) (push) Successful in 2m35s
CI / Integration (api) (push) Successful in 3m43s
CI / UI (playwright) (push) Successful in 2m28s
CI / Deploy (push) Skipped
CI / Deploy worker (push) Skipped
CI / Notify (push) Successful in 3s
CI / UI screenshots (before/after) (push) Skipped
CI / Test (jest) (push) Failing after 46s
CI / Lint (eslint) (push) Successful in 49s
CI / Security (npm audit) (push) Successful in 37s
CI / Scan (secrets, workflows, shell) (push) Successful in 2m35s
CI / Integration (api) (push) Successful in 3m43s
CI / UI (playwright) (push) Successful in 2m28s
CI / Deploy (push) Skipped
CI / Deploy worker (push) Skipped
CI / Notify (push) Successful in 3s
This commit was merged in pull request #80.
This commit is contained in:
commit
156c311217
2 files changed
+32
-4
No files matched your search
@@ -71,10 +71,13 @@
|
||||
/* ------------------------------------------------------------------
|
||||
Loading
|
||||
------------------------------------------------------------------ */
|
||||
async function loadView(view, append) {
|
||||
// keepLoaded: a live refresh fetches as many rows as are already shown, so
|
||||
// rows brought in with Load More don't vanish when an event arrives (#17).
|
||||
async function loadView(view, append, keepLoaded) {
|
||||
const st = state[view];
|
||||
const offset = append ? st.offset : 0;
|
||||
const params = new URLSearchParams({ limit: String(LIMIT), offset: String(offset) });
|
||||
const limit = keepLoaded ? Math.min(Math.max(LIMIT, st.rows.length), 1000) : LIMIT;
|
||||
const params = new URLSearchParams({ limit: String(limit), offset: String(offset) });
|
||||
if (view === 'manual') params.set('hide_internal', 'true');
|
||||
if (view === 'automated') params.set('only_internal', 'true'); // server-side (#4)
|
||||
const term = searchTerm();
|
||||
@@ -102,8 +105,12 @@
|
||||
await loadView(state.view, false);
|
||||
render();
|
||||
}
|
||||
// Live events trigger this; coalesce bursts into at most one reload per 2 s (#10).
|
||||
const reloadCurrent = Pulse.util.throttle(reloadNow, 2000);
|
||||
// Live events trigger this; coalesce bursts into at most one reload per 2 s (#10),
|
||||
// keeping however many rows are loaded (#17).
|
||||
const reloadCurrent = Pulse.util.throttle(async () => {
|
||||
await loadView(state.view, false, true);
|
||||
render();
|
||||
}, 2000);
|
||||
|
||||
// Typing in the search box: search on the server once typing pauses (#16).
|
||||
let searchTimer = null;
|
||||
|
||||
@@ -108,3 +108,24 @@ test('Quick Command remembers the mode and workers after a reload (#31)', async
|
||||
await expect(page.locator('#qc-mode-single')).toBeChecked();
|
||||
await expect(page.locator('#qc-worker option:checked')).toContainText('node-03');
|
||||
});
|
||||
|
||||
test('a live update keeps the rows brought in with Load More (#17)', async ({ page, request }) => {
|
||||
const workers = await (await request.get('/api/workers')).json();
|
||||
const id = workers.find(w => w.name === 'node-01').id;
|
||||
const send = () => request.post(`/api/workers/${id}/command`, { data: { command: 'true' } });
|
||||
for (let i = 0; i < 60; i++) await send();
|
||||
|
||||
await page.goto('/executions');
|
||||
const rows = page.locator('#ex-list-manual .ex-row');
|
||||
await expect(rows).toHaveCount(50);
|
||||
await page.getByRole('button', { name: 'Load More Executions' }).click();
|
||||
await expect.poll(() => rows.count()).toBeGreaterThan(50);
|
||||
const shown = await rows.count();
|
||||
|
||||
// A live event: the list refreshes with the new run on top, and still shows
|
||||
// as many rows as before rather than dropping back to the first 50.
|
||||
const marker = `live-${Date.now().toString(36)}`;
|
||||
await request.post(`/api/workers/${id}/command`, { data: { command: `echo ${marker}` } });
|
||||
await expect(rows.first()).toContainText(marker, { timeout: 10_000 });
|
||||
await expect(rows).toHaveCount(shown);
|
||||
});
|
||||
Reference in new issue
Block a user