@yuneta/gobj-ui 7.27.26 → 7.27.28
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 +90 -30
- package/dist/gobj-ui.cjs.js +1662 -971
- package/dist/gobj-ui.es.js +1662 -971
- package/package.json +1 -1
- package/src/c_yui_gclass.css +104 -22
- package/src/c_yui_gclass.js +413 -94
- package/src/c_yui_gobj_tree_js.js +470 -148
- package/src/gclass_traces.wiring.test.js +241 -0
- package/src/gobj_tree_model.js +51 -10
- package/src/gobj_tree_model.test.js +14 -3
- package/src/gobj_tree_remote.wiring.test.js +98 -7
- package/src/yui_gclass_view.js +11 -0
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
/***********************************************************************
|
|
2
|
+
* gclass_traces.wiring.test.js
|
|
3
|
+
*
|
|
4
|
+
* C_YUI_GCLASS, the gclass viewer, as the gobj tree opens it for a
|
|
5
|
+
* BACKEND gclass: its trace levels can be set for every gobj of
|
|
6
|
+
* the gclass (`set-gclass-trace`), one box per level, the yuno's
|
|
7
|
+
* own scope shown locked; and the layout that came out of the
|
|
8
|
+
* review of 7.27.27 -- the short zones first, a long table capped,
|
|
9
|
+
* the instance named beside its state, the methods in the head.
|
|
10
|
+
*
|
|
11
|
+
* The real gclass, hosted by a test gclass that declares what the
|
|
12
|
+
* viewer publishes.
|
|
13
|
+
*
|
|
14
|
+
* Copyright (c) 2026, ArtGins.
|
|
15
|
+
* All Rights Reserved.
|
|
16
|
+
***********************************************************************/
|
|
17
|
+
import {describe, test, expect, beforeAll, beforeEach} from "vitest";
|
|
18
|
+
import {install_dom_double, fake_event} from "../test/dom_double.js";
|
|
19
|
+
|
|
20
|
+
install_dom_double();
|
|
21
|
+
|
|
22
|
+
if(typeof globalThis.ResizeObserver === "undefined") {
|
|
23
|
+
globalThis.ResizeObserver = class {
|
|
24
|
+
observe() {
|
|
25
|
+
}
|
|
26
|
+
unobserve() {
|
|
27
|
+
}
|
|
28
|
+
disconnect() {
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
const {
|
|
34
|
+
SDATA_END, gclass_create,
|
|
35
|
+
gobj_start_up, gobj_create_yuno, gobj_create,
|
|
36
|
+
gobj_start, gobj_read_attr, gobj_send_event,
|
|
37
|
+
set_log_callback,
|
|
38
|
+
} = await import("@yuneta/gobj-js");
|
|
39
|
+
const {register_c_yui_gclass} = await import("./c_yui_gclass.js");
|
|
40
|
+
|
|
41
|
+
const logged = [];
|
|
42
|
+
const asked = [];
|
|
43
|
+
let yuno = null;
|
|
44
|
+
let host = null;
|
|
45
|
+
let seq = 0;
|
|
46
|
+
|
|
47
|
+
/* A C-dialect description: 25 attrs, a machine whose actions the
|
|
48
|
+
* backend does not name, one output event. */
|
|
49
|
+
const DESCRIPTION = {
|
|
50
|
+
id: "C_TCP",
|
|
51
|
+
gcflag: [],
|
|
52
|
+
instances: 4,
|
|
53
|
+
attrs: Array.from({length: 25}, (_, i) => ({
|
|
54
|
+
id: `attr_${i}`, type: "string", flag: "SDF_RD|SDF_REQUIRED",
|
|
55
|
+
default_value: "", description: `attribute ${i}`
|
|
56
|
+
})),
|
|
57
|
+
commands: [],
|
|
58
|
+
gclass_methods: ["mt_create", "mt_start"],
|
|
59
|
+
internal_methods: [],
|
|
60
|
+
FSM: {
|
|
61
|
+
events: [
|
|
62
|
+
{event_name: "EV_RX_DATA", event_flag: ""},
|
|
63
|
+
{event_name: "EV_CONNECTED", event_flag: "EVF_OUTPUT_EVENT|EVF_PUBLIC_EVENT"},
|
|
64
|
+
],
|
|
65
|
+
states: {
|
|
66
|
+
ST_CONNECTED: [{event_name: "EV_RX_DATA", action: "action", next_state: ""}],
|
|
67
|
+
},
|
|
68
|
+
},
|
|
69
|
+
info_gclass_trace: {traffic: "Trace dump traffic", connections: "Trace connections"},
|
|
70
|
+
};
|
|
71
|
+
|
|
72
|
+
/* What the host read: `connections` on for the gclass, `machine` for
|
|
73
|
+
* the whole yuno (so get-gclass-trace answers it too). */
|
|
74
|
+
const INFO = {
|
|
75
|
+
gclass_levels: {traffic: "Trace dump traffic", connections: "Trace connections"},
|
|
76
|
+
global_levels: {machine: "Trace machine", ev_kw: "Trace event keywords"},
|
|
77
|
+
gclass_on: ["connections", "machine"],
|
|
78
|
+
global_on: ["machine"],
|
|
79
|
+
error: "",
|
|
80
|
+
};
|
|
81
|
+
|
|
82
|
+
function record(gobj, event, kw, src)
|
|
83
|
+
{
|
|
84
|
+
asked.push({event: event, kw: kw});
|
|
85
|
+
return 0;
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
beforeAll(async () => {
|
|
89
|
+
const i18next = (await import("i18next")).default;
|
|
90
|
+
await i18next.init({lng: "en", resources: {en: {translation: {
|
|
91
|
+
"instances": "instances",
|
|
92
|
+
"instances_one": "instance",
|
|
93
|
+
"machine states": "{{count}} states",
|
|
94
|
+
"machine states_one": "{{count}} state",
|
|
95
|
+
"machine events": "{{count}} events",
|
|
96
|
+
"machine events_one": "{{count}} event",
|
|
97
|
+
"show all {{n}}": "show all {{n}}",
|
|
98
|
+
}}}});
|
|
99
|
+
gobj_start_up(null, null, null, null, null, null, null);
|
|
100
|
+
set_log_callback((level, msg) => {
|
|
101
|
+
logged.push({level: String(level), msg: String(msg)});
|
|
102
|
+
});
|
|
103
|
+
gclass_create("C_TEST_GCLASS_YUNO", [], [["ST_IDLE", []]], {}, 0,
|
|
104
|
+
[SDATA_END()], {}, 0, 0, 0, 0);
|
|
105
|
+
gclass_create("C_TEST_GCLASS_TRACES_HOST",
|
|
106
|
+
[["EV_SET_GCLASS_TRACE", 0]],
|
|
107
|
+
[["ST_IDLE", [["EV_SET_GCLASS_TRACE", record, null]]]],
|
|
108
|
+
{}, 0, [SDATA_END()], {}, 0, 0, 0, 0);
|
|
109
|
+
register_c_yui_gclass();
|
|
110
|
+
yuno = gobj_create_yuno("gclass_traces_yuno", "C_TEST_GCLASS_YUNO", {});
|
|
111
|
+
gobj_start(yuno);
|
|
112
|
+
host = gobj_create("host", "C_TEST_GCLASS_TRACES_HOST", {}, yuno);
|
|
113
|
+
});
|
|
114
|
+
|
|
115
|
+
beforeEach(() => {
|
|
116
|
+
logged.length = 0;
|
|
117
|
+
asked.length = 0;
|
|
118
|
+
});
|
|
119
|
+
|
|
120
|
+
function problems()
|
|
121
|
+
{
|
|
122
|
+
return logged.filter((l) => l.level === "error" || l.level === "warning").map((l) => l.msg);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
function open(kw)
|
|
126
|
+
{
|
|
127
|
+
const view = gobj_create(`gclass_view_${++seq}`, "C_YUI_GCLASS",
|
|
128
|
+
Object.assign({description: DESCRIPTION}, kw || {}), host);
|
|
129
|
+
gobj_start(view);
|
|
130
|
+
return view;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
function box_of(view, level)
|
|
134
|
+
{
|
|
135
|
+
return gobj_read_attr(view, "$container").querySelectorAll(".GCLASS_TRACE_GCLASS")
|
|
136
|
+
.find((b) => b.getAttribute("data-level") === level);
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
function visible_rows(view, zone)
|
|
140
|
+
{
|
|
141
|
+
return gobj_read_attr(view, "$container")
|
|
142
|
+
.querySelectorAll(`.GCLASS_ZONE[data-zone="${zone}"] tbody tr`)
|
|
143
|
+
.filter((tr) => !tr.classList.contains("is-hidden")).length;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
describe("C_YUI_GCLASS: the gclass' trace levels, set from the viewer", () => {
|
|
147
|
+
test("one box per level, own and kernel, the yuno's locked", () => {
|
|
148
|
+
const view = open({traces: {info: INFO, pending: false}});
|
|
149
|
+
expect([box_of(view, "traffic").checked, box_of(view, "traffic").disabled]).toEqual([false, false]);
|
|
150
|
+
expect([box_of(view, "connections").checked, box_of(view, "connections").disabled])
|
|
151
|
+
.toEqual([true, false]);
|
|
152
|
+
expect([box_of(view, "machine").checked, box_of(view, "machine").disabled]).toEqual([true, true]);
|
|
153
|
+
expect([box_of(view, "ev_kw").checked, box_of(view, "ev_kw").disabled]).toEqual([false, false]);
|
|
154
|
+
expect(problems()).toEqual([]);
|
|
155
|
+
});
|
|
156
|
+
|
|
157
|
+
test("a box asks the host, and the zone stays locked until it answers", () => {
|
|
158
|
+
const view = open({traces: {info: INFO, pending: false}});
|
|
159
|
+
const $b = box_of(view, "ev_kw");
|
|
160
|
+
$b.checked = true;
|
|
161
|
+
$b.dispatchEvent(fake_event("change"));
|
|
162
|
+
expect(asked).toEqual([{event: "EV_SET_GCLASS_TRACE",
|
|
163
|
+
kw: {gclass: "C_TCP", levels: ["ev_kw"], set: true}}]);
|
|
164
|
+
expect(box_of(view, "traffic").disabled).toBe(true);
|
|
165
|
+
|
|
166
|
+
gobj_send_event(view, "EV_SET_TRACES", {info: Object.assign({}, INFO,
|
|
167
|
+
{gclass_on: ["connections", "machine", "ev_kw"]}), pending: false}, host);
|
|
168
|
+
expect([box_of(view, "ev_kw").checked, box_of(view, "ev_kw").disabled]).toEqual([true, false]);
|
|
169
|
+
expect(problems()).toEqual([]);
|
|
170
|
+
});
|
|
171
|
+
|
|
172
|
+
test("the zone says the gclass' traces survive a restart", () => {
|
|
173
|
+
const view = open({traces: {info: INFO, pending: false}});
|
|
174
|
+
expect(gobj_read_attr(view, "$container").querySelector(".GCLASS_TRACES_NOTE").getAttribute("data-i18n"))
|
|
175
|
+
.toBe("the traces of a gclass survive a restart");
|
|
176
|
+
});
|
|
177
|
+
|
|
178
|
+
test("remove the traces of the gclass turns off its own, not the yuno's", () => {
|
|
179
|
+
const view = open({traces: {info: INFO, pending: false}});
|
|
180
|
+
gobj_read_attr(view, "$container").querySelector(".GCLASS_TRACES_CLEAR").click();
|
|
181
|
+
expect(asked.map((a) => [a.kw.levels, a.kw.set])).toEqual([[["connections"], false]]);
|
|
182
|
+
expect(problems()).toEqual([]);
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
test("with no host that can set them, the levels are only listed", () => {
|
|
186
|
+
const view = open({});
|
|
187
|
+
const $c = gobj_read_attr(view, "$container");
|
|
188
|
+
expect($c.querySelectorAll(".GCLASS_TRACE_GCLASS").length).toBe(0);
|
|
189
|
+
expect($c.querySelectorAll('.GCLASS_ZONE[data-zone="traces"] tbody tr').length).toBe(2);
|
|
190
|
+
expect(problems()).toEqual([]);
|
|
191
|
+
});
|
|
192
|
+
});
|
|
193
|
+
|
|
194
|
+
describe("C_YUI_GCLASS: the layout", () => {
|
|
195
|
+
test("the short zones first, the long tables last, the methods in the head", () => {
|
|
196
|
+
const view = open({});
|
|
197
|
+
const $c = gobj_read_attr(view, "$container");
|
|
198
|
+
expect($c.querySelectorAll(".GCLASS_ZONE").map((z) => z.getAttribute("data-zone")))
|
|
199
|
+
.toEqual(["machine", "traces", "attrs", "commands"]);
|
|
200
|
+
expect($c.querySelectorAll(".GCLASS_HEAD .GCLASS_METHOD").map((m) => m.textContent))
|
|
201
|
+
.toEqual(["mt_create", "mt_start"]);
|
|
202
|
+
expect($c.querySelector('.GCLASS_ZONE[data-zone="machine"] .GCLASS_ZONE_COUNT').textContent)
|
|
203
|
+
.toBe("1 state · 1 event");
|
|
204
|
+
expect($c.querySelector(".GCLASS_INSTANCES_LABEL").textContent).toBe("instances");
|
|
205
|
+
});
|
|
206
|
+
|
|
207
|
+
test("the state the reader came from is said with its instance", () => {
|
|
208
|
+
const view = open({current_state: "ST_CONNECTED", instance_name: "tcp1"});
|
|
209
|
+
const $c = gobj_read_attr(view, "$container");
|
|
210
|
+
expect($c.querySelector(".GCLASS_CURRENT_INSTANCE").textContent).toBe("tcp1");
|
|
211
|
+
expect($c.querySelector(".GCLASS_CURRENT_STATE").textContent).toBe("ST_CONNECTED");
|
|
212
|
+
});
|
|
213
|
+
|
|
214
|
+
test("an action the backend does not name has its own line in the legend", () => {
|
|
215
|
+
const view = open({});
|
|
216
|
+
const $c = gobj_read_attr(view, "$container");
|
|
217
|
+
expect($c.querySelector(".GCLASS_LEGEND_SWATCH.is-unnamed")).not.toBe(null);
|
|
218
|
+
/* no empty cell is drawn, so no legend for one */
|
|
219
|
+
expect($c.querySelector(".GCLASS_LEGEND_SWATCH.is-none")).toBe(null);
|
|
220
|
+
expect($c.querySelectorAll(".GCLASS_PUB_ROW").length).toBe(1);
|
|
221
|
+
});
|
|
222
|
+
|
|
223
|
+
test("a long table shows 20 rows and a button for the rest; a search shows every match", () => {
|
|
224
|
+
const view = open({});
|
|
225
|
+
const $c = gobj_read_attr(view, "$container");
|
|
226
|
+
expect(visible_rows(view, "attrs")).toBe(20);
|
|
227
|
+
const $more = $c.querySelector('.GCLASS_SHOW_ALL[data-zone="attrs"]');
|
|
228
|
+
expect($more.classList.contains("is-hidden")).toBe(false);
|
|
229
|
+
|
|
230
|
+
gobj_send_event(view, "EV_SEARCH", {text: "attr_24"}, view);
|
|
231
|
+
expect(visible_rows(view, "attrs")).toBe(1);
|
|
232
|
+
expect($more.classList.contains("is-hidden")).toBe(true);
|
|
233
|
+
|
|
234
|
+
gobj_send_event(view, "EV_SEARCH", {text: ""}, view);
|
|
235
|
+
expect(visible_rows(view, "attrs")).toBe(20);
|
|
236
|
+
$more.click();
|
|
237
|
+
expect(visible_rows(view, "attrs")).toBe(25);
|
|
238
|
+
expect($more.classList.contains("is-hidden")).toBe(true);
|
|
239
|
+
expect(problems()).toEqual([]);
|
|
240
|
+
});
|
|
241
|
+
});
|
package/src/gobj_tree_model.js
CHANGED
|
@@ -511,9 +511,19 @@ function node_info_rows(d, t)
|
|
|
511
511
|
|
|
512
512
|
|
|
513
513
|
/************************************************************
|
|
514
|
-
* The
|
|
515
|
-
*
|
|
516
|
-
*
|
|
514
|
+
* The trace levels of a backend gobj, one row per level it
|
|
515
|
+
* can trace: the gclass' own levels first (the ones that are
|
|
516
|
+
* about this gobj), then the KERNEL's (`machine`,
|
|
517
|
+
* `create_delete`, `ev_kw`...).
|
|
518
|
+
*
|
|
519
|
+
* Two families of levels and three scopes, and the words must
|
|
520
|
+
* not mix them. The kernel's levels are the table of gobj.c
|
|
521
|
+
* that the C side calls "global" -- but they are not global
|
|
522
|
+
* TRACES: every one of them can be set for one gobj
|
|
523
|
+
* (`set-gobj-trace`), for every gobj of a gclass
|
|
524
|
+
* (`set-gclass-trace`, the way to trace the machine of C_TCP
|
|
525
|
+
* alone) or for the whole yuno (`set-global-trace`). A
|
|
526
|
+
* gclass' own levels have only the first two scopes.
|
|
517
527
|
*
|
|
518
528
|
* `d` is the descriptor (its `gobj_trace_level` is what the
|
|
519
529
|
* gobj traces NOW, whatever the reason). `info` is what the
|
|
@@ -525,19 +535,21 @@ function node_info_rows(d, t)
|
|
|
525
535
|
* global_on [name, ...] get-global-trace
|
|
526
536
|
*
|
|
527
537
|
* `get-gclass-trace` answers the gclass' levels OR'ed with the
|
|
528
|
-
*
|
|
529
|
-
*
|
|
538
|
+
* yuno's (gobj_get_gclass_trace_level), so a level on in both
|
|
539
|
+
* is counted as the yuno's: that is the one that would still
|
|
530
540
|
* hold it on if the gclass let go.
|
|
531
541
|
*
|
|
532
|
-
* Each row says, for
|
|
542
|
+
* Each row says, for each scope:
|
|
533
543
|
*
|
|
544
|
+
* group "gclass" | "kernel"
|
|
534
545
|
* gobj_on, gobj_locked the gobj traces it; locked when
|
|
535
546
|
* that comes from its gclass or
|
|
536
|
-
* from the
|
|
537
|
-
*
|
|
547
|
+
* from the yuno -- turning the
|
|
548
|
+
* gobj's own bit off would not
|
|
538
549
|
* stop it
|
|
539
550
|
* gclass_on, gclass_locked every gobj of the gclass traces
|
|
540
|
-
* it; locked when
|
|
551
|
+
* it; locked when the yuno does
|
|
552
|
+
* global_on the whole yuno traces it
|
|
541
553
|
* origin "global" | "gclass" | ""
|
|
542
554
|
************************************************************/
|
|
543
555
|
function trace_rows(d, info)
|
|
@@ -571,12 +583,38 @@ function trace_rows(d, info)
|
|
|
571
583
|
gobj_locked: by_global || by_gclass,
|
|
572
584
|
gclass_on: by_global || by_gclass,
|
|
573
585
|
gclass_locked: by_global,
|
|
586
|
+
global_on: by_global,
|
|
574
587
|
origin: by_global? "global": (by_gclass? "gclass": ""),
|
|
575
588
|
});
|
|
576
589
|
}
|
|
577
590
|
};
|
|
578
591
|
add("gclass", info.gclass_levels);
|
|
579
|
-
add("
|
|
592
|
+
add("kernel", info.global_levels);
|
|
593
|
+
return rows;
|
|
594
|
+
}
|
|
595
|
+
|
|
596
|
+
/************************************************************
|
|
597
|
+
* The rows of the YUNO's scope: the kernel's levels, and
|
|
598
|
+
* whether the whole yuno traces each one (`set-global-trace`).
|
|
599
|
+
* A gclass' own levels have no such scope.
|
|
600
|
+
************************************************************/
|
|
601
|
+
function global_trace_rows(info)
|
|
602
|
+
{
|
|
603
|
+
let rows = [];
|
|
604
|
+
if(!info) {
|
|
605
|
+
return rows;
|
|
606
|
+
}
|
|
607
|
+
let global_on = Array.isArray(info.global_on)? info.global_on: [];
|
|
608
|
+
let levels = (info.global_levels && typeof info.global_levels === "object")?
|
|
609
|
+
info.global_levels: {};
|
|
610
|
+
for(let level of Object.keys(levels)) {
|
|
611
|
+
rows.push({
|
|
612
|
+
level: level,
|
|
613
|
+
description: String(levels[level] || ""),
|
|
614
|
+
group: "kernel",
|
|
615
|
+
global_on: global_on.indexOf(level) >= 0,
|
|
616
|
+
});
|
|
617
|
+
}
|
|
580
618
|
return rows;
|
|
581
619
|
}
|
|
582
620
|
|
|
@@ -594,6 +632,8 @@ function own_trace_levels(rows, scope)
|
|
|
594
632
|
out.push(r.level);
|
|
595
633
|
} else if(scope === "gclass" && r.gclass_on && !r.gclass_locked) {
|
|
596
634
|
out.push(r.level);
|
|
635
|
+
} else if(scope === "global" && r.global_on) {
|
|
636
|
+
out.push(r.level);
|
|
597
637
|
}
|
|
598
638
|
}
|
|
599
639
|
return out;
|
|
@@ -616,5 +656,6 @@ export {
|
|
|
616
656
|
describe_backend_node,
|
|
617
657
|
describe_backend_tree,
|
|
618
658
|
trace_rows,
|
|
659
|
+
global_trace_rows,
|
|
619
660
|
own_trace_levels,
|
|
620
661
|
};
|
|
@@ -10,6 +10,7 @@ import {
|
|
|
10
10
|
describe_backend_node,
|
|
11
11
|
describe_backend_tree,
|
|
12
12
|
trace_rows,
|
|
13
|
+
global_trace_rows,
|
|
13
14
|
own_trace_levels,
|
|
14
15
|
} from "./gobj_tree_model.js";
|
|
15
16
|
|
|
@@ -178,10 +179,10 @@ describe("trace_rows", () => {
|
|
|
178
179
|
return map;
|
|
179
180
|
};
|
|
180
181
|
|
|
181
|
-
it("lists the gclass levels first, then the
|
|
182
|
+
it("lists the gclass levels first, then the kernel's, each once", () => {
|
|
182
183
|
let rows = trace_rows({gobj_trace_level: []}, INFO);
|
|
183
184
|
expect(rows.map((r) => [r.level, r.group])).toEqual([
|
|
184
|
-
["traffic", "gclass"], ["connections", "gclass"], ["machine", "
|
|
185
|
+
["traffic", "gclass"], ["connections", "gclass"], ["machine", "kernel"]
|
|
185
186
|
]);
|
|
186
187
|
});
|
|
187
188
|
|
|
@@ -192,7 +193,8 @@ describe("trace_rows", () => {
|
|
|
192
193
|
expect(r.connections).toMatchObject({gobj_on: true, gobj_locked: true,
|
|
193
194
|
gclass_on: true, gclass_locked: false, origin: "gclass"});
|
|
194
195
|
expect(r.machine).toMatchObject({gobj_on: true, gobj_locked: true,
|
|
195
|
-
gclass_on: true, gclass_locked: true, origin: "global"});
|
|
196
|
+
gclass_on: true, gclass_locked: true, global_on: true, origin: "global"});
|
|
197
|
+
expect(r.connections.global_on).toBe(false);
|
|
196
198
|
});
|
|
197
199
|
|
|
198
200
|
it("what each scope holds on its own is what its remove turns off", () => {
|
|
@@ -204,6 +206,15 @@ describe("trace_rows", () => {
|
|
|
204
206
|
it("no info, no rows", () => {
|
|
205
207
|
expect(trace_rows({gobj_trace_level: ["machine"]}, null)).toEqual([]);
|
|
206
208
|
expect(own_trace_levels(null, "gobj")).toEqual([]);
|
|
209
|
+
expect(global_trace_rows(null)).toEqual([]);
|
|
210
|
+
});
|
|
211
|
+
|
|
212
|
+
it("the yuno's scope has the kernel's levels only, and what it traces", () => {
|
|
213
|
+
let rows = global_trace_rows(INFO);
|
|
214
|
+
expect(rows.map((r) => [r.level, r.global_on])).toEqual([
|
|
215
|
+
["machine", true], ["connections", false]
|
|
216
|
+
]);
|
|
217
|
+
expect(own_trace_levels(rows, "global")).toEqual(["machine"]);
|
|
207
218
|
});
|
|
208
219
|
});
|
|
209
220
|
|
|
@@ -191,11 +191,23 @@ function row_of(view, level)
|
|
|
191
191
|
const $pop = view.priv.$popover;
|
|
192
192
|
const $gobj = $pop.querySelectorAll(".GOBJ_TREE_TRACE_GOBJ")
|
|
193
193
|
.find((b) => b.getAttribute("data-level") === level);
|
|
194
|
-
const $
|
|
194
|
+
const $global = $pop.querySelectorAll(".GOBJ_TREE_TRACE_GLOBAL")
|
|
195
195
|
.find((b) => b.getAttribute("data-level") === level);
|
|
196
|
-
|
|
196
|
+
const $row = ($gobj || $global) ? ($gobj || $global).closest("tr") : null;
|
|
197
|
+
const $origin = $row ? $row.querySelector(".GOBJ_TREE_TRACES_ORIGIN") : null;
|
|
198
|
+
return {$gobj, $global, origin: $origin ? $origin.textContent : ""};
|
|
197
199
|
}
|
|
198
200
|
|
|
201
|
+
/* What the host fetched for the root's gclass: it carries the yuno's
|
|
202
|
+
* own scope (`machine` on for every gobj). */
|
|
203
|
+
const YUNO_INFO = {
|
|
204
|
+
gclass: "C_YUNO",
|
|
205
|
+
gclass_levels: {},
|
|
206
|
+
global_levels: {machine: "Trace machine", ev_kw: "Trace event keywords"},
|
|
207
|
+
gclass_on: ["machine"],
|
|
208
|
+
global_on: ["machine"],
|
|
209
|
+
};
|
|
210
|
+
|
|
199
211
|
async function open_tcp_card(view)
|
|
200
212
|
{
|
|
201
213
|
gobj_send_event(view, "EV_LOAD_TREE", {tree: TREE}, host);
|
|
@@ -228,13 +240,92 @@ describe("C_YUI_GOBJ_TREE_JS, source remote", () => {
|
|
|
228
240
|
const machine = row_of(view, "machine");
|
|
229
241
|
|
|
230
242
|
/* only tcp1: its own, so it can be turned off here */
|
|
231
|
-
expect([traffic.$gobj.checked, traffic.$gobj.disabled]).toEqual([true, false]);
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
expect([connections.$gclass.checked, connections.$gclass.disabled]).toEqual([true, false]);
|
|
243
|
+
expect([traffic.$gobj.checked, traffic.$gobj.disabled, traffic.origin]).toEqual([true, false, ""]);
|
|
244
|
+
/* the gclass holds it: on and locked for the gobj, saying which */
|
|
245
|
+
expect([connections.$gobj.checked, connections.$gobj.disabled, connections.origin])
|
|
246
|
+
.toEqual([true, true, "C_TCP"]);
|
|
236
247
|
/* nobody */
|
|
237
248
|
expect([machine.$gobj.checked, machine.$gobj.disabled]).toEqual([false, false]);
|
|
249
|
+
/* ONE scope in a card: the gclass' is the gclass viewer's, the
|
|
250
|
+
* yuno's is the toolbar's. */
|
|
251
|
+
expect(view.priv.$popover.querySelectorAll(".GOBJ_TREE_TRACE_GCLASS").length).toBe(0);
|
|
252
|
+
expect(view.priv.$popover.querySelector(".GOBJ_TREE_TRACES_CLEAR_GCLASS")).toBe(null);
|
|
253
|
+
expect(problems()).toEqual([]);
|
|
254
|
+
});
|
|
255
|
+
|
|
256
|
+
test("a card says whether its gobj's traces survive a restart: a service's do", async () => {
|
|
257
|
+
const view = await mount("remote", host);
|
|
258
|
+
await open_tcp_card(view);
|
|
259
|
+
gobj_send_event(view, "EV_TRACE_INFO", TCP_INFO, host);
|
|
260
|
+
const note = () => view.priv.$popover.querySelector(".GOBJ_TREE_TRACES_NOTE").getAttribute("data-i18n");
|
|
261
|
+
expect(note()).toBe("the traces of a gobj that is not a service end with the yuno");
|
|
262
|
+
|
|
263
|
+
const tree = JSON.parse(JSON.stringify(TREE));
|
|
264
|
+
tree["C_YUNO^gate"].children["C_TCP^tcp1"].service = true;
|
|
265
|
+
gobj_send_event(view, "EV_LOAD_TREE", {tree: tree}, host);
|
|
266
|
+
expect(note()).toBe("the traces of a service survive a restart");
|
|
267
|
+
expect(problems()).toEqual([]);
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
test("a level the whole yuno traces is locked in a card, said as the yuno's", async () => {
|
|
271
|
+
const view = await mount("remote", host);
|
|
272
|
+
await open_tcp_card(view);
|
|
273
|
+
gobj_send_event(view, "EV_TRACE_INFO", Object.assign({}, TCP_INFO,
|
|
274
|
+
{gclass_on: ["connections", "machine"], global_on: ["machine"]}), host);
|
|
275
|
+
const machine = row_of(view, "machine");
|
|
276
|
+
expect([machine.$gobj.checked, machine.$gobj.disabled, machine.origin])
|
|
277
|
+
.toEqual([true, true, "yuno"]);
|
|
278
|
+
expect(problems()).toEqual([]);
|
|
279
|
+
});
|
|
280
|
+
|
|
281
|
+
test("the yuno's traces open from the toolbar, from the root's gclass", async () => {
|
|
282
|
+
const view = await mount("remote", host);
|
|
283
|
+
gobj_send_event(view, "EV_LOAD_TREE", {tree: TREE}, host);
|
|
284
|
+
wanted.length = 0;
|
|
285
|
+
|
|
286
|
+
const $btn = gobj_read_attr(view, "$container").querySelector(".GOBJ_TREE_YUNO_TRACES_BUTTON");
|
|
287
|
+
expect($btn).toBeTruthy();
|
|
288
|
+
$btn.click();
|
|
289
|
+
expect(wanted.map((w) => [w.event, w.kw.gclass])).toEqual([["EV_TRACE_INFO_WANTED", "C_YUNO"]]);
|
|
290
|
+
expect(view.priv.popover_mode).toBe("yuno");
|
|
291
|
+
|
|
292
|
+
gobj_send_event(view, "EV_TRACE_INFO", YUNO_INFO, host);
|
|
293
|
+
const machine = row_of(view, "machine");
|
|
294
|
+
const ev_kw = row_of(view, "ev_kw");
|
|
295
|
+
expect([machine.$global.checked, machine.$global.disabled]).toEqual([true, false]);
|
|
296
|
+
expect([ev_kw.$global.checked, ev_kw.$global.disabled]).toEqual([false, false]);
|
|
297
|
+
expect(view.priv.$popover.querySelectorAll(".GOBJ_TREE_TRACE_GOBJ").length).toBe(0);
|
|
298
|
+
/* no gclass button: the yuno's traces are no gclass */
|
|
299
|
+
expect(view.priv.$popover_gclass.classList.contains("is-hidden")).toBe(true);
|
|
300
|
+
|
|
301
|
+
wanted.length = 0;
|
|
302
|
+
ev_kw.$global.checked = true;
|
|
303
|
+
ev_kw.$global.dispatchEvent(fake_event("change"));
|
|
304
|
+
expect(wanted).toEqual([{event: "EV_SET_TRACE_LEVEL", kw: {
|
|
305
|
+
scope: "global", gobj: "C_YUNO^gate", gclass: "C_YUNO",
|
|
306
|
+
levels: ["ev_kw"], set: true
|
|
307
|
+
}}]);
|
|
308
|
+
expect(row_of(view, "machine").$global.disabled).toBe(true);
|
|
309
|
+
|
|
310
|
+
/* The host reloads the tree: the yuno's traces stay open. */
|
|
311
|
+
gobj_send_event(view, "EV_LOAD_TREE", {tree: TREE}, host);
|
|
312
|
+
expect(view.priv.popover_mode).toBe("yuno");
|
|
313
|
+
expect(view.priv.$popover.style.display).toBe("block");
|
|
314
|
+
|
|
315
|
+
wanted.length = 0;
|
|
316
|
+
view.priv.$popover.querySelector(".GOBJ_TREE_TRACES_CLEAR_GLOBAL").click();
|
|
317
|
+
expect(wanted.map((w) => [w.kw.scope, w.kw.levels, w.kw.set])).toEqual([["global", ["machine"], false]]);
|
|
318
|
+
expect(problems()).toEqual([]);
|
|
319
|
+
});
|
|
320
|
+
|
|
321
|
+
test("the gclass viewer's set reaches the host as a set of the gclass", async () => {
|
|
322
|
+
const view = await mount("remote", host);
|
|
323
|
+
await open_tcp_card(view);
|
|
324
|
+
wanted.length = 0;
|
|
325
|
+
gobj_send_event(view, "EV_SET_GCLASS_TRACE", {gclass: "C_TCP", levels: ["machine"], set: true}, view);
|
|
326
|
+
expect(wanted).toEqual([{event: "EV_SET_TRACE_LEVEL", kw: {
|
|
327
|
+
scope: "gclass", gobj: "", gclass: "C_TCP", levels: ["machine"], set: true
|
|
328
|
+
}}]);
|
|
238
329
|
expect(problems()).toEqual([]);
|
|
239
330
|
});
|
|
240
331
|
|
package/src/yui_gclass_view.js
CHANGED
|
@@ -85,6 +85,15 @@ function gclass_view_available()
|
|
|
85
85
|
* current_state the state the INSTANCE the reader came
|
|
86
86
|
* from is in, lit in the machine. Omitted,
|
|
87
87
|
* nothing is lit.
|
|
88
|
+
* instance_name the name of that instance, said beside its
|
|
89
|
+
* state (a gclass has several).
|
|
90
|
+
* traces {info, pending}: the host can set this
|
|
91
|
+
* gclass' traces for every gobj of it. The
|
|
92
|
+
* viewer then publishes EV_SET_GCLASS_TRACE
|
|
93
|
+
* {gclass, levels, set} to the HOST (it is its
|
|
94
|
+
* child), which declares it, and is handed what
|
|
95
|
+
* the backend says next with EV_SET_TRACES.
|
|
96
|
+
* Omitted: the levels are only listed.
|
|
88
97
|
* title_prefix what the window says before the gclass
|
|
89
98
|
* name (the yuno it belongs to).
|
|
90
99
|
* on_close called when the reader dismisses it.
|
|
@@ -134,6 +143,8 @@ function open_gclass_view(host, gclass_name, opts)
|
|
|
134
143
|
* CLASS -- and the caller is the only party that knows,
|
|
135
144
|
* so an omitted one simply lights nothing. */
|
|
136
145
|
current_state: opts.current_state || "",
|
|
146
|
+
instance_name: opts.instance_name || "",
|
|
147
|
+
traces: opts.traces || null,
|
|
137
148
|
subscriber: null,
|
|
138
149
|
},
|
|
139
150
|
host
|