54 lines
1.7 KiB
Python
54 lines
1.7 KiB
Python
"""Offscreen test: the Joinery panel shows only the inputs each feature uses."""
|
|
import os
|
|
|
|
import pytest
|
|
|
|
os.environ.setdefault("QT_QPA_PLATFORM", "offscreen")
|
|
pytest.importorskip("PySide6")
|
|
|
|
from PySide6.QtWidgets import QApplication # noqa: E402
|
|
|
|
from woodshop.gui.controller import Controller # noqa: E402
|
|
from woodshop.gui.feature_panel import FeaturePanel # noqa: E402
|
|
|
|
_app = QApplication.instance() or QApplication([])
|
|
|
|
|
|
def _panel(tmp_path):
|
|
c = Controller(str(tmp_path / "s.json"))
|
|
return c, FeaturePanel(c)
|
|
|
|
|
|
def test_miter_shows_only_angle_fields(tmp_path):
|
|
c, panel = _panel(tmp_path)
|
|
c.place("2x4", 24)
|
|
c.add_feature("miter")
|
|
panel.refresh()
|
|
assert panel._spins["miter_deg"].isVisibleTo(panel)
|
|
assert panel._spins["bevel_deg"].isVisibleTo(panel)
|
|
assert not panel._spins["width_in"].isVisibleTo(panel) # irrelevant -> hidden
|
|
assert not panel._spins["depth_in"].isVisibleTo(panel)
|
|
# face dropdown limited to ends
|
|
faces = [panel.face.itemText(i) for i in range(panel.face.count())]
|
|
assert faces == ["end_a", "end_b"]
|
|
|
|
|
|
def test_chamfer_shows_only_width(tmp_path):
|
|
c, panel = _panel(tmp_path)
|
|
c.place("2x4", 24)
|
|
c.add_feature("chamfer")
|
|
panel.refresh()
|
|
assert panel._spins["width_in"].isVisibleTo(panel)
|
|
assert not panel._spins["depth_in"].isVisibleTo(panel)
|
|
assert not panel._spins["miter_deg"].isVisibleTo(panel)
|
|
|
|
|
|
def test_mortise_shows_box_fields(tmp_path):
|
|
c, panel = _panel(tmp_path)
|
|
c.place("2x4", 24)
|
|
c.add_feature("mortise")
|
|
panel.refresh()
|
|
for k in ("along_in", "width_in", "height_in", "depth_in"):
|
|
assert panel._spins[k].isVisibleTo(panel)
|
|
assert not panel._spins["miter_deg"].isVisibleTo(panel)
|