mirror of
https://github.com/pyscript/pyscript.git
synced 2025-12-23 12:12:59 -05:00
Don't hide undefined elements in the CSS (#837)
* Hide py-config element * display:none for all web components * docs * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * Add style tests for raw html and pyscript enabled html * [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci * test naming Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
This commit is contained in:
68
pyscriptjs/tests/integration/test_03_style.py
Normal file
68
pyscriptjs/tests/integration/test_03_style.py
Normal file
@@ -0,0 +1,68 @@
|
||||
import re
|
||||
|
||||
from playwright.sync_api import expect
|
||||
|
||||
from .support import PyScriptTest
|
||||
|
||||
|
||||
class TestStyle(PyScriptTest):
|
||||
def test_pyscript_not_defined(self):
|
||||
"""Test raw elements that are not defined for display:none"""
|
||||
doc = """
|
||||
<html>
|
||||
<head>
|
||||
<link rel="stylesheet" href="build/pyscript.css" />
|
||||
</head>
|
||||
<body>
|
||||
<py-config>hello</py-config>
|
||||
<py-script>hello</py-script>
|
||||
<py-repl>hello</py-repl>
|
||||
<py-title>hello</py-title>
|
||||
<py-inputbox>hello</py-inputbox>
|
||||
<py-button>hello</py-button>
|
||||
<py-box>hello</py-box>
|
||||
</body>
|
||||
</html>
|
||||
"""
|
||||
self.writefile("test-not-defined-css.html", doc)
|
||||
self.goto("test-not-defined-css.html")
|
||||
expect(self.page.locator("py-config")).to_be_hidden()
|
||||
expect(self.page.locator("py-script")).to_be_hidden()
|
||||
expect(self.page.locator("py-repl")).to_be_hidden()
|
||||
expect(self.page.locator("py-title")).to_be_hidden()
|
||||
expect(self.page.locator("py-inputbox")).to_be_hidden()
|
||||
expect(self.page.locator("py-button")).to_be_hidden()
|
||||
expect(self.page.locator("py-box")).to_be_hidden()
|
||||
|
||||
def test_pyscript_defined(self):
|
||||
"""Test elements have visibility that should"""
|
||||
self.pyscript_run(
|
||||
"""
|
||||
<py-config>
|
||||
name = "foo"
|
||||
</py-config>
|
||||
<py-script>print("hello")</py-script>
|
||||
<py-repl>print("hello")</py-repl>
|
||||
<py-title>hello</py-title>
|
||||
<py-inputbox label="my input">
|
||||
import js
|
||||
def on_keypress(evt):
|
||||
if evt.key == "Enter":
|
||||
js.console.log(evt.target.value)
|
||||
</py-inputbox>
|
||||
<py-box>
|
||||
<py-button label="my button">
|
||||
import js
|
||||
def on_click(evt):
|
||||
js.console.log('clicked!')
|
||||
</py-button>
|
||||
</py-box>
|
||||
"""
|
||||
)
|
||||
expect(self.page.locator("py-config")).to_be_hidden()
|
||||
expect(self.page.locator("py-script")).to_be_visible()
|
||||
expect(self.page.locator("py-repl")).to_be_visible()
|
||||
expect(self.page.locator("py-title")).to_be_visible()
|
||||
expect(self.page.locator("py-inputbox")).to_be_visible()
|
||||
expect(self.page.locator("py-button")).to_be_visible()
|
||||
expect(self.page.locator("py-box")).to_be_visible()
|
||||
Reference in New Issue
Block a user