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

[tests] Debug test_unsaved_changes #903

Closed
wants to merge 12 commits into from
34 changes: 29 additions & 5 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ on:
jobs:
build:
name: Python==${{ matrix.python-version }} | ${{ matrix.django-version }}
runs-on: ubuntu-24.04
runs-on: ubuntu-22.04

services:
redis:
Expand All @@ -33,12 +33,12 @@ jobs:
fail-fast: false
matrix:
python-version:
- "3.8"
- "3.9"
# - "3.8"
# - "3.9"
- "3.10"
django-version:
- django~=3.2.0
- django~=4.1.0
# - django~=3.2.0
# - django~=4.1.0
- django~=4.2.0

steps:
Expand All @@ -50,6 +50,25 @@ jobs:
uses: actions/setup-python@v5
with:
python-version: ${{ matrix.python-version }}
cache: 'pip'
cache-dependency-path: |
**/requirements*.txt

- uses: browser-actions/setup-chrome@v1
# Using a fixed version, see here for more information on why:
# https://github.com/openwisp/openwisp-controller/issues/902#issuecomment-2266219715
# TODO: find a solution to allow using recent versions
with:
chrome-version: 125
install-chromedriver: true
id: setup-chrome

- run: |
${{ steps.setup-chrome.outputs.chrome-path }} --version
chromedriver --version

- name: Checkout code
uses: actions/checkout@v2

- name: Install Dependencies
id: deps
Expand All @@ -63,13 +82,17 @@ jobs:
pip install -U -r requirements-test.txt
pip install -U -e .
pip install ${{ matrix.django-version }}
pip install -U --no-deps --force-reinstall https://github.com/openwisp/openwisp-utils/tarball/chrome_bin

- name: QA checks
run: ./run-qa-checks

- name: Tests
if: ${{ !cancelled() && steps.deps.conclusion == 'success' }}
run: |
cd tests
POSTGRESQL=1 DJANGO_SETTINGS_MODULE=openwisp2.postgresql_settings ./manage.py test --tag selenium_tests openwisp_controller.config.tests.test_selenium.TestDeviceAdmin.test_unsaved_changes
cd ..
coverage run runtests.py --parallel
# the following command runs tests with Postgres/PostGIS but
# only for specific test cases which are tagged with "db_tests"
Expand All @@ -80,6 +103,7 @@ jobs:
coverage xml
env:
SELENIUM_HEADLESS: 1
CHROME_BIN: ${{ steps.setup-chrome.outputs.chrome-path }}

- name: Upload Coverage
if: ${{ success() }}
Expand Down
8 changes: 8 additions & 0 deletions openwisp_controller/config/tests/test_selenium.py
Original file line number Diff line number Diff line change
Expand Up @@ -144,13 +144,21 @@ def test_unsaved_changes(self):
self.fail('Unsaved changes alert displayed without any change')

with self.subTest('Alert should be displayed after making changes'):
# simulate hand gestures
self.web_driver.find_element(by=By.TAG_NAME, value='body').click()
self.web_driver.find_element(by=By.NAME, value='name').click()
# set name
self.web_driver.find_element(by=By.NAME, value='name').send_keys(
'new.device.name'
)
# simulate hand gestures
self.web_driver.find_element(by=By.TAG_NAME, value='body').click()
self.web_driver.refresh()
try:
WebDriverWait(self.web_driver, 1).until(EC.alert_is_present())
except TimeoutException:
for entry in self.web_driver.get_log('browser'):
print(entry)
self.fail('Timed out wating for unsaved changes alert')
else:
alert = Alert(self.web_driver)
Expand Down
Loading