Skip to content

Commit

Permalink
Add material privacy plugin test
Browse files Browse the repository at this point in the history
  • Loading branch information
blueswen committed Dec 29, 2023
1 parent fa9cbbe commit 2f606bf
Show file tree
Hide file tree
Showing 2 changed files with 40 additions and 3 deletions.
13 changes: 13 additions & 0 deletions tests/fixtures/mkdocs-material-privacy.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
site_name: test mkdocs_glightbox
use_directory_urls: true

theme:
name: material

markdown_extensions:
- attr_list
- md_in_html

plugins:
- glightbox
- privacy
30 changes: 27 additions & 3 deletions tests/test_builds.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,13 +4,13 @@
import re
import shutil

# MkDocs
from mkdocs.__main__ import build_command

# other 3rd party
import pytest
from click.testing import CliRunner

# MkDocs
from mkdocs.__main__ import build_command

# ##################################
# ######## Globals #################
# ##################################
Expand Down Expand Up @@ -609,3 +609,27 @@ def test_error(tmp_path):
contents = file.read_text(encoding="utf8")
validate_static(contents)
validate_script(contents)


def test_privacy(tmp_path):
"""
Compatible with material privacy plugin
"""
mkdocs_file = "mkdocs-material-privacy.yml"
testproject_path = validate_mkdocs_file(tmp_path, f"tests/fixtures/{mkdocs_file}")
file = testproject_path / "site/url/index.html"
contents = file.read_text(encoding="utf8")
validate_static(contents, path="../")
validate_script(contents)
image_url = re.escape("../assets/external/dummyimage.com/600x400/bdc3c7/fff.png")
assert re.search(
rf'<a class="glightbox"(?!.*href=).*?><img.*?src="{image_url}".*?><\/a>',
contents,
)
patch_script = re.escape(
"document.querySelectorAll('.glightbox').forEach(function(element) {"
)
assert re.search(
rf"{patch_script}",
contents,
)

0 comments on commit 2f606bf

Please sign in to comment.