Skip to content

notification_bell

django_spire.testing.playwright.components.notification_bell

NotificationBell

Playwright component for django_spire/notification/app/element/notification_bell.html

Source code in django_spire/testing/playwright/components/notification_bell.py
def __init__(self, page: Page) -> None:
    self.page = page

page = page instance-attribute

badge property

bell property

dropdown property

click

Source code in django_spire/testing/playwright/components/notification_bell.py
def click(self) -> None:
    self.bell.click()

get_badge_count

Source code in django_spire/testing/playwright/components/notification_bell.py
def get_badge_count(self) -> int:
    if not self.has_badge():
        return 0

    text = self.badge.inner_text()

    if text.isdigit():
        return int(text)

    return 0

has_badge

Source code in django_spire/testing/playwright/components/notification_bell.py
def has_badge(self) -> bool:
    return self.badge.count() > 0 and self.badge.is_visible()

has_notifications

Source code in django_spire/testing/playwright/components/notification_bell.py
def has_notifications(self) -> bool:
    return self.has_badge() and self.get_badge_count() > 0

is_dropdown_open

Source code in django_spire/testing/playwright/components/notification_bell.py
def is_dropdown_open(self) -> bool:
    return self.dropdown.is_visible()

is_visible

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

open_dropdown

Source code in django_spire/testing/playwright/components/notification_bell.py
def open_dropdown(self) -> None:
    if not self.is_dropdown_open():
        self.click()

close_dropdown

Source code in django_spire/testing/playwright/components/notification_bell.py
def close_dropdown(self) -> None:
    if self.is_dropdown_open():
        self.click()