Files
pyscript/pyscriptjs/tests/integration/test_03_style.py
Mariana Meireles 1587273868 Add display impl, rm outputManage, print and console.log default to browser console (#749)
* Add display impl, remove outputManage, print and console.log defaults to terminal

* Fixing tests

* Lint

* Erase unecessary code, add cuter CSS formating for errors, fix problems around REPL output

* Add fix to repl2 and lint

* lint

* Allow for list of display, fix elif to else

* Add better global option

* test work

* xfails

* (antocuni, mariana): let's try to start again with TDD methodology: write the minimum test and code for a simple display()

* (antocuni, mariana): this test works out of the box

* WIP: this test is broken, mariana is going to fix it

* add a failing test

* Add ability to deal with targets

* Add append arg and append tests

* Add multiple values to display

* Small adjustments to tests. I noticed I wasn;t running all at some point

* add display test

* Add console tests

* Add async tests

* Fix repl tests

* Fixing merging issues

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Address antocuni's review

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* Fixing more tests

* [pre-commit.ci] auto fixes from pre-commit.com hooks

for more information, see https://pre-commit.ci

* linting

* Improve repl tests

* Change my test so codespell is hapy with it

* Test: change test_runtime_config to use json instead of toml to see if stops failing on CI

* kill this file: it is a merge artifact since it was renamed into test_py_config.py on the main branch

* Change test execution order and add async tests to async test file

Co-authored-by: Antonio Cuni <anto.cuni@gmail.com>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
2022-10-17 16:28:40 +02:00

67 lines
2.4 KiB
Python

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>display("hello")</py-script>
<py-repl>display("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()