Skip to content

Commit

Permalink
Also run demo app as headless on CI
Browse files Browse the repository at this point in the history
  • Loading branch information
mutagene committed Nov 26, 2023
1 parent 07ed123 commit 13563f3
Show file tree
Hide file tree
Showing 3 changed files with 55 additions and 0 deletions.
2 changes: 2 additions & 0 deletions .github/workflows/build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -155,6 +155,8 @@ jobs:
run: cmake --build build --parallel $(nproc) --config Release
- name: Run headless test
run: pushd build && ctest --output-on-failure
- name: Run integration test on sample app
run: pushd build/examples && python3 run-tests-selenium.py

build-on-windows-for-cppcli:
runs-on: windows-latest
Expand Down
Binary file modified bin/djinni
Binary file not shown.
53 changes: 53 additions & 0 deletions examples/ts/run-tests-selenium.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,53 @@
#! /usr/bin/env python3

from http.server import HTTPServer, SimpleHTTPRequestHandler
from selenium import webdriver
from selenium.webdriver.common.by import By
from selenium.webdriver.chrome.service import Service
import sys
import time
import threading

port = "8050"
httpd = HTTPServer(("127.0.0.1", int(port)), SimpleHTTPRequestHandler)

def run_server():
print("Serving HTTP on localhost port " + port + " (http://localhost:" + port + "/) ...")
httpd.serve_forever()

server_thread = threading.Thread(target=run_server)
server_thread.start()

service = Service(executable_path=r'/usr/bin/chromedriver')
options = webdriver.ChromeOptions()
options.add_argument('--headless')
options.add_argument('--no-sandbox')
options.add_argument('--disable-dev-shm-usage')
options.add_argument('--disable-gpu')
driver = webdriver.Chrome(service=service, options=options)
print(f"connecting web driver to http://localhost:{port}/")
driver.get(f"http://localhost:{port}/demo.html")
asc_button = driver.find_element(By.ID, "btnAsc")
desc_button = driver.find_element(By.ID, "btnDesc")

asc_button.click()
print("Wait for Asc button press")
time.sleep(0.5)
value = driver.find_element(By.ID, "txt").get_attribute("value")
is_ascending_ok = value == "item1\nitem2\nitem3\nitem4\nitem5"
print(f"text area on Sort Asc pressed:\n{value}")
desc_button.click()
print("Wait for Desc button press")
time.sleep(0.5)
value = driver.find_element(By.ID, "txt").get_attribute("value")
print(f"text area on Sort Desc pressed:\n{value}")
is_descending_ok = value == "item5\nitem4\nitem3\nitem2\nitem1"

driver.quit()
httpd.shutdown()
server_thread.join()
if is_ascending_ok and is_descending_ok:
exit(0)
print(f"is_ascending_ok = {is_ascending_ok}")
print(f"is_descending_ok = {is_descending_ok}")
exit(1)

0 comments on commit 13563f3

Please sign in to comment.