@@ -28,9 +28,34 @@ def test_re_list_item(self):
2828 self .assertEqual (_re_list_item .search (" - forward" ).groups (), ("forward" ,))
2929
3030 def test_resolve_open_in_colab (self ):
31- expected = """
31+ # Test with heading - should place component before the heading
32+ input_with_heading = "[[open-in-colab]]\n \n # Quick tour\n \n Some content here."
33+ expected_with_heading = """<DocNotebookDropdown
34+ containerStyle="float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10;"
35+ options={[
36+ {label: "Mixed", value: "https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/quicktour.ipynb"},
37+ {label: "PyTorch", value: "https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/pytorch/quicktour.ipynb"},
38+ {label: "TensorFlow", value: "https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/tensorflow/quicktour.ipynb"},
39+ {label: "Mixed", value: "https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/quicktour.ipynb"},
40+ {label: "PyTorch", value: "https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/pytorch/quicktour.ipynb"},
41+ {label: "TensorFlow", value: "https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/tensorflow/quicktour.ipynb"},
42+ ]} />
43+
44+ # Quick tour
45+
46+ Some content here."""
47+ self .assertEqual (
48+ resolve_open_in_colab (input_with_heading , {"package_name" : "transformers" , "page" : "quicktour.html" }),
49+ expected_with_heading ,
50+ )
51+
52+ # Test with CopyLLMTxtMenu present - should place component after CopyLLMTxtMenu
53+ # (so CopyLLMTxtMenu appears rightmost when floated)
54+ input_with_copy_menu = '[[open-in-colab]]\n \n <CopyLLMTxtMenu containerStyle="float: right;"></CopyLLMTxtMenu>\n \n # Quick tour\n \n Content.'
55+ expected_with_copy_menu = """<CopyLLMTxtMenu containerStyle="float: right;"></CopyLLMTxtMenu>
56+
3257<DocNotebookDropdown
33- classNames="absolute z-10 right-0 top-0 "
58+ containerStyle="float: right; margin-left: 10px; display: inline-flex; position: relative; z-index: 10; "
3459 options={[
3560 {label: "Mixed", value: "https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/quicktour.ipynb"},
3661 {label: "PyTorch", value: "https://colab.research.google.com/github/huggingface/notebooks/blob/main/transformers_doc/en/pytorch/quicktour.ipynb"},
@@ -39,8 +64,11 @@ def test_resolve_open_in_colab(self):
3964 {label: "PyTorch", value: "https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/pytorch/quicktour.ipynb"},
4065 {label: "TensorFlow", value: "https://studiolab.sagemaker.aws/import/github/huggingface/notebooks/blob/main/transformers_doc/en/tensorflow/quicktour.ipynb"},
4166]} />
42- """
67+
68+ # Quick tour
69+
70+ Content."""
4371 self .assertEqual (
44- resolve_open_in_colab (" \n [[open-in-colab]] \n " , {"package_name" : "transformers" , "page" : "quicktour.html" }),
45- expected ,
72+ resolve_open_in_colab (input_with_copy_menu , {"package_name" : "transformers" , "page" : "quicktour.html" }),
73+ expected_with_copy_menu ,
4674 )
0 commit comments