Skip to content
Merged
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
45 changes: 33 additions & 12 deletions tests/e2e-test/pages/HomePageV2.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,6 +156,25 @@ def get_testdata_files(self):
logger.info(f"Found {len(files)} files in testdata folder: {[os.path.basename(f) for f in files]}")
return files

def _get_import_dialog(self):
"""
Locate the Import Content dialog using both 'dialog' and 'alertdialog' roles.
Fluent UI v9 with modalType='modal' renders as role='dialog', while older
versions or modalType='alert' use 'alertdialog'.
"""
dialog = self.page.get_by_role("dialog", name="Import Content")
alertdialog = self.page.get_by_role("alertdialog", name="Import Content")
import_dialog = dialog.or_(alertdialog).first

try:
expect(import_dialog).to_be_visible(timeout=5000)
except Exception as exc:
raise Exception(
"Import Content dialog not found with role 'dialog' or 'alertdialog'"
) from exc

return import_dialog

def select_schema_for_file(self, file_name, schema_name):
"""
Select a schema from the dropdown for a specific file in the import dialog.
Expand All @@ -166,13 +185,11 @@ def select_schema_for_file(self, file_name, schema_name):
"""
logger.info(f"Selecting schema '{schema_name}' for file '{file_name}'...")

dialog = self._get_import_dialog()

# Get all schema comboboxes and file labels in the import dialog
schema_dropdowns = self.page.get_by_role(
"alertdialog", name="Import Content"
).get_by_placeholder("Select Schema")
file_labels = self.page.get_by_role(
"alertdialog", name="Import Content"
).locator("strong")
schema_dropdowns = dialog.get_by_placeholder("Select Schema")
file_labels = dialog.locator("strong")

# Find the index of this file among all listed files
count = file_labels.count()
Expand All @@ -184,6 +201,8 @@ def select_schema_for_file(self, file_name, schema_name):
break

if target_index == -1:
dialog_text = dialog.inner_text()
logger.error(f"File '{file_name}' not found. Dialog content:\n{dialog_text[:500]}")
raise Exception(f"File '{file_name}' not found in import dialog")

# Click on the schema dropdown for this file
Expand Down Expand Up @@ -249,7 +268,7 @@ def upload_files(self):

logger.info("Validating upload success...")
expect(
self.page.get_by_role("alertdialog", name="Import Content")
self._get_import_dialog()
.locator("path")
.nth(1)
).to_be_visible()
Expand Down Expand Up @@ -818,7 +837,9 @@ def validate_import_without_collection(self):
validation_msg = self.page.locator(
"//div[contains(text(),'Please Select') or contains(text(),'Please select')]"
)
dialog = self.page.get_by_role("alertdialog")
dialog = self.page.get_by_role("dialog", name="Import Content").or_(
self.page.get_by_role("alertdialog", name="Import Content")
)

if validation_msg.count() > 0 and validation_msg.first.is_visible():
logger.info("✓ Validation message is visible")
Expand Down Expand Up @@ -864,7 +885,7 @@ def validate_schema_selection_warning(self):

# Validate the selected collection info message
logger.info("Validating 'Selected Collection: Auto Claim' message...")
dialog = self.page.get_by_role("alertdialog", name="Import Content")
dialog = self._get_import_dialog()
expect(dialog).to_be_visible()
logger.info("✓ Import Content dialog is visible")

Expand Down Expand Up @@ -935,7 +956,7 @@ def validate_unsupported_file_upload(self):
logger.info("✓ Unsupported file error message is visible")
else:
# Check if Import button remains disabled
dialog = self.page.get_by_role("alertdialog", name="Import Content")
dialog = self._get_import_dialog()
import_btn = dialog.locator("//button[normalize-space()='Import']")
expect(import_btn).to_be_disabled()
logger.info("✓ Import button remains disabled for unsupported file")
Expand Down Expand Up @@ -1060,7 +1081,7 @@ def open_import_dialog_with_files(self):

self.page.wait_for_timeout(5000)

dialog = self.page.get_by_role("alertdialog", name="Import Content")
dialog = self._get_import_dialog()
logger.info("Import dialog opened with files ready for schema selection")
return dialog

Expand Down Expand Up @@ -1158,7 +1179,7 @@ def upload_files_with_mismatched_schemas(self):

logger.info("Validating upload success (system accepts mismatched schemas)...")
expect(
self.page.get_by_role("alertdialog", name="Import Content")
self._get_import_dialog()
.locator("path")
.nth(1)
).to_be_visible()
Expand Down
Loading