Skip to content

Commit

Permalink
Merge pull request #176 from plone/playwright-tests
Browse files Browse the repository at this point in the history
Playwright tests
  • Loading branch information
gforcada authored Oct 14, 2023
2 parents cd0a492 + d0982a8 commit 9228e4f
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 0 deletions.
3 changes: 3 additions & 0 deletions config/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -459,6 +459,9 @@ test_environment_variables = """
"""
```

For packages that have `plone.app.robotframework` based tests,
it automatically detects it and primes `playwright` to install the needed browsers.

## Detailed script usage

As said above, the `config-package.py` script is the tool to apply the configuration.
Expand Down
19 changes: 19 additions & 0 deletions config/config-package.py
Original file line number Diff line number Diff line change
Expand Up @@ -352,6 +352,8 @@ def tox(self):
options['package_name'] = self.path.name
options["news_folder_exists"] = (self.path / 'news').exists()

options['prime_robotframework'] = self._detect_robotframework()

if not options['constrain_package_deps']:
options['constrain_package_deps'] = "false" if use_mxdev else "true"
if not options['constraints_file']:
Expand All @@ -363,6 +365,23 @@ def tox(self):
**options
)

def _detect_robotframework(self):
"""Dynamically find out if robotframework is used in the package.
We look at the dependencies, as we expect the depenedency checker
to make it easy for us.
"""
try_files = (
self.path / 'setup.py',
self.path / 'pyproject.toml',
)
for file_obj in try_files:
if file_obj.exists():
text = file_obj.read_text()
if 'plone.app.robotframework' in text:
return True
return False

def news_entry(self):
news = self.path / 'news'

Expand Down
12 changes: 12 additions & 0 deletions config/default/tox.ini.j2
Original file line number Diff line number Diff line change
Expand Up @@ -123,6 +123,9 @@ deps =
# constraints_file = "https://my-server.com/constraints.txt"
##
commands =
{% if prime_robotframework %}
rfbrowser init
{% endif %}
pytest --disable-warnings {posargs} {toxinidir}%(test_path)s
extras =
test
Expand Down Expand Up @@ -154,6 +157,9 @@ deps =
-c %(constraints_file)s
%(test_deps_additional)s
commands =
{% if prime_robotframework %}
rfbrowser init
{% endif %}
coverage run --source %(package_name)s -m pytest {posargs} --disable-warnings {toxinidir}%(test_path)s
coverage report -m --format markdown
coverage xml
Expand Down Expand Up @@ -194,6 +200,9 @@ deps =
# constraints_file = "https://my-server.com/constraints.txt"
##
commands =
{% if prime_robotframework %}
rfbrowser init
{% endif %}
zope-testrunner --all --test-path={toxinidir}%(test_path)s -s %(package_name)s {posargs}
extras =
test
Expand Down Expand Up @@ -228,6 +237,9 @@ deps =
-c %(constraints_file)s
%(test_deps_additional)s
commands =
{% if prime_robotframework %}
rfbrowser init
{% endif %}
coverage run --branch --source %(package_name)s {envbindir}/zope-testrunner --quiet --all --test-path={toxinidir}%(test_path)s -s %(package_name)s {posargs}
coverage report -m --format markdown
coverage xml
Expand Down
3 changes: 3 additions & 0 deletions news/155.feature
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
Install browsers (for playwright) on packages that run
plone.app.robotframework tests.
[gforcada]

0 comments on commit 9228e4f

Please sign in to comment.