mirror of
https://github.com/bilawalsidhu/gods-eye-view.git
synced 2026-11-20 10:12:18 +00:00
Search, Filter, the filter menu's Status and Category options and the bar's two clear chips are ghost UiButtons. Search and the options are pressed toggles in place of hand-written aria-pressed; the options take active as their pressed class, while Search keeps its own active binding, which also stays on while a query is typed. Escape in the menu still gives focus back to the Filter button, now through the UiButton's root. Every Material glyph in it is a UiIcon sized by layer-finder.css. A guard test pins it, and the migration notes say so. Co-authored-by: Manjunath Paparaju <[email protected]>
51 lines
2.1 KiB
JavaScript
51 lines
2.1 KiB
JavaScript
// The Layer Finder's buttons and Material glyphs are the kit's: its template
|
|
// hand-writes no <button>, aria-pressed, Material Symbols span or inline SVG.
|
|
// Its search field is a UiSearchField.
|
|
import { test } from 'node:test';
|
|
import assert from 'node:assert/strict';
|
|
import { readFileSync } from 'node:fs';
|
|
|
|
/** A view's template block: everything outside script and style. */
|
|
function template(file) {
|
|
const source = readFileSync(
|
|
new URL(`../views/panels/${file}`, import.meta.url),
|
|
'utf8',
|
|
);
|
|
return source.replace(/<(script|style)\b[\s\S]*?<\/\1\s*>/g, '');
|
|
}
|
|
const finder = template('LayerFinder.vue');
|
|
|
|
test('the Layer Finder hand-writes no button; each is a UiButton', () => {
|
|
assert.deepEqual(finder.match(/<button\b/gi) ?? [], []);
|
|
// Search, Filter, the Status and Category options, and the two chips.
|
|
assert.equal(finder.match(/<UiButton\b/g)?.length, 6);
|
|
assert.equal(finder.match(/<UiSearchField\b/g)?.length, 1);
|
|
});
|
|
|
|
test('its pressed toggles leave aria-pressed to UiButton', () => {
|
|
assert.deepEqual(finder.match(/aria-pressed/g) ?? [], []);
|
|
const pressed = finder.match(/<UiButton\b[^>]*:pressed=[^>]*>/g) ?? [];
|
|
// Search and the Status and Category options.
|
|
assert.equal(pressed.length, 3);
|
|
// Only the options' active class follows their pressed state; Search's
|
|
// also stays on while a query is typed, so it keeps its own binding.
|
|
assert.equal(
|
|
pressed.filter((tag) => tag.includes('pressed-class="active"')).length,
|
|
2,
|
|
);
|
|
assert.match(
|
|
finder,
|
|
/id="layer-finder-search-btn"[^>]*:class="\{ active: searching \|\| query \}"/,
|
|
);
|
|
});
|
|
|
|
test('the Layer Finder hand-writes no Material glyph; each is a UiIcon', () => {
|
|
assert.deepEqual(finder.match(/material-symbols-outlined/g) ?? [], []);
|
|
assert.deepEqual(finder.match(/<svg\b/gi) ?? [], []);
|
|
const icons = finder.match(/<UiIcon\b[^>]*>/g) ?? [];
|
|
// Search, Filter, the two option radios and the two chips' close.
|
|
assert.equal(icons.length, 6);
|
|
// Without it the kit writes an 18px size that beats layer-finder.css.
|
|
for (const icon of icons) assert.match(icon, /:size="null"/);
|
|
});
|