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

Fe tests robot framework gh actions #39

Open
wants to merge 4 commits into
base: main
Choose a base branch
from

Conversation

msabramo
Copy link
Contributor

@msabramo msabramo commented Apr 1, 2024

#38 + sets up GitHub Actions to run the Robot tests.

After submitting blackaryGH-37 as a potential fix for blackaryGH-35, I wondered if there was a
way to add FE tests that would detect that sort of issue. I found that [Robot
Framework] is a popular tool for this, and it has a [SeleniumLibrary] that can
be used to interact with web pages. This commit adds a simple test case that
opens a browser, inputs text into the `st_keyup` input field, and waits for the
page to contain some expected text. The test case is run by a shell script that
uses the `robot` command to run the test case.  The test case is run by a shell
script that uses the `robot` command to run the test case.

This test fails with the code on `main` when using Streamlit 1.32.2, because of
blackaryGH-35:

```
(.venv)
abramowi at Marcs-MBP-3 in ~/Code/OpenSource/streamlit-keyup (fe-tests-robot-framework)
$ pip freeze | grep '^streamlit'
streamlit==1.32.2

(.venv)
abramowi at Marcs-MBP-3 in ~/Code/OpenSource/streamlit-keyup (fe-tests-robot-framework)
$ ./run-robot-tests
==============================================================================
Robot
==============================================================================
Robot.Test Cases
==============================================================================
Interact with st_keyup                                                | FAIL |
Element 'css:iframe[title="st_keyup.st_keyup"]' not visible after 5 seconds.
------------------------------------------------------------------------------
Robot.Test Cases                                                      | FAIL |
1 test, 0 passed, 1 failed
==============================================================================
Robot                                                                 | FAIL |
1 test, 0 passed, 1 failed
==============================================================================
Output:  /Users/abramowi/Code/OpenSource/streamlit-keyup/tests/robot/output/output.xml
Log:     /Users/abramowi/Code/OpenSource/streamlit-keyup/tests/robot/output/log.html
Report:  /Users/abramowi/Code/OpenSource/streamlit-keyup/tests/robot/output/report.html
```

But it passes with the code in blackaryGH-37:

```
(.venv)
abramowi at Marcs-MBP-3 in ~/Code/OpenSource/streamlit-keyup (blackarygh-35-not-rendering-with-streamlit-1.32.2●)
$ git branch
  fe-tests-robot-framework
* blackarygh-35-not-rendering-with-streamlit-1.32.2
  main

(.venv)
abramowi at Marcs-MBP-3 in ~/Code/OpenSource/streamlit-keyup (blackarygh-35-not-rendering-with-streamlit-1.32.2●)
$ git checkout -b blackarygh-35-not-rendering-with-streamlit-1.32.2-with-fe-tests-robot-framework
Switched to a new branch 'blackarygh-35-not-rendering-with-streamlit-1.32.2-with-fe-tests-robot-framework'

(.venv)
abramowi at Marcs-MBP-3 in ~/Code/OpenSource/streamlit-keyup (blackarygh-35-not-rendering-with-streamlit-1.32.2-with-fe-tests-robot-framework●)
$ git merge fe-tests-robot-framework
Merge made by the 'ort' strategy.
 .gitignore                               |  5 ++++-
 run-robot-tests                          |  3 +++
 tests/robot/resources/app_keywords.robot | 16 ++++++++++++++++
 tests/robot/test_cases.robot             | 16 ++++++++++++++++
 4 files changed, 39 insertions(+), 1 deletion(-)
 create mode 100755 run-robot-tests
 create mode 100644 tests/robot/resources/app_keywords.robot
 create mode 100644 tests/robot/test_cases.robot

(.venv)
abramowi at Marcs-MBP-3 in ~/Code/OpenSource/streamlit-keyup (blackarygh-35-not-rendering-with-streamlit-1.32.2-with-fe-tests-robot-framework)
$ ./run-robot-tests
==============================================================================
Robot
==============================================================================
Robot.Test Cases
==============================================================================
Interact with st_keyup                                                | PASS |
------------------------------------------------------------------------------
Robot.Test Cases                                                      | PASS |
1 test, 1 passed, 0 failed
==============================================================================
Robot                                                                 | PASS |
1 test, 1 passed, 0 failed
==============================================================================
Output:  /Users/abramowi/Code/OpenSource/streamlit-keyup/tests/robot/output/output.xml
Log:     /Users/abramowi/Code/OpenSource/streamlit-keyup/tests/robot/output/log.html
Report:  /Users/abramowi/Code/OpenSource/streamlit-keyup/tests/robot/output/report.html
```

[Robot Framework]: https://robotframework.org/
[SeleniumLibrary]: https://robotframework.org/SeleniumLibrary/SeleniumLibrary.html
with robotframework deps
@msabramo msabramo force-pushed the fe-tests-robot-framework-gh-actions branch 2 times, most recently from 941579a to 516c306 Compare April 1, 2024 18:03
- name: Run Streamlit app
run: streamlit run streamlit_app.py &
- name: Run Robot tests
run: ./run-robot-tests
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You could potentially just add streamlit run streamlit_app.py & to this script itself, which would also be nice for local testing

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I like this idea, although I did something similar but slightly different -- I launch the process within the Robot Framework tests, because there are some nice utilities for starting and stopping processes. See https://github.com/blackary/streamlit-keyup/pull/39/files#diff-a7122111736738c31cad65675cf32cd883b4fdf3ba46225c5d86c189f56d1fc2R12-R24

@msabramo
Copy link
Contributor Author

msabramo commented Apr 7, 2024

Success finally running it w/ GH Actions! 🎉

https://github.com/blackary/streamlit-keyup/actions/runs/8585131661/job/23526202051?pr=39

@msabramo msabramo force-pushed the fe-tests-robot-framework-gh-actions branch 3 times, most recently from 8d517ae to 3442f4f Compare April 7, 2024 21:35
@msabramo msabramo force-pushed the fe-tests-robot-framework-gh-actions branch from 3442f4f to 1cd4914 Compare April 8, 2024 15:48
@msabramo
Copy link
Contributor Author

msabramo commented Apr 8, 2024

@blackary: How do you want to proceed with this and #38? Do you want to merge #38 first and then this or would you rather that I merge this into #38?

@blackary
Copy link
Owner

Thanks so much!! If you could merge this into #38, that would be excellent, and then I can approve these both as a bundle.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants