Smoke & Presentation Tests
Relevant source files
The following files were used as context for generating this wiki page:
Introduction
Smoke and presentation testing in the SSA Consulta Rapida project ensures the integrity of the user interface (UI) layer and its interaction with the underlying domain and query services. These tests validate critical user workflows—such as searching, filtering, pagination, and preference persistence—without requiring a full production environment. The strategy utilizes "Smoke" tests to verify that the application starts correctly and "Presentation" tests to validate the functional contracts of ViewModels.
The testing infrastructure is built primarily using QtTest for presentation logic and Catch2 for core components. A significant portion of the testing logic focuses on the MainViewModel, which serves as the central hub for coordinating UI state and executing asynchronous data requests via the SsaQueryService.
Sources: AGENTS.md:57-61, CMakeLists.txt:135-149, tests/smoke/PresentationSmokeTest.cpp:1-12
Architecture of Presentation Tests
The presentation testing suite employs a decoupled architecture by utilizing mock implementations of ports (interfaces). This allows the testing of ViewModels in isolation from the actual SQLite database or filesystem.
Mock Components
In PresentationSmokeTest.cpp, several "Fake" classes are implemented to simulate infrastructure behavior:
- FakeRepository: Implements
ISsaRepositoryto return predictableSsaPageResultdata and track incomingSsaPageRequestobjects. - FakeCommands: Implements
IExternalCommandPortto stub out OS-level actions like opening URLs or exporting data. - FakePreferences: Implements
IUserPreferencesStoreto simulate the loading and saving of user settings in memory.
Sources: tests/smoke/PresentationSmokeTest.cpp:14-106
Data Flow for UI Requests
The following diagram illustrates the flow of a search request triggered from the presentation layer during a test:
The flow ensures that when apply() is called on the ViewModel, a request generation is incremented, the FakeRepository is queried, and the SsaTableModel is updated with result data.
Sources: src/presentation/MainViewModel.cpp:258-295, tests/smoke/PresentationSmokeTest.cpp:108-124
Component Validation Sections
Search and Filtering Logic
Tests verify that search text and column filters are correctly compiled into the SsaPageRequest contract. This includes validating that specific exclusions, such as the default exclusion of "SCA", "SES", and "STE" statuses, are respected during the query building process.
| Feature | Validation Target | Source Reference |
|---|---|---|
| Search Application | Updates SsaTableModel row count upon search text change. | PresentationSmokeTest.cpp:108-124 |
| Column Filters | Validates that column-specific filters (e.g., situacao:APV) are present in summary. | PresentationSmokeTest.cpp:197-206 |
| Status Exclusion | Confirms default exclusion of SCA/SES/STE statuses is active. | PresentationSmokeTest.cpp:208-220 |
Pagination and Sorting
The presentation layer manages the state of pagination (page index and size) and sorting (column key and direction). Tests ensure that navigating to the "next page" correctly increments the index in the repository request.
Preference Persistence
The MainViewModel is responsible for saving UI state (theme, density, panel widths) to the IUserPreferencesStore. Tests validate that these updates are triggered and correctly clamped to valid ranges.
- Clamping: The
detailsPanelWidthis constrained between 280 and 680 pixels. - Throttling: Saves are managed via a
QTimerto avoid excessive disk I/O.
Sources: src/presentation/MainViewModel.cpp:92-114, src/domain/SsaTypes.h:18-20, tests/smoke/PresentationSmokeTest.cpp:247-260
Startup and QML Smoke Tests
Beyond unit-level presentation tests, the project includes "Smoke" validation during the application's startup phase in app/desktop/main.cpp.
Execution Flow
The application supports a --smoke-exit-ms flag and a --screenshot option for CI/CD environments to verify that the QML engine loads without failure.
Sources: app/desktop/main.cpp:40-101
Command Line Options for Smoke Testing
| Option | Purpose |
|---|---|
--smoke-exit-ms | Automatically terminates the app after N milliseconds to check for startup crashes. |
--screenshot | Saves a visual capture of the initial window state. |
--open-preferences | Forces the preferences dialog open before capturing a screenshot. |
Sources: app/desktop/main.cpp:45-55, packaging/macos/README.md:9-15
Conclusion
The Smoke and Presentation testing framework provides a robust validation layer for the SSA Consulta Rapida C++ application. By combining isolated ViewModel tests using mock repositories with high-level QML startup smoke tests, the project ensures that UI contracts are maintained and visual regressions are caught early in the development lifecycle. This architecture adheres to the project goal of keeping the GUI logic modular and the core domain independent of the visual implementation.
Sources: AGENTS.md:5-9, src/presentation/MainViewModel.cpp:25-30