Skip to content

[BE-40] Write e2e tests for the full asset CRUD flow in opsce module #765

@yusuftomilola

Description

@yusuftomilola

Problem

The asset management flow has no end-to-end tests. It is not possible to verify the full request-response cycle (auth → create asset → update → transfer → delete) without manual testing.

Proposed Solution

Create backend/test/opsce-assets.e2e-spec.ts using Supertest and an in-memory SQLite test database. The test suite should cover the full asset lifecycle.

Acceptance Criteria

  • Setup creates a test app with an in-memory database and seeds a test user (ADMIN role)
  • POST /api/auth/login — returns 200 with tokens for valid credentials
  • POST /api/assets — returns 201 with created asset, returns 401 without token
  • GET /api/assets — returns paginated list with the created asset
  • PATCH /api/assets/:id — updates fields and returns updated asset
  • POST /api/assets/:id/transfer — changes assignee and verifies audit log entry
  • DELETE /api/assets/:id — soft-deletes asset, asset absent from subsequent list
  • Database is reset between each test to ensure isolation

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions