Skip to content

Commit 5145516

Browse files
authored
Merge pull request #128 from matysek/mzibrick-ccxdev16481
[CCXDEV-16481] fix(ocp-advisor-frontend): update CHIP_ROOT selector for PF6 Chip-to-Label migration
2 parents 78f6e67 + d871847 commit 5145516

2 files changed

Lines changed: 34 additions & 1 deletion

File tree

src/widgetastic_patternfly5/components/chip.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,9 @@ def __init__(self, chip, message):
1212

1313

1414
CHIP_ROOT = (
15-
".//*[contains(@data-ouia-component-type, '/Chip') and not(contains(@class, '-m-overflow')) "
15+
".//*[(contains(@data-ouia-component-type, '/Chip') or "
16+
"(contains(@class, '-c-label') and not(contains(@class, '-c-label__')))) "
17+
"and not(contains(@class, '-m-overflow')) "
1618
"and not(contains(@class, '-c-chip-group') or contains(@class, '-c-label-group'))]"
1719
)
1820
CHIP_TEXT = ".//span[contains(@class, '-c-chip__text') or contains(@class, '-c-label__text')]"

testing/components/test_chip.py

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
1+
from urllib.parse import urljoin
2+
13
import pytest
4+
from widgetastic.browser import Browser
25
from widgetastic.widget import View
36

47
from widgetastic_patternfly5 import CategoryChipGroup, ChipGroup
@@ -69,3 +72,31 @@ def test_chipgroup_category(category_chip_group_view):
6972
# This tests that a category disappears after all chips are removed
7073
# category_chip_group_view.category_two.remove_all_chips()
7174
# 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

Comments
 (0)