Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ def init_test(browser: Page, alerts, max_retries=3):

def select_one_facet_option(browser, facet_name, option_name):
expect(
browser.locator("[data-testid='facet']", has_text=facet_name)
browser.locator("[data-testid='facet']", has_text=facet_name).first
).to_be_visible()
option = browser.locator("[data-testid='facet-value']", has_text=option_name)
option.hover()
Expand All @@ -88,9 +88,12 @@ def select_one_facet_option(browser, facet_name, option_name):

def assert_facet(browser, facet_name, alerts, alert_property_name: str):
counters_dict = {}
expect(
browser.locator("[data-testid='facet']", has_text=facet_name)
).to_be_visible()
# While the facet panel re-renders after a reload or a timeframe change it can
# briefly hold two copies of the same facet, which makes a strict locator throw.
# Scope to the first match so the assertion stays unambiguous; Playwright retries
# it until the panel settles.
facet_locator = browser.locator("[data-testid='facet']", has_text=facet_name).first
expect(facet_locator).to_be_visible()
for alert in alerts:
prop_value = None
for prop in alert_property_name.split("."):
Expand All @@ -106,7 +109,6 @@ def assert_facet(browser, facet_name, alerts, alert_property_name: str):
counters_dict[prop_value] += 1

for facet_value, count in counters_dict.items():
facet_locator = browser.locator("[data-testid='facet']", has_text=facet_name)
expect(facet_locator).to_be_visible()
facet_value_locator = facet_locator.locator(
"[data-testid='facet-value']", has_text=facet_value
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def display_all_available_incidents(browser: Page):
for status in ["resolved", "deleted", "acknowledged"]:
facet_option = (
browser.locator("[data-testid='facet']", has_text="Status")
.locator("[data-testid='facet-value']", has_text=status)
.first.locator("[data-testid='facet-value']", has_text=status)
.locator("input[type='checkbox']")
)
if facet_option.is_visible() and not facet_option.is_checked():
Expand All @@ -56,7 +56,7 @@ def display_all_available_incidents(browser: Page):

def select_one_facet_option(browser, facet_name, option_name):
expect(
browser.locator("[data-testid='facet']", has_text=facet_name)
browser.locator("[data-testid='facet']", has_text=facet_name).first
).to_be_visible()
option = browser.locator("[data-testid='facet-value']", has_text=option_name)
option.hover()
Expand All @@ -65,9 +65,12 @@ def select_one_facet_option(browser, facet_name, option_name):

def assert_facet(browser, facet_name, alerts, alert_property_name: str):
counters_dict = {}
expect(
browser.locator("[data-testid='facet']", has_text=facet_name)
).to_be_visible()
# While the facet panel re-renders after a reload or a timeframe change it can
# briefly hold two copies of the same facet, which makes a strict locator throw.
# Scope to the first match so the assertion stays unambiguous; Playwright retries
# it until the panel settles.
facet_locator = browser.locator("[data-testid='facet']", has_text=facet_name).first
expect(facet_locator).to_be_visible()
for alert in alerts:
prop_value = None
for prop in alert_property_name.split("."):
Expand All @@ -86,7 +89,6 @@ def assert_facet(browser, facet_name, alerts, alert_property_name: str):
counters_dict[value] += 1

for facet_value, count in counters_dict.items():
facet_locator = browser.locator("[data-testid='facet']", has_text=facet_name)
expect(facet_locator).to_be_visible()
facet_value_locator = facet_locator.locator(
"[data-testid='facet-value']", has_text=facet_value
Expand Down Expand Up @@ -241,7 +243,7 @@ def test_adding_custom_facet_for_alert_field(browser, setup_test_data):
# region Verify that facet is displayed and has correct facet values with counters
counters_dict = {}
expect(
browser.locator("[data-testid='facet']", has_text=facet_name)
browser.locator("[data-testid='facet']", has_text=facet_name).first
).to_be_visible()
for incident in current_incidents:
incident_alerts = incidents_alert.get(incident["id"], [])
Expand All @@ -258,7 +260,9 @@ def test_adding_custom_facet_for_alert_field(browser, setup_test_data):
counters_dict[facet_value] += 1
seen_values.add(facet_value)

facet_locator = browser.locator("[data-testid='facet']", has_text=facet_name)
facet_locator = browser.locator(
"[data-testid='facet']", has_text=facet_name
).first

for facet_value, count in counters_dict.items():
expect(facet_locator).to_be_visible()
Expand Down
Loading