Skip to content

Commit

Permalink
[ci/tests] Temporary workaround for beforeunload event #902
Browse files Browse the repository at this point in the history
Simulate gestures but is not enough.
Ref: https://chromium.googlesource.com/chromium/src/+/5b3168e8f8c4487320c654dd761622b89d548514.
Use chromium 125 for testing.
Added pip dependency caching.
I had to set CI to run on ubuntu-22.04, on ubuntu-24.04 the workaround did not work.

Related to #902
  • Loading branch information
nemesifier authored Aug 3, 2024
1 parent 73c25d7 commit 2723a36
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
19 changes: 18 additions & 1 deletion .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 Down Expand Up @@ -50,6 +50,22 @@ 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: Install Dependencies
id: deps
Expand Down Expand Up @@ -80,6 +96,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

0 comments on commit 2723a36

Please sign in to comment.