live.test.mjs RawHistoryFolder

1// Tests of the "live updates paused" delay of static/js/ermite.js
2// (window.ermiteLive.lost/back) with mocked timers. Only the ermiteLive part of
3// the file is evaluated: the rest needs a page. Run with
4//   node --test 'internal/adapters/web/jstest/*.test.mjs'
5import assert from 'node:assert/strict';
6import { readFileSync } from 'node:fs';
7import { test } from 'node:test';
8
9const src = readFileSync(new URL('../static/js/ermite.js', import.meta.url), 'utf8');
10const live = src.slice(src.indexOf('window.ermiteLive = '));
11
12function setup(t) {
13  t.mock.timers.enable({ apis: ['setTimeout'] });
14  const hint = { dataset: { state: 'connecting' } };
15  globalThis.window = {};
16  globalThis.document = { querySelector: (sel) => (sel === '.hint-live' ? hint : null) };
17  new Function(live)();
18  return { live: globalThis.window.ermiteLive, hint };
19}
20
21test('a drop shorter than the delay says nothing', (t) => {
22  const { live, hint } = setup(t);
23  live.back();
24  live.lost();
25  t.mock.timers.tick(4000);
26  live.back();
27  t.mock.timers.tick(10000);
28  assert.equal(hint.dataset.state, 'live');
29});
30
31test('a drop that lasts shows offline, once, until the stream is back', (t) => {
32  const { live, hint } = setup(t);
33  live.lost();
34  t.mock.timers.tick(3000);
35  live.lost(); // a second error does not restart the delay
36  t.mock.timers.tick(2000);
37  assert.equal(hint.dataset.state, 'offline');
38  live.back();
39  assert.equal(hint.dataset.state, 'live');
40});

Keyboard shortcuts

Single-key shortcuts are on. ctrl k and esc work whatever this says.

ctrl k :
go to a section, branch, tag, file or repository
?
this list
j k
move the row cursor down / up
enter
open the row under the cursor; on Files, a directory opens or closes in place
↑ ↓ ← → home end
in the file tree (focus on a row): previous / next row, close / open a directory or go to its parent / first entry, first / last row. They never open a file
l h
on Files: open a directory or a file / close a directory or go up to its parent, then to the parent page. Elsewhere: into the side panel (on a merge request, its files) / back to the content; there j k move between its controls
g g G
first / last row
/
filter the list; on Files, find a file anywhere in the repository (esc clears, enter opens the best match)
b
switch branch or tag
g s g f g c g b g m g i g r g a
tabs: summary, files, commits, branches & tags, merge requests, issues, releases, actions (when available)
g h
home
w
wide mode: use the whole width of the screen, or not (remembered)
y
copy a permalink pinned to the commit
d u x
diff: split / unified / collapse or expand all
e E
diff: the whole file in view / every file, with the lines the hunks hide
n
merge request: next note in the diff
esc
close a dialog, leave a field

Branches 2

Tags 45

↑↓ moveenter openesc close