-
Notifications
You must be signed in to change notification settings - Fork 22
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
4 changed files
with
65 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
import { useConfirmAccount } from 'composables/api' | ||
import { useModalAlert } from 'composables/useModalAlert' | ||
|
||
export default defineNuxtRouteMiddleware((_to, from) => { | ||
const route = useRoute() | ||
const confirmationCode = route.query.code as string | ||
const modalAlertState = useModalAlert().value | ||
|
||
if (from !== `/confirm-account?code=${confirmationCode}`) { | ||
navigateTo('/', { replace: true }) | ||
} | ||
|
||
useConfirmAccount(confirmationCode, { | ||
onError: () => { | ||
modalAlertState.show = true | ||
modalAlertState.title = 'Something went wrong...' | ||
modalAlertState.body = 'Unable to confirm account.' | ||
modalAlertState.type = 'error' | ||
navigateTo('/', { replace: true }) | ||
}, | ||
onOkay: () => { | ||
modalAlertState.show = true | ||
modalAlertState.title = 'Success!' | ||
modalAlertState.body = 'Account confirmed successfully!' | ||
modalAlertState.type = 'success' | ||
navigateTo('/', { replace: true }) | ||
}, | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,23 @@ | ||
import { mount, enableAutoUnmount } from '@vue/test-utils' | ||
import { getByClass } from 'root/testUtils' | ||
import confirmAccount from 'pages/confirm-account.vue' | ||
|
||
function getConfirmAccountWrapper() { | ||
return mount(confirmAccount) | ||
} | ||
|
||
vi.stubGlobal('definePageMeta', () => {}) | ||
|
||
enableAutoUnmount(afterEach) | ||
|
||
describe('/confirm-account?code=<CONFIRMATION_CODE>', () => { | ||
it('should render without crashing', () => { | ||
const wrapper = getConfirmAccountWrapper() | ||
expect(wrapper.isVisible()).toBe(true) | ||
}) | ||
|
||
it('should render the loader', () => { | ||
const wrapper = getConfirmAccountWrapper() | ||
expect(getByClass(wrapper, 'loader__container').isVisible()).toBe(true) | ||
}) | ||
}) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
<script setup lang="ts"> | ||
import Loader from 'blocks/Loader/Loader.vue' | ||
definePageMeta({ | ||
layout: false, | ||
middleware: 'confirm-account', | ||
}) | ||
</script> | ||
|
||
<template> | ||
<Loader /> | ||
</template> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters