Test CRUD backed by SQLite.
JSON columns: steps, tags (arrays stored as JSON strings). Boolean columns: isJourneyTest, assertionEnhanced, isApiTest (stored as 0/1).
All read queries filter WHERE deletedAt IS NULL by default.
Hard deletes are replaced with soft-deletes: deletedAt = datetime('now').
Use getDeletedByProjectId / restore for recycle-bin operations.
Pagination
getByProjectIdPaged and getAllPagedByProjectIds return
{ data: Test[], meta: { total, page, pageSize, hasMore } }.
- Source:
Methods
(static) bulkSetStale(testIds, isStale)
Bulk-set the isStale flag for a list of test IDs.
Parameters:
| Name | Type | Description |
|---|---|---|
testIds |
Array.<string> | |
isStale |
boolean |
(static) bulkUpdateReviewStatus(testIds, projectId, reviewStatus, reviewedAt) → {Array.<Object>}
Bulk update review status for a list of test IDs within a project. Only applies to non-deleted tests.
Parameters:
| Name | Type | Description |
|---|---|---|
testIds |
Array.<string> | |
projectId |
string | |
reviewStatus |
string | |
reviewedAt |
string | null |
Returns:
Updated test objects.
- Type
- Array.<Object>
(static) clearStaleByProjectIds(projectIds) → {number}
Clear the isStale flag on all tests for the given project IDs. Called before re-evaluating staleness so previously-stale tests that have since been run are unflagged.
Parameters:
| Name | Type | Description |
|---|---|---|
projectIds |
Array.<string> |
Returns:
Number of tests that had their stale flag cleared.
- Type
- number
(static) countApprovedByProjectIds(projectIds) → {number}
Count approved tests for a set of project IDs.
Parameters:
| Name | Type | Description |
|---|---|---|
projectIds |
Array.<string> |
Returns:
- Type
- number
(static) countByProjectIds(projectIds) → {number}
Count non-deleted tests for a set of project IDs.
Parameters:
| Name | Type | Description |
|---|---|---|
projectIds |
Array.<string> |
Returns:
- Type
- number
(static) countByReviewStatus(projectId) → {Object}
Count tests by review status for a project (non-deleted only). Also returns last-result breakdown (passed/failed) for approved tests and category breakdown (api/ui) across all statuses — so the frontend can display accurate stats without fetching all rows.
Parameters:
| Name | Type | Description |
|---|---|---|
projectId |
string |
Returns:
- Type
- Object
(static) countDraftByProjectIds(projectIds) → {number}
Count draft tests for a set of project IDs.
Parameters:
| Name | Type | Description |
|---|---|---|
projectIds |
Array.<string> |
Returns:
- Type
- number
(static) create(test)
Create a test.
Parameters:
| Name | Type | Description |
|---|---|---|
test |
Object |
(static) deleteById(id)
Soft-delete a test by ID (sets deletedAt to now).
Parameters:
| Name | Type | Description |
|---|---|---|
id |
string |
(static) deleteByProjectId(projectId) → {Array.<string>}
Soft-delete all tests for a project. Returns IDs of the tests that were just soft-deleted (excludes already-deleted).
Parameters:
| Name | Type | Description |
|---|---|---|
projectId |
string |
Returns:
IDs of newly soft-deleted tests.
- Type
- Array.<string>
(static) findStaleByAge(projectIds, staleDays) → {Array.<string>}
Find non-deleted tests that have not been run in the last N days.
Parameters:
| Name | Type | Description |
|---|---|---|
projectIds |
Array.<string> | — Scope to these projects. |
staleDays |
number | — Days since last run to consider stale. |
Returns:
Test IDs.
- Type
- Array.<string>
(static) getAll() → {Array.<Object>}
Get all non-deleted tests.
- Source:
Returns:
- Type
- Array.<Object>
(static) getAllByProjectIds(projectIds) → {Array.<Object>}
Get all non-deleted tests belonging to the given project IDs. Used by the workspace-scoped GET /api/tests endpoint (ACL-001).
Parameters:
| Name | Type | Description |
|---|---|---|
projectIds |
Array.<string> |
- Source:
Returns:
- Type
- Array.<Object>
(static) getAllIdsByProjectIdsIncludeDeleted(projectIds) → {Array.<string>}
Get all test IDs (including soft-deleted) for the given project IDs. Used by data-management cleanup endpoints that need to clear derived data (e.g. healing history) for ALL tests, not just live ones.
Parameters:
| Name | Type | Description |
|---|---|---|
projectIds |
Array.<string> |
Returns:
- Type
- Array.<string>
(static) getAllPagedByProjectIds(projectIds, pageopt, pageSizeopt) → {PagedResult}
Get all non-deleted tests belonging to the given project IDs with pagination. Used by the workspace-scoped GET /api/tests endpoint (ACL-001).
Parameters:
| Name | Type | Attributes | Default | Description |
|---|---|---|---|---|
projectIds |
Array.<string> | |||
page |
number | string |
<optional> |
1 | |
pageSize |
number | string |
<optional> |
DEFAULT_PAGE_SIZE |
Returns:
- Type
- PagedResult
(static) getById(id) → {Object|undefined}
Get a non-deleted test by ID.
Parameters:
| Name | Type | Description |
|---|---|---|
id |
string |
Returns:
- Type
- Object | undefined
(static) getByIdIncludeDeleted(id) → {Object|undefined}
Get a test by ID including soft-deleted (needed for restore operations).
Parameters:
| Name | Type | Description |
|---|---|---|
id |
string |
Returns:
- Type
- Object | undefined
(static) getByProjectId(projectId) → {Array.<Object>}
Get non-deleted tests for a specific project.
Parameters:
| Name | Type | Description |
|---|---|---|
projectId |
string |
Returns:
- Type
- Array.<Object>
(static) getByProjectIdPaged(projectId, pageopt, pageSizeopt, filtersopt) → {PagedResult}
Get non-deleted tests for a project with pagination and optional filters.
Parameters:
| Name | Type | Attributes | Default | Description | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
projectId |
string | |||||||||||||||||||
page |
number | string |
<optional> |
1 | |||||||||||||||||
pageSize |
number | string |
<optional> |
DEFAULT_PAGE_SIZE | |||||||||||||||||
filters |
Object |
<optional> |
Properties
|
Returns:
- Type
- PagedResult
(static) getDeletedAll() → {Array.<Object>}
Get all soft-deleted tests across all projects.
Returns:
- Type
- Array.<Object>
(static) getDeletedByProjectId(projectId) → {Array.<Object>}
Get soft-deleted tests for a project (recycle bin view).
Parameters:
| Name | Type | Description |
|---|---|---|
projectId |
string |
Returns:
- Type
- Array.<Object>
(static) hardDeleteById(id)
Hard-delete a test by ID (permanent — use only for purge operations).
Parameters:
| Name | Type | Description |
|---|---|---|
id |
string |
(static) hardDeleteByProjectId(projectId) → {Array.<string>}
Hard-delete all tests for a project (permanent — for project purge).
Parameters:
| Name | Type | Description |
|---|---|---|
projectId |
string |
Returns:
IDs of all deleted tests.
- Type
- Array.<string>
(static) restore(id) → {boolean}
Restore a soft-deleted test (clears deletedAt).
Parameters:
| Name | Type | Description |
|---|---|---|
id |
string |
Returns:
Whether the test was found and restored.
- Type
- boolean
(static) restoreByProjectIdAfter(projectId, deletedAfter) → {number}
Restore soft-deleted tests for a project that were deleted at or after a given timestamp. Used by project cascade-restore to avoid restoring items that were individually deleted before the project.
Parameters:
| Name | Type | Description |
|---|---|---|
projectId |
string | |
deletedAfter |
string | — ISO timestamp (inclusive lower bound). |
Returns:
Number of tests restored.
- Type
- number
(static) update(id, fields)
Update specific fields on a test.
Parameters:
| Name | Type | Description |
|---|---|---|
id |
string | |
fields |
Object | — Partial test fields to update. |
(inner) countByProjectIdsAndStatus(projectIds, reviewStatus) → {number}
Count tests by review status for a set of project IDs.
Parameters:
| Name | Type | Description |
|---|---|---|
projectIds |
Array.<string> | |
reviewStatus |
"approved" | "draft" |
Returns:
- Type
- number