Skip to content

infinite_scroll

django_spire.testing.playwright.components.infinite_scroll

InfiniteScroll

Playwright component for django_spire/infinite_scroll/base.html and django_spire/infinite_scroll/scroll.html

Source code in django_spire/testing/playwright/components/infinite_scroll.py
def __init__(self, page: Page, container_selector: str = '[x-ref="scroll_container"]') -> None:
    self.container_selector = container_selector
    self.page = page

container_selector = container_selector instance-attribute

page = page instance-attribute

content_container property

loaded_count_text property

scroll_container property

spinner property

total_count_text property

get_loaded_count

Source code in django_spire/testing/playwright/components/infinite_scroll.py
def get_loaded_count(self) -> int:
    return int(self.loaded_count_text.inner_text())

get_total_count

Source code in django_spire/testing/playwright/components/infinite_scroll.py
def get_total_count(self) -> int:
    return int(self.total_count_text.inner_text())

is_loading

Source code in django_spire/testing/playwright/components/infinite_scroll.py
def is_loading(self) -> bool:
    return self.spinner.is_visible()

scroll_to_bottom

Source code in django_spire/testing/playwright/components/infinite_scroll.py
def scroll_to_bottom(self) -> None:
    self.scroll_container.evaluate('el => el.scrollTop = el.scrollHeight')

scroll_to_top

Source code in django_spire/testing/playwright/components/infinite_scroll.py
def scroll_to_top(self) -> None:
    self.scroll_container.evaluate('el => el.scrollTop = 0')

wait_for_count_to_increase

Source code in django_spire/testing/playwright/components/infinite_scroll.py
def wait_for_count_to_increase(self, initial_count: int, timeout: int = 5000) -> None:
    self.page.wait_for_function(
        f'() => parseInt(document.querySelector("[x-text=\\"loaded_count\\"]").textContent) > {initial_count}',
        timeout=timeout
    )

wait_for_items_to_load

Source code in django_spire/testing/playwright/components/infinite_scroll.py
def wait_for_items_to_load(self) -> None:
    self.loaded_count_text.wait_for()

InfiniteScrollList

Bases: InfiniteScroll

Playwright component for infinite scroll with list items

Source code in django_spire/testing/playwright/components/infinite_scroll.py
def __init__(self, page: Page, container_selector: str = '[x-ref="scroll_container"]') -> None:
    self.container_selector = container_selector
    self.page = page

item_selector = '[data-row-id]' class-attribute instance-attribute

items property

get_item

Source code in django_spire/testing/playwright/components/infinite_scroll.py
def get_item(self, index: int) -> Locator:
    return self.items.nth(index)

get_item_count

Source code in django_spire/testing/playwright/components/infinite_scroll.py
def get_item_count(self) -> int:
    return self.items.count()

get_item_ids

Source code in django_spire/testing/playwright/components/infinite_scroll.py
def get_item_ids(self) -> list[str]:
    items = self.items
    return [items.nth(i).get_attribute('data-row-id') for i in range(items.count())]

InfiniteScrollTable

Bases: InfiniteScroll

Playwright component for django_spire/table/base.html

Source code in django_spire/testing/playwright/components/infinite_scroll.py
def __init__(self, page: Page, container_selector: str = '.table-container[x-ref="scroll_container"]') -> None:
    super().__init__(page, container_selector)

row_selector = 'tbody tr[data-row-id]' class-attribute instance-attribute

skeleton_selector = '.skeleton-box' class-attribute instance-attribute

rows property

select_all_checkbox property

selected_count_text property

skeleton_rows property

table property

click_header

Source code in django_spire/testing/playwright/components/infinite_scroll.py
def click_header(self, header_text: str) -> None:
    self.get_header(header_text).click()

deselect_all_rows

Source code in django_spire/testing/playwright/components/infinite_scroll.py
def deselect_all_rows(self) -> None:
    self.select_all_checkbox.click()

deselect_row

Source code in django_spire/testing/playwright/components/infinite_scroll.py
def deselect_row(self, index: int) -> None:
    self.get_row(index).locator('input[type="checkbox"]').click()

get_first_row_text

Source code in django_spire/testing/playwright/components/infinite_scroll.py
def get_first_row_text(self) -> str:
    return self.rows.first.inner_text()

get_header

Source code in django_spire/testing/playwright/components/infinite_scroll.py
def get_header(self, header_text: str) -> Locator:
    return self.page.locator(f'th:has-text("{header_text}")')

get_row

Source code in django_spire/testing/playwright/components/infinite_scroll.py
def get_row(self, index: int) -> Locator:
    return self.rows.nth(index)

get_row_count

Source code in django_spire/testing/playwright/components/infinite_scroll.py
def get_row_count(self) -> int:
    return self.rows.count()

get_selected_count

Source code in django_spire/testing/playwright/components/infinite_scroll.py
def get_selected_count(self) -> int:
    return int(self.selected_count_text.inner_text())

get_sort_icon

Source code in django_spire/testing/playwright/components/infinite_scroll.py
def get_sort_icon(self, header_text: str) -> Locator:
    return self.get_header(header_text).locator('i.bi')

is_sorted_ascending

Source code in django_spire/testing/playwright/components/infinite_scroll.py
def is_sorted_ascending(self, header_text: str) -> bool:
    icon = self.get_sort_icon(header_text)
    return 'bi-chevron-up' in (icon.get_attribute('class') or '')

is_sorted_descending

Source code in django_spire/testing/playwright/components/infinite_scroll.py
def is_sorted_descending(self, header_text: str) -> bool:
    icon = self.get_sort_icon(header_text)
    return 'bi-chevron-down' in (icon.get_attribute('class') or '')

select_all_rows

Source code in django_spire/testing/playwright/components/infinite_scroll.py
def select_all_rows(self) -> None:
    self.select_all_checkbox.click()

select_row

Source code in django_spire/testing/playwright/components/infinite_scroll.py
def select_row(self, index: int) -> None:
    self.get_row(index).locator('input[type="checkbox"]').click()

wait_for_rows_to_load

Source code in django_spire/testing/playwright/components/infinite_scroll.py
def wait_for_rows_to_load(self) -> None:
    self.rows.first.wait_for()

wait_for_table

Source code in django_spire/testing/playwright/components/infinite_scroll.py
def wait_for_table(self) -> None:
    self.table.wait_for()