@yuneta/gobj-ui 7.26.42 → 7.26.43
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 +227 -36
- package/dist/gobj-ui.cjs.js +768 -191
- package/dist/gobj-ui.es.js +768 -191
- package/package.json +1 -1
- package/scripts/validate-locales.mjs +355 -63
- package/src/c_yui_form.js +261 -154
- package/src/c_yui_node.js +51 -7
- package/src/c_yui_schema_editor.js +49 -3
- package/src/c_yui_shell.css +4 -1
- package/src/c_yui_shell.js +28 -2
- package/src/c_yui_window.js +373 -62
- package/src/c_yui_window_manager.js +74 -2
- package/src/escape_taken.js +58 -0
- package/src/form_close_asks_for_edits.wiring.test.js +6 -3
- package/src/form_json_editor_names.js +3 -1
- package/src/form_json_editor_names.wiring.test.js +8 -4
- package/src/form_json_expand.wiring.test.js +6 -3
- package/src/form_json_field.wiring.test.js +8 -4
- package/src/form_label_i18n.wiring.test.js +10 -5
- package/src/form_table_edits_ask.wiring.test.js +18 -8
- package/src/form_table_rearm.wiring.test.js +13 -5
- package/src/form_table_rows.wiring.test.js +489 -0
- package/src/form_table_validator.wiring.test.js +8 -4
- package/src/form_template_field.wiring.test.js +6 -3
- package/src/g6_long_press_clock.test.js +8 -3
- package/src/i18n_key_functions.js +63 -25
- package/src/i18n_key_functions.test.js +230 -8
- package/src/modal_guard_back.wiring.test.js +53 -0
- package/src/named_controls.wiring.test.js +53 -13
- package/src/node_nav_events.wiring.test.js +93 -1
- package/src/schema_editor_diagram_click.wiring.test.js +277 -0
- package/src/shell_dialog_names.wiring.test.js +149 -0
- package/src/shell_escape_taken.wiring.test.js +142 -0
- package/src/shell_focus_trap.js +30 -2
- package/src/shell_focus_trap.test.js +90 -6
- package/src/shell_modals.js +90 -19
- package/src/table_editor_name.wiring.test.js +10 -5
- package/src/treedb_column_title.wiring.test.js +8 -4
- package/src/treedb_graph_writes.wiring.test.js +6 -3
- package/src/treedb_json_drill.wiring.test.js +6 -3
- package/src/uplot_add_serie.test.js +6 -3
- package/src/uplot_ink.test.js +8 -4
- package/src/window_dialog.wiring.test.js +486 -0
- package/src/window_dock_band.wiring.test.js +189 -0
- package/src/window_rect_rounding.wiring.test.js +121 -0
- package/src/yui_tabulator_i18n.js +31 -1
- package/src/yui_tabulator_i18n.test.js +46 -0
|
@@ -37,6 +37,16 @@
|
|
|
37
37
|
* and the like, a const bound to one, a plain `let`
|
|
38
38
|
* only ever given one -- known by where it comes
|
|
39
39
|
* from, never by a variable's name.
|
|
40
|
+
* fallbacks optional: a position that is only the FALLBACK
|
|
41
|
+
* of others the function reads first, and those
|
|
42
|
+
* others -- {"0.id": ["0.name", "0.aria_label"]}
|
|
43
|
+
* for `it.name || it.aria_label || it.id`. An
|
|
44
|
+
* object that surely gives one of them (a
|
|
45
|
+
* non-empty string in every value it can take)
|
|
46
|
+
* does not reach the position: its id is no key,
|
|
47
|
+
* and it is not held to the rule there. Each
|
|
48
|
+
* fallback is a position of `keys` with the same
|
|
49
|
+
* parent (up to its last ".").
|
|
40
50
|
*
|
|
41
51
|
* What is read at a position: a string literal, a template with
|
|
42
52
|
* no `${}`, every branch of a `?:`, `||`, `??` (the right one of
|
|
@@ -65,7 +75,9 @@
|
|
|
65
75
|
*
|
|
66
76
|
* A call reaches a function of this table however it names it:
|
|
67
77
|
* its name, an import under any name, a re-export, a const alias,
|
|
68
|
-
* a map (`API.info(...)`), `.call()`, `.apply()`.
|
|
78
|
+
* a map (`API.info(...)`), `.call()`, `.apply()`; and a `.bind()`
|
|
79
|
+
* of it is read as the call it prepares, at the positions it binds
|
|
80
|
+
* (`yui_shell_show_info.bind(null, shell, "k")` hands "k").
|
|
69
81
|
*
|
|
70
82
|
* The rule, per CALL: a key position given anything else than a
|
|
71
83
|
* literal (or DOM, or nothing), a const the reader follows, a key
|
|
@@ -138,11 +150,14 @@ export const I18N_KEY_FUNCTIONS = Object.freeze([
|
|
|
138
150
|
/* yui_time.js -- a granularity names itself by its id */
|
|
139
151
|
{module: "yui_time.js", name: "period_name", exported: true, keys: ["0", "0.id"]},
|
|
140
152
|
/* nav_cards_helpers.js -- a nav item's name, tooltip and aria label,
|
|
141
|
-
* and its id: the key of an item with
|
|
153
|
+
* and its id: the key of an item with neither a `name` nor an
|
|
154
|
+
* `aria_label` (`name || aria_label || id`) */
|
|
142
155
|
{module: "nav_cards_helpers.js", name: "card_descriptor", exported: true,
|
|
143
|
-
keys: ["0.name", "0.tooltip", "0.aria_label", "0.id"]
|
|
156
|
+
keys: ["0.name", "0.tooltip", "0.aria_label", "0.id"],
|
|
157
|
+
fallbacks: {"0.id": ["0.name", "0.aria_label"]}},
|
|
144
158
|
{module: "nav_cards_helpers.js", name: "cards_grid_descriptor", exported: true,
|
|
145
|
-
keys: ["0[].name", "0[].tooltip", "0[].aria_label", "0[].id"]
|
|
159
|
+
keys: ["0[].name", "0[].tooltip", "0[].aria_label", "0[].id"],
|
|
160
|
+
fallbacks: {"0[].id": ["0[].name", "0[].aria_label"]}},
|
|
146
161
|
/* yui_gclass_view.js -- the dialog's title is the gclass name */
|
|
147
162
|
{module: "yui_gclass_view.js", name: "open_gclass_view", exported: true, keys: ["1"]},
|
|
148
163
|
/* g6_canvas_tab_order.js -- the name of a graph's main canvas, the
|
|
@@ -228,52 +243,75 @@ export const I18N_KEY_FUNCTIONS = Object.freeze([
|
|
|
228
243
|
{module: "yui_dev.js", name: "grp", exported: false, keys: ["0"]},
|
|
229
244
|
{module: "yui_dev.js", name: "grp_scroll", exported: false, keys: ["0"]},
|
|
230
245
|
/* c_yui_nav.js -- the items of a menu: the app's nav declaration.
|
|
231
|
-
* The id is the key of an item with
|
|
246
|
+
* The id is the key of an item with neither a `name` nor an
|
|
247
|
+
* `aria_label` (of a crumb's text, with no `name`). */
|
|
232
248
|
{module: "c_yui_nav.js", name: "item_li", exported: false,
|
|
233
|
-
keys: ["1.name", "1.tooltip", "1.aria_label", "1.id"]
|
|
249
|
+
keys: ["1.name", "1.tooltip", "1.aria_label", "1.id"],
|
|
250
|
+
fallbacks: {"1.id": ["1.name", "1.aria_label"]}},
|
|
234
251
|
{module: "c_yui_nav.js", name: "item_iconbar", exported: false,
|
|
235
|
-
keys: ["1.name", "1.tooltip", "1.aria_label", "1.id"]
|
|
252
|
+
keys: ["1.name", "1.tooltip", "1.aria_label", "1.id"],
|
|
253
|
+
fallbacks: {"1.id": ["1.name", "1.aria_label"]}},
|
|
236
254
|
{module: "c_yui_nav.js", name: "render_vertical", exported: false,
|
|
237
|
-
keys: ["1[].name", "1[].tooltip", "1[].aria_label", "1[].id"]
|
|
255
|
+
keys: ["1[].name", "1[].tooltip", "1[].aria_label", "1[].id"],
|
|
256
|
+
fallbacks: {"1[].id": ["1[].name", "1[].aria_label"]}},
|
|
238
257
|
{module: "c_yui_nav.js", name: "render_icon_bar", exported: false,
|
|
239
|
-
keys: ["1[].name", "1[].tooltip", "1[].aria_label", "1[].id"]
|
|
258
|
+
keys: ["1[].name", "1[].tooltip", "1[].aria_label", "1[].id"],
|
|
259
|
+
fallbacks: {"1[].id": ["1[].name", "1[].aria_label"]}},
|
|
240
260
|
{module: "c_yui_nav.js", name: "render_tabs", exported: false,
|
|
241
|
-
keys: ["1[].name", "1[].tooltip", "1[].aria_label", "1[].id"]
|
|
261
|
+
keys: ["1[].name", "1[].tooltip", "1[].aria_label", "1[].id"],
|
|
262
|
+
fallbacks: {"1[].id": ["1[].name", "1[].aria_label"]}},
|
|
242
263
|
{module: "c_yui_nav.js", name: "render_cards", exported: false,
|
|
243
|
-
keys: ["1[].name", "1[].tooltip", "1[].aria_label", "1[].id"]
|
|
264
|
+
keys: ["1[].name", "1[].tooltip", "1[].aria_label", "1[].id"],
|
|
265
|
+
fallbacks: {"1[].id": ["1[].name", "1[].aria_label"]}},
|
|
244
266
|
{module: "c_yui_nav.js", name: "render_submenu", exported: false,
|
|
245
|
-
keys: ["1[].name", "1[].tooltip", "1[].aria_label", "1[].id"]
|
|
267
|
+
keys: ["1[].name", "1[].tooltip", "1[].aria_label", "1[].id"],
|
|
268
|
+
fallbacks: {"1[].id": ["1[].name", "1[].aria_label"]}},
|
|
246
269
|
{module: "c_yui_nav.js", name: "render_drawer", exported: false,
|
|
247
|
-
keys: ["1[].name", "1[].tooltip", "1[].aria_label", "1[].id"]
|
|
270
|
+
keys: ["1[].name", "1[].tooltip", "1[].aria_label", "1[].id"],
|
|
271
|
+
fallbacks: {"1[].id": ["1[].name", "1[].aria_label"]}},
|
|
248
272
|
{module: "c_yui_nav.js", name: "render_breadcrumb", exported: false,
|
|
249
|
-
keys: ["1[].name", "1[].id", "1[].tooltip", "1[].aria_label"]
|
|
273
|
+
keys: ["1[].name", "1[].id", "1[].tooltip", "1[].aria_label"],
|
|
274
|
+
fallbacks: {"1[].id": ["1[].name"]}},
|
|
250
275
|
{module: "c_yui_nav.js", name: "render_accordion", exported: false,
|
|
251
276
|
keys: ["1[].name", "1[].tooltip", "1[].aria_label", "1[].id",
|
|
252
277
|
"1[].submenu.items[].name", "1[].submenu.items[].tooltip",
|
|
253
|
-
"1[].submenu.items[].aria_label", "1[].submenu.items[].id"]
|
|
278
|
+
"1[].submenu.items[].aria_label", "1[].submenu.items[].id"],
|
|
279
|
+
fallbacks: {"1[].id": ["1[].name", "1[].aria_label"],
|
|
280
|
+
"1[].submenu.items[].id": ["1[].submenu.items[].name", "1[].submenu.items[].aria_label"]}},
|
|
254
281
|
/* c_yui_shell.js -- the toolbar items: the app's shell declaration.
|
|
255
282
|
* The id is the key of an item with no `aria_label` nor `name`, and
|
|
256
283
|
* of the menu it opens. */
|
|
257
284
|
{module: "c_yui_shell.js", name: "build_toolbar", exported: false,
|
|
258
285
|
keys: ["1.toolbar.aria_label", "1.toolbar.items[].name", "1.toolbar.items[].aria_label",
|
|
259
|
-
"1.toolbar.items[].tooltip", "1.toolbar.items[].wordmark", "1.toolbar.items[].id"]
|
|
286
|
+
"1.toolbar.items[].tooltip", "1.toolbar.items[].wordmark", "1.toolbar.items[].id"],
|
|
287
|
+
fallbacks: {"1.toolbar.items[].id": ["1.toolbar.items[].aria_label"]}},
|
|
260
288
|
{module: "c_yui_shell.js", name: "build_toolbar_action_item", exported: false,
|
|
261
|
-
keys: ["1.name", "1.aria_label", "1.tooltip", "1.id"]
|
|
289
|
+
keys: ["1.name", "1.aria_label", "1.tooltip", "1.id"],
|
|
290
|
+
fallbacks: {"1.id": ["1.aria_label", "1.name"]}},
|
|
262
291
|
{module: "c_yui_shell.js", name: "build_toolbar_brand_item", exported: false,
|
|
263
|
-
keys: ["1.name", "1.aria_label", "1.tooltip", "1.wordmark", "1.id"]
|
|
292
|
+
keys: ["1.name", "1.aria_label", "1.tooltip", "1.wordmark", "1.id"],
|
|
293
|
+
fallbacks: {"1.id": ["1.aria_label"]}},
|
|
264
294
|
{module: "c_yui_shell.js", name: "build_toolbar_avatar_item", exported: false,
|
|
265
|
-
keys: ["1.name", "1.aria_label", "1.tooltip", "1.id"]
|
|
295
|
+
keys: ["1.name", "1.aria_label", "1.tooltip", "1.id"],
|
|
296
|
+
fallbacks: {"1.id": ["1.aria_label", "1.name"]}},
|
|
266
297
|
{module: "c_yui_shell.js", name: "build_toolbar_connection_item", exported: false,
|
|
267
|
-
keys: ["1.name", "1.aria_label", "1.tooltip", "1.id"]
|
|
268
|
-
|
|
298
|
+
keys: ["1.name", "1.aria_label", "1.tooltip", "1.id"],
|
|
299
|
+
fallbacks: {"1.id": ["1.aria_label", "1.name"]}},
|
|
300
|
+
{module: "c_yui_shell.js", name: "attach_context_action", exported: false,
|
|
301
|
+
keys: ["2.name", "2.aria_label", "2.id"],
|
|
302
|
+
fallbacks: {"2.id": ["2.aria_label", "2.name"]}},
|
|
269
303
|
{module: "c_yui_shell.js", name: "handle_toolbar_action", exported: false,
|
|
270
|
-
keys: ["1.name", "1.aria_label", "1.id"]
|
|
304
|
+
keys: ["1.name", "1.aria_label", "1.id"],
|
|
305
|
+
fallbacks: {"1.id": ["1.aria_label", "1.name"]}},
|
|
271
306
|
{module: "c_yui_shell.js", name: "toggle_toolbar_dropdown", exported: false,
|
|
272
|
-
keys: ["1.name", "1.aria_label", "1.id"]
|
|
307
|
+
keys: ["1.name", "1.aria_label", "1.id"],
|
|
308
|
+
fallbacks: {"1.id": ["1.aria_label", "1.name"]}},
|
|
273
309
|
{module: "c_yui_shell.js", name: "open_toolbar_dropdown", exported: false,
|
|
274
|
-
keys: ["1.name", "1.aria_label", "1.id"]
|
|
310
|
+
keys: ["1.name", "1.aria_label", "1.id"],
|
|
311
|
+
fallbacks: {"1.id": ["1.aria_label", "1.name"]}},
|
|
275
312
|
{module: "c_yui_shell.js", name: "build_dropdown_row", exported: false,
|
|
276
|
-
keys: ["1.name", "1.aria_label", "1.id"]
|
|
313
|
+
keys: ["1.name", "1.aria_label", "1.id"],
|
|
314
|
+
fallbacks: {"1.id": ["1.aria_label", "1.name"]}},
|
|
277
315
|
/* c_yui_shell.js -- the name of a badged item, said with its count:
|
|
278
316
|
* the app's shell declaration */
|
|
279
317
|
{module: "c_yui_shell.js", name: "announce_badge", exported: false, keys: ["1"]},
|
|
@@ -25,6 +25,14 @@
|
|
|
25
25
|
* - the table is CORRECT (V22): the same search started from no
|
|
26
26
|
* table finds every entry, at every position, with the same
|
|
27
27
|
* `exported` -- an entry nothing forwards to fails;
|
|
28
|
+
* - a position the table declares the FALLBACK of others
|
|
29
|
+
* (`fallbacks`: a card's id, behind its name and aria_label) is
|
|
30
|
+
* one in the code: every hand-off of it is the right side of a
|
|
31
|
+
* `||` whose left reads those positions;
|
|
32
|
+
* - a `code` is a key only in the modules whose codes reach t()
|
|
33
|
+
* (CODE_KEY_MODULES), and those are the modules that write one;
|
|
34
|
+
* - the reader gives up on no value of the library (a chain too
|
|
35
|
+
* deep, a const that leads back to itself, too many values);
|
|
28
36
|
* - a parameter handed on through what no position can name (V22:
|
|
29
37
|
* `k.toLowerCase()`, a concatenation, `Object.entries(opts)`, a
|
|
30
38
|
* rest parameter walked, `arguments[i]`, an array pattern) fails,
|
|
@@ -77,6 +85,8 @@ import {fileURLToPath, pathToFileURL} from "node:url";
|
|
|
77
85
|
|
|
78
86
|
import {I18N_KEY_FUNCTIONS} from "./i18n_key_functions.js";
|
|
79
87
|
import {
|
|
88
|
+
CODE_KEY_MODULES,
|
|
89
|
+
gave_up,
|
|
80
90
|
parse_source,
|
|
81
91
|
walk,
|
|
82
92
|
line_of,
|
|
@@ -938,6 +948,93 @@ function table_errors(found, table = I18N_KEY_FUNCTIONS)
|
|
|
938
948
|
}
|
|
939
949
|
|
|
940
950
|
|
|
951
|
+
/*
|
|
952
|
+
* A FALLBACK of the table is one in the code: every hand-off of the
|
|
953
|
+
* position, in its function, is the right operand of a `||` / `??`
|
|
954
|
+
* chain whose left operands read every position the entry names as
|
|
955
|
+
* read first (`it.name || it.aria_label || it.id`, the left read
|
|
956
|
+
* through a `let` or a const too) -- or a key position of a key
|
|
957
|
+
* function whose own fallbacks are positions of this one, handed
|
|
958
|
+
* there with it (`{...it}`, not `{id: it.id}`, which drops them). A
|
|
959
|
+
* fallback the code does not show would let the validator skip a key
|
|
960
|
+
* the function asks for.
|
|
961
|
+
*/
|
|
962
|
+
function fallback_errors(table = I18N_KEY_FUNCTIONS, asts = ast_of)
|
|
963
|
+
{
|
|
964
|
+
let out = [];
|
|
965
|
+
let ancestors_of = (ast, node) => {
|
|
966
|
+
let found = null;
|
|
967
|
+
walk(ast, (n, ancestors) => {
|
|
968
|
+
if(!found && n === node) {
|
|
969
|
+
found = ancestors.slice();
|
|
970
|
+
}
|
|
971
|
+
});
|
|
972
|
+
return found || [];
|
|
973
|
+
};
|
|
974
|
+
let guards_in_code = (ast, e, node) => {
|
|
975
|
+
let guards = new Set();
|
|
976
|
+
let ancestors = ancestors_of(ast, node);
|
|
977
|
+
let cur = node;
|
|
978
|
+
for(let i = ancestors.length - 1; i >= 0; i--) {
|
|
979
|
+
let a = ancestors[i];
|
|
980
|
+
if(a.type === "LogicalExpression" && a.operator !== "&&" && a.right === cur) {
|
|
981
|
+
for(let f of param_flows(a.left, ancestors.slice(0, i + 1))) {
|
|
982
|
+
if(f.binding.name === e.name && f.path !== null) {
|
|
983
|
+
guards.add(`${f.binding.index}${f.path}`);
|
|
984
|
+
}
|
|
985
|
+
}
|
|
986
|
+
} else if(!(a.type === "LogicalExpression" && a.left === cur)
|
|
987
|
+
&& !(a.type === "ConditionalExpression" && a.test !== cur)
|
|
988
|
+
&& a.type !== "ChainExpression") {
|
|
989
|
+
break;
|
|
990
|
+
}
|
|
991
|
+
cur = a;
|
|
992
|
+
}
|
|
993
|
+
return guards;
|
|
994
|
+
};
|
|
995
|
+
let modules = [...new Set(table.filter((e) => e.fallbacks).map((e) => e.module))];
|
|
996
|
+
for(let module of modules) {
|
|
997
|
+
let ast = asts(module);
|
|
998
|
+
let entries = table.filter((e) => e.module === module && e.fallbacks);
|
|
999
|
+
for(let place of key_places(ast, {lib_module: module, table})) {
|
|
1000
|
+
for(let leaf of place.leaves) {
|
|
1001
|
+
for(let p of handed_params(leaf)) {
|
|
1002
|
+
let pos = `${p.binding.index}${p.path}`;
|
|
1003
|
+
let e = entries.find((x) => x.name === p.binding.name && x.fallbacks[pos]);
|
|
1004
|
+
if(!e) {
|
|
1005
|
+
continue;
|
|
1006
|
+
}
|
|
1007
|
+
let guards;
|
|
1008
|
+
let callee_firsts = (place.what === "call" && place.entry.fallbacks)?
|
|
1009
|
+
place.entry.fallbacks[place.path] : null;
|
|
1010
|
+
if(callee_firsts) {
|
|
1011
|
+
/* What the callee reads first, where it is handed: the
|
|
1012
|
+
* positions of this function that arrive there */
|
|
1013
|
+
let k = key_calls(ast, module, table).find((c) => c.call === place.node);
|
|
1014
|
+
guards = new Set();
|
|
1015
|
+
for(let f of callee_firsts) {
|
|
1016
|
+
for(let l of values_at(k.call, f, k.scope, k.args)) {
|
|
1017
|
+
if(l.kind === "param" && l.binding.name === e.name && l.path !== null) {
|
|
1018
|
+
guards.add(`${l.binding.index}${l.path}`);
|
|
1019
|
+
}
|
|
1020
|
+
}
|
|
1021
|
+
}
|
|
1022
|
+
} else {
|
|
1023
|
+
guards = guards_in_code(ast, e, p.node);
|
|
1024
|
+
}
|
|
1025
|
+
let lacking = e.fallbacks[pos].filter((f) => !guards.has(f));
|
|
1026
|
+
if(lacking.length > 0) {
|
|
1027
|
+
out.push(`${module}:${line_of(ast, p.node.start)} ${e.name}() hands [${pos}] to a place a key ` +
|
|
1028
|
+
`is read without reading [${lacking.join(", ")}] first: its \`fallbacks\` in ` +
|
|
1029
|
+
`I18N_KEY_FUNCTIONS say otherwise`);
|
|
1030
|
+
}
|
|
1031
|
+
}
|
|
1032
|
+
}
|
|
1033
|
+
}
|
|
1034
|
+
}
|
|
1035
|
+
return [...new Set(out)];
|
|
1036
|
+
}
|
|
1037
|
+
|
|
941
1038
|
describe("I18N_KEY_FUNCTIONS: the table", () => {
|
|
942
1039
|
test("every entry names a function of its module, at positions that can be followed", () => {
|
|
943
1040
|
let wrong = [];
|
|
@@ -973,6 +1070,29 @@ describe("I18N_KEY_FUNCTIONS: the table", () => {
|
|
|
973
1070
|
wrong.push(`${where}: key position ${JSON.stringify(k)} cannot be followed`);
|
|
974
1071
|
}
|
|
975
1072
|
}
|
|
1073
|
+
if(e.fallbacks === undefined) {
|
|
1074
|
+
continue;
|
|
1075
|
+
}
|
|
1076
|
+
if(!e.fallbacks || typeof e.fallbacks !== "object" || Array.isArray(e.fallbacks)) {
|
|
1077
|
+
wrong.push(`${where}: \`fallbacks\` is not an object`);
|
|
1078
|
+
continue;
|
|
1079
|
+
}
|
|
1080
|
+
for(let [k, firsts] of Object.entries(e.fallbacks)) {
|
|
1081
|
+
let parent = k.slice(0, k.lastIndexOf(".") + 1);
|
|
1082
|
+
if(!e.keys.includes(k) || !parent) {
|
|
1083
|
+
wrong.push(`${where}: the fallback ${JSON.stringify(k)} is no property position of \`keys\``);
|
|
1084
|
+
}
|
|
1085
|
+
if(!Array.isArray(firsts) || firsts.length === 0) {
|
|
1086
|
+
wrong.push(`${where}: the fallback ${JSON.stringify(k)} names no position read first`);
|
|
1087
|
+
continue;
|
|
1088
|
+
}
|
|
1089
|
+
for(let f of firsts) {
|
|
1090
|
+
if(f === k || !e.keys.includes(f) || !f.startsWith(parent) || f.slice(parent.length).includes("[]")) {
|
|
1091
|
+
wrong.push(`${where}: ${JSON.stringify(f)}, read before ${JSON.stringify(k)}, is no other ` +
|
|
1092
|
+
`position of \`keys\` under ${JSON.stringify(parent)}`);
|
|
1093
|
+
}
|
|
1094
|
+
}
|
|
1095
|
+
}
|
|
976
1096
|
}
|
|
977
1097
|
expect(wrong).toEqual([]);
|
|
978
1098
|
});
|
|
@@ -987,6 +1107,38 @@ describe("REV-CLOUD V21.4.1: every forwarder is in the table", () => {
|
|
|
987
1107
|
expect(table_errors(find_forwarders(MODULES, ast_of, []).found)).toEqual([]);
|
|
988
1108
|
});
|
|
989
1109
|
|
|
1110
|
+
test("every fallback of the table is one in the code, and the check fails when it is not", () => {
|
|
1111
|
+
expect(fallback_errors()).toEqual([]);
|
|
1112
|
+
let module = "nav_cards_helpers.js";
|
|
1113
|
+
let wider = I18N_KEY_FUNCTIONS.map((e) => (e.name !== "card_descriptor")? e :
|
|
1114
|
+
Object.assign({}, e, {fallbacks: {"0.id": ["0.name", "0.aria_label", "0.tooltip"]}}));
|
|
1115
|
+
expect(fallback_errors(wider)).toEqual([
|
|
1116
|
+
`${module}:55 card_descriptor() hands [0.id] to a place a key is read without reading [0.tooltip] ` +
|
|
1117
|
+
`first: its \`fallbacks\` in I18N_KEY_FUNCTIONS say otherwise`
|
|
1118
|
+
]);
|
|
1119
|
+
let code = readFileSync(join(SRC, module), "utf8");
|
|
1120
|
+
let plain = code.replace('"data-disabled": it.disabled ? "1" : "0",',
|
|
1121
|
+
'"data-disabled": it.disabled ? "1" : "0", "data-i18n-placeholder": it.id,');
|
|
1122
|
+
expect(plain).not.toBe(code);
|
|
1123
|
+
let mutated = parse_as(plain, module);
|
|
1124
|
+
expect(fallback_errors(I18N_KEY_FUNCTIONS, (m) => (m === module)? mutated : ast_of(m))).toEqual([
|
|
1125
|
+
`${module}:61 card_descriptor() hands [0.id] to a place a key is read without reading [0.name, ` +
|
|
1126
|
+
`0.aria_label] first: its \`fallbacks\` in I18N_KEY_FUNCTIONS say otherwise`
|
|
1127
|
+
]);
|
|
1128
|
+
/* A hand-off to a key function counts its fallbacks only when they
|
|
1129
|
+
* arrive with the id: `{id: it.id}` drops them (7.26.42's right-click) */
|
|
1130
|
+
let shell = "c_yui_shell.js";
|
|
1131
|
+
let shell_code = readFileSync(join(SRC, shell), "utf8");
|
|
1132
|
+
let dropped = shell_code.replace("{...it, action: it.context_action}", "{id: it.id, action: it.context_action}");
|
|
1133
|
+
expect(dropped).not.toBe(shell_code);
|
|
1134
|
+
let shell_mutated = parse_as(dropped, shell);
|
|
1135
|
+
let table = I18N_KEY_FUNCTIONS.map((e) => (e.name !== "attach_context_action")? e :
|
|
1136
|
+
Object.assign({}, e, {keys: ["2.id"]}));
|
|
1137
|
+
let said = fallback_errors(table, (m) => (m === shell)? shell_mutated : ast_of(m));
|
|
1138
|
+
expect(said.length).toBe(1);
|
|
1139
|
+
expect(said[0]).toMatch(/^c_yui_shell\.js:\d+ attach_context_action\(\) hands \[2\.id\] to a place a key is read without reading \[2\.aria_label, 2\.name\] first/);
|
|
1140
|
+
});
|
|
1141
|
+
|
|
990
1142
|
test("the search finds what it should, and nothing else", () => {
|
|
991
1143
|
let code = [
|
|
992
1144
|
`import {yui_shell_show_error} from "./shell_modals.js";`,
|
|
@@ -999,14 +1151,16 @@ describe("REV-CLOUD V21.4.1: every forwarder is in the table", () => {
|
|
|
999
1151
|
`function by_pattern(gobj, {title, label = "fallback"}) { return t(title); }`,
|
|
1000
1152
|
`function ac_show(gobj, event, kw, src) { yui_shell_show_error(shell, kw.comment); }`,
|
|
1001
1153
|
`function ac_marked(gobj, event, kw, src) { return t(/* i18n: data */ kw.comment); }`,
|
|
1002
|
-
`
|
|
1154
|
+
`function by_bind(gobj, msg) { return yui_shell_show_error.bind(null, shell, msg); }`,
|
|
1155
|
+
`function by_bound_t(gobj, key) { return t.bind(null, key); }`,
|
|
1156
|
+
`say(); told(); relay(); own(); as_dom(); by_let(); by_pattern(); by_bind(); by_bound_t();`
|
|
1003
1157
|
].join("\n");
|
|
1004
1158
|
let ast = parse_as(code, "x.js");
|
|
1005
1159
|
let found = find_forwarders(["x.js"], () => ast);
|
|
1006
1160
|
let got = Object.fromEntries(found.missing.map((m) => [m.name, m.keys.sort()]));
|
|
1007
1161
|
expect(got).toEqual({
|
|
1008
1162
|
say: ["1"], told: ["1.message"], relay: ["1"], as_dom: ["1"],
|
|
1009
|
-
by_let: ["1.name"], by_pattern: ["1.title"]
|
|
1163
|
+
by_let: ["1.name"], by_pattern: ["1.title"], by_bind: ["1"], by_bound_t: ["1"]
|
|
1010
1164
|
});
|
|
1011
1165
|
expect(found.unmarked.map((u) => `${u.name} ${u.pos}`)).toEqual(["ac_show 2.comment"]);
|
|
1012
1166
|
|
|
@@ -1039,6 +1193,55 @@ describe("REV-CLOUD V21.4.1: every forwarder is in the table", () => {
|
|
|
1039
1193
|
});
|
|
1040
1194
|
});
|
|
1041
1195
|
|
|
1196
|
+
describe("a `code` is a key where the library makes one", () => {
|
|
1197
|
+
test("the modules that write a literal `code` are CODE_KEY_MODULES, and only those", () => {
|
|
1198
|
+
let writers = new Set();
|
|
1199
|
+
for(let module of MODULES) {
|
|
1200
|
+
walk(ast_of(module), (n, ancestors) => {
|
|
1201
|
+
let parent = ancestors[ancestors.length - 1];
|
|
1202
|
+
if(n.type === "Property" && parent && parent.type === "ObjectExpression"
|
|
1203
|
+
&& !n.computed && ((n.key.type === "Identifier" && n.key.name === "code")
|
|
1204
|
+
|| (n.key.type === "Literal" && n.key.value === "code"))
|
|
1205
|
+
&& n.value.type === "Literal" && typeof n.value.value === "string") {
|
|
1206
|
+
writers.add(module);
|
|
1207
|
+
}
|
|
1208
|
+
});
|
|
1209
|
+
}
|
|
1210
|
+
expect([...writers].sort()).toEqual([...CODE_KEY_MODULES].sort());
|
|
1211
|
+
});
|
|
1212
|
+
|
|
1213
|
+
test("there a literal `code` is asked for; in any other module it is not", () => {
|
|
1214
|
+
let code = `let finding = {severity: "error", code: "a finding code"};`;
|
|
1215
|
+
expect([...scan_ast(parse_as(code, "schema_validate.js"), {lib_module: "schema_validate.js"}).keys])
|
|
1216
|
+
.toEqual(["a finding code"]);
|
|
1217
|
+
expect([...scan_ast(parse_as(code, "x.js"), {lib_module: "x.js"}).keys]).toEqual([]);
|
|
1218
|
+
});
|
|
1219
|
+
});
|
|
1220
|
+
|
|
1221
|
+
describe("the reader never gives up on the library", () => {
|
|
1222
|
+
test("no chain too deep, no const that leads back to itself, no value with too many values", () => {
|
|
1223
|
+
let said = [];
|
|
1224
|
+
for(let module of MODULES) {
|
|
1225
|
+
let ast = ast_of(module);
|
|
1226
|
+
scan_ast(ast, {lib_module: module});
|
|
1227
|
+
call_rule_violations(ast, module);
|
|
1228
|
+
said.push(...gave_up(ast).map((g) => `${module}:${g.line} \`${g.text}\`: ${g.why}`));
|
|
1229
|
+
}
|
|
1230
|
+
expect(said).toEqual([]);
|
|
1231
|
+
});
|
|
1232
|
+
|
|
1233
|
+
test("...and says where it would", () => {
|
|
1234
|
+
let lines = [`const K0 = "far";`];
|
|
1235
|
+
for(let i = 1; i <= 24; i++) {
|
|
1236
|
+
lines.push(`const K${i} = K${i - 1};`);
|
|
1237
|
+
}
|
|
1238
|
+
lines.push(`function f() { return t(K24); }`);
|
|
1239
|
+
let ast = parse_as(lines.join("\n"), "x.js");
|
|
1240
|
+
scan_ast(ast, {lib_module: "x.js"});
|
|
1241
|
+
expect(gave_up(ast).map((g) => `${g.line} ${g.text}`)).toEqual([`1 "far"`]);
|
|
1242
|
+
});
|
|
1243
|
+
});
|
|
1244
|
+
|
|
1042
1245
|
describe("the rule, per call: a key position gets what the validator can read, or a marker", () => {
|
|
1043
1246
|
test("every call of a key function, in every module of the library", () => {
|
|
1044
1247
|
let wrong = [];
|
|
@@ -2113,6 +2316,13 @@ describe("REV-CLOUD V24.5: every write counts; a translated text fails unmarked
|
|
|
2113
2316
|
* module `var` given more in a block included */
|
|
2114
2317
|
expect(keys_of([`var key = "a module key";`, `if(c) {`, ` var key = "a block key";`, `}`, `t(key);`]))
|
|
2115
2318
|
.toEqual(["a block key", "a module key"]);
|
|
2319
|
+
/* An INDIRECT eval -- `eval?.()`, `(0, eval)()` -- runs in the global
|
|
2320
|
+
* scope and writes no variable of the module: the let is still
|
|
2321
|
+
* followed (up to 7.26.42 `eval?.()` counted as a direct eval) */
|
|
2322
|
+
for(let call of [`eval?.(code);`, `(0, eval)(code);`]) {
|
|
2323
|
+
expect(keys_of([`function f(code) {`, ` let key = "an eval-proof key";`, ` ${call}`,
|
|
2324
|
+
` return t(key);`, `}`]), call).toEqual(["an eval-proof key"]);
|
|
2325
|
+
}
|
|
2116
2326
|
/* A `var` of a class's static block is the block's own: it hides an
|
|
2117
2327
|
* outer `let` of the same name (up to 7.26.41 it was not seen) */
|
|
2118
2328
|
expect(keys_of([`let key = "-";`, `class A {`, ` static {`, ` var key = kw.data;`, ` t(key);`,
|
|
@@ -2139,8 +2349,8 @@ describe("REV-CLOUD V24.5: every write counts; a translated text fails unmarked
|
|
|
2139
2349
|
`el.setAttribute("data-i18n-title", t("k"));`, // 4
|
|
2140
2350
|
`t(t("k") + "!");`, // 5
|
|
2141
2351
|
`el.dataset.i18nTitle = tr("k");`, // 6
|
|
2142
|
-
`x = {code: i18next.t("k")};`, // 7
|
|
2143
|
-
`add("error", t("k"));`, // 8
|
|
2352
|
+
`x = {code: i18next.t("k")};`, // 7: no key place in x.js
|
|
2353
|
+
`add("error", t("k"));`, // 8: no key function
|
|
2144
2354
|
`t([t("k"), "fallback"]);`, // 9
|
|
2145
2355
|
`const L = t("k");`, // 10: the text, read at 11
|
|
2146
2356
|
`x = {"data-i18n": L};`,
|
|
@@ -2148,15 +2358,19 @@ describe("REV-CLOUD V24.5: every write counts; a translated text fails unmarked
|
|
|
2148
2358
|
`x = {i18n: ["p", {}, t("k")]};`, // DOM is DOM
|
|
2149
2359
|
`let held = t("k");`,
|
|
2150
2360
|
`x = {i18n: held};`]); // in a let: the documented limit
|
|
2151
|
-
expect(r.translated_errors.map((e) => e.line)).toEqual([3, 4, 5, 6,
|
|
2361
|
+
expect(r.translated_errors.map((e) => e.line)).toEqual([3, 4, 5, 6, 9, 10, 12]);
|
|
2152
2362
|
expect(r.translated_errors[0].why).toBe('`t("k")` is a TRANSLATED text given to a property that holds a key ' +
|
|
2153
2363
|
'(i18n, code, data-i18n*): the translation is kept as its key and never changes language: hand the key, ' +
|
|
2154
2364
|
'not t(key)');
|
|
2155
2365
|
expect(r.translated_errors[1].why).toMatch(/^`t\("k"\)` is a TRANSLATED text given to a data-i18n\* attribute: /);
|
|
2156
2366
|
expect(r.translated_errors[2].why).toMatch(/^`t\("k"\) \+ "!"` is a TRANSLATED text handed to a translator as its key: /);
|
|
2157
|
-
expect(r.translated_errors[
|
|
2158
|
-
expect(r.translated_errors[
|
|
2367
|
+
expect(r.translated_errors[5].why).toMatch(/^`t\("k"\)` is a TRANSLATED text given to a property .* \(read at line 11\): /);
|
|
2368
|
+
expect(r.translated_errors[6].why).toMatch(/^marked as data, but `t\("k"\)` is a TRANSLATED text: .*no marker excuses it/);
|
|
2159
2369
|
expect(r.marker_errors).toEqual([]);
|
|
2370
|
+
/* Where a `code` is a key, a translated one fails as well */
|
|
2371
|
+
let c = scan_ast(parse_as([`x = {code: i18next.t("k")};`].join("\n"), "schema_import.js"),
|
|
2372
|
+
{lib_module: "schema_import.js"});
|
|
2373
|
+
expect(c.translated_errors.map((e) => e.line)).toEqual([1]);
|
|
2160
2374
|
});
|
|
2161
2375
|
|
|
2162
2376
|
test("no module of the library hands a TRANSLATED text to a place a key is read", () => {
|
|
@@ -2212,6 +2426,7 @@ describe("REV-CLOUD V24.5: every write counts; a translated text fails unmarked
|
|
|
2212
2426
|
});
|
|
2213
2427
|
|
|
2214
2428
|
test("a bound translator: what a call of it is handed is i18next's options, no key; a bound key function counts them", () => {
|
|
2429
|
+
/* The key it binds is read where the bind is written */
|
|
2215
2430
|
expect(keys_of([`const tk = t.bind(null, "bound key");`,
|
|
2216
2431
|
`tk("an option");`,
|
|
2217
2432
|
`tk.call(null, "another option");`,
|
|
@@ -2219,7 +2434,7 @@ describe("REV-CLOUD V24.5: every write counts; a translated text fails unmarked
|
|
|
2219
2434
|
`["an element"].map(tk);`,
|
|
2220
2435
|
`["another element"].map(t.bind(null, "bound key"));`,
|
|
2221
2436
|
`const tt = t.bind(i18next);`,
|
|
2222
|
-
`tt("a key: nothing bound");`])).toEqual(["a key: nothing bound"]);
|
|
2437
|
+
`tt("a key: nothing bound");`])).toEqual(["a key: nothing bound", "bound key"]);
|
|
2223
2438
|
/* Its text is translated text all the same */
|
|
2224
2439
|
expect(scan([`const tk = t.bind(null, "bound key");`, `x = {i18n: tk()};`]).translated_errors.map((e) => e.line))
|
|
2225
2440
|
.toEqual([4]);
|
|
@@ -2229,7 +2444,14 @@ describe("REV-CLOUD V24.5: every write counts; a translated text fails unmarked
|
|
|
2229
2444
|
expect(rule([`const show = yui_shell_show_info.bind(null, shell);`, `show(kw.message);`,
|
|
2230
2445
|
`const more = yui_shell_show_info.bind(null, ...args);`, `more("k");`])).toEqual([
|
|
2231
2446
|
`${module}:4 yui_shell_show_info() [1]: kw.message`,
|
|
2447
|
+
`${module}:5 yui_shell_show_info() [1]: ...args`, // what the bind hands, unknown: loud
|
|
2232
2448
|
`${module}:6 yui_shell_show_info() [1]: more("k")` // a spread hides the positions: loud
|
|
2233
2449
|
]);
|
|
2450
|
+
/* What a bind binds is read where it is written: keys asked, and the rule per call */
|
|
2451
|
+
let b = scan([`const say = yui_shell_show_info.bind(null, shell, "a bound message");`, `say();`,
|
|
2452
|
+
`const ask = yui_shell_show_info.bind(null, shell).bind(null, "a twice bound one");`]);
|
|
2453
|
+
expect([...b.keys].sort()).toEqual(["a bound message", "a twice bound one"]);
|
|
2454
|
+
expect(rule([`function relay(msg) {`, ` return yui_shell_show_info.bind(null, shell, msg);`, `}`]))
|
|
2455
|
+
.toEqual([`${module}:4 yui_shell_show_info() [1]: msg`]);
|
|
2234
2456
|
});
|
|
2235
2457
|
});
|
|
@@ -270,6 +270,59 @@ describe("what the guard's promise settles with is the answer", () => {
|
|
|
270
270
|
expect(errors()).toEqual([]);
|
|
271
271
|
});
|
|
272
272
|
|
|
273
|
+
/* An `async` guard that ends in `return;` settles with undefined:
|
|
274
|
+
* a veto, as for every promise, and with no question on the screen
|
|
275
|
+
* the reader is left with a modal that does not close. Said, so
|
|
276
|
+
* the developer learns it from the log and not from the reader. */
|
|
277
|
+
test("an async guard that settles with undefined and asked nothing is a veto, said", async () => {
|
|
278
|
+
const {shell, handle, counts} = open_sheet(async () => {
|
|
279
|
+
return;
|
|
280
|
+
});
|
|
281
|
+
document.querySelector(".TEST_SHEET .yui-dialog-x").click();
|
|
282
|
+
await settle();
|
|
283
|
+
expect(sheets()).toBe(1);
|
|
284
|
+
expect(counts.closes).toBe(0);
|
|
285
|
+
expect(warnings().some((m) => m.includes("before_close") &&
|
|
286
|
+
m.includes("undefined") &&
|
|
287
|
+
m.includes("asked nothing"))).toBe(true);
|
|
288
|
+
|
|
289
|
+
handle.close();
|
|
290
|
+
expect(sheets()).toBe(0);
|
|
291
|
+
expect(shell.priv.overlay_stack).toEqual([]);
|
|
292
|
+
expect(errors()).toEqual([]);
|
|
293
|
+
});
|
|
294
|
+
|
|
295
|
+
/* The README's guard: a question, and a `.then()` that returns
|
|
296
|
+
* nothing -- it closes the modal itself on "yes". On "no" the
|
|
297
|
+
* undefined is the veto it means, and nothing is said. */
|
|
298
|
+
test("a guard that asked and settles with undefined on \"no\" is a veto, said nothing", async () => {
|
|
299
|
+
let shell_of = null;
|
|
300
|
+
const {shell, handle, counts} = open_sheet((handle_of) => {
|
|
301
|
+
return yui_shell_confirm_yesnocancel(shell_of, "all changes will be lost", {
|
|
302
|
+
yes_label: "yes", no_label: "no", cancel_label: "cancel"
|
|
303
|
+
}).then((answer) => {
|
|
304
|
+
if(answer === "yes") {
|
|
305
|
+
handle_of().close();
|
|
306
|
+
}
|
|
307
|
+
});
|
|
308
|
+
});
|
|
309
|
+
shell_of = shell;
|
|
310
|
+
document.querySelector(".TEST_SHEET .yui-dialog-x").click();
|
|
311
|
+
await settle();
|
|
312
|
+
expect(questions()).toBe(1);
|
|
313
|
+
document.querySelector('.CONFIRM [data-modal-button-value="no"]').click();
|
|
314
|
+
await settle();
|
|
315
|
+
await settle();
|
|
316
|
+
expect(questions()).toBe(0);
|
|
317
|
+
expect(sheets()).toBe(1);
|
|
318
|
+
expect(counts.closes).toBe(0);
|
|
319
|
+
expect(warnings()).toEqual([]);
|
|
320
|
+
|
|
321
|
+
handle.close();
|
|
322
|
+
expect(sheets()).toBe(0);
|
|
323
|
+
expect(errors()).toEqual([]);
|
|
324
|
+
});
|
|
325
|
+
|
|
273
326
|
test("a promise that rejects is a veto, said, and Back gets its entry back", async () => {
|
|
274
327
|
const {shell, handle, counts} = open_sheet(() => Promise.reject(new Error("no answer")));
|
|
275
328
|
press_back(shell);
|
|
@@ -37,9 +37,12 @@ install_dom_double();
|
|
|
37
37
|
|
|
38
38
|
if(typeof globalThis.ResizeObserver === "undefined") {
|
|
39
39
|
globalThis.ResizeObserver = class {
|
|
40
|
-
observe() {
|
|
41
|
-
|
|
42
|
-
|
|
40
|
+
observe() {
|
|
41
|
+
}
|
|
42
|
+
unobserve() {
|
|
43
|
+
}
|
|
44
|
+
disconnect() {
|
|
45
|
+
}
|
|
43
46
|
};
|
|
44
47
|
}
|
|
45
48
|
|
|
@@ -59,7 +62,8 @@ vi.mock("@antv/g6", async (importOriginal) => {
|
|
|
59
62
|
draw() {
|
|
60
63
|
return Promise.resolve();
|
|
61
64
|
}
|
|
62
|
-
on() {
|
|
65
|
+
on() {
|
|
66
|
+
}
|
|
63
67
|
getZoom() {
|
|
64
68
|
return 1;
|
|
65
69
|
}
|
|
@@ -81,7 +85,8 @@ vi.mock("@antv/g6", async (importOriginal) => {
|
|
|
81
85
|
getOptions() {
|
|
82
86
|
return {behaviors: []};
|
|
83
87
|
}
|
|
84
|
-
destroy() {
|
|
88
|
+
destroy() {
|
|
89
|
+
}
|
|
85
90
|
}
|
|
86
91
|
return {...real, Graph: FakeGraph};
|
|
87
92
|
});
|
|
@@ -109,7 +114,8 @@ vi.mock("tabulator-tables", () => {
|
|
|
109
114
|
off(ev) {
|
|
110
115
|
delete this.externalEvents.events[ev];
|
|
111
116
|
}
|
|
112
|
-
destroy() {
|
|
117
|
+
destroy() {
|
|
118
|
+
}
|
|
113
119
|
}
|
|
114
120
|
return {TabulatorFull: FakeTabulator, Tabulator: FakeTabulator};
|
|
115
121
|
});
|
|
@@ -123,16 +129,23 @@ vi.mock("tom-select", () => ({
|
|
|
123
129
|
this.settings = settings;
|
|
124
130
|
selects.push(this);
|
|
125
131
|
}
|
|
126
|
-
on() {
|
|
127
|
-
|
|
128
|
-
|
|
132
|
+
on() {
|
|
133
|
+
}
|
|
134
|
+
disable() {
|
|
135
|
+
}
|
|
136
|
+
enable() {
|
|
137
|
+
}
|
|
129
138
|
getValue() {
|
|
130
139
|
return [];
|
|
131
140
|
}
|
|
132
|
-
clear() {
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
141
|
+
clear() {
|
|
142
|
+
}
|
|
143
|
+
setValue() {
|
|
144
|
+
}
|
|
145
|
+
addOption() {
|
|
146
|
+
}
|
|
147
|
+
destroy() {
|
|
148
|
+
}
|
|
136
149
|
}
|
|
137
150
|
}));
|
|
138
151
|
|
|
@@ -600,6 +613,33 @@ describe("the items of the toolbar: what the nav got (REV-CLOUD V24.5.4)", () =>
|
|
|
600
613
|
expect(errors()).toEqual([]);
|
|
601
614
|
});
|
|
602
615
|
|
|
616
|
+
test("the menu a right-click opens is named as its trigger, as the left-click one is", () => {
|
|
617
|
+
const shell = toolbar_shell([
|
|
618
|
+
{id: "conn", type: "connection", aria_label: "server link",
|
|
619
|
+
context_action: {type: "dropdown", items: [
|
|
620
|
+
{id: "logs", icon: "yi-list", action: {type: "event", event: "EV_LOGS"}}
|
|
621
|
+
]}},
|
|
622
|
+
{id: "tools", icon: "yi-gear", name: "tools key", action: {type: "event", event: "EV_TOOLS"},
|
|
623
|
+
context_action: {type: "dropdown", items: [
|
|
624
|
+
{id: "about", name: "about", action: {type: "event", event: "EV_ABOUT"}}
|
|
625
|
+
]}}
|
|
626
|
+
]);
|
|
627
|
+
const right_click = ($el) => $el.dispatchEvent({type: "contextmenu", preventDefault() {}});
|
|
628
|
+
/* Up to 7.26.42 it was named by the raw id: the right-click handed
|
|
629
|
+
* the shell `{id, action}`, which dropped the trigger's names */
|
|
630
|
+
right_click(item_of(shell, "conn"));
|
|
631
|
+
let $panel = document.querySelector('[data-toolbar-dropdown-for="conn"]');
|
|
632
|
+
expect($panel.getAttribute("aria-label")).toBe("server link");
|
|
633
|
+
expect($panel.getAttribute("data-i18n-aria-label")).toBe("server link");
|
|
634
|
+
expect_named($panel.querySelector('[data-dropdown-item-id="logs"]'), "logs");
|
|
635
|
+
right_click(item_of(shell, "conn"));
|
|
636
|
+
right_click(item_of(shell, "tools"));
|
|
637
|
+
$panel = document.querySelector('[data-toolbar-dropdown-for="tools"]');
|
|
638
|
+
expect($panel.getAttribute("aria-label")).toBe("tools key");
|
|
639
|
+
right_click(item_of(shell, "tools"));
|
|
640
|
+
expect(errors()).toEqual([]);
|
|
641
|
+
});
|
|
642
|
+
|
|
603
643
|
test("a connection dot with neither: the library's own key, from the start", () => {
|
|
604
644
|
const shell = toolbar_shell([{id: "conn", type: "connection"}]);
|
|
605
645
|
expect_named(item_of(shell, "conn"), "backend connection");
|