A place for the small utilities a technician reaches for at a bench. The plugin owns no API and no tables: every tool runs entirely in the browser, so an air-gapped site gets them for free and a bad network cannot break them. Adding the next tool is a view, a route, and one entry in tools.js. First tool is a barcode/QR generator. Content is typed text, a URL, or a CSV (content,label,copies - quoted fields and an optional header both handled), so a batch of a few hundred is one paste. Label stock is adjustable in inches with five presets, and the code renders to an SVG data URI rather than a PNG: a bitmap gets downscaled to label size and smears the module edges a scanner reads, where SVG rasterizes at the printer's resolution with hard edges. It also carries the dot-grid rule that is easy to get wrong by eye. A thermal head cannot render a fraction of a dot, so a code sized off the grid gets uneven modules; pick a DPI and the page says what the current size lands on and what to use instead. The quiet zone is blank label rather than white baked into the code, so it can be tuned - and it applies to CODE128 too, which needs clear space at each end and was letting bars run into the caption. Tech Tools is the first bundled plugin that owns no schema, which two guards did not model: it belongs in the universal installer profile, and upgrade-all reports it 'no-migrations' where every plugin was assumed to report 'ok'. The migration test now asserts that status explicitly for schema-less plugins, so a table-owning plugin whose chain went missing still fails.
56 lines
1.9 KiB
Python
56 lines
1.9 KiB
Python
"""Tests for the Tech Tools plugin.
|
|
|
|
The plugin owns no API and no tables, so the whole backend contract is: it
|
|
loads, it advertises one nav entry, and it claims no database. That last part
|
|
matters - a plugin that accidentally returns models would pull the tools
|
|
section into the migration and prune-schema machinery it has no business in.
|
|
"""
|
|
|
|
import json
|
|
import os
|
|
|
|
from plugins.tools.plugin import ToolsPlugin
|
|
|
|
|
|
PLUGIN_DIR = os.path.join(os.path.dirname(os.path.dirname(
|
|
os.path.dirname(os.path.abspath(__file__)))), 'plugins', 'tools')
|
|
|
|
|
|
def test_meta_matches_manifest():
|
|
"""The manifest is the single source of truth per ADR-002."""
|
|
with open(os.path.join(PLUGIN_DIR, 'manifest.json'), encoding='utf-8') as handle:
|
|
manifest = json.load(handle)
|
|
|
|
meta = ToolsPlugin().meta
|
|
assert meta.name == manifest['name']
|
|
assert meta.version == manifest['version']
|
|
assert meta.core_version == manifest['core_version']
|
|
|
|
|
|
def test_no_backend_surface():
|
|
"""Client-side only: no blueprint to register, no tables to migrate."""
|
|
plugin = ToolsPlugin()
|
|
assert plugin.get_blueprint() is None
|
|
assert plugin.get_models() == []
|
|
|
|
|
|
def test_navigation_item():
|
|
items = ToolsPlugin().get_navigation_items()
|
|
assert len(items) == 1
|
|
item = items[0]
|
|
assert item['name'] == 'Tech Tools'
|
|
assert item['route'] == '/tools'
|
|
# The icon has to exist in AppLayout's iconMap or the nav entry renders
|
|
# with no glyph.
|
|
assert item['icon'] == 'wrench'
|
|
|
|
|
|
def test_nav_icon_is_mapped_in_the_frontend():
|
|
"""Guard the one cross-file coupling: nav icon name -> AppLayout iconMap."""
|
|
layout = os.path.join(os.path.dirname(PLUGIN_DIR), '..', 'frontend', 'src',
|
|
'views', 'AppLayout.vue')
|
|
with open(os.path.normpath(layout), encoding='utf-8') as handle:
|
|
source = handle.read()
|
|
for item in ToolsPlugin().get_navigation_items():
|
|
assert f"'{item['icon']}':" in source
|