Skip to content

Commit c8df50f

Browse files
authored
32101 - Small fix for BCOL validation (#3607)
1 parent 1b151c2 commit c8df50f

File tree

4 files changed

+52
-8
lines changed

4 files changed

+52
-8
lines changed

auth-web/package-lock.json

Lines changed: 3 additions & 3 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

auth-web/package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "auth-web",
3-
"version": "2.10.42",
3+
"version": "2.10.43",
44
"appName": "Auth Web",
55
"sbcName": "SBC Common Components",
66
"private": true,

auth-web/src/components/auth/account-settings/payment/AccountPaymentMethods.vue

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -468,10 +468,10 @@ export default defineComponent({
468468
case 409:
469469
case 400:
470470
state.errorText = `${formatText(normalized.code)}<br>` +
471-
`${formatText(normalized.detail) || ''}`.trim()
471+
`${formatText(normalized.message?.detail) || ''}`.trim()
472472
473-
state.errorTitle = formatText(normalized.title) ||
474-
formatText(normalized.message) ||
473+
state.errorTitle = formatText(normalized.message?.title) ||
474+
formatText(normalized.message?.detail) ||
475475
'Error'
476476
break
477477
default:

auth-web/tests/unit/components/AccountPaymentMethods.spec.ts

Lines changed: 45 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,16 @@
1+
import { LoginSource, PaymentTypes } from '@/util/constants'
12
import { createLocalVue, shallowMount } from '@vue/test-utils'
23
import { useBusinessStore, useOrgStore, useUserStore } from '@/stores'
34
import AccountPaymentMethods from '@/components/auth/account-settings/payment/AccountPaymentMethods.vue'
4-
import { LoginSource } from '@/util/constants'
55
import VueRouter from 'vue-router'
66
import Vuetify from 'vuetify'
77

8+
vi.mock('@/composables/product-payment-factory', () => ({
9+
useProductPayment: () => ({
10+
hasProductOrPaymentBackendChanges: vi.fn().mockResolvedValue(false)
11+
})
12+
}))
13+
814
const vuetify = new Vuetify({})
915

1016
vi.mock('../../../src/services/user.services')
@@ -77,4 +83,42 @@ describe('AccountPaymentMethods.vue', () => {
7783
it('renders the components properly and address is being shown', () => {
7884
expect(wrapper.findComponent(AccountPaymentMethods).exists()).toBe(true)
7985
})
86+
87+
const bcolErrorFields = {
88+
code: 'BCOL API Error',
89+
detail: null,
90+
message: {
91+
detail: 'Invalid User ID or Password',
92+
title: 'Invalid Credentials',
93+
type: 'INVALID_CREDENTIALS'
94+
}
95+
}
96+
97+
async function saveWithMockError (errorData: object) {
98+
const orgStore = useOrgStore()
99+
orgStore.updateOrg = vi.fn().mockRejectedValue({
100+
response: { status: 400, data: errorData }
101+
})
102+
wrapper.vm.selectedPaymentMethod = PaymentTypes.CREDIT_CARD
103+
wrapper.vm.isBtnSaved = false
104+
wrapper.vm.$refs.errorDialog = { open: vi.fn(), close: vi.fn() }
105+
await wrapper.vm.save()
106+
}
107+
108+
it('sets errorText and errorTitle correctly for a 400 BCOL error response', async () => {
109+
await saveWithMockError(bcolErrorFields)
110+
111+
expect(wrapper.vm.errorTitle).toBe('Invalid Credentials')
112+
expect(wrapper.vm.errorText).toBe('BCOL API Error<br>Invalid User ID or Password')
113+
})
114+
115+
it('sets errorText and errorTitle correctly for a 400 BCOL error with rootCause', async () => {
116+
await saveWithMockError({
117+
errorMessage: 'API backend third party service error.',
118+
rootCause: bcolErrorFields
119+
})
120+
121+
expect(wrapper.vm.errorTitle).toBe('Invalid Credentials')
122+
expect(wrapper.vm.errorText).toBe('BCOL API Error<br>Invalid User ID or Password')
123+
})
80124
})

0 commit comments

Comments
 (0)