chingu-voyages / v52-tier3-team-34

This application, Live Music Finder, is designed for people who want to discover venues with live music happening in real time, without the wait associated with big concert events. | Voyage-52 | https://chingu.io/ | Twitter: https://twitter.com/ChinguCollabs
0 stars 0 forks source link

Bug: (BE) - API Tests do not run after PR - Need a Refactor #66 #67

Open Morais-C opened 2 days ago

Morais-C commented 2 days ago

Describe the problem Afer run

npm test :

> your-app-name@1.0.0 test
> set NODE_ENV=development && jest

 PASS  tests/utils/environment.test.ts
  ● Console

    console.log
      Test Environment: development

      at Object.<anonymous> (tests/setup.ts:17:13)

    console.log
      API URL: http://localhost:3000/api

      at Object.<anonymous> (tests/setup.ts:18:13)

 FAIL  tests/api/venues.test.ts
  ● Test suite failed to run

    tests/api/venues.test.ts:27:15 - error TS2554: Expected 2 arguments, but got 0.

    27         await validateTestData();
                     ~~~~~~~~~~~~~~~~

      tests/utils/testData.ts:22:34
        22 export function validateTestData(data: Record<string, any>, context: string): void {
                                            ~~~~~~~~~~~~~~~~~~~~~~~~~
        An argument for 'data' was not provided.
    tests/api/venues.test.ts:39:53 - error TS2339: Property 'venues' does not exist on type 'Venue[]'.

    39             expect(Array.isArray(response.data.data.venues)).toBe(true);
                                                           ~~~~~~
    tests/api/venues.test.ts:47:34 - error TS2339: Property 'status' does not exist on type 'Venue'.

    47             expect(response.data.status).toBe('success');
                                        ~~~~~~
    tests/api/venues.test.ts:48:34 - error TS2339: Property 'data' does not exist on type 'Venue'.

    48             expect(response.data.data).toHaveProperty('id');
                                        ~~~~
    tests/api/venues.test.ts:49:34 - error TS2339: Property 'data' does not exist on type 'Venue'.

    49             expect(response.data.data).toHaveProperty('userId', testData.new.userId);
                                        ~~~~
    tests/api/venues.test.ts:50:34 - error TS2339: Property 'data' does not exist on type 'Venue'.

    50             expect(response.data.data.name).toContain(`(${currentEnv.slice(0, 3)})`);
                                        ~~~~
    tests/api/venues.test.ts:51:44 - error TS2339: Property 'data' does not exist on type 'Venue'.

    51             createdVenueId = response.data.data.id;
                                                  ~~~~
    tests/api/venues.test.ts:59:34 - error TS2339: Property 'status' does not exist on type 'Venue'.

    59             expect(response.data.status).toBe('success');
                                        ~~~~~~
    tests/api/venues.test.ts:60:34 - error TS2339: Property 'data' does not exist on type 'Venue'.

    60             expect(response.data.data).toHaveProperty('id', createdVenueId);
                                        ~~~~
    tests/api/venues.test.ts:61:34 - error TS2339: Property 'data' does not exist on type 'Venue'.

    61             expect(response.data.data).toHaveProperty('userId');
                                        ~~~~
    tests/api/venues.test.ts:62:34 - error TS2339: Property 'data' does not exist on type 'Venue'.

    62             expect(response.data.data).toHaveProperty('user');
                                        ~~~~
    tests/api/venues.test.ts:84:34 - error TS2339: Property 'status' does not exist on type 'Venue'.

    84             expect(response.data.status).toBe('success');
                                        ~~~~~~
    tests/api/venues.test.ts:85:34 - error TS2339: Property 'data' does not exist on type 'Venue'.

    85             expect(response.data.data).toHaveProperty('id', createdVenueId);
                                        ~~~~
    tests/api/venues.test.ts:86:34 - error TS2339: Property 'data' does not exist on type 'Venue'.

    86             expect(response.data.data.description).toBe(testData.update.description);
                                        ~~~~
    tests/api/venues.test.ts:97:34 - error TS2339: Property 'status' does not exist on type 'Venue'.

    97             expect(response.data.status).toBe('success');
                                        ~~~~~~
    tests/api/venues.test.ts:98:34 - error TS2339: Property 'data' does not exist on type 'Venue'.

    98             expect(response.data.data).toHaveProperty('id', createdVenueId);
                                        ~~~~
    tests/api/venues.test.ts:99:34 - error TS2339: Property 'data' does not exist on type 'Venue'.

    99             expect(response.data.data.name).toContain(`(${currentEnv.slice(0, 3)})`);
                                        ~~~~
    tests/api/venues.test.ts:107:34 - error TS2339: Property 'status' does not exist on type 'Venue'.

    107             expect(response.data.status).toBe('success');
                                         ~~~~~~

 FAIL  tests/api/events.test.ts
  ● Test suite failed to run

    tests/api/events.test.ts:38:34 - error TS2339: Property 'data' does not exist on type 'Event'.

    38             expect(response.data.data).toBeDefined();
                                        ~~~~
    tests/api/events.test.ts:39:34 - error TS2339: Property 'data' does not exist on type 'Event'.

    39             expect(response.data.data.title).toBe(testData.new.title);
                                        ~~~~
    tests/api/events.test.ts:42:44 - error TS2339: Property 'data' does not exist on type 'Event'.

    42             createdEventId = response.data.data.id;
                                                  ~~~~
    tests/api/events.test.ts:57:34 - error TS2339: Property 'status' does not exist on type 'EventListResponse'.

    57             expect(response.data.status).toBe('success');
                                        ~~~~~~
    tests/api/events.test.ts:58:48 - error TS2339: Property 'data' does not exist on type 'EventListResponse'.

    58             expect(Array.isArray(response.data.data)).toBe(true);
                                                      ~~~~
    tests/api/events.test.ts:59:34 - error TS2339: Property 'pagination' does not exist on type 'EventListResponse'.

    59             expect(response.data.pagination).toBeDefined();
                                        ~~~~~~~~~~
    tests/api/events.test.ts:65:34 - error TS2339: Property 'status' does not exist on type 'EventListResponse'.

    65             expect(response.data.status).toBe('success');
                                        ~~~~~~
    tests/api/events.test.ts:66:48 - error TS2339: Property 'data' does not exist on type 'EventListResponse'.

    66             expect(Array.isArray(response.data.data)).toBe(true);
                                                      ~~~~
    tests/api/events.test.ts:67:27 - error TS2339: Property 'data' does not exist on type 'EventListResponse'.

    67             response.data.data.forEach(event => {
                                 ~~~~
    tests/api/events.test.ts:67:40 - error TS7006: Parameter 'event' implicitly has an 'any' type.

    67             response.data.data.forEach(event => {
                                              ~~~~~
    tests/api/events.test.ts:75:34 - error TS2339: Property 'status' does not exist on type 'EventListResponse'.

    75             expect(response.data.status).toBe('success');
                                        ~~~~~~
    tests/api/events.test.ts:76:48 - error TS2339: Property 'data' does not exist on type 'EventListResponse'.

    76             expect(Array.isArray(response.data.data)).toBe(true);
                                                      ~~~~
    tests/api/events.test.ts:82:34 - error TS2339: Property 'status' does not exist on type 'EventGeoJSONCollection'.

    82             expect(response.data.status).toBe('success');
                                        ~~~~~~
    tests/api/events.test.ts:83:34 - error TS2339: Property 'data' does not exist on type 'EventGeoJSONCollection'.

    83             expect(response.data.data.type).toBe('FeatureCollection');
                                        ~~~~
    tests/api/events.test.ts:84:48 - error TS2339: Property 'data' does not exist on type 'EventGeoJSONCollection'.

    84             expect(Array.isArray(response.data.data.features)).toBe(true);
                                                      ~~~~
    tests/api/events.test.ts:87:31 - error TS2339: Property 'data' does not exist on type 'EventGeoJSONCollection'.

    87             if (response.data.data.features.length > 0) {
                                     ~~~~
    tests/api/events.test.ts:88:47 - error TS2339: Property 'data' does not exist on type 'EventGeoJSONCollection'.

    88                 const feature = response.data.data.features[0];
                                                     ~~~~
    tests/api/events.test.ts:100:34 - error TS2339: Property 'status' does not exist on type 'EventListResponse'.

    100             expect(response.data.status).toBe('success');
                                         ~~~~~~
    tests/api/events.test.ts:101:34 - error TS2339: Property 'pagination' does not exist on type 'EventListResponse'.

    101             expect(response.data.pagination).toBeDefined();
                                         ~~~~~~~~~~
    tests/api/events.test.ts:102:34 - error TS2339: Property 'pagination' does not exist on type 'EventListResponse'.

    102             expect(response.data.pagination?.itemsPerPage).toBe(pageSize);
                                         ~~~~~~~~~~
    tests/api/events.test.ts:115:34 - error TS2339: Property 'status' does not exist on type 'EventListResponse'.

    115             expect(response.data.status).toBe('success');
                                         ~~~~~~
    tests/api/events.test.ts:116:48 - error TS2339: Property 'data' does not exist on type 'EventListResponse'.

    116             expect(Array.isArray(response.data.data)).toBe(true);
                                                       ~~~~
    tests/api/events.test.ts:128:34 - error TS2339: Property 'status' does not exist on type 'EventListResponse'.

    128             expect(response.data.status).toBe('success');
                                         ~~~~~~
    tests/api/events.test.ts:129:48 - error TS2339: Property 'data' does not exist on type 'EventListResponse'.

    129             expect(Array.isArray(response.data.data)).toBe(true);
                                                       ~~~~
    tests/api/events.test.ts:142:34 - error TS2339: Property 'status' does not exist on type 'EventListResponse'.

    142             expect(response.data.status).toBe('success');
                                         ~~~~~~
    tests/api/events.test.ts:143:48 - error TS2339: Property 'data' does not exist on type 'EventListResponse'.

    143             expect(Array.isArray(response.data.data)).toBe(true);
                                                       ~~~~
    tests/api/events.test.ts:163:34 - error TS2339: Property 'data' does not exist on type 'Event'.

    163             expect(response.data.data.id).toBe(createdEventId);
                                         ~~~~
    tests/api/events.test.ts:194:34 - error TS2339: Property 'data' does not exist on type 'Event'.

    194             expect(response.data.data.description).toBe(testData.update.description);
                                         ~~~~

----------|---------|----------|---------|---------|-------------------
File      | % Stmts | % Branch | % Funcs | % Lines | Uncovered Line #s
----------|---------|----------|---------|---------|-------------------
All files |       0 |        0 |       0 |       0 |                  
----------|---------|----------|---------|---------|-------------------
Test Suites: 2 failed, 1 passed, 3 total
Tests:       6 passed, 6 total
Snapshots:   0 total
Time:        5.909 s, estimated 11 s
Ran all test suites. 
Morais-C commented 1 day ago

API Test Framework Code Review Report

Date: November 23, 2024

Overview

This document presents a comprehensive review and action plan for the Live Music Finder API test framework.

Current State Analysis

Architecture

Areas for Improvement

Action Plan

Phase 1: Cross-Cutting Concerns (Test Infrastructure)

1.1 Review and Document Current Infrastructure

1.2 Define Test Response Types

1.3 Test Utilities Enhancement

1.4 Test Data Management

Phase 2: Health Endpoint (Reference Implementation)

2.1 Health Endpoint Analysis

2.2 Health Test Refinement

Phase 3: Users Domain

3.1 User Test Infrastructure

3.2 User CRUD Tests

3.3 User Error Cases

Phase 4: Venues Domain

4.1 Venue Test Infrastructure

4.2 Venue CRUD Tests

4.3 Venue Error Cases

Phase 5: Events Domain

5.1 Event Test Infrastructure

5.2 Event CRUD Tests

5.3 Event Error Cases

Phase 6: Integration Tests

6.1 User-Venue Integration

6.2 Venue-Event Integration

Phase 7: Documentation Finalization

7.1 Update Framework Documentation

7.2 Create Test Report Template

Success Criteria

Implementation Notes

Change Management

Handling New Requirements

Handling Inconsistencies

Version Control

Change History