-
Notifications
You must be signed in to change notification settings - Fork 49
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
14946 - Add a new dialog for account missing email and phone (#561)
* add new dialog for account missing email and phone * 5.4.2 * add error types as enums * remove extra code
- Loading branch information
Showing
8 changed files
with
153 additions
and
9 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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
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
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,66 @@ | ||
<template> | ||
<v-dialog | ||
v-model="dialog" | ||
width="45rem" | ||
persistent | ||
:attach="attach" | ||
content-class="account-authorization-dialog" | ||
> | ||
<v-card> | ||
<v-card-title id="dialog-title"> | ||
Account Error | ||
</v-card-title> | ||
|
||
<v-card-text> | ||
<p class="font-14"> | ||
This account seems to have incomplete information. Click ‘OK’ to update your account details. | ||
</p> | ||
</v-card-text> | ||
|
||
<v-divider class="my-0" /> | ||
|
||
<v-card-actions> | ||
<v-btn | ||
id="dialog-exit-button" | ||
color="primary" | ||
text | ||
@click="exit()" | ||
> | ||
Exit | ||
</v-btn> | ||
<v-spacer /> | ||
<v-btn | ||
id="to-user-profile-button" | ||
color="primary" | ||
text | ||
@click="redirectToUserProfile" | ||
> | ||
OK | ||
</v-btn> | ||
</v-card-actions> | ||
</v-card> | ||
</v-dialog> | ||
</template> | ||
|
||
<script lang="ts"> | ||
import { Component, Emit, Prop, Vue } from 'vue-property-decorator' | ||
@Component({}) | ||
export default class AccountContactMissingDialog extends Vue { | ||
/** Prop to display the dialog. */ | ||
@Prop({ default: false }) readonly dialog!: boolean | ||
/** Prop to provide attachment selector. */ | ||
@Prop({ default: '' }) readonly attach!: string | ||
// Pass click events to parent. | ||
@Emit() exit (): void {} | ||
// Method to redirect to user profile page | ||
redirectToUserProfile (): void { | ||
const authWebUrl = sessionStorage.getItem('AUTH_WEB_URL') | ||
const userProfileUrl = `${authWebUrl}/userprofile` | ||
window.location.href = userProfileUrl | ||
} | ||
} | ||
</script> |
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
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,7 @@ | ||
export enum ErrorTypes { | ||
INVALID_USER_INFO='Invalid user info', | ||
INVALID_USER_EMAIL='Invalid user email', | ||
INVALID_USER_FIRST_NAME='Invalid user first name', | ||
INVALID_USER_LAST_NAME = 'Invalid user last name', | ||
INVALID_USER_PHONE='Invalid user phone' | ||
} |
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
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,56 @@ | ||
import { shallowMount } from '@vue/test-utils' | ||
import AccountContactMissingDialog from '@/dialogs/AccountContactMissingDialog.vue' | ||
import Vuetify from 'vuetify' | ||
import Vue from 'vue' | ||
|
||
Vue.use(Vuetify) | ||
|
||
// Prevent the warning "[Vuetify] Unable to locate target [data-app]" | ||
document.body.setAttribute('data-app', 'true') | ||
|
||
describe('AccountContactMissingDialog.vue', () => { | ||
let vuetify: any | ||
|
||
beforeEach(() => { | ||
vuetify = new Vuetify() | ||
}) | ||
|
||
it('renders the dialog', () => { | ||
const wrapper = shallowMount(AccountContactMissingDialog, { | ||
vuetify, | ||
propsData: { dialog: true } | ||
}) | ||
expect(wrapper.find('#dialog-title').text()).toBe('Account Error') | ||
}) | ||
|
||
it('redirects to user profile on OK click', () => { | ||
// Mocking sessionStorage | ||
const sessionStorageMock = { | ||
getItem () { | ||
return 'https://dev.account.bcregistry.gov.bc.ca' | ||
} | ||
} | ||
Object.defineProperty(window, 'sessionStorage', { value: sessionStorageMock }) | ||
|
||
// Mounting the component | ||
const wrapper = shallowMount(AccountContactMissingDialog, { | ||
vuetify, | ||
propsData: { dialog: true } | ||
}) | ||
|
||
// Override window.location.href | ||
let redirectedUrl = '' | ||
// eslint-disable-next-line accessor-pairs | ||
Object.defineProperty(window.location, 'href', { | ||
set (url: string) { | ||
redirectedUrl = url | ||
} | ||
}) | ||
|
||
// Calling the method directly | ||
wrapper.vm.redirectToUserProfile() | ||
|
||
// Checking the logic inside the method | ||
expect(redirectedUrl).toBe('https://dev.account.bcregistry.gov.bc.ca/userprofile') | ||
}) | ||
}) |