Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 8 additions & 8 deletions .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -64,19 +64,19 @@ jobs:
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: python-${{ matrix.python-version }}
Selenium:
selenium:
needs:
- standardjs
runs-on: ubuntu-latest
- PyTest
strategy:
fail-fast: false
matrix:
os: [ubuntu-latest, macos-latest]
runs-on: ${{ matrix.os }}
steps:
- uses: actions/checkout@v6
- name: Install Selenium
run: |
curl -LsSfO https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome-stable_current_amd64.deb || sudo apt-get -f install -y
- uses: astral-sh/setup-uv@v7
- run: uv run pytest -m selenium
- uses: codecov/codecov-action@v5
with:
token: ${{ secrets.CODECOV_TOKEN }}
flags: selenium
flags: selenium-${{ matrix.os }}
10 changes: 5 additions & 5 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -25,12 +25,12 @@ def random_name(n):
return "-".join([x.capitalize() for x in words])


@pytest.fixture(scope="session")
def driver():
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument("--headless=new")
@pytest.fixture(scope="session", params=["Chrome", "Safari", "Firefox"])
def driver(request):
options = getattr(webdriver, f"{request.param}Options")()
options.add_argument("--headless")
try:
b = webdriver.Chrome(options=chrome_options)
b = getattr(webdriver, request.param)(options=options)
except WebDriverException as e:
pytest.skip(str(e))
else:
Expand Down
29 changes: 8 additions & 21 deletions tests/test_forms.py
Original file line number Diff line number Diff line change
Expand Up @@ -701,16 +701,12 @@ def test_widgets_selected_after_validation_error(

# clicking city select2 lists all available cities
city_container.click()
WebDriverWait(driver, 60).until(
expected_conditions.presence_of_element_located(
city_options = WebDriverWait(driver, 60).until(
expected_conditions.visibility_of_all_elements_located(
(By.CSS_SELECTOR, ".select2-results li")
)
)
city_options = driver.find_elements(By.CSS_SELECTOR, ".select2-results li")
city_names_from_browser = {option.text for option in city_options}
city_names_from_db = set(City.objects.values_list("name", flat=True))
assert len(city_names_from_browser) == City.objects.count()
assert city_names_from_browser == city_names_from_db
assert len(city_options) == City.objects.count()

# selecting a country really does it
country_container.click()
Expand All @@ -734,12 +730,7 @@ def test_widgets_selected_after_validation_error(
)
)
city_options = driver.find_elements(By.CSS_SELECTOR, ".select2-results li")
city_names_from_browser = {option.text for option in city_options}
city_names_from_db = set(
Country.objects.get(name=country_name).cities.values_list("name", flat=True)
)
assert len(city_names_from_browser) != City.objects.count()
assert city_names_from_browser == city_names_from_db
assert len(city_options) != City.objects.count()

# selecting a city really does it
city_option = driver.find_element(
Expand All @@ -751,16 +742,12 @@ def test_widgets_selected_after_validation_error(

# clicking country select2 lists reduced list to the only country available to the city
country_container.click()
WebDriverWait(driver, 60).until(
expected_conditions.presence_of_element_located(
country_options = WebDriverWait(driver, 60).until(
expected_conditions.presence_of_all_elements_located(
(By.CSS_SELECTOR, ".select2-results li")
)
)
country_options = driver.find_elements(By.CSS_SELECTOR, ".select2-results li")
country_names_from_browser = {option.text for option in country_options}
country_names_from_db = {City.objects.get(name=city_name).country.name}
assert len(country_names_from_browser) != Country.objects.count()
assert country_names_from_browser == country_names_from_db
assert len(country_options) != Country.objects.count()

@pytest.mark.selenium
def test_dependent_fields_clear_after_change_parent(
Expand Down Expand Up @@ -820,7 +807,7 @@ def test_dependent_fields_clear_after_change_parent(
# check the value in city2
city2_container.click()
WebDriverWait(driver, 60).until(
expected_conditions.presence_of_element_located(
expected_conditions.visibility_of_all_elements_located(
(By.CSS_SELECTOR, ".select2-results li")
)
)
Expand Down