@@ -83,6 +83,49 @@ def test_comparison_rejection_explains_the_removal():
8383 assert 'DocxDiff' in message
8484
8585
86+ # ---------------------------------------------------------------------------
87+ # HTML preview mode resolution
88+ #
89+ # Docx2Html on NuGet now supports --track-changes, so the action self-test
90+ # requires a rendered preview. That leaves the tolerant 'auto' path — the
91+ # default, and the one most callers hit — without integration coverage, so its
92+ # behaviour is pinned here instead, without depending on what is installed.
93+ # ---------------------------------------------------------------------------
94+
95+ def test_resolve_previewer_returns_none_when_disabled (monkeypatch ):
96+ """'false' must not even look for the tool — that is what makes .NET optional."""
97+ def fail ():
98+ raise AssertionError ('find_docx2html() called despite html-preview: false' )
99+
100+ monkeypatch .setattr (ra , 'find_docx2html' , fail )
101+ inputs = ra .Inputs .from_env ({'INPUT_HTML_PREVIEW' : 'false' })
102+ assert ra .resolve_previewer (inputs ) is None
103+
104+
105+ def test_resolve_previewer_auto_warns_and_skips_when_tool_is_missing (monkeypatch , capsys ):
106+ monkeypatch .setattr (ra , 'find_docx2html' , lambda : None )
107+ inputs = ra .Inputs .from_env ({'INPUT_HTML_PREVIEW' : 'auto' })
108+
109+ assert ra .resolve_previewer (inputs ) is None
110+ assert '::warning::' in capsys .readouterr ().out
111+
112+
113+ def test_resolve_previewer_true_fails_when_tool_is_missing (monkeypatch ):
114+ monkeypatch .setattr (ra , 'find_docx2html' , lambda : None )
115+ inputs = ra .Inputs .from_env ({'INPUT_HTML_PREVIEW' : 'true' })
116+
117+ with pytest .raises (ra .ConfigError , match = 'Docx2Html' ):
118+ ra .resolve_previewer (inputs )
119+
120+
121+ @pytest .mark .parametrize ('mode' , ['auto' , 'true' ])
122+ def test_resolve_previewer_returns_the_tool_when_available (monkeypatch , mode ):
123+ monkeypatch .setattr (ra , 'find_docx2html' , lambda : '/usr/local/bin/docx2html' )
124+ inputs = ra .Inputs .from_env ({'INPUT_HTML_PREVIEW' : mode })
125+
126+ assert ra .resolve_previewer (inputs ) == '/usr/local/bin/docx2html'
127+
128+
86129@pytest .mark .parametrize ('env' , [
87130 {'INPUT_ENGINE' : 'wordperfect' },
88131 {'INPUT_HTML_PREVIEW' : 'maybe' },
0 commit comments