-
Notifications
You must be signed in to change notification settings - Fork 0
fix: standardize API error handling across services and composables #137
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -7,7 +7,7 @@ vi.mock('vue-i18n', () => ({ | |||||
| useI18n: () => ({ t: (key: string) => key }), | ||||||
| })) | ||||||
|
|
||||||
| vi.mock('@/helpers/roles.ts', () => ({ | ||||||
| vi.mock('@/helpers/role.ts', () => ({ | ||||||
|
||||||
| vi.mock('@/helpers/role.ts', () => ({ | |
| vi.mock('@/helpers/roles.ts', () => ({ |
Copilot
AI
Mar 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The rendered role text for business_staff is built from domains.roles.${role} (see the mock and the component’s usage), so the expectation should remain domains.roles.business_staff unless the role strings were intentionally changed everywhere. As-is, expecting domains.roles.businessStaff will fail with the current role values used throughout the app.
| expect(wrapper.text()).toContain('domains.roles.businessStaff') | |
| expect(wrapper.text()).toContain('domains.roles.business_staff') |
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -85,9 +85,16 @@ describe('useAuthStore', () => { | |||||
| }) | ||||||
|
|
||||||
| it('throws when the response is not ok', async () => { | ||||||
|
||||||
| it('throws when the response is not ok', async () => { | |
| it('resolves without throwing when the response is not ok', async () => { |
Copilot
AI
Mar 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test case name still says "throws when the response is not ok", but the updated expectation now asserts the action resolves without throwing. Renaming the test (e.g., "returns early when response is not ok") will keep the suite self-documenting and avoid confusion.
Copilot
AI
Mar 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This test case name still says "throws when the response is not ok", but the updated expectations now assert the action resolves without throwing. Rename the test to reflect the new contract (early return / no state mutation) to avoid misleading future readers.
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -118,7 +118,7 @@ paths: | |||||||||
| "201": | ||||||||||
| description: Account created successfully | ||||||||||
| "400": | ||||||||||
| description: Bad request (e.g., account already exists) | ||||||||||
| $ref: "error.yaml#/components/responses/BadRequest" | ||||||||||
|
||||||||||
| $ref: "error.yaml#/components/responses/BadRequest" | |
| $ref: "error.yaml#/components/responses/BadRequest" | |
| "409": | |
| $ref: "error.yaml#/components/responses/Conflict" |
Copilot
AI
Mar 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
YAML indentation is off for the 401 response here ($ref is indented more than other response fields). As written, this will likely make the OpenAPI document invalid or move $ref under the wrong node. Align $ref indentation with the other response entries (same level as description/content under the status code).
| $ref: "error.yaml#/components/responses/Unauthorized" | |
| $ref: "error.yaml#/components/responses/Unauthorized" |
Copilot
AI
Mar 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same indentation issue for the 401 response under /me: $ref is indented too far, which can invalidate the OpenAPI YAML structure. Ensure $ref is at the correct level directly under the "401" response object.
Copilot
AI
Mar 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Same indentation issue for the "401" response under /me: $ref is over-indented, making the OpenAPI YAML invalid.
Copilot
AI
Mar 28, 2026
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The 403 response under /subdomains/{domainName} has $ref indented too far (line 322), which will break the OpenAPI YAML structure. $ref should be directly under the "403" response object with the same indentation as other status-code entries.
| $ref: "error.yaml#/components/responses/Forbidden" | |
| $ref: "error.yaml#/components/responses/Forbidden" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
PushNotificationToast.vueimports the composable using the full path@/composables/useWebPushNotifications.ts, but this test mocks@/composables/useWebPushNotifications(no extension). Vitest module IDs are string-based, so the mock may not match and the real composable will be used. Make the mock path exactly match the component import (or remove the.tsextension from the component import for consistency).