|
|
@@ -8,11 +8,13 @@ import * as user from '@/api/user'
|
|
|
import { deleteApproachOrder } from '@/api/shop'
|
|
|
import { getLanguages } from '@/api/setting'
|
|
|
import { toThousandFilter } from '@/filters'
|
|
|
+import handleClipboard from '@/utils/clipboard'
|
|
|
import { load } from '../../purchase/__tests__/loadComponent'
|
|
|
|
|
|
jest.mock('@/api/user', () => Object.fromEntries(['fetchWelcomePack', 'createWelcomePack', 'fetchFullInfo', 'fetchInspectNetwork', 'fetchAutoPlace', 'fetchBrandAmbassadorInfo', 'fetchGuestDec', 'createGuestDec', 'fetchGuestFullInfo', 'fetchGuestInspectNetwork'].map(key => [key, jest.fn()])))
|
|
|
jest.mock('@/api/shop', () => ({ deleteApproachOrder: jest.fn() }))
|
|
|
jest.mock('@/api/setting', () => ({ getLanguages: jest.fn() }))
|
|
|
+jest.mock('@/utils/clipboard', () => jest.fn())
|
|
|
jest.mock('@/utils/usersInfo', () => ({ userName: () => 'OPERATOR', userEmail: () => 'operator@example.test', baseData: () => ({ COUNTRY_ID: 'C1' }), loginTimestamp: () => 'session' }))
|
|
|
jest.mock('vue-paystack', () => ({
|
|
|
name: 'Paystack',
|
|
|
@@ -129,6 +131,50 @@ it.each([['guest', '/signup', 299900, 20923.26], ['member', '/dashboard/member-w
|
|
|
expect(flow.product.taxAmount).toBe(tax)
|
|
|
})
|
|
|
|
|
|
+it('keeps the country selector read-only while open and still selects the country', async() => {
|
|
|
+ const { root, entry } = await mount('/signup')
|
|
|
+ const input = root.$el.querySelector('#ng-signup-SignupPagevue-0')
|
|
|
+ input.click()
|
|
|
+ await settle()
|
|
|
+ expect(input.readOnly).toBe(true)
|
|
|
+ expect(input.getAttribute('autocomplete')).toBe('ng-registration')
|
|
|
+ Array.from(document.body.querySelectorAll('.el-select-dropdown__item')).find(item => item.textContent.trim() === 'Nigeria').click()
|
|
|
+ await settle()
|
|
|
+ expect(entry.$refs.flow.form.countryId).toBe('620699181539139625')
|
|
|
+ expect(user.fetchGuestDec).toHaveBeenCalledWith({ countryId: '620699181539139625' })
|
|
|
+})
|
|
|
+
|
|
|
+it.each(['/signup', '/dashboard/member-welcome-pack'])('suppresses saved-person autofill throughout %s while retaining new-password semantics and editing', async route => {
|
|
|
+ const { root, entry } = await mount(route)
|
|
|
+ if (route === '/signup') await chooseGuestCountry(root)
|
|
|
+ expect(root.$el.querySelector('form').getAttribute('autocomplete')).toBe('off')
|
|
|
+ const fields = root.$el.querySelector('.ng-welcome-fields')
|
|
|
+ for (const input of fields.querySelectorAll('input:not([type="radio"]), textarea')) {
|
|
|
+ if (input.closest('.el-cascader')) {
|
|
|
+ expect(input.readOnly).toBe(true)
|
|
|
+ } else {
|
|
|
+ expect(input.getAttribute('autocomplete')).toBe(input.type === 'password' ? 'new-password' : 'ng-registration')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ const flow = entry.$refs.flow
|
|
|
+ for (const [id, key, value] of [
|
|
|
+ ['realName', 'realName', 'New member'], ['email', 'email', 'new-member@example.test'],
|
|
|
+ ['address', 'address', 'Sample street'], ['city', 'cityName', 'Sample city'],
|
|
|
+ ['district', 'lgaName', 'Sample district'], ['consignee', 'consignee', 'Sample recipient']
|
|
|
+ ]) {
|
|
|
+ const input = fields.querySelector('#ng-welcome-' + id)
|
|
|
+ input.value = value
|
|
|
+ input.dispatchEvent(new Event('input', { bubbles: true }))
|
|
|
+ await settle()
|
|
|
+ expect(flow.form[key]).toBe(value)
|
|
|
+ }
|
|
|
+ const password = fields.querySelector('#ng-welcome-password')
|
|
|
+ password.closest('.el-input').querySelector('.el-icon-view').click()
|
|
|
+ await settle()
|
|
|
+ expect(password.type).toBe('text')
|
|
|
+ expect(password.getAttribute('autocomplete')).toBe('new-password')
|
|
|
+})
|
|
|
+
|
|
|
it('recreates the flow when changing modes and ignores a late guest payment callback', async() => {
|
|
|
const { root, router, entry } = await mount('/signup?ref=INVITER')
|
|
|
await chooseGuestCountry(root)
|
|
|
@@ -191,7 +237,7 @@ it('keeps member navigation blocked while payment is active and uses the shared
|
|
|
expect(entry.$refs.flow.form.countryId).toBe('')
|
|
|
})
|
|
|
|
|
|
-it('continues guest payment through accessCode and returns to login with the original query', async() => {
|
|
|
+it('shows the submitted Member ID after guest payment, copies it and returns to login on confirmation', async() => {
|
|
|
const { root, router, entry } = await mount('/signup?ref=INVITER&redirect=/dashboard/repeat-purchase')
|
|
|
await chooseGuestCountry(root)
|
|
|
const flow = entry.$refs.flow
|
|
|
@@ -214,6 +260,22 @@ it('continues guest payment through accessCode and returns to login with the ori
|
|
|
expect(resume).toHaveBeenCalledWith('guest-access', expect.objectContaining({ onSuccess: expect.any(Function) }))
|
|
|
resume.mock.calls[0][1].onSuccess({ reference: 'guest-reference' })
|
|
|
await settle()
|
|
|
+ expect(router.currentRoute.path).toBe('/signup')
|
|
|
+ const success = document.body.querySelector('.ng-signup-success')
|
|
|
+ expect(success).not.toBeNull()
|
|
|
+ expect(success.textContent).toContain('Payment Successful')
|
|
|
+ expect(success.querySelector('.ng-signup-success-member-id').textContent).toBe('GUEST-NEW')
|
|
|
+ expect(success.textContent).not.toContain('OPERATOR')
|
|
|
+ expect(success.textContent).not.toContain('INVITER')
|
|
|
+ success.querySelector('.ng-signup-success-copy').click()
|
|
|
+ expect(handleClipboard).toHaveBeenCalledWith('GUEST-NEW', expect.any(MouseEvent))
|
|
|
+ const dialog = descendants(flow).find(child => child.$options.name === 'RegistrationSuccessDialog')
|
|
|
+ const elementDialog = descendants(dialog).find(child => child.$options.name === 'ElDialog')
|
|
|
+ expect(elementDialog.closeOnClickModal).toBe(false)
|
|
|
+ expect(elementDialog.closeOnPressEscape).toBe(false)
|
|
|
+ expect(elementDialog.showClose).toBe(false)
|
|
|
+ success.querySelector('.ng-signup-success-confirm').click()
|
|
|
+ await settle()
|
|
|
expect(router.currentRoute.path).toBe('/login')
|
|
|
expect(router.currentRoute.query).toEqual({ ref: 'INVITER', redirect: '/dashboard/repeat-purchase' })
|
|
|
})
|