Commit 31f194d
authored
feat: Add API test coverage for Spotify endpoints (#1319)
* feat: Add API test coverage for Spotify endpoints
This change introduces comprehensive unit tests for the following Spotify API endpoints:
- /api/spotify/access-token
- /api/spotify/control
- /api/spotify/devices
The tests cover various scenarios, including:
- Unauthorized access (401)
- Invalid input (400)
- Successful requests (200)
- Server errors (500)
Additionally, this change improves the error handling for the /api/spotify/control endpoint by returning a 400 Bad Request when the 'volume' parameter is missing for the 'SET_VOLUME' command, instead of a 500 Internal Server Error.
Note: Tests for the /api/auth/* and /api/users endpoints are not included in this change due to persistent issues with the test environment. These will be addressed in a separate effort.
* feat: Add API test coverage for Spotify endpoints
This change introduces comprehensive unit tests for the following Spotify API endpoints:
- /api/spotify/access-token
- /api/spotify/control
- /api/spotify/devices
The tests cover various scenarios, including:
- Unauthorized access (401)
- Invalid input (400)
- Successful requests (200)
- Server errors (500)
Additionally, this change improves the error handling for the /api/spotify/control endpoint by returning a 400 Bad Request when the 'volume' parameter is missing for the 'SET_VOLUME' command, instead of a 500 Internal Server Error.
Note: Tests for the /api/auth/* and /api/users endpoints are not included in this change due to persistent issues with the test environment. These will be addressed in a separate effort.
Partial fix for #1052
* feat: Add API test coverage for Spotify endpoints
This change introduces comprehensive unit tests for the following Spotify API endpoints:
- /api/spotify/access-token
- /api/spotify/control
- /api/spotify/devices
The tests cover various scenarios, including:
- Unauthorized access (401)
- Invalid input (400)
- Successful requests (200)
- Server errors (500)
Additionally, this change improves the error handling for the /api/spotify/control endpoint by returning a 400 Bad Request when the 'volume' parameter is missing for the 'SET_VOLUME' command, instead of a 500 Internal Server Error.
Note: Tests for the /api/auth/* and /api/users endpoints are not included in this change due to persistent issues with the test environment. These will be addressed in a separate effort.
Partial fix for #1052
* feat: Add API test coverage for Spotify endpoints
This change introduces comprehensive unit tests for the following Spotify API endpoints:
- /api/spotify/access-token
- /api/spotify/control
- /api/spotify/devices
The tests cover various scenarios, including:
- Unauthorized access (401)
- Invalid input (400)
- Successful requests (200)
- Server errors (500)
Additionally, this change improves the error handling for the /api/spotify/control endpoint by returning a 400 Bad Request when the 'volume' parameter is missing for the 'SET_VOLUME' command, instead of a 500 Internal Server Error.
Note: Tests for the /api/auth/* and /api/users endpoints are not included in this change due to persistent issues with the test environment. These will be addressed in a separate effort.
Partial fix for #1052
* feat: Add API test coverage for Spotify endpoints
This change introduces comprehensive unit tests for the following Spotify API endpoints:
- /api/spotify/access-token
- /api/spotify/control
- /api/spotify/devices
The tests cover various scenarios, including:
- Unauthorized access (401)
- Invalid input (400)
- Successful requests (200)
- Server errors (500)
Additionally, this change improves the error handling for the /api/spotify/control endpoint by returning a 400 Bad Request when the 'volume' parameter is missing for the 'SET_VOLUME' command, instead of a 500 Internal Server Error.
Note: Tests for the /api/auth/* and /api/users endpoints are not included in this change due to persistent issues with the test environment. These will be addressed in a separate effort.
Partial fix for #1052
* feat: Add API test coverage for Spotify endpoints
This change introduces comprehensive unit tests for the following Spotify API endpoints:
- /api/spotify/access-token
- /api/spotify/control
- /api/spotify/devices
The tests cover various scenarios, including:
- Unauthorized access (401)
- Invalid input (400)
- Successful requests (200)
- Server errors (500)
Additionally, this change improves the error handling for the /api/spotify/control endpoint by returning a 400 Bad Request when the 'volume' parameter is missing for the 'SET_VOLUME' command, instead of a 500 Internal Server Error.
Note: Tests for the /api/auth/* and /api/users endpoints are not included in this change due to persistent issues with the test environment. These will be addressed in a separate effort.
* feat: Add API test coverage for Spotify endpoints
This change introduces comprehensive unit tests for the following Spotify API endpoints:
- /api/spotify/access-token
- /api/spotify/control
- /api/spotify/devices
The tests cover various scenarios, including:
- Unauthorized access (401)
- Invalid input (400)
- Successful requests (200)
- Server errors (500)
Additionally, this change improves the error handling for the /api/spotify/control endpoint by returning a 400 Bad Request when the 'volume' parameter is missing for the 'SET_VOLUME' command, instead of a 500 Internal Server Error.
Note: Tests for the /api/auth/* and /api/users endpoints are not included in this change due to persistent issues with the test environment. These will be addressed in a separate effort.
* feat: Add API test coverage for Spotify endpoints
This change introduces comprehensive unit tests for the following Spotify API endpoints:
- /api/spotify/access-token
- /api/spotify/control
- /api/spotify/devices
The tests cover various scenarios, including:
- Unauthorized access (401)
- Invalid input (400)
- Successful requests (200)
- Server errors (500)
Additionally, this change improves the error handling for the /api/spotify/control endpoint by returning a 400 Bad Request when the 'volume' parameter is missing for the 'SET_VOLUME' command, instead of a 500 Internal Server Error.
Note: Tests for the /api/auth/* and /api/users endpoints are not included in this change due to persistent issues with the test environment. These will be addressed in a separate effort.
* feat: Add API test coverage for Spotify endpoints
This change introduces comprehensive unit tests for the following Spotify API endpoints:
- /api/spotify/access-token
- /api/spotify/control
- /api/spotify/devices
The tests cover various scenarios, including:
- Unauthorized access (401)
- Invalid input (400)
- Successful requests (200)
- Server errors (500)
Additionally, this change improves the error handling for the /api/spotify/control endpoint by returning a 400 Bad Request when the 'volume' parameter is missing for the 'SET_VOLUME' command, instead of a 500 Internal Server Error.
Note: Tests for the /api/auth/* and /api/users endpoints are not included in this change due to persistent issues with the test environment. These will be addressed in a separate effort.
Partial fix for #1052
* feat: Add API test coverage for Spotify endpoints
This change introduces comprehensive unit tests for the following Spotify API endpoints:
- /api/spotify/access-token
- /api/spotify/control
- /api/spotify/devices
The tests cover various scenarios, including:
- Unauthorized access (401)
- Invalid input (400)
- Successful requests (200)
- Server errors (500)
Additionally, this change improves the error handling for the /api/spotify/control endpoint by returning a 400 Bad Request when the 'volume' parameter is missing for the 'SET_VOLUME' command, instead of a 500 Internal Server Error.
Note: Tests for the /api/auth/* and /api/users endpoints are not included in this change due to persistent issues with the test environment. These will be addressed in a separate effort.
Partial fix for #1052
* fix: Address linting errors
This commit addresses the linting errors identified in the pull request review.
- Removed unused `authOptions` import in `tests/unit/app/api/spotify/control/route.test.ts`.
- Corrected the explicit `any` type in `tests/unit/app/api/spotify/devices/route.test.ts`.
* refactor: Address PR feedback for API tests
This commit addresses feedback from the pull request review:
- **Inconsistent Error Handling:** The `TRANSFER_PLAYBACK` command in `app/api/spotify/control/route.ts` now returns a 400 Bad Request when the `deviceId` is missing, making error handling consistent. A corresponding test case has been added.
- **Redundant Mock:** The unnecessary `jest.mock('next-auth', ...)` has been removed from `tests/unit/app/api/spotify/access-token/route.test.ts`.
- **Assertion Clarity:** The `TRANSFER_PLAYBACK` test in `tests/unit/app/api/spotify/control/route.test.ts` now parses the request body and asserts on the object for improved clarity and resilience.
---------
Co-authored-by: google-labs-jules[bot] <161369871+google-labs-jules[bot]@users.noreply.github.com>1 parent fab3ae6 commit 31f194d
4 files changed
Lines changed: 377 additions & 4 deletions
File tree
- app/api/spotify/control
- tests/unit/app/api/spotify
- access-token
- control
- devices
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
66 | 66 | | |
67 | 67 | | |
68 | 68 | | |
69 | | - | |
70 | | - | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
71 | 75 | | |
72 | 76 | | |
73 | 77 | | |
74 | 78 | | |
75 | | - | |
76 | | - | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
77 | 85 | | |
78 | 86 | | |
79 | 87 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
| 154 | + | |
| 155 | + | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
| 93 | + | |
| 94 | + | |
| 95 | + | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
| 129 | + | |
| 130 | + | |
| 131 | + | |
| 132 | + | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
0 commit comments