|
| 1 | +from urllib.parse import urljoin |
| 2 | + |
1 | 3 | import pytest |
| 4 | +from widgetastic.browser import Browser |
2 | 5 | from widgetastic.widget import View |
3 | 6 |
|
4 | 7 | from widgetastic_patternfly5 import CategoryChipGroup, ChipGroup |
@@ -69,3 +72,31 @@ def test_chipgroup_category(category_chip_group_view): |
69 | 72 | # This tests that a category disappears after all chips are removed |
70 | 73 | # category_chip_group_view.category_two.remove_all_chips() |
71 | 74 | # assert not category_chip_group_view.category_two.is_displayed |
| 75 | + |
| 76 | + |
| 77 | +@pytest.fixture(scope="module") |
| 78 | +def label_overflow_view(browser_context, pf_version): |
| 79 | + """Navigate to the PF6 Label page to test overflow exclusion on label-based chips.""" |
| 80 | + testing_pages = {"v6": "https://www.patternfly.org", "v5": "https://v5-archive.patternfly.org"} |
| 81 | + page = browser_context.new_page() |
| 82 | + page.goto(urljoin(testing_pages[pf_version], "components/label"), wait_until="networkidle") |
| 83 | + b = Browser(page) |
| 84 | + |
| 85 | + class TestView(View): |
| 86 | + ROOT = './/h3[text()="Label group with overflow"]/ancestor::div[@class="ws-example" or contains(@class, "pf-m-gutter")][1]' |
| 87 | + label_group = ChipGroup() |
| 88 | + |
| 89 | + yield TestView(b) |
| 90 | + page.close() |
| 91 | + |
| 92 | + |
| 93 | +@pytest.mark.skip_if_pf5 |
| 94 | +def test_overflow_text_excluded_from_label_chips(label_overflow_view): |
| 95 | + """Overflow button text must not appear in chip list when matching via -c-label class.""" |
| 96 | + group = label_overflow_view.label_group |
| 97 | + assert group.is_displayed |
| 98 | + assert group.overflow.is_displayed |
| 99 | + chips = [chip.text for chip in group.get_chips(show_more=False)] |
| 100 | + overflow_text = group.overflow.text |
| 101 | + assert len(chips) > 0 |
| 102 | + assert overflow_text not in chips |
0 commit comments