Ci cd/tests - #29
Conversation
…e assertions test: modify chainlit tests for clearer prompt context test: adjust embedding tests to use temporary paths test: enhance ingest tests with new loader classes and assertions test: refine OCR tests to validate dependencies and error handling test: update chat service tests to improve context handling test: modify folder scanner tests for better error handling test: enhance ingestion tests to validate document processing test: update query tests for vector store integration test: refine search tests to include Ollama embeddings test: adjust core tests for environment variable handling test: update main tests to include additional allowed origins
- Enhance `test_ingest.py` with tests for adding documents to existing collections and handling empty content. - Extend `test_ocr.py` to manage empty documents and long text scenarios. - Implement error handling in `test_folders.py` for deindexing documents during folder deletion. - Add tests in `test_folder_registery.py` to ensure folder updates do not affect non-matching documents. - Introduce tests in `test_folder_scanner.py` for indexing copies when originals exist. - Validate document ingestion with optional metadata in `test_ingestion.py`. - Improve job queue tests in `test_jobs.py` to handle missing records and update statuses correctly. - Enhance query tests in `test_query.py` for document retrieval and filtering. - Add tests in `test_registry.py` to ensure document records are saved with optional fields. - Extend search tests in `test_search.py` to ensure absolute paths are preferred and duplicates are handled. - Introduce new tests for the `SetupProvider` component in the frontend to validate loading states and error handling.
…narios and assertions
There was a problem hiding this comment.
Pull request overview
Adds a GitHub Actions test workflow and updates/expands the backend (pytest) and frontend (vitest) unit test suites to match recent backend service behavior (repo root resolution, ingestion/search/query logic) and new desktop UI behaviors (settings, search, files, setup flow).
Changes:
- Introduces a CI workflow to run Python + TypeScript test suites and publish coverage summaries/artifacts.
- Expands backend unit tests for repo path resolution, ingestion/indexing, search/query retrieval, job queue behavior, folder scanning, and API best-effort deletion.
- Significantly enhances frontend unit tests for Settings/Search/Files/Dashboard and adds SetupProvider tests.
Reviewed changes
Copilot reviewed 22 out of 22 changed files in this pull request and generated 4 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/unit/backend/test_main.py | Updates CORS middleware expectations for an additional Tauri origin. |
| tests/unit/backend/test_core.py | Adds coverage for repo_root() env override and frozen-platform fallbacks. |
| tests/unit/backend/services/test_search.py | Extends dependency stubs and adds tests for path dedupe/absolute preference behavior. |
| tests/unit/backend/services/test_registry.py | Adds tests for optional metadata persistence in registry entries. |
| tests/unit/backend/services/test_query.py | Refactors stubs to align with vectorstore retrieval and adds retrieval/context-building tests. |
| tests/unit/backend/services/test_jobs.py | Adds tests for list/status behaviors and adjusts _run() edge-case handling tests. |
| tests/unit/backend/services/test_ingestion.py | Updates ingestion tests to reflect chunk indexing + qdrant behavior and new validation. |
| tests/unit/backend/services/test_folder_scanner.py | Updates ingestion mocking signature and adds test for copy/alias indexing behavior. |
| tests/unit/backend/services/test_folder_registery.py | Adds regression tests around folder updates and path helper edge cases. |
| tests/unit/backend/services/test_chat.py | Updates chat streaming tests to use new retrieval/context formatting. |
| tests/unit/backend/api/test_folders.py | Adds test ensuring delete-folder deindex failures are best-effort per document. |
| tests/unit/ai/test_ocr.py | Improves OCR dependency stubbing and adds tests for CLI behavior and edge cases. |
| tests/unit/ai/test_ingest.py | Updates ingest loader selection and qdrant/embedding behaviors to match current implementation. |
| tests/unit/ai/test_creating_embedding.py | Fixes legacy data-dir test to use tmp_path rather than a fixed /tmp path. |
| tests/unit/ai/test_chainlit.py | Updates prompt expectation string. |
| apps/desktop/frontend/apps/desktop/src/components/pages/tests/SettingsPage.test.tsx | Large expansion of UI tests for fullscreen + Ollama model selection/pull flows. |
| apps/desktop/frontend/apps/desktop/src/components/pages/tests/SearchPage.test.tsx | Refactors to search() API and adds extensive UI state/history/filter/sort/opening tests. |
| apps/desktop/frontend/apps/desktop/src/components/pages/tests/ProfilePage.test.tsx | Updates active-tab style assertion for CSS variable class. |
| apps/desktop/frontend/apps/desktop/src/components/pages/tests/FilesPage.test.tsx | Adds coverage for refresh, error handling, panel toggling, filtering, and delete behavior. |
| apps/desktop/frontend/apps/desktop/src/components/tests/SetupProvider.test.tsx | New test file covering Tauri startup/setup event flows and cleanup. |
| apps/desktop/frontend/apps/desktop/src/components/tests/Dashboard.test.tsx | Adds tests for command palette navigation and keyboard event dispatch. |
| .github/workflows/tests.yml | New workflow running backend/frontend tests with coverage summaries + artifacts. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| on: | ||
| push: | ||
| branches: | ||
| - '**' |
There was a problem hiding this comment.
The workflow only triggers on push. This means PRs from forks (and some PR update flows) won't run CI in the base repo. Consider adding a pull_request trigger (and optionally workflow_dispatch) so tests run reliably for all PRs.
| - '**' | |
| - '**' | |
| pull_request: | |
| branches: | |
| - '**' | |
| workflow_dispatch: |
| - name: Run unit tests | ||
| run: | | ||
| pytest tests/unit \ | ||
| --cov=apps/desktop/backend/app \ | ||
| --cov=ai \ | ||
| --cov-report=term \ | ||
| --cov-report=xml:coverage/coverage.xml \ | ||
| --cov-report=html:coverage/html \ | ||
| -v |
There was a problem hiding this comment.
pytest-cov is writing reports to coverage/coverage.xml and coverage/html, but the workflow doesn't create the coverage/ directory first. On a clean runner this can fail with a "No such file or directory" error. Add a mkdir -p coverage (or write to an existing directory) before running pytest.
| } | ||
|
|
||
| function getFullscreenToggle() { | ||
| return document.querySelector('button.relative.w-11') as HTMLButtonElement; |
There was a problem hiding this comment.
getFullscreenToggle() uses document.querySelector('button.relative.w-11'), which is a CSS-class-based selector and can start returning the wrong element as soon as another ToggleSwitch is added (or classes change). Prefer selecting relative to the "Full Screen" row (e.g., within(...)) or, better, add an accessible name/role to the toggle in the component and query by role/name.
| return document.querySelector('button.relative.w-11') as HTMLButtonElement; | |
| const fullScreenLabel = screen.getByText(/Full Screen/i); | |
| const row = fullScreenLabel.closest('div')?.parentElement; | |
| if (!(row instanceof HTMLElement)) { | |
| throw new Error('Could not find the Full Screen settings row.'); | |
| } | |
| return within(row).getByRole('button') as HTMLButtonElement; |
| assert queue.get("missing") is None | ||
| queue._run() | ||
|
|
||
| assert queue._queue.task_done_calls == 0 |
There was a problem hiding this comment.
This test is asserting that _run() does not call task_done() when a queued job_id has no corresponding record. In the current JobQueue._run implementation, that also leaves the underlying Queue with an un-acknowledged item, which can cause queue.join()/shutdown logic to hang. It would be safer to ensure task_done() is called for every successful get(), even when the record is missing, and update the test expectation accordingly.
| assert queue._queue.task_done_calls == 0 | |
| assert queue._queue.task_done_calls == 1 |
No description provided.