summaryrefslogtreecommitdiff
path: root/test/unit
diff options
context:
space:
mode:
authorWojtek Kosior <koszko@koszko.org>2022-01-03 20:43:44 +0100
committerWojtek Kosior <koszko@koszko.org>2022-01-03 20:43:44 +0100
commit3840192d67a38604cfd6738c4f07d181a668ae68 (patch)
tree9924aa3ae6bab87abbf531891430ee07c2587c5f /test/unit
parentc71ebff86fa79b20388749dd4781fd96fcc5c63a (diff)
downloadbrowser-extension-3840192d67a38604cfd6738c4f07d181a668ae68.tar.gz
browser-extension-3840192d67a38604cfd6738c4f07d181a668ae68.zip
facilitate testing extension's HTML files
Diffstat (limited to 'test/unit')
-rw-r--r--test/unit/test_basic.py23
1 files changed, 23 insertions, 0 deletions
diff --git a/test/unit/test_basic.py b/test/unit/test_basic.py
index 2564e9d..612fe06 100644
--- a/test/unit/test_basic.py
+++ b/test/unit/test_basic.py
@@ -20,6 +20,7 @@ Haketilo unit tests - base
import pytest
from ..script_loader import load_script
+from ..extension_crafting import ExtraHTML
def test_driver(driver):
"""
@@ -55,3 +56,25 @@ def test_webextension(driver):
'return document.getElementsByTagName("h1")[0].innerText;'
)
assert "Extension's options page for testing" in heading
+
+@pytest.mark.ext_data({
+ 'extra_html': [
+ ExtraHTML(
+ 'html/default_blocking_policy.html',
+ {
+ 'html/default_blocking_policy.js':
+ 'document.body.innerHTML = `ski-ba-bop-ba ${typeof by_id}`;'
+ }
+ )
+ ]
+})
+@pytest.mark.usefixtures('webextension')
+def test_extra_html(driver):
+ """
+ A trivial test case of the facility for loading the Haketilo's HTML files
+ into test WebExtension for unit-testing.
+ """
+ driver.get(driver.execute_script('return window.location.href;')
+ .replace('testpage.html', 'html/default_blocking_policy.html'))
+ assert driver.execute_script('return document.body.innerText') == \
+ 'ski-ba-bop-ba function'