|
|
@@ -31,6 +31,7 @@ Vue.prototype.$confirm = jest.fn().mockResolvedValue()
|
|
|
const countries = [{ ID: 'C1', NAME: 'Nigeria', DEFAULT_LANGUAGE_ID: 'EN' }]
|
|
|
Vue.prototype.$store = { getters: { getCountriesList: countries }, dispatch: jest.fn().mockResolvedValue(countries) }
|
|
|
const Page = load(path.resolve(__dirname, '../MemberWelcomePack.vue'))
|
|
|
+const PublicHeader = load(path.resolve('src/ui-refactor/layouts/PublicHeader.vue'), true)
|
|
|
const product = { ID: 'P1', GOODS_NAME: 'Sample product', GOODS_NO: 'SKU1', SELL_PRICE: '199000.00', MARKET_PRICE: '299900.00', TAX_RATE: 7.5, PRICE_PV: 70, STORE_NUMS: 10, CODE: 'NGN' }
|
|
|
const instances = []
|
|
|
const errors = []
|
|
|
@@ -41,7 +42,8 @@ async function mount(location) {
|
|
|
const router = new Router({ mode: 'abstract', routes: [
|
|
|
{ path: '/signup', component: Page, props: { mode: 'guest' }},
|
|
|
{ path: '/dashboard/member-welcome-pack', component: Page, props: { mode: 'member' }},
|
|
|
- ...['/login', '/guest-order', '/dashboard/index'].map(route => ({ path: route, component: { render: h => h('div', route) }}))
|
|
|
+ { path: '/guest-order', name: 'GuestOrder', component: { render: h => h('div') }},
|
|
|
+ ...['/login', '/dashboard/index'].map(route => ({ path: route, component: { render: h => h('div', route) }}))
|
|
|
] })
|
|
|
const root = new Vue({ router, render: h => h('router-view') }).$mount()
|
|
|
document.body.appendChild(root.$el)
|
|
|
@@ -272,6 +274,26 @@ it('keeps member navigation blocked while payment is active and uses the shared
|
|
|
expect(entry.$refs.flow.form.countryId).toBe('')
|
|
|
})
|
|
|
|
|
|
+it('replaces the signed-out order detail with a clean login URL', async() => {
|
|
|
+ const { router } = await mount('/guest-order?order=OLD-ORDER')
|
|
|
+ await PublicHeader.methods.logout.call({ $store: Vue.prototype.$store, $router: router, $route: router.currentRoute })
|
|
|
+ expect(Vue.prototype.$store.dispatch).toHaveBeenCalledWith('user/logout')
|
|
|
+ expect(router.currentRoute.fullPath).toBe('/login')
|
|
|
+ expect(router.history.stack.map(route => route.fullPath)).toEqual(['/login'])
|
|
|
+})
|
|
|
+
|
|
|
+it('drops a previous order redirect when a new member confirms registration', async() => {
|
|
|
+ const { router, entry } = await mount('/signup?redirect=/guest-order?order=OLD-ORDER&order=OLD-ORDER&ref=INVITER')
|
|
|
+ const flow = entry.$refs.flow
|
|
|
+ flow.paymentOrder = { reference: 'guest-reference' }
|
|
|
+ flow.processPayment({ reference: 'guest-reference' })
|
|
|
+ expect(flow.registrationSuccessVisible).toBe(true)
|
|
|
+ flow.confirmRegistration()
|
|
|
+ await settle()
|
|
|
+ expect(router.currentRoute.path).toBe('/login')
|
|
|
+ expect(router.currentRoute.query).toEqual({ ref: 'INVITER' })
|
|
|
+})
|
|
|
+
|
|
|
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 verifyGuestReferrer(root)
|