@yuneta/gobj-ui 7.29.1 → 7.29.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +9 -9
- package/dist/gobj-ui.cjs.js +3 -3
- package/dist/gobj-ui.es.js +3 -3
- package/package.json +1 -1
- package/src/data_as_text.wiring.test.js +1 -1
- package/src/g6_nodes_tree_i18n_keys.test.js +1 -1
- package/src/g6_replace_behavior.js +1 -1
- package/src/gclass_traces.wiring.test.js +3 -3
- package/src/i18n_key_functions.test.js +15 -15
- package/src/schema_editor_reload.wiring.test.js +14 -14
- package/src/selector_from_data.wiring.test.js +1 -1
- package/src/treedb_fold_model.js +2 -2
- package/src/treedb_fold_model.test.js +51 -51
- package/src/treedb_layout.test.js +34 -34
- package/src/yui_dev_controls.test.js +1 -1
- package/src/yui_dev_copy.test.js +4 -4
- package/src/yui_gobj_tree_view.js +3 -3
package/README.md
CHANGED
|
@@ -2074,9 +2074,9 @@ Consumer i18n keys: `matches` (counted), `not shown`, `hidden topics`,
|
|
|
2074
2074
|
|
|
2075
2075
|
### The graph opens FOLDED, like a JSON viewer
|
|
2076
2076
|
|
|
2077
|
-
A treedb drawn whole is a pile. A
|
|
2078
|
-
|
|
2079
|
-
|
|
2077
|
+
A treedb drawn whole is a pile. A site with two hundred devices was a **row of
|
|
2078
|
+
two hundred cards** under one parent, the edges to them a band of parallel
|
|
2079
|
+
lines, and a treedb of several thousand records took every one of them
|
|
2080
2080
|
through a DOM card before the first pixel appeared. So the graph now reads the
|
|
2081
2081
|
treedb the way a JSON viewer reads a document: **a tree by its hooks**, opened
|
|
2082
2082
|
a level or two, with a count on every cut.
|
|
@@ -3400,10 +3400,10 @@ import {open_gobj_tree_view, close_gobj_tree_view}
|
|
|
3400
3400
|
from "@yuneta/gobj-ui/src/yui_gobj_tree_view.js";
|
|
3401
3401
|
|
|
3402
3402
|
priv.view = open_gobj_tree_view(gobj, {
|
|
3403
|
-
name: "
|
|
3403
|
+
name: "gate_energy-4046", /* names the window, the tree and its saved arrangement */
|
|
3404
3404
|
source: "remote",
|
|
3405
|
-
yuno_name: "
|
|
3406
|
-
title_prefix: "
|
|
3405
|
+
yuno_name: "gate_energy^4046", /* before the gclass in the gclass window's title */
|
|
3406
|
+
title_prefix: "gate_energy^4046",
|
|
3407
3407
|
title: "gobj tree", /* an i18n KEY */
|
|
3408
3408
|
$header: priv.$status,
|
|
3409
3409
|
on_close: () => gobj_send_event(gobj, "EV_VIEW_CLOSED", {}, gobj),
|
|
@@ -4860,7 +4860,7 @@ i18next**, so every key it asks for must be defined by the app. The library it
|
|
|
4860
4860
|
scans is the one it ships in, the package the app builds with. The app's own
|
|
4861
4861
|
source is read recursively. Code and catalogs shared by several apps are named
|
|
4862
4862
|
with `--src <dir>` (repeatable) and `--locales <dir>` (for instance:
|
|
4863
|
-
`--src ../gui
|
|
4863
|
+
`--src ../shared-gui/src --locales ../shared-gui/src/locales`); `--config`
|
|
4864
4864
|
names a shell declaration other than `src/app_config.json`.
|
|
4865
4865
|
|
|
4866
4866
|
What is particular to an app goes in ITS `package.json`, not in the script:
|
|
@@ -5564,7 +5564,7 @@ violation of its own: since `7.26.35` its literals are asked for, above --
|
|
|
5564
5564
|
every one of them, so a literal that is no key fails as a missing key. The
|
|
5565
5565
|
marker is what makes it a claim to check.)
|
|
5566
5566
|
|
|
5567
|
-
**A `let` that holds a TABLE is held the same way** (since
|
|
5567
|
+
**A `let` that holds a TABLE is held the same way** (since `7.26.35`:
|
|
5568
5568
|
up to then a marked member of one passed unread). When what is marked is read
|
|
5569
5569
|
FROM a `let` -- a property of it (`LABELS[k]`, `opts.title` at a key
|
|
5570
5570
|
position), the element of a `.map()` / `.forEach()` / `for...of` over it, or
|
|
@@ -5732,7 +5732,7 @@ fails no check"*:
|
|
|
5732
5732
|
entry is redundant, and dropping it loses no key for a consumer.
|
|
5733
5733
|
|
|
5734
5734
|
The test proves itself: with the `COVERAGE` entries that pin them taken
|
|
5735
|
-
away, it reports each of the keys
|
|
5735
|
+
away, it reports each of the keys they pin as pinned by nothing.
|
|
5736
5736
|
|
|
5737
5737
|
A list is also named by a marker or by `COVERAGE`: one that is neither is an
|
|
5738
5738
|
ORPHAN, and fails. Two lists have a test of their own instead, and the pin
|
package/dist/gobj-ui.cjs.js
CHANGED
|
@@ -17288,7 +17288,7 @@ function classify_press(press, x, y, t) {
|
|
|
17288
17288
|
* every page load.
|
|
17289
17289
|
*
|
|
17290
17290
|
* gobj-ui replaces two built-ins on purpose (`drag-canvas` and
|
|
17291
|
-
* `zoom-canvas`, the touch
|
|
17291
|
+
* `zoom-canvas`, the touch support of 7.23.9), so that every graph
|
|
17292
17292
|
* gets the fix without touching its behaviors list. G6's
|
|
17293
17293
|
* `register()` warns whenever a type is registered again --
|
|
17294
17294
|
* "The extension drag-canvas of behavior has been registered
|
|
@@ -65534,8 +65534,8 @@ function node_label(desc, record) {
|
|
|
65534
65534
|
*
|
|
65535
65535
|
* A treedb is a graph: a record hangs from every parent one of its
|
|
65536
65536
|
* fkeys names, and a parent reaches its children through a hook.
|
|
65537
|
-
* Drawn whole it is a pile -- a
|
|
65538
|
-
*
|
|
65537
|
+
* Drawn whole it is a pile -- a site with two hundred devices is
|
|
65538
|
+
* a row of two hundred cards -- so the graph
|
|
65539
65539
|
* opens FOLDED, the way a JSON viewer opens: the roots, a level or
|
|
65540
65540
|
* two under them, and a count on every cut saying what went with it.
|
|
65541
65541
|
*
|
package/dist/gobj-ui.es.js
CHANGED
|
@@ -17283,7 +17283,7 @@ function classify_press(press, x, y, t) {
|
|
|
17283
17283
|
* every page load.
|
|
17284
17284
|
*
|
|
17285
17285
|
* gobj-ui replaces two built-ins on purpose (`drag-canvas` and
|
|
17286
|
-
* `zoom-canvas`, the touch
|
|
17286
|
+
* `zoom-canvas`, the touch support of 7.23.9), so that every graph
|
|
17287
17287
|
* gets the fix without touching its behaviors list. G6's
|
|
17288
17288
|
* `register()` warns whenever a type is registered again --
|
|
17289
17289
|
* "The extension drag-canvas of behavior has been registered
|
|
@@ -65529,8 +65529,8 @@ function node_label(desc, record) {
|
|
|
65529
65529
|
*
|
|
65530
65530
|
* A treedb is a graph: a record hangs from every parent one of its
|
|
65531
65531
|
* fkeys names, and a parent reaches its children through a hook.
|
|
65532
|
-
* Drawn whole it is a pile -- a
|
|
65533
|
-
*
|
|
65532
|
+
* Drawn whole it is a pile -- a site with two hundred devices is
|
|
65533
|
+
* a row of two hundred cards -- so the graph
|
|
65534
65534
|
* opens FOLDED, the way a JSON viewer opens: the roots, a level or
|
|
65535
65535
|
* two under them, and a count on every cut saying what went with it.
|
|
65536
65536
|
*
|
package/package.json
CHANGED
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*
|
|
4
4
|
* Values that come from a backend, a schema or a record are
|
|
5
5
|
* DATA: they are shown as text, never parsed as markup. One case
|
|
6
|
-
* per sink
|
|
6
|
+
* per sink that once parsed one: each one is fed a
|
|
7
7
|
* markup string and must show it, with no element created.
|
|
8
8
|
*
|
|
9
9
|
* Copyright (c) 2026, ArtGins.
|
|
@@ -264,7 +264,7 @@ describe("c_g6_nodes_tree publishes the keys it hands to t() as data", () => {
|
|
|
264
264
|
expect(bad).toEqual([]);
|
|
265
265
|
});
|
|
266
266
|
|
|
267
|
-
test("the published list holds the keys
|
|
267
|
+
test("the published list holds the keys that were missing", () => {
|
|
268
268
|
const published = new Set(array_of("G6_NODES_TREE_I18N_KEYS"));
|
|
269
269
|
for(const key of ["some records were gone before the delete",
|
|
270
270
|
"node properties", "delete node", "edge properties",
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* every page load.
|
|
6
6
|
*
|
|
7
7
|
* gobj-ui replaces two built-ins on purpose (`drag-canvas` and
|
|
8
|
-
* `zoom-canvas`, the touch
|
|
8
|
+
* `zoom-canvas`, the touch support of 7.23.9), so that every graph
|
|
9
9
|
* gets the fix without touching its behaviors list. G6's
|
|
10
10
|
* `register()` warns whenever a type is registered again --
|
|
11
11
|
* "The extension drag-canvas of behavior has been registered
|
|
@@ -4,9 +4,9 @@
|
|
|
4
4
|
* C_YUI_GCLASS, the gclass viewer, as the gobj tree opens it for a
|
|
5
5
|
* BACKEND gclass: its trace levels can be set for every gobj of
|
|
6
6
|
* the gclass (`set-gclass-trace`), one box per level, the yuno's
|
|
7
|
-
* own scope shown locked; and the layout
|
|
8
|
-
*
|
|
9
|
-
*
|
|
7
|
+
* own scope shown locked; and the layout of 7.27.27 -- the short
|
|
8
|
+
* zones first, a long table capped, the instance named beside its
|
|
9
|
+
* state, the methods in the head.
|
|
10
10
|
*
|
|
11
11
|
* The real gclass, hosted by a test gclass that declares what the
|
|
12
12
|
* viewer publishes.
|
|
@@ -641,7 +641,7 @@ function with_key_dropped(lists, name, key)
|
|
|
641
641
|
* `{...opts}`), directly or through a `let` it is given to. What their
|
|
642
642
|
* callers give there is a key the validator reads ONLY when the
|
|
643
643
|
* function is in I18N_KEY_FUNCTIONS: up to 7.26.28 39 were not (the
|
|
644
|
-
*
|
|
644
|
+
* 17 of them are named below), 6 entries lacked positions, and a literal
|
|
645
645
|
* handed to one would have gone unasked.
|
|
646
646
|
*
|
|
647
647
|
* - A forwarder called by NAME -- in its module, or exported -- goes
|
|
@@ -1206,7 +1206,7 @@ describe("every forwarder is in the table", () => {
|
|
|
1206
1206
|
expect(find_forwarders(["x.js"], () => ast, table).missing).toEqual([]);
|
|
1207
1207
|
});
|
|
1208
1208
|
|
|
1209
|
-
test("the functions
|
|
1209
|
+
test("the 17 functions that were missing are found, with the table as it was", () => {
|
|
1210
1210
|
let names = ["name_form_control", "create_form_field", "item_li", "item_iconbar",
|
|
1211
1211
|
"build_toolbar_action_item", "build_toolbar_brand_item", "build_toolbar_avatar_item",
|
|
1212
1212
|
"build_toolbar_connection_item", "open_toolbar_dropdown", "build_dropdown_row",
|
|
@@ -1442,7 +1442,7 @@ describe("the reader the rule and the validator share", () => {
|
|
|
1442
1442
|
let whys = (r) => r.marker_errors.map((e) => `${e.line}: ${e.why}`);
|
|
1443
1443
|
let marked = (r, line) => r.marker_refs.find((ref) => ref.line === line).keys.sort();
|
|
1444
1444
|
|
|
1445
|
-
/* The
|
|
1445
|
+
/* The repro: a let table, a let array walked, a let read from one */
|
|
1446
1446
|
let r = scan([
|
|
1447
1447
|
`let LABELS = {a: "in it", b: "a brand new let-table key"};`,
|
|
1448
1448
|
`function f(k) { return t(/* i18n: X_I18N_KEYS */ LABELS[k]); }`,
|
|
@@ -1532,7 +1532,7 @@ describe("the data marker is a claim; DOM is no key; a translated text is no key
|
|
|
1532
1532
|
let scan = (lines) => scan_ast(parse_as([...head, ...lines].join("\n"), module), {lib_module: module});
|
|
1533
1533
|
let rule = (lines) => rule_report(parse_as([...head, ...lines].join("\n"), module), module);
|
|
1534
1534
|
|
|
1535
|
-
test("the
|
|
1535
|
+
test("the repro: a data marker on a call that returns a literal FAILS", () => {
|
|
1536
1536
|
let r = scan([
|
|
1537
1537
|
`function pick() { return "a literal behind a call"; }`,
|
|
1538
1538
|
`yui_shell_show_info(shell, /* i18n: data */ pick());`
|
|
@@ -1587,7 +1587,7 @@ describe("the data marker is a claim; DOM is no key; a translated text is no key
|
|
|
1587
1587
|
});
|
|
1588
1588
|
});
|
|
1589
1589
|
|
|
1590
|
-
describe("a
|
|
1590
|
+
describe("a repro, on the real module", () => {
|
|
1591
1591
|
let original = readFileSync(join(SRC, "c_yui_treedb_topics.js"), "utf8");
|
|
1592
1592
|
let call = `actions.push(card_action_anchor(\n "TREEDB_CARD_TABLE", "yi-table", "table", fill(routes.table)));`;
|
|
1593
1593
|
|
|
@@ -1635,8 +1635,8 @@ describe("a marker on a let does not let it pass unread", () => {
|
|
|
1635
1635
|
expect(original).toContain(use);
|
|
1636
1636
|
});
|
|
1637
1637
|
|
|
1638
|
-
test("the
|
|
1639
|
-
/* The let and its marker, as they were, plus
|
|
1638
|
+
test("the repro: a new literal branch on the marked let FAILS", () => {
|
|
1639
|
+
/* The let and its marker, as they were, plus a new branch */
|
|
1640
1640
|
let mutated = original
|
|
1641
1641
|
.replace(decl, ` let title = (mode === "clone")? "a brand new clone title" :\n` +
|
|
1642
1642
|
` (mode === "create")? "new" : ((mode === "view")? "view" : "edit");`)
|
|
@@ -1779,8 +1779,8 @@ describe("the published *_I18N_KEYS lists", () => {
|
|
|
1779
1779
|
test("the pin check fails when it should", () => {
|
|
1780
1780
|
let lists = all_lists();
|
|
1781
1781
|
|
|
1782
|
-
/* Without the coverage
|
|
1783
|
-
* pinned by nothing
|
|
1782
|
+
/* Without the coverage entries, the keys they pin are reported as
|
|
1783
|
+
* pinned by nothing, each one */
|
|
1784
1784
|
let added = ["C_YUI_FORM_I18N_KEYS", "FORM_JSON_FIELD_I18N_KEYS", "SHELL_ROUTE_MAP_I18N_KEYS",
|
|
1785
1785
|
"WIZARD_HELPERS_I18N_KEYS", "C_YUI_SCHEMA_EDITOR_I18N_KEYS"];
|
|
1786
1786
|
let report = unpinned_keys(lists, COVERAGE.filter((e) => !added.includes(e.list)));
|
|
@@ -1797,7 +1797,7 @@ describe("the published *_I18N_KEYS lists", () => {
|
|
|
1797
1797
|
expect(reported(name, key), `${name} ${key}`).toBe(true);
|
|
1798
1798
|
}
|
|
1799
1799
|
|
|
1800
|
-
/* ...and with it, the
|
|
1800
|
+
/* ...and with it, the repro -- a key dropped from its
|
|
1801
1801
|
* list -- fails the coverage of that list */
|
|
1802
1802
|
/* "app" (the route map's root when the app names no brand) is pinned
|
|
1803
1803
|
* twice since 7.26.29: the marker moved to the call of render_node()
|
|
@@ -1828,7 +1828,7 @@ describe("the published *_I18N_KEYS lists", () => {
|
|
|
1828
1828
|
]);
|
|
1829
1829
|
}
|
|
1830
1830
|
|
|
1831
|
-
/* The rest of the
|
|
1831
|
+
/* The rest of the 17 keys have no list any more: the
|
|
1832
1832
|
* module reads them where it writes them */
|
|
1833
1833
|
let reads = (module, key) => scan_of(module).read_keys.has(key);
|
|
1834
1834
|
for(let [module, key] of [
|
|
@@ -1882,7 +1882,7 @@ describe("a COVERAGE source is read the way the validator reads", () => {
|
|
|
1882
1882
|
let decl = `function field_validation_key($input)`;
|
|
1883
1883
|
let other_routes = ` if(Array.isArray(map.other) && map.other.length) {`;
|
|
1884
1884
|
|
|
1885
|
-
test("the
|
|
1885
|
+
test("the repro: a const the function returns, a const label it pushes -- each FAILS", () => {
|
|
1886
1886
|
let ast = mutated(form.module, [
|
|
1887
1887
|
[missing, ` if(v && v.typeMismatch) {\n return TYPE_MISMATCH_KEY;\n }\n${missing}`],
|
|
1888
1888
|
[decl, `const TYPE_MISMATCH_KEY = "a brand new type mismatch key";\n${decl}`]
|
|
@@ -1946,7 +1946,7 @@ describe("a recursive helper is read once, and never hangs the reader", () => {
|
|
|
1946
1946
|
let rule = (lines) => rule_report(parse_as([...head, ...lines].join("\n"), module), module);
|
|
1947
1947
|
let scan = (lines) => scan_ast(parse_as([...head, ...lines].join("\n"), module), {lib_module: module});
|
|
1948
1948
|
|
|
1949
|
-
/* The
|
|
1949
|
+
/* The case that hung, verbatim: 7.26.28 read it in 12 ms, 7.26.29 in
|
|
1950
1950
|
* more than two minutes (x3 per level of MAX_DEPTH), and with three
|
|
1951
1951
|
* recursive ifs it never ended */
|
|
1952
1952
|
let label_of = (branches) => [
|
|
@@ -1958,7 +1958,7 @@ describe("a recursive helper is read once, and never hangs the reader", () => {
|
|
|
1958
1958
|
`}`
|
|
1959
1959
|
];
|
|
1960
1960
|
|
|
1961
|
-
test("the
|
|
1961
|
+
test("the case that hung (two and three recursive branches): fast, and `n.name` is data", () => {
|
|
1962
1962
|
for(let branches of [2, 3]) {
|
|
1963
1963
|
let t0 = Date.now();
|
|
1964
1964
|
let lines = [...label_of(branches),
|
|
@@ -2316,7 +2316,7 @@ describe("every write counts; a translated text fails unmarked too; the callback
|
|
|
2316
2316
|
/* Each body gives `key` the sentinel "-" and then a value the reader
|
|
2317
2317
|
* does not read: up to 7.26.41 the eight first asked for "-" */
|
|
2318
2318
|
let writes = [
|
|
2319
|
-
`for([key, label] of rows) { el.setAttribute("data-i18n", key); }`, // the
|
|
2319
|
+
`for([key, label] of rows) { el.setAttribute("data-i18n", key); }`, // the probe
|
|
2320
2320
|
`for({key} of rows) { t(key); }`,
|
|
2321
2321
|
`for({k: key = "d"} of rows) { t(key); }`,
|
|
2322
2322
|
`for([key] in obj) { t(key); }`,
|
|
@@ -1596,7 +1596,7 @@ describe("the body while a write is in flight", () => {
|
|
|
1596
1596
|
* and Delete or Enter there sent an action ST_SAVING does not
|
|
1597
1597
|
* declare. `inert` takes the body out of the keyboard's reach too. */
|
|
1598
1598
|
test("is inert, and answers again when the write ends", () => {
|
|
1599
|
-
const {editor, remote, host} = build("
|
|
1599
|
+
const {editor, remote, host} = build("inert1", "db/users");
|
|
1600
1600
|
const $body = $in(editor, ".SCHEMA_BODY");
|
|
1601
1601
|
expect($body.hasAttribute("inert")).toBe(false);
|
|
1602
1602
|
|
|
@@ -1610,7 +1610,7 @@ describe("the body while a write is in flight", () => {
|
|
|
1610
1610
|
});
|
|
1611
1611
|
|
|
1612
1612
|
test("a drop that ends the write gives the body back too", () => {
|
|
1613
|
-
const {editor, remote, host} = build("
|
|
1613
|
+
const {editor, remote, host} = build("inert2", "db/users");
|
|
1614
1614
|
start_a_write(editor, host, "name");
|
|
1615
1615
|
drop(editor, remote, host);
|
|
1616
1616
|
expect($in(editor, ".SCHEMA_BODY").hasAttribute("inert")).toBe(false);
|
|
@@ -1671,7 +1671,7 @@ describe("the writes of an import mark the topic they write", () => {
|
|
|
1671
1671
|
}
|
|
1672
1672
|
|
|
1673
1673
|
test("from another topic's screen: the topic it wrote, not the one on screen", () => {
|
|
1674
|
-
const {editor, remote, host} = build("
|
|
1674
|
+
const {editor, remote, host} = build("wrote1", "db/users");
|
|
1675
1675
|
run_the_import(editor, host);
|
|
1676
1676
|
answer_every_write(editor, remote);
|
|
1677
1677
|
expect(gobj_current_state(editor)).toBe("ST_COLUMNS");
|
|
@@ -1680,7 +1680,7 @@ describe("the writes of an import mark the topic they write", () => {
|
|
|
1680
1680
|
});
|
|
1681
1681
|
|
|
1682
1682
|
test("from the topics screen, where no topic is on screen", () => {
|
|
1683
|
-
const {editor, remote, host} = build("
|
|
1683
|
+
const {editor, remote, host} = build("wrote2", "db");
|
|
1684
1684
|
run_the_import(editor, host);
|
|
1685
1685
|
answer_every_write(editor, remote);
|
|
1686
1686
|
expect(gobj_current_state(editor)).toBe("ST_TOPICS");
|
|
@@ -1689,7 +1689,7 @@ describe("the writes of an import mark the topic they write", () => {
|
|
|
1689
1689
|
});
|
|
1690
1690
|
|
|
1691
1691
|
test("a column answered with no record: the record it queued says the topic", () => {
|
|
1692
|
-
const {editor, remote, host} = build("
|
|
1692
|
+
const {editor, remote, host} = build("wrote3", "db/users");
|
|
1693
1693
|
run_the_import(editor, host);
|
|
1694
1694
|
const [topic] = take("update-node");
|
|
1695
1695
|
expect(topic.kw.topic_name).toBe("topics");
|
|
@@ -1704,10 +1704,10 @@ describe("the writes of an import mark the topic they write", () => {
|
|
|
1704
1704
|
describe("the reason a load failed", () => {
|
|
1705
1705
|
|
|
1706
1706
|
test("is a key the notice translates, not a string frozen in one language", () => {
|
|
1707
|
-
const remote = gobj_create_service("
|
|
1707
|
+
const remote = gobj_create_service("lfail1_remote", "C_TEST_REMOTE", {}, yuno);
|
|
1708
1708
|
gobj_change_state(remote, "ST_SESSION");
|
|
1709
|
-
const host = gobj_create("
|
|
1710
|
-
const editor = gobj_create("
|
|
1709
|
+
const host = gobj_create("lfail1_host", "C_TEST_EDITOR_HOST", {}, yuno);
|
|
1710
|
+
const editor = gobj_create("lfail1_editor", "C_YUI_SCHEMA_EDITOR", {
|
|
1711
1711
|
gobj_remote_yuno: remote, treedb_name: "treedb_system_schema"
|
|
1712
1712
|
}, host);
|
|
1713
1713
|
gobj_start(editor);
|
|
@@ -1721,10 +1721,10 @@ describe("the reason a load failed", () => {
|
|
|
1721
1721
|
});
|
|
1722
1722
|
|
|
1723
1723
|
test("the backend's own words travel as its key", () => {
|
|
1724
|
-
const remote = gobj_create_service("
|
|
1724
|
+
const remote = gobj_create_service("lfail2_remote", "C_TEST_REMOTE", {}, yuno);
|
|
1725
1725
|
gobj_change_state(remote, "ST_SESSION");
|
|
1726
|
-
const host = gobj_create("
|
|
1727
|
-
const editor = gobj_create("
|
|
1726
|
+
const host = gobj_create("lfail2_host", "C_TEST_EDITOR_HOST", {}, yuno);
|
|
1727
|
+
const editor = gobj_create("lfail2_editor", "C_YUI_SCHEMA_EDITOR", {
|
|
1728
1728
|
gobj_remote_yuno: remote, treedb_name: "treedb_system_schema"
|
|
1729
1729
|
}, host);
|
|
1730
1730
|
gobj_start(editor);
|
|
@@ -1736,9 +1736,9 @@ describe("the reason a load failed", () => {
|
|
|
1736
1736
|
});
|
|
1737
1737
|
|
|
1738
1738
|
test("a load that cannot leave keeps its key", () => {
|
|
1739
|
-
const remote = gobj_create_service("
|
|
1740
|
-
const host = gobj_create("
|
|
1741
|
-
const editor = gobj_create("
|
|
1739
|
+
const remote = gobj_create_service("lfail3_remote", "C_TEST_REMOTE", {}, yuno);
|
|
1740
|
+
const host = gobj_create("lfail3_host", "C_TEST_EDITOR_HOST", {}, yuno);
|
|
1741
|
+
const editor = gobj_create("lfail3_editor", "C_YUI_SCHEMA_EDITOR", {
|
|
1742
1742
|
gobj_remote_yuno: remote, treedb_name: "treedb_system_schema"
|
|
1743
1743
|
}, host);
|
|
1744
1744
|
gobj_start(editor);
|
|
@@ -115,7 +115,7 @@ let yuno = null;
|
|
|
115
115
|
let host = null;
|
|
116
116
|
let seq = 0;
|
|
117
117
|
|
|
118
|
-
/*
|
|
118
|
+
/* Names that broke the selector, and the old one with a dot. */
|
|
119
119
|
const NAMES = [
|
|
120
120
|
"local~gate", /* gui_agent 0.29.106: node~key */
|
|
121
121
|
"n~x%5Ey", /* a `^` in the key, encoded */
|
package/src/treedb_fold_model.js
CHANGED
|
@@ -5,8 +5,8 @@
|
|
|
5
5
|
*
|
|
6
6
|
* A treedb is a graph: a record hangs from every parent one of its
|
|
7
7
|
* fkeys names, and a parent reaches its children through a hook.
|
|
8
|
-
* Drawn whole it is a pile -- a
|
|
9
|
-
*
|
|
8
|
+
* Drawn whole it is a pile -- a site with two hundred devices is
|
|
9
|
+
* a row of two hundred cards -- so the graph
|
|
10
10
|
* opens FOLDED, the way a JSON viewer opens: the roots, a level or
|
|
11
11
|
* two under them, and a count on every cut saying what went with it.
|
|
12
12
|
*
|
|
@@ -52,7 +52,7 @@ const devices_desc = {
|
|
|
52
52
|
{id: "id", flag: []},
|
|
53
53
|
{id: "place", flag: ["fkey"], fkey: {places: "devices"}},
|
|
54
54
|
{id: "controller", flag: ["fkey"], fkey: {controllers: "devices"}},
|
|
55
|
-
{id: "
|
|
55
|
+
{id: "photo", flag: ["fkey", "file"], fkey: {__assets__: "photos"}},
|
|
56
56
|
],
|
|
57
57
|
};
|
|
58
58
|
const controllers_desc = {
|
|
@@ -88,13 +88,13 @@ const descs = {
|
|
|
88
88
|
device_groups: groups_desc,
|
|
89
89
|
};
|
|
90
90
|
|
|
91
|
-
/*
|
|
91
|
+
/* region > (north, south); north > site1; site1 has 30 devices and one
|
|
92
92
|
* controller c1 that also reaches devices d0..d9. */
|
|
93
93
|
function make_records(n_devices)
|
|
94
94
|
{
|
|
95
95
|
let devices = [];
|
|
96
96
|
for(let i = 0; i < n_devices; i++) {
|
|
97
|
-
let rec = {id: `d${i}`, place: "places^
|
|
97
|
+
let rec = {id: `d${i}`, place: "places^site1^devices", photo: "x^y^photos"};
|
|
98
98
|
if(i < 10) {
|
|
99
99
|
rec.controller = ["controllers^c1^devices"];
|
|
100
100
|
}
|
|
@@ -102,13 +102,13 @@ function make_records(n_devices)
|
|
|
102
102
|
}
|
|
103
103
|
return {
|
|
104
104
|
places: [
|
|
105
|
-
{id: "
|
|
106
|
-
{id: "
|
|
107
|
-
{id: "
|
|
108
|
-
{id: "
|
|
105
|
+
{id: "region", place: ""},
|
|
106
|
+
{id: "north", place: "places^region^places"},
|
|
107
|
+
{id: "south", place: "places^region^places"},
|
|
108
|
+
{id: "site1", place: "places^north^places"},
|
|
109
109
|
],
|
|
110
110
|
devices: devices,
|
|
111
|
-
controllers: [{id: "c1", place: "places^
|
|
111
|
+
controllers: [{id: "c1", place: "places^site1^controllers"}],
|
|
112
112
|
device_groups: [{id: "g1"}],
|
|
113
113
|
};
|
|
114
114
|
}
|
|
@@ -124,9 +124,9 @@ describe("the model", () => {
|
|
|
124
124
|
|
|
125
125
|
test("children hang from the hook the fkey names, in record order", () => {
|
|
126
126
|
let m = fold_build_model(descs, make_records(3));
|
|
127
|
-
expect(m.groups.get(fold_group_key(K("places", "
|
|
128
|
-
.toEqual([K("places", "
|
|
129
|
-
expect(m.groups.get(fold_group_key(K("places", "
|
|
127
|
+
expect(m.groups.get(fold_group_key(K("places", "region"), "places")))
|
|
128
|
+
.toEqual([K("places", "north"), K("places", "south")]);
|
|
129
|
+
expect(m.groups.get(fold_group_key(K("places", "site1"), "devices")))
|
|
130
130
|
.toEqual([K("devices", "d0"), K("devices", "d1"), K("devices", "d2")]);
|
|
131
131
|
expect(m.groups.get(fold_group_key(K("controllers", "c1"), "devices")))
|
|
132
132
|
.toEqual([K("devices", "d0"), K("devices", "d1"), K("devices", "d2")]);
|
|
@@ -136,14 +136,14 @@ describe("the model", () => {
|
|
|
136
136
|
let m = fold_build_model(descs, make_records(3));
|
|
137
137
|
let d0 = m.nodes.get(K("devices", "d0"));
|
|
138
138
|
expect(d0.parents.map((p) => p.node_key).sort())
|
|
139
|
-
.toEqual([K("controllers", "c1"), K("places", "
|
|
139
|
+
.toEqual([K("controllers", "c1"), K("places", "site1")]);
|
|
140
140
|
});
|
|
141
141
|
|
|
142
142
|
test("roots: no drawable parent -- and a fkey into a topic nobody fetched is not a parent", () => {
|
|
143
143
|
let m = fold_build_model(descs, make_records(3));
|
|
144
|
-
expect(m.groups.get(fold_root_group_key("places"))).toEqual([K("places", "
|
|
144
|
+
expect(m.groups.get(fold_root_group_key("places"))).toEqual([K("places", "region")]);
|
|
145
145
|
expect(m.groups.get(fold_root_group_key("devices"))).toBeUndefined();
|
|
146
|
-
/* `
|
|
146
|
+
/* `photo` names __assets__, which has no desc: ignored */
|
|
147
147
|
expect(m.nodes.get(K("devices", "d0")).parents.length).toBe(2);
|
|
148
148
|
expect(m.groups.get(fold_root_group_key("device_groups"))).toEqual([K("device_groups", "g1")]);
|
|
149
149
|
});
|
|
@@ -181,8 +181,8 @@ describe("the model", () => {
|
|
|
181
181
|
});
|
|
182
182
|
|
|
183
183
|
test("group keys split back", () => {
|
|
184
|
-
expect(fold_split_group_key("places^
|
|
185
|
-
.toEqual({node_key: "places^
|
|
184
|
+
expect(fold_split_group_key("places^site1|devices"))
|
|
185
|
+
.toEqual({node_key: "places^site1", hook: "devices"});
|
|
186
186
|
expect(fold_split_group_key("|devices")).toEqual({node_key: "", hook: "devices"});
|
|
187
187
|
expect(fold_split_group_key("nope")).toBeNull();
|
|
188
188
|
});
|
|
@@ -238,7 +238,7 @@ describe("main topic, hidden topics, loose records", () => {
|
|
|
238
238
|
expect(m.main_topic).toBe("controllers");
|
|
239
239
|
expect([...m.linked].sort()).toEqual(["controllers", "devices"]);
|
|
240
240
|
/* places is not linked to controllers, so its roots are roots */
|
|
241
|
-
expect(m.groups.get(fold_root_group_key("places"))).toEqual([K("places", "
|
|
241
|
+
expect(m.groups.get(fold_root_group_key("places"))).toEqual([K("places", "region")]);
|
|
242
242
|
/* a pick the rule refuses is ignored, and the trunk is deduced */
|
|
243
243
|
let m2 = fold_build_model(descs, make_records(3), {main_topic: "controllers"});
|
|
244
244
|
expect(m2.main_topic).toBe("places");
|
|
@@ -275,15 +275,15 @@ describe("main topic, hidden topics, loose records", () => {
|
|
|
275
275
|
let m = fold_build_model(descs, make_records(30), {hidden_topics: ["devices"]});
|
|
276
276
|
expect(m.topics).toEqual(["places", "controllers", "device_groups"]);
|
|
277
277
|
expect(m.totals.devices).toBe(30);
|
|
278
|
-
expect(m.nodes.get(K("places", "
|
|
279
|
-
expect(fold_pills_of(m, fold_new_state(24), K("places", "
|
|
278
|
+
expect(m.nodes.get(K("places", "site1")).hooks.devices).toBeUndefined();
|
|
279
|
+
expect(fold_pills_of(m, fold_new_state(24), K("places", "site1")).map((p) => p.hook))
|
|
280
280
|
.toEqual(["controllers"]);
|
|
281
281
|
expect(m.hidden.has("devices")).toBe(true);
|
|
282
282
|
});
|
|
283
283
|
|
|
284
284
|
test("hiding a topic in the middle: what hung from it alone becomes loose", () => {
|
|
285
285
|
let m = fold_build_model(descs, make_records(12), {hidden_topics: ["controllers"]});
|
|
286
|
-
/* d0..d9 hang from
|
|
286
|
+
/* d0..d9 hang from site1 AND c1: still under site1 */
|
|
287
287
|
expect(m.nodes.get(K("devices", "d0")).parents.length).toBe(1);
|
|
288
288
|
expect(m.loose.devices).toEqual([]);
|
|
289
289
|
/* places hidden = the main topic gone: nothing governs, and
|
|
@@ -313,7 +313,7 @@ describe("main topic, hidden topics, loose records", () => {
|
|
|
313
313
|
let st = fold_new_state(24);
|
|
314
314
|
let m = fold_build_model(descs, recs);
|
|
315
315
|
fold_expand_to_depth(m, st, 4);
|
|
316
|
-
let g = fold_group_key(K("places", "
|
|
316
|
+
let g = fold_group_key(K("places", "site1"), "devices");
|
|
317
317
|
expect(fold_group_shown(m, st, g)).toBe(24);
|
|
318
318
|
let m_hidden = fold_build_model(descs, recs, {hidden_topics: ["devices"]});
|
|
319
319
|
expect(fold_group_shown(m_hidden, st, g)).toBe(0); /* no group: nothing shown */
|
|
@@ -328,7 +328,7 @@ describe("depth", () => {
|
|
|
328
328
|
let st = fold_new_state(24);
|
|
329
329
|
fold_expand_to_depth(m, st, 1);
|
|
330
330
|
expect([...fold_visible_set(m, st)].sort())
|
|
331
|
-
.toEqual([K("device_groups", "g1"), K("places", "
|
|
331
|
+
.toEqual([K("device_groups", "g1"), K("places", "region")]);
|
|
332
332
|
});
|
|
333
333
|
|
|
334
334
|
test("depth 2 opens the roots' hooks on their first page", () => {
|
|
@@ -336,9 +336,9 @@ describe("depth", () => {
|
|
|
336
336
|
let st = fold_new_state(24);
|
|
337
337
|
fold_expand_to_depth(m, st, 2);
|
|
338
338
|
let v = fold_visible_set(m, st);
|
|
339
|
-
expect(v.has(K("places", "
|
|
340
|
-
expect(v.has(K("places", "
|
|
341
|
-
expect(v.has(K("places", "
|
|
339
|
+
expect(v.has(K("places", "north"))).toBe(true);
|
|
340
|
+
expect(v.has(K("places", "south"))).toBe(true);
|
|
341
|
+
expect(v.has(K("places", "site1"))).toBe(false);
|
|
342
342
|
expect(v.has(K("devices", "d0"))).toBe(false);
|
|
343
343
|
});
|
|
344
344
|
|
|
@@ -366,11 +366,11 @@ describe("depth", () => {
|
|
|
366
366
|
describe("levels of the main tree (the toolbar's stepper)", () => {
|
|
367
367
|
test("levels count from the main topic's roots, down every hook", () => {
|
|
368
368
|
let m = fold_build_model(descs, make_records(30));
|
|
369
|
-
/*
|
|
369
|
+
/* region 1, north/south 2, site1 3, its devices and c1 4 */
|
|
370
370
|
expect(m.levels).toBe(4);
|
|
371
|
-
expect(m.level_of.get(K("places", "
|
|
372
|
-
expect(m.level_of.get(K("places", "
|
|
373
|
-
/* d0 hangs from
|
|
371
|
+
expect(m.level_of.get(K("places", "region"))).toBe(1);
|
|
372
|
+
expect(m.level_of.get(K("places", "site1"))).toBe(3);
|
|
373
|
+
/* d0 hangs from site1 (3) and c1 (4): the shallowest wins */
|
|
374
374
|
expect(m.level_of.get(K("devices", "d0"))).toBe(4);
|
|
375
375
|
/* device_groups is not tied to places: a tree of its own, no level */
|
|
376
376
|
expect(m.level_of.has(K("device_groups", "g1"))).toBe(false);
|
|
@@ -397,13 +397,13 @@ describe("levels of the main tree (the toolbar's stepper)", () => {
|
|
|
397
397
|
let st = fold_new_state(24);
|
|
398
398
|
fold_expand_to_level(m, st, 1);
|
|
399
399
|
expect([...fold_visible_set(m, st)].sort())
|
|
400
|
-
.toEqual([K("device_groups", "g1"), K("places", "
|
|
400
|
+
.toEqual([K("device_groups", "g1"), K("places", "region")]);
|
|
401
401
|
fold_open_levels(m, st, 2);
|
|
402
402
|
let v = fold_visible_set(m, st);
|
|
403
|
-
expect(v.has(K("places", "
|
|
404
|
-
expect(v.has(K("places", "
|
|
403
|
+
expect(v.has(K("places", "north"))).toBe(true);
|
|
404
|
+
expect(v.has(K("places", "site1"))).toBe(false);
|
|
405
405
|
fold_open_levels(m, st, 3);
|
|
406
|
-
expect(fold_visible_set(m, st).has(K("places", "
|
|
406
|
+
expect(fold_visible_set(m, st).has(K("places", "site1"))).toBe(true);
|
|
407
407
|
expect(fold_visible_set(m, st).has(K("devices", "d0"))).toBe(false);
|
|
408
408
|
fold_open_levels(m, st, 4);
|
|
409
409
|
v = fold_visible_set(m, st);
|
|
@@ -416,25 +416,25 @@ describe("levels of the main tree (the toolbar's stepper)", () => {
|
|
|
416
416
|
let m = fold_build_model(descs, make_records(30));
|
|
417
417
|
let st = fold_new_state(24);
|
|
418
418
|
fold_expand_to_level(m, st, 4);
|
|
419
|
-
let g = fold_group_key(K("places", "
|
|
419
|
+
let g = fold_group_key(K("places", "site1"), "devices");
|
|
420
420
|
fold_show_more(m, st, g); /* 30 */
|
|
421
421
|
fold_open_levels(m, st, 4);
|
|
422
422
|
expect(fold_group_shown(m, st, g)).toBe(30);
|
|
423
423
|
fold_close_levels(m, st, 3);
|
|
424
424
|
let v = fold_visible_set(m, st);
|
|
425
|
-
expect(v.has(K("places", "
|
|
425
|
+
expect(v.has(K("places", "site1"))).toBe(true); /* level 3 stays */
|
|
426
426
|
expect(v.has(K("devices", "d0"))).toBe(false); /* its hooks folded */
|
|
427
427
|
expect(v.has(K("controllers", "c1"))).toBe(false);
|
|
428
|
-
expect(fold_is_open(st, fold_group_key(K("places", "
|
|
428
|
+
expect(fold_is_open(st, fold_group_key(K("places", "north"), "places"))).toBe(true);
|
|
429
429
|
});
|
|
430
430
|
|
|
431
431
|
test("closing does not reopen what the reader folded above the level", () => {
|
|
432
432
|
let m = fold_build_model(descs, make_records(3));
|
|
433
433
|
let st = fold_new_state(24);
|
|
434
434
|
fold_expand_to_level(m, st, 4);
|
|
435
|
-
fold_toggle(m, st, fold_group_key(K("places", "
|
|
435
|
+
fold_toggle(m, st, fold_group_key(K("places", "region"), "places")); /* fold region */
|
|
436
436
|
fold_close_levels(m, st, 3);
|
|
437
|
-
expect(fold_is_open(st, fold_group_key(K("places", "
|
|
437
|
+
expect(fold_is_open(st, fold_group_key(K("places", "region"), "places"))).toBe(false);
|
|
438
438
|
});
|
|
439
439
|
});
|
|
440
440
|
|
|
@@ -443,7 +443,7 @@ describe("toggle and pages", () => {
|
|
|
443
443
|
let m = fold_build_model(descs, make_records(30));
|
|
444
444
|
let st = fold_new_state(24);
|
|
445
445
|
fold_expand_to_depth(m, st, 3);
|
|
446
|
-
let g = fold_group_key(K("places", "
|
|
446
|
+
let g = fold_group_key(K("places", "site1"), "devices");
|
|
447
447
|
expect(fold_toggle(m, st, g)).toBe(true);
|
|
448
448
|
expect(fold_visible_set(m, st).has(K("devices", "d5"))).toBe(true);
|
|
449
449
|
expect(fold_toggle(m, st, g)).toBe(false);
|
|
@@ -453,7 +453,7 @@ describe("toggle and pages", () => {
|
|
|
453
453
|
test("show more adds a page and stops at the total", () => {
|
|
454
454
|
let m = fold_build_model(descs, make_records(30));
|
|
455
455
|
let st = fold_new_state(24);
|
|
456
|
-
let g = fold_group_key(K("places", "
|
|
456
|
+
let g = fold_group_key(K("places", "site1"), "devices");
|
|
457
457
|
expect(fold_show_more(m, st, g)).toBe(24);
|
|
458
458
|
expect(fold_show_more(m, st, g)).toBe(30);
|
|
459
459
|
expect(fold_show_more(m, st, g)).toBe(30);
|
|
@@ -463,11 +463,11 @@ describe("toggle and pages", () => {
|
|
|
463
463
|
let m = fold_build_model(descs, make_records(30));
|
|
464
464
|
let st = fold_new_state(24);
|
|
465
465
|
fold_expand_to_depth(m, st, 4);
|
|
466
|
-
fold_toggle(m, st, fold_group_key(K("places", "
|
|
466
|
+
fold_toggle(m, st, fold_group_key(K("places", "region"), "places")); /* close */
|
|
467
467
|
let v = fold_visible_set(m, st);
|
|
468
468
|
expect(v.has(K("devices", "d0"))).toBe(false);
|
|
469
469
|
expect(v.size).toBe(2);
|
|
470
|
-
fold_toggle(m, st, fold_group_key(K("places", "
|
|
470
|
+
fold_toggle(m, st, fold_group_key(K("places", "region"), "places")); /* reopen */
|
|
471
471
|
expect(fold_visible_set(m, st).has(K("devices", "d0"))).toBe(true);
|
|
472
472
|
});
|
|
473
473
|
|
|
@@ -475,13 +475,13 @@ describe("toggle and pages", () => {
|
|
|
475
475
|
let m = fold_build_model(descs, make_records(30));
|
|
476
476
|
let st = fold_new_state(24);
|
|
477
477
|
fold_expand_to_depth(m, st, 4);
|
|
478
|
-
let g_place = fold_group_key(K("places", "
|
|
478
|
+
let g_place = fold_group_key(K("places", "site1"), "devices");
|
|
479
479
|
let g_ctrl = fold_group_key(K("controllers", "c1"), "devices");
|
|
480
480
|
fold_toggle(m, st, g_ctrl); /* c1's devices open too */
|
|
481
|
-
fold_toggle(m, st, g_place); /*
|
|
481
|
+
fold_toggle(m, st, g_place); /* site1's devices folded */
|
|
482
482
|
let v = fold_visible_set(m, st);
|
|
483
483
|
expect(v.has(K("devices", "d3"))).toBe(true); /* via c1 */
|
|
484
|
-
expect(v.has(K("devices", "d15"))).toBe(false); /* only via
|
|
484
|
+
expect(v.has(K("devices", "d15"))).toBe(false); /* only via site1 */
|
|
485
485
|
});
|
|
486
486
|
|
|
487
487
|
test("pending groups: what the +N chips are for", () => {
|
|
@@ -492,8 +492,8 @@ describe("toggle and pages", () => {
|
|
|
492
492
|
let pending = fold_pending_groups(m, st, v);
|
|
493
493
|
expect(pending.length).toBe(1);
|
|
494
494
|
expect(pending[0]).toMatchObject({
|
|
495
|
-
group_key: fold_group_key(K("places", "
|
|
496
|
-
node_key: K("places", "
|
|
495
|
+
group_key: fold_group_key(K("places", "site1"), "devices"),
|
|
496
|
+
node_key: K("places", "site1"), hook: "devices",
|
|
497
497
|
shown: 24, total: 30, rest: 6,
|
|
498
498
|
});
|
|
499
499
|
});
|
|
@@ -502,11 +502,11 @@ describe("toggle and pages", () => {
|
|
|
502
502
|
let m = fold_build_model(descs, make_records(30));
|
|
503
503
|
let st = fold_new_state(24);
|
|
504
504
|
fold_expand_to_depth(m, st, 4);
|
|
505
|
-
let pills = fold_pills_of(m, st, K("places", "
|
|
505
|
+
let pills = fold_pills_of(m, st, K("places", "site1"));
|
|
506
506
|
expect(pills.map((p) => p.hook)).toEqual(["devices", "controllers"]);
|
|
507
507
|
expect(pills[0]).toMatchObject({total: 30, shown: 24, open: true, child_topic: "devices"});
|
|
508
508
|
expect(pills[1]).toMatchObject({total: 1, shown: 1, open: true, child_topic: "controllers"});
|
|
509
|
-
expect(fold_pills_of(m, st, K("places", "
|
|
509
|
+
expect(fold_pills_of(m, st, K("places", "south"))).toEqual([]);
|
|
510
510
|
});
|
|
511
511
|
});
|
|
512
512
|
|
|
@@ -521,14 +521,14 @@ describe("reveal", () => {
|
|
|
521
521
|
/* d40 is the 41st: two pages, not three, and not all */
|
|
522
522
|
expect(v.has(K("devices", "d47"))).toBe(true);
|
|
523
523
|
expect(v.has(K("devices", "d48"))).toBe(false);
|
|
524
|
-
expect(v.has(K("places", "
|
|
524
|
+
expect(v.has(K("places", "south"))).toBe(true); /* region|places opened whole page */
|
|
525
525
|
});
|
|
526
526
|
|
|
527
527
|
test("does not close what was open", () => {
|
|
528
528
|
let m = fold_build_model(descs, make_records(60));
|
|
529
529
|
let st = fold_new_state(24);
|
|
530
530
|
fold_expand_to_depth(m, st, 4);
|
|
531
|
-
fold_show_more(m, st, fold_group_key(K("places", "
|
|
531
|
+
fold_show_more(m, st, fold_group_key(K("places", "site1"), "devices")); /* 48 */
|
|
532
532
|
fold_reveal(m, st, K("devices", "d3"));
|
|
533
533
|
expect(fold_visible_set(m, st).has(K("devices", "d47"))).toBe(true);
|
|
534
534
|
});
|
|
@@ -8,40 +8,40 @@
|
|
|
8
8
|
import { describe, test, expect } from "vitest";
|
|
9
9
|
import { spanning_tree, layout_tree, layout_radial } from "./treedb_layout.js";
|
|
10
10
|
|
|
11
|
-
/*
|
|
11
|
+
/* region -> (north, south); north -> site; site -> d0, d1 (hook rank 1) and
|
|
12
12
|
* c1 (hook rank 2); c1 -> d0 as well (second parent). */
|
|
13
13
|
const N = (id, w, h) => ({id, w, h});
|
|
14
14
|
const nodes = [
|
|
15
|
-
N("
|
|
15
|
+
N("region", 172, 96), N("north", 172, 96), N("south", 172, 96), N("site", 172, 120),
|
|
16
16
|
N("d0", 116, 40), N("d1", 116, 40), N("c1", 172, 96),
|
|
17
17
|
];
|
|
18
18
|
const edges = [
|
|
19
|
-
{source: "
|
|
20
|
-
{source: "
|
|
21
|
-
{source: "
|
|
22
|
-
{source: "
|
|
23
|
-
{source: "
|
|
24
|
-
{source: "
|
|
19
|
+
{source: "region", target: "north", rank: 0},
|
|
20
|
+
{source: "region", target: "south", rank: 0},
|
|
21
|
+
{source: "north", target: "site", rank: 0},
|
|
22
|
+
{source: "site", target: "c1", rank: 2},
|
|
23
|
+
{source: "site", target: "d0", rank: 1},
|
|
24
|
+
{source: "site", target: "d1", rank: 1},
|
|
25
25
|
{source: "c1", target: "d0", rank: 0},
|
|
26
26
|
];
|
|
27
27
|
|
|
28
28
|
describe("the spanning tree", () => {
|
|
29
29
|
test("roots are the nodes with no incoming edge, in node order", () => {
|
|
30
30
|
let t = spanning_tree(nodes, edges);
|
|
31
|
-
expect(t.roots).toEqual(["
|
|
32
|
-
expect(t.depth.get("
|
|
31
|
+
expect(t.roots).toEqual(["region"]);
|
|
32
|
+
expect(t.depth.get("site")).toBe(2);
|
|
33
33
|
expect(t.depth.get("d0")).toBe(3);
|
|
34
34
|
});
|
|
35
35
|
|
|
36
36
|
test("children are ordered by hook rank, then by node order", () => {
|
|
37
37
|
let t = spanning_tree(nodes, edges);
|
|
38
|
-
expect(t.children.get("
|
|
39
|
-
expect(t.children.get("
|
|
38
|
+
expect(t.children.get("site")).toEqual(["d0", "d1", "c1"]);
|
|
39
|
+
expect(t.children.get("region")).toEqual(["north", "south"]);
|
|
40
40
|
});
|
|
41
41
|
|
|
42
42
|
test("a node with two parents belongs to the first that reaches it", () => {
|
|
43
43
|
let t = spanning_tree(nodes, edges);
|
|
44
|
-
expect(t.children.get("c1")).toEqual([]); /* d0 is
|
|
44
|
+
expect(t.children.get("c1")).toEqual([]); /* d0 is site's */
|
|
45
45
|
expect(t.depth.get("d0")).toBe(3);
|
|
46
46
|
});
|
|
47
47
|
|
|
@@ -66,11 +66,11 @@ describe("the spanning tree", () => {
|
|
|
66
66
|
describe("the tidy tree, read down (the default)", () => {
|
|
67
67
|
test("depths are rows; a row is as tall as its tallest card", () => {
|
|
68
68
|
let pos = layout_tree(nodes, edges, {nodesep: 10, ranksep: 100});
|
|
69
|
-
expect(pos.get("
|
|
70
|
-
expect(pos.get("
|
|
71
|
-
expect(pos.get("
|
|
72
|
-
/* depth 2 holds
|
|
73
|
-
expect(pos.get("
|
|
69
|
+
expect(pos.get("region").y).toBe(48); /* 96/2 */
|
|
70
|
+
expect(pos.get("north").y).toBe(96 + 100 + 48);
|
|
71
|
+
expect(pos.get("south").y).toBe(pos.get("north").y);
|
|
72
|
+
/* depth 2 holds site (120 tall): the row is 120 tall */
|
|
73
|
+
expect(pos.get("site").y).toBe(2 * (96 + 100) + 60);
|
|
74
74
|
/* depth 3 holds chips (40) and c1 (96): row is 96 tall, the
|
|
75
75
|
* chips are centred in it */
|
|
76
76
|
let row3 = 2 * (96 + 100) + 120 + 100;
|
|
@@ -80,12 +80,12 @@ describe("the tidy tree, read down (the default)", () => {
|
|
|
80
80
|
|
|
81
81
|
test("siblings sit side by side; a parent is centred over its children", () => {
|
|
82
82
|
let pos = layout_tree(nodes, edges, {nodesep: 10, ranksep: 100});
|
|
83
|
-
/*
|
|
83
|
+
/* site's children: d0 (116), d1 (116), c1 (172) = 424 wide */
|
|
84
84
|
expect(pos.get("d1").x - pos.get("d0").x).toBe(126);
|
|
85
85
|
expect(pos.get("c1").x - pos.get("d1").x).toBe(58 + 10 + 86);
|
|
86
86
|
let first = pos.get("d0").x - 58;
|
|
87
87
|
let last = pos.get("c1").x + 86;
|
|
88
|
-
expect(pos.get("
|
|
88
|
+
expect(pos.get("site").x).toBe((first + last) / 2);
|
|
89
89
|
});
|
|
90
90
|
|
|
91
91
|
test("two trees sit side by side, not overlapped", () => {
|
|
@@ -100,9 +100,9 @@ describe("the tidy tree, read down (the default)", () => {
|
|
|
100
100
|
describe("the tidy tree, read right", () => {
|
|
101
101
|
test("depths are columns; a column is as wide as its widest card", () => {
|
|
102
102
|
let pos = layout_tree(nodes, edges, {nodesep: 10, ranksep: 100, direction: "LR"});
|
|
103
|
-
expect(pos.get("
|
|
104
|
-
expect(pos.get("
|
|
105
|
-
expect(pos.get("
|
|
103
|
+
expect(pos.get("region").x).toBe(86); /* 172/2 */
|
|
104
|
+
expect(pos.get("north").x).toBe(172 + 100 + 86);
|
|
105
|
+
expect(pos.get("south").x).toBe(pos.get("north").x);
|
|
106
106
|
/* depth 3 holds chips (116) and c1 (172): column is 172 wide,
|
|
107
107
|
* the chips are centred in it */
|
|
108
108
|
let col3 = 3 * (172 + 100);
|
|
@@ -112,12 +112,12 @@ describe("the tidy tree, read right", () => {
|
|
|
112
112
|
|
|
113
113
|
test("siblings stack with the gap; a parent is centred on its children", () => {
|
|
114
114
|
let pos = layout_tree(nodes, edges, {nodesep: 10, ranksep: 100, direction: "LR"});
|
|
115
|
-
/*
|
|
115
|
+
/* site's children: d0 (40), d1 (40), c1 (96) = 196 tall */
|
|
116
116
|
expect(pos.get("d1").y - pos.get("d0").y).toBe(50);
|
|
117
117
|
expect(pos.get("c1").y - pos.get("d1").y).toBe(20 + 10 + 48);
|
|
118
118
|
let first = pos.get("d0").y - 20;
|
|
119
119
|
let last = pos.get("c1").y + 48;
|
|
120
|
-
expect(pos.get("
|
|
120
|
+
expect(pos.get("site").y).toBe((first + last) / 2);
|
|
121
121
|
});
|
|
122
122
|
|
|
123
123
|
test("a parent taller than its children keeps its own height", () => {
|
|
@@ -140,9 +140,9 @@ describe("the tidy tree, read right", () => {
|
|
|
140
140
|
test("opening a hook does not move what is not under or beside it", () => {
|
|
141
141
|
let base = layout_tree(nodes, edges, {nodesep: 10, ranksep: 100, direction: "LR"});
|
|
142
142
|
let more = nodes.concat([N("d2", 116, 40)]);
|
|
143
|
-
let more_edges = edges.concat([{source: "
|
|
143
|
+
let more_edges = edges.concat([{source: "site", target: "d2", rank: 1}]);
|
|
144
144
|
let pos = layout_tree(more, more_edges, {nodesep: 10, ranksep: 100, direction: "LR"});
|
|
145
|
-
expect(pos.get("
|
|
145
|
+
expect(pos.get("region").x).toBe(base.get("region").x);
|
|
146
146
|
expect(pos.get("d0").y).toBe(base.get("d0").y); /* above the new one */
|
|
147
147
|
expect(pos.get("d1").y).toBe(base.get("d1").y);
|
|
148
148
|
expect(pos.get("d2").y).toBe(base.get("d1").y + 50);
|
|
@@ -153,17 +153,17 @@ describe("the tidy tree, read right", () => {
|
|
|
153
153
|
describe("the radial tree", () => {
|
|
154
154
|
test("one root sits at the centre, its children on a ring around it", () => {
|
|
155
155
|
let pos = layout_radial(nodes, edges, {nodesep: 10, ranksep: 100});
|
|
156
|
-
expect(pos.get("
|
|
157
|
-
let r = Math.hypot(pos.get("
|
|
156
|
+
expect(pos.get("region")).toEqual({x: 0, y: 0});
|
|
157
|
+
let r = Math.hypot(pos.get("north").x, pos.get("north").y);
|
|
158
158
|
expect(r).toBeGreaterThanOrEqual(100);
|
|
159
|
-
expect(Math.hypot(pos.get("
|
|
160
|
-
/*
|
|
159
|
+
expect(Math.hypot(pos.get("south").x, pos.get("south").y)).toBeCloseTo(r, 6);
|
|
160
|
+
/* north carries 3 of region's 4 leaves: three quarters of the
|
|
161
161
|
* circle, from the top (-90°) clockwise, so its middle is at
|
|
162
|
-
* +45°;
|
|
162
|
+
* +45°; south gets the last quarter, from 180° to 270°, centred
|
|
163
163
|
* at 225° (-135°) */
|
|
164
164
|
let ang = (id) => Math.atan2(pos.get(id).y, pos.get(id).x);
|
|
165
|
-
expect(ang("
|
|
166
|
-
expect(ang("
|
|
165
|
+
expect(ang("north")).toBeCloseTo(Math.PI / 4, 6);
|
|
166
|
+
expect(ang("south")).toBeCloseTo(-3 * Math.PI / 4, 6);
|
|
167
167
|
});
|
|
168
168
|
|
|
169
169
|
test("a ring is long enough for its nodes: no two neighbours closer than a card", () => {
|
|
@@ -105,7 +105,7 @@ describe("the Developer window's controls", () => {
|
|
|
105
105
|
expect(wrong).toEqual([]);
|
|
106
106
|
});
|
|
107
107
|
|
|
108
|
-
it("names the nine buttons
|
|
108
|
+
it("names the nine buttons that had no name", () => {
|
|
109
109
|
const sel = [
|
|
110
110
|
'[data-toggle="automata-simple"]',
|
|
111
111
|
'[data-output="window"]', '[data-output="console"]', '[data-output="both"]',
|
package/src/yui_dev_copy.test.js
CHANGED
|
@@ -30,7 +30,7 @@ function painted(kw)
|
|
|
30
30
|
{
|
|
31
31
|
return render_detailed({
|
|
32
32
|
kind: "traffic", dir: "in", event: "EV_MT_COMMAND_ANSWER",
|
|
33
|
-
title: "
|
|
33
|
+
title: "hub_yuno", ts: "09:04:11.914", size: 1473431, kw: kw,
|
|
34
34
|
});
|
|
35
35
|
}
|
|
36
36
|
|
|
@@ -38,12 +38,12 @@ describe("entry_shown_lines", () => {
|
|
|
38
38
|
it("copies a closed branch as its one-line summary", () => {
|
|
39
39
|
const $e = painted({
|
|
40
40
|
result: 0,
|
|
41
|
-
comment: "db_history^
|
|
41
|
+
comment: "db_history^4620: 500 nodes",
|
|
42
42
|
data: {places: [1, 2, 3], families: [4], devices: [5, 6]},
|
|
43
43
|
});
|
|
44
44
|
expect(entry_shown_lines($e)).toEqual([
|
|
45
45
|
" • result: 0",
|
|
46
|
-
" • comment: db_history^
|
|
46
|
+
" • comment: db_history^4620: 500 nodes",
|
|
47
47
|
" ▸ data {places:[…],families:[…],devices:[…]}",
|
|
48
48
|
]);
|
|
49
49
|
});
|
|
@@ -66,7 +66,7 @@ describe("render_name (the line view)", () => {
|
|
|
66
66
|
const $e = render_name({
|
|
67
67
|
kind: "traffic", dir: "in", event: "EV_YUNO_STATS", command: "",
|
|
68
68
|
title: "gui_agent_yuno <== wss://cc:1996", ts: "09:19:03.421", size: 1024,
|
|
69
|
-
kw: {result: 0, data: {yuno_id: "
|
|
69
|
+
kw: {result: 0, data: {yuno_id: "4046", kind: "cpu"}},
|
|
70
70
|
});
|
|
71
71
|
expect($e.classList.contains("TRAFFIC_NAME")).toBe(true);
|
|
72
72
|
expect($e.querySelector(".TRAFFIC_EVENT").textContent).toBe("EV_YUNO_STATS");
|
|
@@ -12,10 +12,10 @@
|
|
|
12
12
|
* is only its frame.
|
|
13
13
|
*
|
|
14
14
|
* let handle = open_gobj_tree_view(gobj, {
|
|
15
|
-
* name: "
|
|
15
|
+
* name: "gate_energy-4046",
|
|
16
16
|
* source: "remote",
|
|
17
|
-
* yuno_name: "
|
|
18
|
-
* title_prefix: "
|
|
17
|
+
* yuno_name: "gate_energy^4046",
|
|
18
|
+
* title_prefix: "gate_energy^4046",
|
|
19
19
|
* title: "gobj tree", // an i18n KEY
|
|
20
20
|
* $header: $status, // optional
|
|
21
21
|
* on_close: () => gobj_send_event(gobj, "EV_VIEW_CLOSED", {}, gobj),
|