Skip to content

Commit 7f85d3a

Browse files
committed
Add playwright inv task.
1 parent 39323c2 commit 7f85d3a

File tree

3 files changed

+30
-3
lines changed

3 files changed

+30
-3
lines changed

.pytest.ini

+1-1
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ testpaths =
44

55
# Acceptance tests are ignored because they are
66
# slow. Run them using "inv accept".
7-
addopts = --ignore=tests/acceptance/
7+
addopts = --ignore=tests/acceptance/ --ignore=tests/playwright/
88

99
# Acceptance tests were raising FutureWarning:
1010
# FutureWarning: Deleting all cookies via CookieManager.delete()

docs/development.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -63,7 +63,7 @@ Shut down your dev instance of Lute if it's running, and then run
6363
inv full
6464
```
6565

66-
to do a full pylint, test, and acceptance test run. This should complete without errors, as lute master and develop branch are always kept passing in CI.
66+
to do a full pylint, test, acceptance, and playwright test run. This should complete without errors, as lute master and develop branch are always kept passing in CI.
6767

6868
# Development
6969

@@ -88,6 +88,7 @@ Some useful tasks:
8888
| inv start | start the app on a development Flask server in dev/debug mode |
8989
| inv lint | lint |
9090
| inv accept | start a running instance of the app server if needed, and run acceptance tests |
91+
| inv playwright | start a running instance of the app server if needed, and run playwright tests |
9192

9293
## Database changes
9394

tasks.py

+27-1
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,31 @@ def accept( # pylint: disable=too-many-arguments
147147
app_process.terminate()
148148

149149

150+
@task(pre=[_ensure_test_db])
151+
def playwright(c):
152+
"""
153+
Start lute, run playwright tests.
154+
155+
Only uses port 5000.
156+
157+
If Lute's not running on specified port, start a server.
158+
"""
159+
run_test = [
160+
"python",
161+
"-m",
162+
"tests.playwright.playwright",
163+
]
164+
165+
port = 5000
166+
if _site_is_running(port):
167+
c.run(" ".join(run_test))
168+
else:
169+
cmd = ["python", "-m", "tests.acceptance.start_acceptance_app", f"{port}"]
170+
with subprocess.Popen(cmd) as app_process:
171+
subprocess.run(run_test, check=True)
172+
app_process.terminate()
173+
174+
150175
@task(pre=[_ensure_test_db], help={"html": "open html report"})
151176
def coverage(c, html=False):
152177
"""
@@ -170,7 +195,7 @@ def black(c):
170195
c.run("python -m black .")
171196

172197

173-
@task(pre=[test, accept, black, lint])
198+
@task(pre=[test, accept, playwright, black, lint])
174199
def full(c): # pylint: disable=unused-argument
175200
"""
176201
Run full check and lint.
@@ -183,6 +208,7 @@ def full(c): # pylint: disable=unused-argument
183208
ns.add_task(lint)
184209
ns.add_task(test)
185210
ns.add_task(accept)
211+
ns.add_task(playwright)
186212
ns.add_task(coverage)
187213
ns.add_task(todos)
188214
ns.add_task(start)

0 commit comments

Comments
 (0)