v0.34.3_ht2

This commit is contained in:
Mateusz Gruszczyński committed 2026-10-20 12:36:58 +02:00
1 parent 29d9a7dd6c
commit 1fd81eaf5f
9 files changed
+80 -37

No files matched your search

+16 -3
View File
@@ -44,7 +44,9 @@ const render = vm.runInNewContext(`${src.slice(renderBegin + 1, end)}; renderCac
});
render(result, 10);
assert.equal(dom("cache-mix-headline").textContent, "40.0% HIT");
assert.equal(dom("cache-mix-caption").textContent, "Since service start · 10 HTTP requests");
assert.equal(dom("cache-mix-caption").textContent, "10");
assert.equal(dom("cache-mix-caption").attributes.title, "Since service start · 10 HTTP requests");
assert.equal(dom("cache-mix-caption").attributes["aria-label"], "Since service start · 10 HTTP requests");
for (const [name, count, percent] of [["hit", 4, 40], ["miss", 2, 20],
["bypass", 3, 30], ["other", 1, 10]]) {
assert.equal(dom(`cache-mix-${name}-count`).textContent, String(count));
@@ -53,12 +55,17 @@ for (const [name, count, percent] of [["hit", 4, 40], ["miss", 2, 20],
}
assert.match(dom("cache-mix-bar").attributes["aria-label"], /4 HIT, 2 MISS, 3 BYPASS, 1 OTHER/);
render(null, 0);
assert.equal(dom("cache-mix-caption").textContent, english.cacheMixWaiting);
assert.equal(dom("cache-mix-caption").textContent, "0");
assert.equal(dom("cache-mix-caption").attributes.title, "Since service start · 0 HTTP requests");
assert.equal(dom("cache-mix-hit-count").textContent, "-");
assert.equal(dom("cache-mix-hit").style.width, "0%");
render(null, 10);
assert.equal(dom("cache-mix-caption").textContent, english.cacheMixInvalid);
assert.equal(dom("cache-mix-caption").textContent, "10");
assert.equal(dom("cache-mix-caption").attributes.title, "Since service start · 10 HTTP requests");
assert.equal(dom("cache-mix-bar").attributes["aria-label"], english.cacheMixInvalid);
render(null, NaN);
assert.equal(dom("cache-mix-caption").textContent, "-");
assert.equal(dom("cache-mix-caption").attributes.title, english.cacheMixInvalid);
const widgets = JSON.parse(fs.readFileSync(path.join(root, "src/admin/web/dashboard-widgets.json"), "utf8"));
const defaults = JSON.parse(fs.readFileSync(path.join(root, "src/admin/web/dashboard-defaults.json"), "utf8"));
@@ -68,6 +75,12 @@ assert.equal(widgets.find(widget => widget.id === "cache_outcomes").default_hidd
assert.equal(defaults.dashboard_hidden_widgets.filter(id => id === "cache_outcomes").length, 1, "hidden in factory layout");
const html = fs.readFileSync(path.join(root, "src/admin/web/partials/overview-metrics.html"), "utf8");
assert.match(html, /data-dashboard-widget="cache_outcomes"/);
assert.match(html, /class="cache-mix-header">\s*<span data-i18n="cacheMixTitle">[^<]+<\/span>\s*<small class="cache-mix-caption" id="cache-mix-caption"/);
assert.equal((html.match(/id="cache-mix-caption"/g) || []).length, 1, "counter shown only in top-right header");
const css = fs.readFileSync(path.join(root, "src/admin/web/style.css"), "utf8");
assert.match(css, /\.stat-cache-outcomes \.cache-mix-header \{\s*display: flex;/);
assert.match(css, /\.stat-cache-outcomes \.cache-mix-caption \{[^}]*text-align: right;/);
for (const key of ["hit", "miss", "bypass", "other"]) {
assert.match(html, new RegExp(`id="cache-mix-${key}"`));
assert.match(html, new RegExp(`id="cache-mix-${key}-count"`));