Skip to content

Commit

Permalink
Initial e2e test setup
Browse files Browse the repository at this point in the history
  • Loading branch information
ritwik-g committed Jan 31, 2025
1 parent 10f48e0 commit b04281f
Show file tree
Hide file tree
Showing 4 changed files with 60 additions and 1 deletion.
8 changes: 8 additions & 0 deletions .github/workflows/ci-test.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -45,13 +45,21 @@ jobs:
recreate: true
path: runner-report.md

- name: Render the e2e report to the PR
uses: marocchino/sticky-pull-request-comment@v2
with:
header: e2e-test-report
recreate: true
path: e2e-report.md

- name: Output reports to the job summary when tests fail
shell: bash
run: |
if [ -f "runner-report.md" ]; then
echo "<details><summary>Runner Test Report</summary>" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
cat "runner-report.md" >> $GITHUB_STEP_SUMMARY
cat "e2e-report.md" >> $GITHUB_STEP_SUMMARY
echo "" >> $GITHUB_STEP_SUMMARY
echo "</details>" >> $GITHUB_STEP_SUMMARY
fi
5 changes: 5 additions & 0 deletions tests/e2e/requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
pytest~=8.0
pytest-mock~=3.0
pytest-cov~=6.0
pytest-md-report~=0.6.0
selenium~=4.28
34 changes: 34 additions & 0 deletions tests/e2e/test_login.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,34 @@
from selenium import webdriver
from selenium.webdriver.chrome.options import Options
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.common.by import By


class TestLogin:
def setup_method(self, method):
options = Options()
options.add_argument("--headless=new")
self.driver = webdriver.Chrome(options=options)

def teardown_method(self, method):
self.driver.quit()

def test_login(self):
self.driver.get("http://frontend.unstract.localhost")
self.driver.implicitly_wait(0.5)
self.driver.set_window_size(960, 615)
# 3 | click | css=span |
self.driver.find_element(By.CSS_SELECTOR, "span").click()
# 4 | click | id=username |
self.driver.find_element(By.ID, "username").click()
# 5 | type | id=username | unstract
self.driver.find_element(By.ID, "username").send_keys("unstract")
# 6 | type | id=password | unstract
self.driver.find_element(By.ID, "password").send_keys("unstract")
# 7 | click | css=input:nth-child(11) |
self.driver.find_element(By.CSS_SELECTOR, "input:nth-child(11)").click()
WebDriverWait(self.driver, timeout=5).until(
lambda _: self.driver.current_url.endswith("/mock_org/onboard"),
"Login failed."
)
self.driver.close()
14 changes: 13 additions & 1 deletion tox.ini
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
[tox]
env_list = py{39,310,311}, runner
env_list = py{39,310,311}, runner, e2e

# [testenv]
# skip_install = true
Expand All @@ -17,3 +17,15 @@ commands_pre =
sh -c '[ -f cloud_requirements.txt ] && pip install -r cloud_requirements.txt || echo "cloud_requirements.txt not found"'
commands =
pytest -v --md-report-verbose=1 --md-report --md-report-flavor gfm --md-report-output ../runner-report.md

[testenv:e2e]
deps = pip
allowlist_externals=
sh
commands_pre =
pip install -r tests/e2e/requirements.txt
./run-platform.sh -b
sleep 30
docker compose -f docker/docker-compose.yaml ps -a
commands =
pytest -v --md-report-verbose=1 --md-report --md-report-flavor gfm --md-report-output ../e2e-report.md tests/e2e/

0 comments on commit b04281f

Please sign in to comment.