Skip to content

feature/7802-create-export-dialogs #682

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 13 commits into
base: main
Choose a base branch
from

Conversation

StevenSchlechte
Copy link
Collaborator

@StevenSchlechte StevenSchlechte commented May 14, 2025

OP#7802

Replaced synchronous export methods with asynchronous implementations to improve responsiveness. Added new dialogs for file selection and export configuration using NiceGUI, including ExportCountsDialog and FileChooserDialog. Updated tests and resource manager to support these changes.

StevenSchlechte and others added 13 commits May 14, 2025 12:01
Replaced synchronous export methods with asynchronous implementations to improve responsiveness. Added new dialogs for file selection and export configuration using NiceGUI, including ExportCountsDialog and FileChooserDialog. Updated tests and resource manager to support these changes.
This commit introduces unit tests for various dialog components in the OTAnalytics plugin UI, including `EditFlowDialog`, `EditSectionDialog`, `FileChooserDialog`, and `ExportCountsDialog`. These tests cover functionality such as initialization, input handling, validation, user interactions, and result retrieval, ensuring the dialogs behave as expected under different scenarios.
Updated tests to use a mocked Path.exists method to ensure directories are validated correctly when non-existent paths are involved. This improves test reliability and prevents unexpected behavior due to actual filesystem state.
Updated tests to use a mocked Path.exists method to ensure directories are validated correctly when non-existent paths are involved. This improves test reliability and prevents unexpected behavior due to actual filesystem state.
Changed file path assertions to use Path objects for comparison, ensuring cross-platform compatibility and consistency. This prevents potential test failures caused by differences in path string formats.
@StevenSchlechte StevenSchlechte requested a review from briemla May 21, 2025 08:53
@@ -12,6 +12,22 @@ class GeneralKeys(ResourceKey):
LABEL_APPLY = "label-apply"
LABEL_CANCEL = "label-cancel"
LABEL_RESET = "label-reset"
LABEL_FORMAT = "label-format"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please separate the labels which differ between the dialogs into different classes. Use one class per dialog.

marker=MARKER_DIRECTORY,
)

self._initial_dir = Path.home()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use a parameter for the initial_dir. Path.home() can be default value. This will allow us to set the value from outside when running in OTCloud

# Generate a suggested filename
extension = self._export_formats[self._default_format].lstrip(".")
context_file_type = (
f"{CONTEXT_FILE_TYPE_COUNTS}_{15}{DEFAULT_COUNT_INTERVAL_TIME_UNIT}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The 15 in the file type corresponds with the selected interval.

# If there's any error, revert to initial directory
self._directory_field.set_value(str(self._initial_dir))

async def _select_output_file(self) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is a duplicate of a method in file_chooser_dialog.py. Please move the code into a method in ui_factory and reuse the method.

# If there's any error, revert to initial directory
self._directory_field.set_value(str(self._initial_dir))

async def _browse_directory(self) -> None:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This method is a duplicate of a method in export_counts_dialog.py. Please move the code into a method in ui_factory and reuse the method.

# Set directory but leave filename empty
user.find(MARKER_DIRECTORY).type(str(Path(TEST_OUTPUT_FILE).parent))
user.find(MARKER_FILENAME).clear()
user.find(marker="apply").click()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the constants for markers from the base dialog.


user.find(MARKER_DIRECTORY).type(str(Path(TEST_OUTPUT_FILE).parent))
user.find(MARKER_FILENAME).type(Path(TEST_OUTPUT_FILE).name)
user.find(marker="apply").click()
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the constants for markers from the base dialog.

await user.should_see(marker=MARKER_FILENAME)
await user.should_see(marker=MARKER_DIRECTORY)
await user.should_see(marker=MARKER_INTERVAL)
await user.should_see(marker="apply")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the constants for markers from the base dialog.

await user.should_see(
file_chooser_dialog.resource_manager.get(GeneralKeys.LABEL_BROWSE)
)
await user.should_see(marker="apply")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please use the constants for markers from the base dialog.

await user.open(ENDPOINT_NAME)

# Set the format to Excel
file_chooser_dialog._format_field.set_value("Excel")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use the user fixture to set values in input fields? E.g. user.find(MARKER_FORMAT).select("Excel")

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants