- Uusi catalog-moduuli: palveluyksikkö → (palvelu) → työtehtävä ilman hintoja. - Pohjatiedot-sivu /catalog/ pääkäyttäjälle ja johdolle (oikeus catalog.manage): lisäys ja muokkaus dialogissa, Siirrä ylös / Siirrä alas, käytöstä poisto ja käyttöön otto. Fokus ja aria-live-ilmoitus jokaisen muutoksen jälkeen. - Rivejä ei poisteta. Käytöstä poistetun yläkohdan alla olevat rivit säilyttävät oman tilansa, mutta eivät ole valittavissa. Nimi on yksilöllinen samalla tasolla kirjainkoosta riippumatta. - Työtehtävän voi siirtää saman yksikön toiseen palveluun tai suoraan yksikön alle. - Luvun 11.1 lista data-migraationa (0002_seed), jos taulut ovat tyhjiä. - CatalogQueries: work_type_options, active_service_units ja get_work_type tehtäviä ja tuntikirjausta varten. - Import-linter-sopimukset, suomennokset, yksikkö-, integraatio- ja selaintestit. - Päivitetty CLAUDE.md ja määrittelyn kohta 16.3. Co-Authored-By: Claude Opus 5.5 <[email protected]>
88 lines
3.3 KiB
Python
88 lines
3.3 KiB
Python
import re
|
|
from collections.abc import Callable
|
|
from typing import Any
|
|
|
|
import pytest
|
|
|
|
from tests.browser.conftest import ALL, assert_accessible, no_horizontal_scroll
|
|
|
|
|
|
@pytest.fixture
|
|
def seeded(transactional_db: Any) -> None:
|
|
"""transactional_db flushes tables between tests, so rerun the seed migration's data."""
|
|
from importlib import import_module
|
|
|
|
from django.apps import apps
|
|
|
|
import_module("apps.catalog.migrations.0002_seed").seed(apps, None)
|
|
from apps.catalog.infrastructure.orm import ServiceUnitModel
|
|
|
|
ServiceUnitModel.objects.filter(name="Markkinointi").update(is_active=False)
|
|
|
|
|
|
@pytest.mark.parametrize("themed_page", ALL, indirect=True, ids=lambda p: f"{p[0]}-{p[1]}")
|
|
def test_catalog_page(
|
|
themed_page: Any,
|
|
live_server: Any,
|
|
admin_user: Any,
|
|
seeded: None,
|
|
login: Callable[[Any, str], None],
|
|
) -> None:
|
|
login(themed_page, admin_user.email)
|
|
themed_page.goto(f"{live_server.url}/catalog/")
|
|
assert_accessible(themed_page)
|
|
assert no_horizontal_scroll(themed_page)
|
|
|
|
# The work type dialog (loaded with HTMX) is accessible too.
|
|
themed_page.get_by_role(
|
|
"link", name=re.compile(r"^Lisää työtehtävä\s*: Mediatuotanto$")
|
|
).click()
|
|
themed_page.locator("#item-dialog[open] #id_name").wait_for()
|
|
themed_page.wait_for_timeout(300)
|
|
assert_accessible(themed_page)
|
|
|
|
themed_page.goto(f"{live_server.url}/catalog/service-units/new/")
|
|
assert_accessible(themed_page)
|
|
assert no_horizontal_scroll(themed_page)
|
|
|
|
|
|
def test_reorder_and_rename_with_keyboard(
|
|
page: Any, live_server: Any, admin_user: Any, seeded: None, login: Callable[[Any, str], None]
|
|
) -> None:
|
|
from apps.catalog.infrastructure.orm import ServiceUnitModel
|
|
|
|
media = ServiceUnitModel.objects.get(name="Mediatuotanto")
|
|
login(page, admin_user.email)
|
|
page.goto(f"{live_server.url}/catalog/")
|
|
|
|
page.get_by_role("button", name=re.compile(r"^Siirrä alas\s*: Mediatuotanto$")).focus()
|
|
page.keyboard.press("Enter")
|
|
page.wait_for_function(
|
|
"document.getElementById('live-region').textContent.includes('siirretty alas')"
|
|
)
|
|
assert page.evaluate("document.activeElement.id") == f"move-unit-{media.pk}-down"
|
|
headings = page.locator("#catalog-tree h2").all_inner_texts()
|
|
assert headings[0].startswith("Markkinointi")
|
|
assert headings[1].startswith("Mediatuotanto")
|
|
|
|
# Rename in the dialog; focus returns to the row's name.
|
|
page.get_by_role("link", name=re.compile(r"^Muokkaa\s*: Mediatuotanto$")).focus()
|
|
page.keyboard.press("Enter")
|
|
name = page.locator("#item-dialog[open] #id_name")
|
|
name.wait_for()
|
|
name.fill("Mediatuotannot")
|
|
page.keyboard.press("Enter")
|
|
page.wait_for_function(
|
|
"document.getElementById('live-region').textContent.includes('tallennettu')"
|
|
)
|
|
assert page.evaluate("document.activeElement.id") == f"name-unit-{media.pk}"
|
|
assert not page.evaluate("document.getElementById('item-dialog').open")
|
|
|
|
page.get_by_role("button", name=re.compile(r"^Poista käytöstä\s*: Mediatuotannot$")).focus()
|
|
page.keyboard.press("Enter")
|
|
page.wait_for_function(
|
|
"document.getElementById('live-region').textContent.includes('poistettu käytöstä')"
|
|
)
|
|
assert page.evaluate("document.activeElement.id") == f"toggle-unit-{media.pk}"
|
|
assert "Ei käytössä" in page.locator(f"#row-unit-{media.pk} h2").inner_text()
|