Files
project-work/sources/task-brief.md
2026-11-10 21:00:57 -05:00

8.2 KiB
Raw Blame History

1. Task Description

NearBeach's search tests need to be expanded. The HTTP-status checks can be made into deterministic, data-driven tests verifying actual search results. There are explicit TODOs in NearBeach/tests/tests_views/tests_search/test_search.py for customer, organisation search. Address those gaps and extend coverage across main, customer, organisation, group, user, sprint, tag, notification, and permission-set searches.

Add at least 20 new test methods covering matching semantics, result counts, pagination, permissions, and closed/include_closed behaviour wherever those features exist in the code. This is a test-engineering task, not a search redesign: preserve existing endpoint contract.


2. How to Judge Completion

Start at the NearBeach repository root, create a virtual environment and install the project requirements plus coverage:

python3 -m venv .venv
source .venv/bin/activate
python3 -m pip install -r requirements.txt
python3 -m pip install coverage

Use the supplied repository's documented Django settings and database configuration. Run the existing search suite before making changes and record the baseline. Django's test runner should create and migrate its test database, so a running development server or manually created superuser is not required.

python3 manage.py test NearBeach.tests.tests_views.tests_search -v 2

After implementation, rerun that command. All existing search tests and at least 20 additional test methods should pass, with assertions on returned object identities, counts, or pagination metadata rather than only HTTP 200 responses. Inspect the tests to confirm that each of the nine search categories above has meaningful result assertions and that permission cases use ordinary users, not only superusers.

Run for coverage:

coverage run --source=NearBeach.views.search_views,NearBeach.views.search \
  manage.py test NearBeach.tests.tests_views.tests_search
coverage report -m

Both NearBeach/views/search_views.py and NearBeach/views/search/search_objects.py should individually reach at least 80% statement coverage. Record the actual percentages and uncovered lines; do not omit difficult branches or alter coverage exclusions merely to meet the target.

Finally, run the complete existing suite:

python3 manage.py test

There should be no new failures. If the supplied environment has pre-existing failures or unavailable dependencies, document the exact commands, failures, and comparison with the baseline rather than reporting an unverified pass.


3. Other Notes for Reviewer

NearBeach is an open-source Django/Vue project management application used to track projects, tasks, requirements, and related team activity. Search is a navigation mechanism across multiple business objects and administrative records, so a successful HTTP response alone does not show that users can find the right records or that restricted records stay hidden.

Research finds gaps explicitly documented as TODOs in the existing search tests. Deterministic fixtures and result-level assertions will make filtering and permission regressions visible, providing a safety net for future search maintenance without changing the user interface or adding a new search API. Permission tests are especially important because a search can return plausible results while silently including objects outside a user's authorised groups.

Endpoint capabilities and permission rules must be confirmed against the supplied repository before encoding expectations. Not every search type necessarily supports pagination, closed-state filtering, or the same ObjectAssignment-based visibility rules; tests should exercise the actual contract for each type rather than invent uniform behaviour. This document describes planned acceptance criteria, not evidence that the code has already been inspected, changed, or tested.


Implementation Essentials (for Model)

View & Template:

  • Server-rendered Django template (no Vue component): NearBeach/templates/NearBeach/tasks/task_list.html
  • URL: path("tasks/", views.task_list, name="task_list")
  • Follows sprint_list pattern for permission filtering via ObjectAssignment → UserGroup → Group
  • All state (filters, sort, page, page_size) lives in the query string; every link rebuilds it

Filter Sidebar (GET form, action="/tasks/"):

Param Control Query
status (repeatable) Checkboxes; value = task_status_id task_status_id__in=[...]
assignee Select; value = user id (0 = Unassigned) task_assigned_to=<id> / task_assigned_to__isnull=True
project Select; value = project_id Tasks linked via ObjectAssignment
start_date <input type="date">, optional task_start_date__gte=value
end_date <input type="date">, optional task_end_date__lte=value
  • Status options from ListOfTaskStatus ordered by task_status_sort_order
  • Assignee options: "All", users with task access in accessible projects, "Unassigned" (0)
  • Project options: "All", projects user can reach through their groups
  • Clear Filters = link to /tasks/ (drops all params); Apply = form submit
  • Hidden sort input in form carries current sort; hidden page_size dropdown in form

Table (9 columns):

Column Sort Field Rendering
Title task_short_description Bold description + #T-{task_id} small
Status task_status__task_status_sort_order Badge: badge-{{ higher_order_status|lower }}
Priority task_priority 8px dot + {{ get_task_priority_display }}
Assignee task_assigned_to__username Username or -
Project first_project_name (annotated) Via ObjectAssignment subquery
Start Date task_start_date Y-m-d
End Date task_end_date Y-m-d
Created date_created Y-m-d (default sort: -date_created)
Actions — "View" → {% url 'task_information' task.task_id %}

Status Badges (4 classes by task_higher_order_status):

  • badge-backlog (New, Backlog) — yellow
  • badge-normal (In Progress, Test/Review) — blue
  • badge-blocked (Blocked) — red
  • badge-closed (Closed) — green

Priority (3 color groups):

  • priority-high (0=Highest, 1=High) — red
  • priority-normal (2=Normal) — orange
  • priority-low (3=Low, 4=Lowest) — blue

Sorting:

  • ?sort=field = ASC (▲), ?sort=-field = DESC (▼)
  • Click active column → toggle; click different column → ASC
  • Allowed fields: the 8 above only; invalid falls back to default
  • Header links keep all other params, reset page=1
  • Hidden sort input in filter form persists current sort

Pagination:

  • page_size: 10/25/50/100 (default 25); invalid → 25; dropdown in filter form, auto-submits
  • page: Paginator.get_page() (safe); elided range: on_each_side=2, on_ends=1
  • Prev/Next: disabled (<span>) on first/last page
  • All page links preserve filters, sort, page_size; change only page
  • Apply / sort click / page_size change / Clear Filters → reset to page=1
  • Results: Showing {{ page_obj.start_index }}–{{ page_obj.end_index }} of {{ paginator.count }} tasks

Actions Column: Pinned right (th:last-child, td:last-child { position: sticky; right: 0; }); other columns scroll sideways inside container

Empty State: {% empty %} row with colspan="9", centered "No tasks found"; count shows "0–0 of 0"

Permissions (DB-level, not template):

  • Queryset limited to tasks from projects user's groups can reach via ObjectAssignment
  • Superusers see all
  • user_level = max task permission across groups
  • "+ New Task" button: user_level >= 3
  • "View" button: user_level >= 1
  • Filter sidebar: always visible

Styling:

  • New partial: src/sass/components/_task_list.scss → imported in main.scss
  • Add --nb-* tokens for new colors in both _light_theme.scss and _dark_theme.scss
  • Reuse: btn btn-primary, btn btn-secondary, form-control, badge, card/spacing styles
  • Layout: desktop = sidebar (~280px) + table; <1024px = stacked
  • Table cells: 12px 16px padding
  • Badge text + background readable in both themes

Tests: 12 test methods in NearBeach/tests/tests_views/tests_task/test_task_list.py