-
Notifications
You must be signed in to change notification settings - Fork 24
Expand file tree
/
Copy pathtest_metadata.py
More file actions
7380 lines (6078 loc) · 306 KB
/
Copy pathtest_metadata.py
File metadata and controls
7380 lines (6078 loc) · 306 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
"""Package metadata consistency tests."""
from __future__ import annotations
import json
import re
import shutil
import subprocess
import tomllib
import xml.etree.ElementTree as ET
from fractions import Fraction
from pathlib import Path
import pytest
import browsertrace
def test_package_version_matches_module_version():
project_root = Path(__file__).resolve().parents[1]
pyproject = tomllib.loads((project_root / "pyproject.toml").read_text())
assert pyproject["project"]["version"] == "0.1.20"
assert pyproject["project"]["version"] == browsertrace.__version__
def test_public_docs_do_not_reference_stale_v011_release():
project_root = Path(__file__).resolve().parents[1]
public_docs = [
project_root / "llms.txt",
project_root / "README.md",
project_root / "LAUNCH.md",
*sorted((project_root / "docs").rglob("*.md")),
*sorted((project_root / "docs").rglob("*.html")),
project_root / "docs" / "llms.txt",
]
stale_release = re.compile(r"v0\.1\.1(?!\d)")
stale_mentions = [
str(path.relative_to(project_root))
for path in public_docs
if stale_release.search(path.read_text())
]
assert stale_mentions == []
def test_pyproject_has_launch_discovery_metadata():
project_root = Path(__file__).resolve().parents[1]
pyproject = tomllib.loads((project_root / "pyproject.toml").read_text())
project = pyproject["project"]
assert (
project["description"]
== "Replay failed Browser Use runs locally with screenshots, model I/O, failed-step timelines, and public-safe exports."
)
assert "Browser Use" in project["description"]
assert "AI browser agent" not in project["description"]
keywords = set(project["keywords"])
assert {
"ai-agent-debugging",
"browser-agent",
"browser-agents",
"computer-use",
"llm-observability",
} <= keywords
classifiers = set(project["classifiers"])
assert "Topic :: Scientific/Engineering :: Artificial Intelligence" in classifiers
assert "Topic :: Software Development :: Testing" in classifiers
urls = project["urls"]
assert urls["Debugging Guide"] == "https://aaronlab.github.io/browsertrace/debug-browser-agent-failure.html"
assert urls["Computer Use Guide"] == "https://aaronlab.github.io/browsertrace/computer-use-agent-debugging.html"
assert urls["Browser Use Guide"] == "https://aaronlab.github.io/browsertrace/browser-use-debugging.html"
assert urls["Stagehand Guide"] == "https://aaronlab.github.io/browsertrace/stagehand-debugging.html"
assert urls["Skyvern Guide"] == "https://aaronlab.github.io/browsertrace/skyvern-debugging.html"
assert urls["Playwright + LLM Guide"] == "https://aaronlab.github.io/browsertrace/playwright-llm-debugging.html"
assert urls["Changelog"] == "https://github.com/aaronlab/browsertrace/blob/main/CHANGELOG.md"
assert urls["Roadmap"] == "https://github.com/aaronlab/browsertrace/blob/main/ROADMAP.md"
assert urls["Discussions"] == "https://github.com/aaronlab/browsertrace/discussions/6"
def test_readme_intro_is_browser_use_first_for_pypi_description():
project_root = Path(__file__).resolve().parents[1]
readme = (project_root / "README.md").read_text()
intro = readme.split("## See a failure trace in 60 seconds", 1)[0]
assert "> Local replay debugger for Browser Use failures." in intro
assert "Your Browser Use agent failed." in intro
assert "Browser Use is the primary path." in intro
assert "file:///tmp/browsertrace-report.html" in intro
assert "upload preview never appears" in intro
assert "`browsertrace compare <failed_run_id> <success_run_id>`" in intro
assert "divergent action, URL, status, or error" in intro
assert "Local flight recorder" not in intro
assert "AI browser agents" not in intro
def test_social_preview_source_uses_browser_use_first_positioning():
project_root = Path(__file__).resolve().parents[1]
svg = (project_root / "docs" / "social-preview.svg").read_text()
assert "Local replay debugger for Browser Use failures" in svg
assert "Replay failed Browser Use runs locally" in svg
assert "Local flight recorder" not in svg
assert "AI browser agents" not in svg
def test_publish_workflow_is_ready_for_trusted_publishing():
project_root = Path(__file__).resolve().parents[1]
workflow = (project_root / ".github" / "workflows" / "publish.yml").read_text()
assert "workflow_dispatch:" in workflow
assert re.search(r"publish:\n(?: {4}.*\n)* {4}environment: pypi", workflow)
assert re.search(
r"publish:\n(?: {4}.*\n)* {4}permissions:\n"
r"(?: {6}.*\n)* {6}contents: read\n"
r"(?: {6}.*\n)* {6}id-token: write",
workflow,
)
assert "pypa/gh-action-pypi-publish@release/v1" in workflow
def test_readme_uses_pypi_install_after_publish():
project_root = Path(__file__).resolve().parents[1]
readme = (project_root / "README.md").read_text()
install_section = readme.split("## Install From PyPI", 1)[1].split(
"For a walkthrough", 1
)[0]
assert 'pip install "browsertrace[ui]"' in install_section
assert "pip install browsertrace" in install_section
assert "https://pypi.org/project/browsertrace/" in install_section
assert "@ git+https://github.com/aaronlab/browsertrace" not in install_section
assert "PyPI publishing is not enabled yet" not in readme
def test_launch_plan_uses_pypi_install_after_publish():
project_root = Path(__file__).resolve().parents[1]
plan = (
project_root
/ "docs"
/ "superpowers"
/ "plans"
/ "2026-05-09-browsertrace-launch-readiness.md"
).read_text()
assert "pip install browsertrace" in plan
assert 'pip install "browsertrace[ui]"' in plan
assert "pip install git+https://github.com/aaronlab/browsertrace" not in plan
assert "@ git+https://github.com/aaronlab/browsertrace" not in plan
def test_readme_shows_pypi_badge_after_publish():
project_root = Path(__file__).resolve().parents[1]
readme = (project_root / "README.md").read_text()
header = readme.split("(docs/demo.gif)", 1)[0]
assert "[![PyPI]" in header
assert "https://img.shields.io/pypi/v/browsertrace.svg" in header
assert "https://pypi.org/project/browsertrace/" in header
def test_readme_demo_gif_has_descriptive_alt_text():
project_root = Path(__file__).resolve().parents[1]
readme = (project_root / "README.md").read_text()
assert "" not in readme
assert (
"![BrowserTrace failed browser-agent trace timeline showing the first red step]"
"(docs/demo.gif)"
in readme
)
def test_readme_surfaces_first_awesome_list_inclusion_near_intro():
project_root = Path(__file__).resolve().parents[1]
readme = (project_root / "README.md").read_text()
intro = readme.split("## See a failure trace in 60 seconds", 1)[0]
normalized_intro = re.sub(r"\s+", " ", intro)
assert (
"Listed in [Jenqyang/Awesome-AI-Agents]"
"(https://github.com/Jenqyang/Awesome-AI-Agents) under"
" `Applications` -> `Tools`."
in normalized_intro
)
def test_homepage_has_software_source_code_json_ld():
project_root = Path(__file__).resolve().parents[1]
homepage = (project_root / "docs" / "index.html").read_text()
match = re.search(
r'<script type="application/ld\+json">\s*(.*?)\s*</script>',
homepage,
re.S,
)
assert match is not None
metadata = json.loads(match.group(1))
assert metadata["@context"] == "https://schema.org"
assert metadata["@type"] == "SoftwareSourceCode"
assert metadata["name"] == "BrowserTrace"
assert metadata["codeRepository"] == "https://github.com/aaronlab/browsertrace"
assert metadata["programmingLanguage"] == "Python"
assert metadata["license"] == "https://opensource.org/license/mit"
def test_core_guides_have_tech_article_json_ld():
project_root = Path(__file__).resolve().parents[1]
guide_pages = [
("debug-browser-agent-failure.html", "How to debug a Browser Use failure"),
("browser-use-debugging.html", "Debug Browser Use failures with BrowserTrace"),
("stagehand-debugging.html", "Debug Stagehand runs with BrowserTrace"),
("skyvern-debugging.html", "Debug Skyvern task failures with BrowserTrace"),
(
"playwright-llm-debugging.html",
"Debug Playwright + LLM browser-agent failures with BrowserTrace",
),
(
"computer-use-agent-debugging.html",
"Debug custom computer-use agent failures with BrowserTrace",
),
]
for filename, headline in guide_pages:
page = (project_root / "docs" / filename).read_text()
match = re.search(
r'<script type="application/ld\+json">\s*(.*?)\s*</script>',
page,
re.S,
)
assert match is not None, filename
metadata = json.loads(match.group(1))
assert metadata["@context"] == "https://schema.org", filename
assert metadata["@type"] == "TechArticle", filename
assert metadata["headline"] == headline, filename
assert metadata["isPartOf"]["name"] == "BrowserTrace", filename
assert metadata["codeRepository"] == "https://github.com/aaronlab/browsertrace", filename
def test_windows_powershell_first_run_docs_cover_env_vars():
project_root = Path(__file__).resolve().parents[1]
docs_text = "\n".join(
[
(project_root / "README.md").read_text(),
(project_root / "examples" / "README.md").read_text(),
]
)
assert 'powershell' in docs_text.lower()
assert '$env:BROWSERTRACE_HOME = "$env:TEMP\\browsertrace-demo"' in docs_text
assert '$env:BROWSERTRACE_PORT = "4000"' in docs_text
assert "BROWSERTRACE_HOME=/tmp/browsertrace-demo" in docs_text
assert "BROWSERTRACE_PORT=4000 browsertrace" in docs_text
def test_readme_browsertrace_home_note_links_isolated_storage_recipe():
project_root = Path(__file__).resolve().parents[1]
readme = (project_root / "README.md").read_text()
first_run_notes = readme.split(
"`BROWSERTRACE_PORT=3001 browsertrace` starts the local UI", 1
)[1].split("If install or demo startup fails", 1)[0]
assert "`BROWSERTRACE_HOME` to use an isolated trace store" in first_run_notes
assert (
"[isolated trace storage recipe](examples/#testing-with-isolated-trace-storage)"
in first_run_notes
)
assert '$env:BROWSERTRACE_HOME = "$env:TEMP\\browsertrace-demo"' in first_run_notes
def test_examples_readme_links_first_pr_recipe_for_small_contributions():
project_root = Path(__file__).resolve().parents[1]
examples = (project_root / "examples" / "README.md").read_text()
assert "First PR Recipe" in examples
assert "CONTRIBUTING.md#first-pr-recipe" in examples
assert "first contribution small and reviewable" in examples
assert "stars" not in examples.lower()
assert "upvotes" not in examples.lower()
assert "reposts" not in examples.lower()
def test_issue_chooser_links_first_pr_recipe_for_small_contributions():
project_root = Path(__file__).resolve().parents[1]
config = (
project_root / ".github" / "ISSUE_TEMPLATE" / "config.yml"
).read_text()
assert "name: First PR Recipe" in config
assert (
"url: https://github.com/aaronlab/browsertrace/blob/main/CONTRIBUTING.md#first-pr-recipe"
in config
)
assert "first contribution small and reviewable" in config
assert "stars" not in config.lower()
assert "upvotes" not in config.lower()
assert "reposts" not in config.lower()
def test_issue_chooser_links_code_of_conduct_for_issue_expectations():
project_root = Path(__file__).resolve().parents[1]
config = (
project_root / ".github" / "ISSUE_TEMPLATE" / "config.yml"
).read_text()
assert "name: Code of Conduct" in config
assert (
"url: https://github.com/aaronlab/browsertrace/blob/main/CODE_OF_CONDUCT.md"
in config
)
assert "constructive issues, discussions, reviews, and pull requests" in config
def test_issue_chooser_links_security_policy_for_sensitive_reports():
project_root = Path(__file__).resolve().parents[1]
config = (
project_root / ".github" / "ISSUE_TEMPLATE" / "config.yml"
).read_text()
assert "name: Security Policy" in config
assert (
"url: https://github.com/aaronlab/browsertrace/blob/main/SECURITY.md"
in config
)
assert "sensitive issues" in config
assert "private trace data" in config
def test_homepage_links_first_pr_recipe_for_small_contributions():
project_root = Path(__file__).resolve().parents[1]
homepage = (project_root / "docs" / "index.html").read_text()
assert "First PR Recipe" in homepage
assert (
"https://github.com/aaronlab/browsertrace/labels/good%20first%20issue"
in homepage
)
assert (
"https://github.com/aaronlab/browsertrace/blob/main/CONTRIBUTING.md#first-pr-recipe"
in homepage
)
assert "Good first issues" in homepage
assert "first contribution small and reviewable" in homepage
assert "stars" not in homepage.lower()
assert "upvotes" not in homepage.lower()
assert "reposts" not in homepage.lower()
def test_homepage_surfaces_first_awesome_list_inclusion_near_intro():
project_root = Path(__file__).resolve().parents[1]
homepage = (project_root / "docs" / "index.html").read_text()
intro = homepage.split('<section class="trace"', 1)[0]
normalized_intro = re.sub(r"\s+", " ", intro)
assert (
'Listed in <a href="https://github.com/Jenqyang/Awesome-AI-Agents">'
"Awesome-AI-Agents</a> under Applications -> Tools."
in normalized_intro
)
assert "stars" not in normalized_intro.lower()
assert "upvotes" not in normalized_intro.lower()
assert "reposts" not in normalized_intro.lower()
def test_homepage_names_current_adapter_surfaces():
project_root = Path(__file__).resolve().parents[1]
homepage = (project_root / "docs" / "index.html").read_text()
assert "Browser Use run hooks" in homepage
assert (
"Secondary integrations: Stagehand, Skyvern, Playwright + LLM, and custom "
"computer-use workflows."
in homepage
)
def test_homepage_and_readme_link_failure_patterns_page():
project_root = Path(__file__).resolve().parents[1]
homepage = (project_root / "docs" / "index.html").read_text()
readme = (project_root / "README.md").read_text()
assert 'href="./browser-agent-failure-patterns.html">Failure patterns</a>' in homepage
assert (
"[Failure patterns](https://aaronlab.github.io/browsertrace/browser-agent-failure-patterns.html)"
in readme
)
assert "browser-agent-failure-patterns.html" in readme
assert "Concrete Browser Use failure patterns" in readme
assert "new-tab desync" in readme
assert "local HTML upload navigation mistakes" in readme
assert "remote CDP hangs" in readme
assert "icon-only target" in readme
assert "Stagehand semantic verification boundary" in readme
assert "Skyvern multi-session VNC control drift" in readme
assert "stars" not in homepage.lower()
assert "upvotes" not in homepage.lower()
assert "reposts" not in homepage.lower()
def test_homepage_intro_uses_mobile_friendly_copy():
project_root = Path(__file__).resolve().parents[1]
homepage = (project_root / "docs" / "index.html").read_text()
assert "Browser Use failed?" in homepage
assert "Replay an AI browser-agent failure</h1>" not in homepage
assert (
"BrowserTrace replays a failed Browser Use run as a local timeline" in homepage
)
assert "Demo story: Browser Use tries to upload" in homepage
assert "upload preview never appears" in homepage
assert (
'aria-label="Primary Browser Use run hooks" title="Primary Browser Use run hooks">Browser Use-first</span>'
in homepage
)
intro = homepage.split('<section class="trace"', 1)[0]
assert "Stagehand</span>" not in intro
assert "Skyvern</span>" not in intro
assert "Playwright + LLM</span>" not in intro
assert "Secondary integrations: Stagehand, Skyvern, Playwright + LLM" in intro
assert "font-size: clamp(34px, 6vw, 60px)" not in homepage
assert "@media (max-width: 620px)" in homepage
assert "@media (max-width: 420px)" in homepage
assert "text-wrap: wrap" in homepage
assert ".story" in homepage
assert "overflow-wrap: normal" in homepage
assert "min-width: max-content" in homepage
assert ".meta span" in homepage
assert "flex: 0 0 auto" in homepage
def test_homepage_surfaces_failed_vs_good_compare_value():
project_root = Path(__file__).resolve().parents[1]
homepage = (project_root / "docs" / "index.html").read_text()
intro = homepage.split('<section class="trace"', 1)[0]
assert "failed-vs-good run differences" in homepage
assert "<code>browsertrace compare</code>" in intro
assert "known-good run" in intro
assert "first divergent action, URL, status, or error" in intro
assert 'href="./compare-browser-agent-debugging.html">Compare runs</a>' in intro
def test_homepage_download_links_use_current_release():
project_root = Path(__file__).resolve().parents[1]
homepage = (project_root / "docs" / "index.html").read_text()
assert "releases/download/v0.1.20/browsertrace-demo.html" in homepage
assert "releases/download/v0.1.20/browsertrace-demo-public.html" in homepage
assert "releases/download/v0.1.18/browsertrace-demo.html" not in homepage
assert "releases/download/v0.1.18/browsertrace-demo-public.html" not in homepage
def test_homepage_intro_grid_can_shrink_on_mobile():
project_root = Path(__file__).resolve().parents[1]
homepage = (project_root / "docs" / "index.html").read_text()
assert "grid-template-columns: minmax(0, 1fr)" in homepage
assert ".intro > *" in homepage
assert "min-width: 0" in homepage
assert "max-width: 16ch" not in homepage
def test_homepage_intro_uses_natural_title_wrapping():
project_root = Path(__file__).resolve().parents[1]
homepage = (project_root / "docs" / "index.html").read_text()
h1_css = re.search(r"h1\s*\{(?P<body>.*?)\n \}", homepage, re.S)
dek_html = re.search(r'<p class="dek">(?P<body>.*?)</p>', homepage, re.S)
assert h1_css is not None
assert dek_html is not None
assert '<h1 id="title">Browser Use failed?</h1>' in homepage
assert "text-wrap: balance" in h1_css.group("body")
assert "BrowserTrace replays a failed Browser Use run as a local timeline" in dek_html.group(
"body"
)
assert "Stagehand, Skyvern, Playwright + LLM" in homepage
assert "and custom computer-use workflows" in homepage
assert "custom computer-use agents" not in dek_html.group("body")
assert 'class="title-line"' not in homepage
assert ".title-line" not in homepage
def test_homepage_mobile_title_has_line_length_guard():
project_root = Path(__file__).resolve().parents[1]
homepage = (project_root / "docs" / "index.html").read_text()
mobile_css = re.search(
r"@media \(max-width: 620px\) \{(?P<body>.*?)\n \}\n\n @media \(max-width: 420px\)",
homepage,
re.S,
)
small_phone_css = re.search(
r"@media \(max-width: 420px\) \{(?P<body>.*?)\n \}\n </style>",
homepage,
re.S,
)
assert mobile_css is not None
assert small_phone_css is not None
assert re.search(
r"h1\s*\{[^}]*font-size: 32px;[^}]*max-width: 100%;[^}]*text-wrap: wrap;",
mobile_css.group("body"),
re.S,
)
assert re.search(
r"h1\s*\{[^}]*font-size: 30px;",
small_phone_css.group("body"),
re.S,
)
assert "max-width: min(100%, 20ch);" not in homepage
assert "max-width: 16ch;" not in homepage
def test_homepage_intro_actions_do_not_squeeze_copy_column():
project_root = Path(__file__).resolve().parents[1]
homepage = (project_root / "docs" / "index.html").read_text()
intro_css = re.search(r"\.intro\s*\{(?P<body>.*?)\n \}", homepage, re.S)
actions_css = re.search(r"\.actions\s*\{(?P<body>.*?)\n \}", homepage, re.S)
assert intro_css is not None
assert actions_css is not None
assert "grid-template-columns: minmax(0, 1fr)" in intro_css.group("body")
assert ".intro > *" in homepage
assert "min-width: 0" in homepage
assert "minmax(260px, 320px)" not in intro_css.group("body")
assert "justify-content: flex-start" in actions_css.group("body")
assert "justify-self: start" in actions_css.group("body")
assert "width: 100%" in actions_css.group("body")
def test_homepage_intro_keeps_mobile_action_count_focused():
project_root = Path(__file__).resolve().parents[1]
homepage = (project_root / "docs" / "index.html").read_text()
actions = re.search(
r'<div class="actions" aria-label="Actions">(?P<body>.*?)</div>',
homepage,
re.S,
)
assert actions is not None
body = actions.group("body")
assert 'href="./browser-use-debugging.html">Browser Use guide</a>' in body
assert 'href="./compare-browser-agent-debugging.html">Compare runs</a>' in body
assert 'href="https://github.com/aaronlab/browsertrace">View repo</a>' in body
assert 'href="./debug-browser-agent-failure.html">Replay walkthrough</a>' not in body
assert 'href="./browser-agent-failure-patterns.html">Failure patterns</a>' not in body
def test_homepage_mobile_nav_stays_scrollable_and_actions_wrap_compactly():
project_root = Path(__file__).resolve().parents[1]
homepage = (project_root / "docs" / "index.html").read_text()
mobile_css = re.search(
r"@media \(max-width: 620px\) \{(?P<body>.*?)\n \}\n\n @media \(max-width: 420px\)",
homepage,
re.S,
)
assert mobile_css is not None
mobile_body = mobile_css.group("body")
assert re.search(
r"\.topbar\s*\{[^}]*flex-wrap: nowrap;[^}]*align-items: center;",
mobile_body,
re.S,
)
assert re.search(
r"nav\s*\{[^}]*flex-wrap: nowrap;[^}]*overflow-x: auto;[^}]*min-width: 0;",
mobile_body,
re.S,
)
assert re.search(r"nav a\s*\{[^}]*white-space: nowrap;", mobile_body, re.S)
assert re.search(
r"\.actions\s*\{[^}]*flex-wrap: wrap;[^}]*overflow-x: visible;",
mobile_body,
re.S,
)
assert re.search(
r"\.actions \.button\s*\{[^}]*flex: 1 1 148px;",
mobile_body,
re.S,
)
assert ".actions::-webkit-scrollbar" not in mobile_body
def test_homepage_intro_no_longer_needs_tablet_sidebar_override():
project_root = Path(__file__).resolve().parents[1]
homepage = (project_root / "docs" / "index.html").read_text()
assert "@media (max-width: 980px)" not in homepage
def test_integrations_page_links_first_pr_recipe_for_small_contributions():
project_root = Path(__file__).resolve().parents[1]
integrations = (project_root / "docs" / "integrations.html").read_text()
assert "First PR Recipe" in integrations
assert (
"https://github.com/aaronlab/browsertrace/blob/main/CONTRIBUTING.md#first-pr-recipe"
in integrations
)
assert "first contribution small and reviewable" in integrations
assert "stars" not in integrations.lower()
assert "upvotes" not in integrations.lower()
assert "reposts" not in integrations.lower()
def test_integrations_page_has_discovery_metadata():
project_root = Path(__file__).resolve().parents[1]
integrations = (project_root / "docs" / "integrations.html").read_text()
assert (
'<link rel="alternate" type="text/plain" title="llms.txt" href="./llms.txt">'
in integrations
)
match = re.search(
r'<script type="application/ld\+json">\s*(.*?)\s*</script>',
integrations,
re.S,
)
assert match is not None
metadata = json.loads(match.group(1))
assert metadata["@context"] == "https://schema.org"
assert metadata["@type"] == "CollectionPage"
assert metadata["name"] == "BrowserTrace integrations"
assert metadata["url"] == "https://aaronlab.github.io/browsertrace/integrations.html"
assert metadata["isPartOf"]["name"] == "BrowserTrace"
assert metadata["isPartOf"]["codeRepository"] == "https://github.com/aaronlab/browsertrace"
def test_integrations_page_includes_aos_mapping_research_table():
project_root = Path(__file__).resolve().parents[1]
integrations = (project_root / "docs" / "integrations.html").read_text()
section = integrations.split('<h2 id="aos-mapping">AOS mapping research</h2>', 1)[
1
].split('<section class="band" aria-labelledby="browser-use">', 1)[0]
rows = {
cells[0]: cells
for cells in re.findall(
r"<tr>\s*((?:<td(?:\s+[^>]*)?>.*?</td>\s*){4})</tr>",
section,
re.S,
)
for cells in [
[
re.sub(r"<.*?>", "", cell).strip()
for cell in re.findall(r"<td(?:\s+[^>]*)?>(.*?)</td>", cells, re.S)
]
]
}
assert "not an AOS compliance claim" in section
assert "https://github.com/aaronlab/browsertrace/issues/237" in section
assert 'data-label="BrowserTrace field"' in section
assert ".mapping-table td::before" in integrations
assert rows["Run id and step id"][2] == "partially mapped"
assert rows["Action label or tool call"][1] == "steps/toolCallRequest"
assert rows["Action label or tool call"][2] == "partially mapped"
assert rows["Status and error"][1] == "steps/toolCallResult with isError"
assert rows["Status and error"][2] == "partially mapped"
assert "research-only toolCallResult result shape" in rows["Status and error"][3]
assert "run status" in rows["Status and error"][3]
assert "step status" in rows["Status and error"][3]
assert "error message/type" in rows["Status and error"][3]
assert "action/tool label" in rows["Status and error"][3]
assert "step id" in rows["Status and error"][3]
assert "public export/redaction state" in rows["Status and error"][3]
assert "not an AOS compliance claim" in rows["Status and error"][3]
assert rows["Screenshot or future video artifact"][1] == (
"FileWithUri preferred over inline FileWithBytes"
)
assert rows["Screenshot or future video artifact"][2] == "research gap"
assert rows["Current browser URL"][2] == "research gap"
assert "redact each field independently" in rows["Current browser URL"][3]
assert rows["Model input and output"][2] == "research gap"
assert "do not force full prompt or model I/O" in rows["Model input and output"][3]
assert rows["Public export redaction state"][2] == "research gap"
assert "explicit omitted or redacted markers" in rows["Public export redaction state"][3]
assert "stars" not in section.lower()
assert "upvotes" not in section.lower()
assert "reposts" not in section.lower()
def test_browser_use_guide_links_first_pr_recipe_for_small_contributions():
project_root = Path(__file__).resolve().parents[1]
guide = (project_root / "docs" / "browser-use-debugging.html").read_text()
assert "First PR Recipe" in guide
assert (
"https://github.com/aaronlab/browsertrace/blob/main/CONTRIBUTING.md#first-pr-recipe"
in guide
)
assert "first contribution small and reviewable" in guide
assert "stars" not in guide.lower()
assert "upvotes" not in guide.lower()
assert "reposts" not in guide.lower()
def test_browser_use_guide_covers_local_html_upload_navigation_boundary():
project_root = Path(__file__).resolve().parents[1]
guide = (project_root / "docs" / "browser-use-debugging.html").read_text()
assert 'id="debug-local-html-upload-navigation"' in guide
assert "local HTML upload" in guide
assert "misread as a navigation target" in guide
assert "browser-use/browser-use/issues/4794" in guide
section = guide.split('id="debug-local-html-upload-navigation"', 1)[1].split(
"</section>",
1,
)[0]
for expected in [
"task prompt",
"model-visible file or attachment context",
"local filename",
"extension",
"MIME type",
"raw model action before validation",
"parsed action type",
"bad URL",
"security/watchdog block reason",
"allowed-domains",
]:
assert expected in section
assert "future adapter boundary" in section
assert "does not mean BrowserTrace already captures every internal Browser Use field" in section
assert "stars" not in section.lower()
assert "upvotes" not in section.lower()
assert "reposts" not in section.lower()
def test_browser_use_guide_covers_action_schema_validation_boundary():
project_root = Path(__file__).resolve().parents[1]
guide = (project_root / "docs" / "browser-use-debugging.html").read_text()
assert 'id="debug-action-schema-validation"' in guide
assert "action schema" in guide
assert "schema coercion" in guide
assert "browser-use/browser-use/issues/4796" in guide
section = guide.split('id="debug-action-schema-validation"', 1)[1].split(
"</section>",
1,
)[0]
for expected in [
"raw model action",
"validated or normalized action",
"schema or normalization warning",
"selected element metadata",
"final executed target",
]:
assert expected in section
assert "future adapter boundary" in section
assert "does not mean BrowserTrace already captures every internal Browser Use field" in section
assert "stars" not in section.lower()
assert "upvotes" not in section.lower()
assert "reposts" not in section.lower()
def test_stagehand_guide_links_first_pr_recipe_for_small_contributions():
project_root = Path(__file__).resolve().parents[1]
guide = (project_root / "docs" / "stagehand-debugging.html").read_text()
assert "First PR Recipe" in guide
assert (
"https://github.com/aaronlab/browsertrace/blob/main/CONTRIBUTING.md#first-pr-recipe"
in guide
)
assert "first contribution small and reviewable" in guide
assert "stars" not in guide.lower()
assert "upvotes" not in guide.lower()
assert "reposts" not in guide.lower()
def test_skyvern_guide_links_first_pr_recipe_for_small_contributions():
project_root = Path(__file__).resolve().parents[1]
guide = (project_root / "docs" / "skyvern-debugging.html").read_text()
assert "First PR Recipe" in guide
assert (
"https://github.com/aaronlab/browsertrace/blob/main/CONTRIBUTING.md#first-pr-recipe"
in guide
)
assert "first contribution small and reviewable" in guide
assert "stars" not in guide.lower()
assert "upvotes" not in guide.lower()
assert "reposts" not in guide.lower()
def test_playwright_llm_guide_links_first_pr_recipe_for_small_contributions():
project_root = Path(__file__).resolve().parents[1]
guide = (project_root / "docs" / "playwright-llm-debugging.html").read_text()
assert "First PR Recipe" in guide
assert (
"https://github.com/aaronlab/browsertrace/blob/main/CONTRIBUTING.md#first-pr-recipe"
in guide
)
assert "first contribution small and reviewable" in guide
assert "stars" not in guide.lower()
assert "upvotes" not in guide.lower()
assert "reposts" not in guide.lower()
def test_integration_guides_link_share_safe_export_recipe():
project_root = Path(__file__).resolve().parents[1]
recipe_url = (
"https://github.com/aaronlab/browsertrace/blob/main/examples/README.md"
"#creating-a-share-safe-export"
)
for filename in [
"playwright-llm-debugging.html",
"stagehand-debugging.html",
"skyvern-debugging.html",
]:
guide = (project_root / "docs" / filename).read_text()
share_section = guide.split("<h2>Share only what is safe</h2>", 1)[1].split(
"</section>", 1
)[0]
assert recipe_url in share_section, filename
assert "share-safe export recipe" in share_section, filename
def test_playwright_llm_guide_mentions_sync_snapshot_helper():
project_root = Path(__file__).resolve().parents[1]
guide = (project_root / "docs" / "playwright-llm-debugging.html").read_text()
assert "run.snapshot_sync(page, action=...)" in guide
assert (
"https://github.com/aaronlab/browsertrace/blob/main/examples/README.md"
"#playwright-sync-api-snapshot"
) in guide
assert "Playwright's sync API" in guide
def test_computer_use_guide_links_first_pr_recipe_for_small_contributions():
project_root = Path(__file__).resolve().parents[1]
guide = (project_root / "docs" / "computer-use-agent-debugging.html").read_text()
assert "First PR Recipe" in guide
assert (
"https://github.com/aaronlab/browsertrace/blob/main/CONTRIBUTING.md#first-pr-recipe"
in guide
)
assert "first contribution small and reviewable" in guide
assert "stars" not in guide.lower()
assert "upvotes" not in guide.lower()
assert "reposts" not in guide.lower()
def test_failure_walkthrough_links_first_pr_recipe_for_small_contributions():
project_root = Path(__file__).resolve().parents[1]
guide = (project_root / "docs" / "debug-browser-agent-failure.html").read_text()
assert "First PR Recipe" in guide
assert (
"https://github.com/aaronlab/browsertrace/blob/main/CONTRIBUTING.md#first-pr-recipe"
in guide
)
assert "first contribution small and reviewable" in guide
assert "stars" not in guide.lower()
assert "upvotes" not in guide.lower()
assert "reposts" not in guide.lower()
def test_failure_walkthrough_demo_video_has_accessible_context():
project_root = Path(__file__).resolve().parents[1]
guide = (project_root / "docs" / "debug-browser-agent-failure.html").read_text()
video_block = re.search(r"<figure.*?</figure>", guide, re.S)
assert video_block is not None
block = video_block.group(0)
assert '<video controls muted playsinline poster="./demo-poster.png"' in block
assert "<figcaption>" in block
assert "BrowserTrace" in block
assert "failed browser-agent trace timeline" in block
assert "first red step" in block
def test_demo_mp4_uses_social_upload_safe_frame_rate():
if shutil.which("ffprobe") is None:
pytest.skip("ffprobe is required to inspect demo.mp4 frame rate")
project_root = Path(__file__).resolve().parents[1]
completed = subprocess.run(
[
"ffprobe",
"-v",
"error",
"-select_streams",
"v:0",
"-show_entries",
"stream=avg_frame_rate",
"-of",
"json",
str(project_root / "docs" / "demo.mp4"),
],
check=True,
capture_output=True,
text=True,
)
payload = json.loads(completed.stdout)
frame_rate = Fraction(payload["streams"][0]["avg_frame_rate"])
assert frame_rate >= 10
def test_comparison_page_links_first_pr_recipe_for_small_contributions():
project_root = Path(__file__).resolve().parents[1]
page = (project_root / "docs" / "compare-browser-agent-debugging.html").read_text()
assert "First PR Recipe" in page
assert (
"https://github.com/aaronlab/browsertrace/blob/main/CONTRIBUTING.md#first-pr-recipe"
in page
)
assert "first contribution small and reviewable" in page
assert "stars" not in page.lower()
assert "upvotes" not in page.lower()
assert "reposts" not in page.lower()
assert "browsertrace compare <failed_run_id> <success_run_id>" in page
assert "failed run and one known-good run" in page
assert "divergent action, URL, status, or error" in page
def test_trace_demo_page_links_first_pr_recipe_for_small_contributions():
project_root = Path(__file__).resolve().parents[1]
page = (project_root / "docs" / "trace.html").read_text()
assert "First PR Recipe" in page
assert (
"https://github.com/aaronlab/browsertrace/blob/main/CONTRIBUTING.md#first-pr-recipe"
in page
)
assert "first contribution small and reviewable" in page
assert "stars" not in page.lower()
assert "upvotes" not in page.lower()
assert "reposts" not in page.lower()
def test_trace_demo_page_has_mobile_export_metadata():
project_root = Path(__file__).resolve().parents[1]
page = (project_root / "docs" / "trace.html").read_text()
assert "<html lang='en'>" in page
assert "<meta name='viewport' content='width=device-width, initial-scale=1'>" in page
assert "@media(max-width:720px){body{padding:14px}.step{grid-template-columns:1fr}}" in page
def test_trace_demo_page_has_discovery_metadata():
project_root = Path(__file__).resolve().parents[1]
page = (project_root / "docs" / "trace.html").read_text()
assert "<link rel='canonical' href='https://aaronlab.github.io/browsertrace/trace.html'>" in page
assert "<link rel='alternate' type='text/plain' title='llms.txt' href='./llms.txt'>" in page
match = re.search(
r"<script type='application/ld\+json'>\s*(.*?)\s*</script>",
page,
re.S,
)
assert match is not None
metadata = json.loads(match.group(1))
assert metadata["@context"] == "https://schema.org"
assert metadata["@type"] == "TechArticle"
assert metadata["headline"] == "BrowserTrace exported failure trace"
assert metadata["url"] == "https://aaronlab.github.io/browsertrace/trace.html"
assert metadata["isPartOf"]["name"] == "BrowserTrace"
assert metadata["isPartOf"]["codeRepository"] == "https://github.com/aaronlab/browsertrace"
def test_trace_demo_page_uses_browser_use_first_failure_story():
project_root = Path(__file__).resolve().parents[1]
page = (project_root / "docs" / "trace.html").read_text()
assert "demo: Browser Use local HTML upload navigation failure" in page
assert "Browser Use navigated away from the upload page" in page
assert "file:///tmp/browsertrace-report.html" in page
assert "assert uploaded file preview" in page
assert "demo: checkout agent fails on disabled button" not in page
assert "click disabled checkout button" not in page
def test_failure_patterns_page_has_discovery_metadata_and_examples():
project_root = Path(__file__).resolve().parents[1]
page = (project_root / "docs" / "browser-agent-failure-patterns.html").read_text()