Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

PREOPS-5286: Add Playwright end-to-end tests #95

Merged
merged 36 commits into from
Jul 29, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
36 commits
Select commit Hold shift + click to select a range
18b4a06
Playwright tests for title, logo, no data messages and loading data.
alserene Feb 15, 2024
ae21c78
Playwright testing cont.
alserene Feb 16, 2024
b69d5df
Continue developing playwright tests.
alserene Feb 20, 2024
0df881d
Playwright tests continued.
alserene Feb 22, 2024
859080f
Playwright tests continued.
alserene Feb 22, 2024
ef9332d
Playwright tests continued.
alserene Feb 22, 2024
222fb62
Check for problems in debugging messages.
alserene Feb 24, 2024
d66d44c
Update standard E2E test.
alserene May 7, 2024
2ac545a
Add E2E test for data_from_urls mode.
alserene May 7, 2024
2a06c75
Add E2E test for LFA mode.
alserene May 7, 2024
22deb06
Correct an incorrect element locator.
May 7, 2024
558cf18
Add/modify sleeps.
alserene May 8, 2024
8fc4ef8
Update playwright_testing.rst
alserene May 8, 2024
a6e90e7
Control the port used when doing playwright tests of the snapshot das…
ehneilsen May 15, 2024
0212ea8
Add custom decorator to Playwright classes to disable tests as default.
alserene Jun 7, 2024
f0cf7c6
Update playwright_testing.rst with env variable to enable tests.
alserene Jun 7, 2024
eb7964e
get load box with get_by_role instead of get_by_label
ehneilsen May 16, 2024
2a7fd89
make headlessness more easily configurable
ehneilsen May 29, 2024
6af3ab6
add playwright and pre-commit to test dependencies
ehneilsen Jun 14, 2024
25d60ad
make git ignore vscode settings
ehneilsen Jun 14, 2024
24b69db
update sample data for latest rubin_scheduler
ehneilsen Jun 14, 2024
ad27bfe
make scheduler dashboard test more robust w.r.t. dates
ehneilsen Jun 14, 2024
df3b863
interpret values of ENABLE_PLAYWRIGHT_TESTS indicating false as false
ehneilsen Jun 14, 2024
342444f
run playwright tests headless by default
ehneilsen Jun 14, 2024
69b7200
Remove outdated test data before merge.
alserene Jul 4, 2024
a01c885
Add playwright browser install to CI workflow.
alserene Jul 4, 2024
63840b6
Add playwright to test requirements.
alserene Jul 4, 2024
420434f
Add pip install playwright to workflow.
alserene Jul 4, 2024
19c3c25
Add python -m in front of pytest call.
alserene Jul 5, 2024
c6d133a
Add conditional statements to playwright commands to prevent github w…
alserene Jul 5, 2024
43bb989
Test alternate run command.
alserene Jul 5, 2024
3832c3f
Test alternate run command.
alserene Jul 5, 2024
0a559cb
Test alternate run command.
alserene Jul 5, 2024
b1c2c09
Make date change check more robust.
alserene Jul 23, 2024
5116422
Remove Playwright from CI workflow.
alserene Jul 23, 2024
c7ee2e6
Reinstating lost data files.
alserene Jul 23, 2024
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/test_and_build.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -83,7 +83,7 @@ jobs:
shell: bash -l {0}
run: |
export RUBIN_SIM_DATA_DIR=~/rubin_sim_data
pytest -r a -v --cov=schedview --cov=tests --cov-report=xml --cov-report=term --cov-branch
python -m pytest -r a -v --cov=schedview --cov=tests --cov-report=xml --cov-report=term --cov-branch

- name: Upload coverage to codecov
uses: codecov/codecov-action@v4
Expand Down
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -150,3 +150,4 @@ notebooks/MPCORB.DAT.gz
# Other temporary files
tmp/*
util/tmp/*
.vscode/settings.json
76 changes: 76 additions & 0 deletions docs/playwright_testing.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
Playwright Testing
==================

Install playwright + browsers in environment
--------------------------------------------
`Install info <https://playwright.dev/python/docs/intro>`_

::

conda activate schedview
pip install playwright
playwright install # install browsers

Depending on your OS, you may also need to run:

::

playwright install-deps

Run (headless) tests
--------------------
Tests should be run from the root (where the tests are run during workflow).
The playwright tests are disabled by default, so, to run them, the environment variable ENABLE_PLAYWRIGHT_TESTS must be set.

::

ENABLE_PLAYWRIGHT_TESTS=1 pytest tests/test_scheduler_dashboard.py

Headed tests
------------
Tests will run in headless mode by default. If you would like to see the tests in action (headed), the tests must be run locally (where the LFA mode test will fail) or using NoMachine (or a supported equivalent).

`Instruction to set up NoMachine <https://s3df.slac.stanford.edu/public/doc/#/reference>`_

In the code, also comment/uncommment the following lines in each of the 3 classes' SetUpClass functions to swap to headed mode:

::

cls.browser = cls.playwright.chromium.launch(headless=True) # comment this out and uncomment the other lines
# cls.browser = cls.playwright.chromium.launch(
# headless=False,
# slow_mo=100
# )

Increase the 'slow_mo' parameter to slow the tests down (e.g. 500).

Debug tests
-----------
Visualise stepping through actions and assertions. Again, this needs to be run locally or using NoMachine.

`Docs <https://playwright.dev/python/docs/debug>`_

::

ENABLE_PLAYWRIGHT_TESTS=1 PWDEBUG=1 pytest -s tests/test_scheduler_dashboard.py

Note that when actions are taken that initiate the loading indicator + pop-up messages (e.g. load pickle, change date, reset dashboard), the assertions need to be stepped through very quickly or else the events will be missed and the test will fail. Be prepared for button mashing.

Test Generator
--------------
Generates testing code as you perform actions. Again, this needs to be run locally or using NoMachine.

`Docs <https://playwright.dev/python/docs/codegen>`_

Launch server from one terminal:

::

python schedview/app/scheduler_dashboard/scheduler_dashboard.py

Run test generator from another terminal:

::

playwright codegen http://localhost:8080/schedview-snapshot/dashboard

4 changes: 3 additions & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,9 @@ test = [
"isort",
"ruff",
"pytest-cov",
"geckodriver"
"geckodriver",
"playwright",
"pre-commit"
]
dev = [
"documenteer[guide]",
Expand Down
1 change: 1 addition & 0 deletions test-requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -7,3 +7,4 @@ geckodriver
pre-commit
boto3
botocore
playwright
Loading
Loading