@@ -190,6 +190,45 @@ def test_graph_growth_labels_are_conservative_for_exact_signed_formulas(self):
190190 expect (self .page .locator ('.path' )).to_have_count (2 )
191191 expect (self .page .get_by_role ('button' , name = 'Hide other routes' , exact = True )).to_be_visible ()
192192
193+ def test_typst_math_keeps_vector_glyphs_and_colors_in_both_themes (self ):
194+ self .visit ('problem/KSatisfiability?variant=k=K3' )
195+ expect (self .page .locator ('article.typst-detail' )).to_be_visible ()
196+ formula = self .page .locator ('.typst-math > svg' ).filter (has = self .page .locator ('g + g use' )).first
197+ expect (formula ).to_be_visible ()
198+ self .page .evaluate ('document.fonts.ready' )
199+ # Include an intentional color and a fraction-like stroke alongside the real Typst glyphs.
200+ formula .locator ('use' ).first .evaluate ("node => node.setAttribute('fill', '#e15759')" )
201+ formula .evaluate ('''svg => {
202+ const line = document.createElementNS('http://www.w3.org/2000/svg', 'path');
203+ line.setAttribute('d', 'M0 .1H4'); line.setAttribute('stroke', '#000000');
204+ line.setAttribute('stroke-width', '.1'); svg.append(line);
205+ }''' )
206+ for theme , ink , paper in [('dark' , '#eef3e9' , '#0b110d' ), ('light' , '#112011' , '#ffffff' )]:
207+ with self .subTest (theme = theme ):
208+ self .page .evaluate ('''({ink, paper}) => {
209+ document.documentElement.style.setProperty('--ink', ink);
210+ document.documentElement.style.setProperty('--paper', paper);
211+ }''' , {'ink' : ink , 'paper' : paper })
212+ expect (formula .locator ('use' ).first ).to_have_css ('fill' , 'rgb(225, 87, 89)' )
213+ actual = formula .screenshot ()
214+ # Reference the same vectors with explicit theme paint and no rasterizing filter.
215+ saved = formula .evaluate ('''(svg, ink) => {
216+ const painted = [...svg.querySelectorAll('[fill="#000000"], [stroke="#000000"]')];
217+ const saved = [svg.getAttribute('style'), painted.map(node => node.getAttribute('style'))];
218+ svg.style.filter = 'none';
219+ for (const node of painted) {
220+ if (node.getAttribute('fill') === '#000000') node.style.fill = ink;
221+ if (node.getAttribute('stroke') === '#000000') node.style.stroke = ink;
222+ }
223+ return saved;
224+ }''' , ink )
225+ self .assertEqual (actual , formula .screenshot (), 'Theme styling changed the rendered math vectors' )
226+ formula .evaluate ('''(svg, [style, paints]) => {
227+ const restore = (node, value) => value === null ? node.removeAttribute('style') : node.setAttribute('style', value);
228+ restore(svg, style);
229+ [...svg.querySelectorAll('[fill="#000000"], [stroke="#000000"]')].forEach((node, i) => restore(node, paints[i]));
230+ }''' , saved )
231+
193232 def test_accessibility_atlas (self ):
194233 self .visit ('atlas' )
195234 expect (self .page .locator ('.atlas-row' ).first ).to_be_visible ()
@@ -390,7 +429,7 @@ def test_graph_place_card_hands_a_reachable_problem_to_directions(self):
390429 self .page .locator ('.act.primary' ).click ()
391430 self .page .locator ('#target' ).fill ('QUBO' )
392431 self .page .locator ('#suggest button' , has_text = 'QUBO' ).first .click ()
393- expect (self .page .locator ('#results .summary strong' )).to_contain_text ('best route ' )
432+ expect (self .page .locator ('#results .summary strong' )).to_contain_text ('size-bound candidate ' )
394433
395434 def test_accessibility_graph_desktop_drawer (self ):
396435 self .page .goto (self .base + 'graph.html#directions' )
@@ -525,7 +564,7 @@ def test_explore_defers_path_engine_until_directions(self):
525564 expect (self .page .locator ('.path' )).to_have_count (0 )
526565 self .choose_endpoint ('source' , 'SAT' )
527566 self .choose_endpoint ('target' , 'QUBO' )
528- expect (self .page .locator ('#results .summary strong' )).to_contain_text ('best route ' )
567+ expect (self .page .locator ('#results .summary strong' )).to_contain_text ('size-bound candidate ' )
529568 route = self .copy_route ()
530569 self .assertEqual (route ['path' ][0 ]['from' ]['name' ], 'Satisfiability' )
531570 self .assertEqual (route ['path' ][- 1 ]['to' ]['name' ], 'QUBO' )
@@ -1026,12 +1065,38 @@ def test_graph_sat_size_badges_finish_promptly_after_routes_arrive(self):
10261065 expect (self .page .locator ('.path' ).first .locator ('.size' )).to_contain_text ('n' )
10271066
10281067 def test_graph_unavailable_parameters_keep_size_badges_unknown (self ):
1068+ # Keep unavailable-field UI coverage independent of improvements to registry bounds.
1069+ nodes = [{'name' : name , 'category' : 'formula' , 'variant' : {}, 'default' : True }
1070+ for name in ['Satisfiability' , 'QUBO' ]]
1071+ known = {'certificate' : 'num_vars^3' , 'accuracy' : {'kind' : 'upper_bound' }}
1072+ unavailable = {'certificate' : None , 'accuracy' : {'kind' : 'unavailable' ,
1073+ 'reason' : {'kind' : 'unavailable' , 'detail' : 'Synthetic unavailable parameter' }}}
1074+ fields = {'num_vars' : known , 'num_quadratic_terms' : unavailable }
1075+ scene = {'nodes' : nodes , 'edges' : [{'source' : 0 , 'target' : 1 , 'witness' : True ,
1076+ 'aggregate' : False , 'turing' : False , 'fields' : fields }], 'aliases' : {},
1077+ 'layout' : {'Satisfiability' : {'x' : 0 , 'y' : 0 }, 'QUBO' : {'x' : 100 , 'y' : 70 }}}
1078+ self .page .route ('**/graph-scene.json.gz' , lambda route : route .fulfill (
1079+ body = gzip .compress (json .dumps (scene ).encode ()), content_type = 'application/gzip' ))
1080+ endpoint = lambda i : {'name' : nodes [i ]['name' ], 'variant' : {}}
1081+ paths = {'truncated' : False , 'paths' : [{'steps' : 1 ,
1082+ 'path' : [{'from' : endpoint (0 ), 'to' : endpoint (1 )}]}]}
1083+ comparison = {'profiles' : [{'source_coordinates' : ['num_vars' ], 'fields' : fields }],
1084+ 'front' : [1 ], 'counts' : {'Dominated' : 0 , 'Equivalent' : 0 , 'Incomparable' : 0 , 'Unknown' : 0 }}
1085+ worker = 'self.onmessage = () => {' + '' .join ('self.postMessage(' + json .dumps (reply ) + ');'
1086+ for reply in [{'phase' : 'paths' , 'result' : paths }, {'phase' : 'comparison' , 'result' : comparison }]) + '};'
1087+ self .page .route ('**/path-worker.js' , lambda route : route .fulfill (body = worker , content_type = 'text/javascript' ))
10291088 self .page .goto (self .base + 'graph.html#directions' )
1030- self .choose_endpoint ('source' , 'MVC' )
1031- self .page .locator ('#source-options [aria-label="weight"]' ).get_by_role ('button' , name = 'One' , exact = True ).click ()
1032- self .choose_endpoint ('target' , 'LongestCommonSubsequence' )
1033- expect (self .page .locator ('#results .summary strong' )).to_contain_text ('size-bound candidate' , timeout = 3000 )
1034- expect (self .page .locator ('.path' ).first .locator ('.size' )).to_have_text ('?' , timeout = 500 )
1089+ expect (self .page .locator ('#results .summary strong' )).to_have_text ('1 size-bound candidate' )
1090+ expect (self .page .locator ('.size.pending' )).to_have_count (0 )
1091+ expect (self .page .locator ('.path .size' )).to_have_text ('?' )
1092+ expect (self .page .locator ('.path .size' )).to_have_attribute ('title' , 'Size unavailable for one or more parameters' )
1093+ summaries = self .page .locator ('.growth' ).evaluate ('''dl => Object.fromEntries(
1094+ [...dl.querySelectorAll('dt')].map(term=>[term.textContent,term.nextElementSibling.textContent]))''' )
1095+ self .assertEqual (summaries , {'vars' : 'O(vars³)' , 'quadratic terms' : 'unavailable' })
1096+ expect (self .page .locator ('.steps .rule-link .oh' )).to_have_text ('?' )
1097+ edge = self .page .locator ('.scene-edge[data-edge="Satisfiability→QUBO"]' )
1098+ expect (edge ).to_have_count (1 )
1099+ self .assertTrue ({'route' , 'e-unknown' } <= set (edge .get_attribute ('class' ).split ()))
10351100
10361101 def test_directions_preloads_engine_before_graph_initialization (self ):
10371102 self .page .goto (self .base + 'graph.html#directions' )
0 commit comments