[PR #23614] [CLOSED] test: add integration tests for notes API #50324

Closed
opened 2026-04-30 02:58:51 -05:00 by GiteaMirror · 0 comments
Owner

📋 Pull Request Information

Original PR: https://github.com/open-webui/open-webui/pull/23614
Author: @mohi-devhub
Created: 4/12/2026
Status: Closed

Base: devHead: test/notes-api-coverage


📝 Commits (1)

  • 423050a test: add integration tests for notes API

📊 Changes

3 files changed (+551 additions, -0 deletions)

View changed files

backend/open_webui/test/apps/webui/routers/test_notes.py (+343 -0)
backend/open_webui/test/util/abstract_integration_test.py (+163 -0)
backend/open_webui/test/util/mock_user.py (+45 -0)

📄 Description

Pull Request Checklist

  • Target branch: Verify that the pull request targets the dev branch.
  • Description: Provided below.
  • Changelog: Added below.
  • Documentation: No user-facing behaviour changed — no docs needed.
  • Dependencies: No new or upgraded dependencies.
  • Testing: All 20 tests pass locally against a real Postgres instance via Docker.
  • Agentic AI Code: Confirm this Pull Request is not written by any AI Agent or has at least gone through additional human review AND manual testing.
  • Code review: Self-reviewed.
  • Design & Architecture: Test files only - no settings, no UI, no architecture changes.
  • Git Hygiene: Single atomic commit targeting one logical change.
  • Title Prefix: test:

Changelog Entry

Description

The notes API (routers/notes.py) had no test coverage. This PR adds a full integration test suite for it, following the same pattern as test_users.py.

It also introduces the shared test utilities (AbstractPostgresTest, mock_webui_user) that the existing test files depend on but were previously absent from the repository.

Added

  • backend/open_webui/test/apps/webui/routers/test_notes.py — 20 integration tests covering:

    • Create: happy path, 401 when the notes feature is disabled via USER_PERMISSIONS
    • Get by ID: owner access (write_access: true), 404 for unknown ID, 403 for a non-owner with no access grant
    • List: empty result, results scoped to the requesting user only
    • Search:
      • Single-word title match
      • Multi-word normalization ("to do" matches "to-do list")
      • Content body match
      • No-results case
      • Cross-user isolation
    • Update: happy path, 403 for non-owner, 404 for unknown ID
    • Delete: happy path, confirmed gone on re-fetch, 403 for non-owner, 404 for unknown ID
    • Admin: can get and delete any user's note regardless of ownership
  • backend/open_webui/test/util/abstract_integration_test.py — Postgres Docker fixture base class (AbstractPostgresTest)

  • backend/open_webui/test/util/mock_user.py — auth dependency override helper (mock_webui_user)

Fixed

  • Adds a regression test (test_search_notes_multi_word_query) that validates the multi-word search normalization fix, ensuring queries like "to do" correctly match notes titled "to-do list" via hyphen/space stripping.

Additional Information

Screenshots or Videos

N/A — backend tests only.


Contributor License Agreement


🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.

## 📋 Pull Request Information **Original PR:** https://github.com/open-webui/open-webui/pull/23614 **Author:** [@mohi-devhub](https://github.com/mohi-devhub) **Created:** 4/12/2026 **Status:** ❌ Closed **Base:** `dev` ← **Head:** `test/notes-api-coverage` --- ### 📝 Commits (1) - [`423050a`](https://github.com/open-webui/open-webui/commit/423050a95e0b987ea5930b823229b4ed90c22a18) test: add integration tests for notes API ### 📊 Changes **3 files changed** (+551 additions, -0 deletions) <details> <summary>View changed files</summary> ➕ `backend/open_webui/test/apps/webui/routers/test_notes.py` (+343 -0) ➕ `backend/open_webui/test/util/abstract_integration_test.py` (+163 -0) ➕ `backend/open_webui/test/util/mock_user.py` (+45 -0) </details> ### 📄 Description # Pull Request Checklist - [x] **Target branch:** Verify that the pull request targets the `dev` branch. - [x] **Description:** Provided below. - [x] **Changelog:** Added below. - [x] **Documentation:** No user-facing behaviour changed — no docs needed. - [x] **Dependencies:** No new or upgraded dependencies. - [x] **Testing:** All 20 tests pass locally against a real Postgres instance via Docker. - [x] **Agentic AI Code:** Confirm this Pull Request is not written by any AI Agent or has at least gone through additional human review AND manual testing. - [x] **Code review:** Self-reviewed. - [x] **Design & Architecture:** Test files only - no settings, no UI, no architecture changes. - [x] **Git Hygiene:** Single atomic commit targeting one logical change. - [x] **Title Prefix:** `test:` --- # Changelog Entry ## Description The notes API (`routers/notes.py`) had no test coverage. This PR adds a full integration test suite for it, following the same pattern as `test_users.py`. It also introduces the shared test utilities (`AbstractPostgresTest`, `mock_webui_user`) that the existing test files depend on but were previously absent from the repository. ## Added - `backend/open_webui/test/apps/webui/routers/test_notes.py` — 20 integration tests covering: - Create: happy path, 401 when the notes feature is disabled via `USER_PERMISSIONS` - Get by ID: owner access (`write_access: true`), 404 for unknown ID, 403 for a non-owner with no access grant - List: empty result, results scoped to the requesting user only - Search: - Single-word title match - Multi-word normalization (`"to do"` matches `"to-do list"`) - Content body match - No-results case - Cross-user isolation - Update: happy path, 403 for non-owner, 404 for unknown ID - Delete: happy path, confirmed gone on re-fetch, 403 for non-owner, 404 for unknown ID - Admin: can get and delete any user's note regardless of ownership - `backend/open_webui/test/util/abstract_integration_test.py` — Postgres Docker fixture base class (`AbstractPostgresTest`) - `backend/open_webui/test/util/mock_user.py` — auth dependency override helper (`mock_webui_user`) ## Fixed - Adds a regression test (`test_search_notes_multi_word_query`) that validates the multi-word search normalization fix, ensuring queries like `"to do"` correctly match notes titled `"to-do list"` via hyphen/space stripping. --- ## Additional Information - Closes #23613 - Related to #21783 (backend has no test coverage in CI) - Tests use a real Postgres instance (no mocks), consistent with the existing test infrastructure in this repository. ## Screenshots or Videos N/A — backend tests only. --- ## Contributor License Agreement - [x] By submitting this pull request, I confirm that I have read and fully agree to the [Contributor License Agreement (CLA)](https://github.com/open-webui/open-webui/blob/main/CONTRIBUTOR_LICENSE_AGREEMENT), and I am providing my contributions under its terms. --- <sub>🔄 This issue represents a GitHub Pull Request. It cannot be merged through Gitea due to API limitations.</sub>
GiteaMirror added the pull-request label 2026-04-30 02:58:51 -05:00
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: github-starred/open-webui#50324