@@ -7,13 +7,11 @@ import withSetup from '../utils/with-setup';
77import { useUserStore } from '@/stores/user-store' ;
88import { RouterLink } from 'vue-router' ;
99import NavBar from '@/components/NavBar.vue' ;
10- import { accountsTbProfileUrlKey } from '@/keys' ;
1110
1211
1312describe ( 'NavBar' , ( ) => {
1413 var app ;
1514 var wrapper ;
16- const testAccountsTbProfileUrl = 'https://accounts.tb.pro/dashboard' ;
1715
1816 // list of route names that are also lang keys (format: label.<key>), used as nav items
1917 // these routes are added in addition to the routes already specified in NavBar.vue
@@ -29,9 +27,6 @@ describe('NavBar', () => {
2927 propsData : ourProps ,
3028 global : {
3129 plugins : [ i18ninstance , router ] ,
32- provide : {
33- [ accountsTbProfileUrlKey ] : testAccountsTbProfileUrl ,
34- } ,
3530 } ,
3631 } ) ;
3732
@@ -57,7 +52,7 @@ describe('NavBar', () => {
5752 expect ( foundLinks [ 0 ] [ 'name' ] , 'expected link component to be rendered' ) . toBe ( 'home' ) ;
5853 } ) ;
5954
60- it ( 'renders correctly when logged in' , ( ) => {
55+ it ( 'renders correctly when logged in' , async ( ) => {
6156 // fake sign-in via user store
6257 const user = useUserStore ( ) ;
6358 user . data . accessToken = 'abc' ;
@@ -79,8 +74,12 @@ describe('NavBar', () => {
7974 expect ( foundLinks , 'expected link component to be rendered' ) . toContain ( expRoute ) ;
8075 }
8176
77+ // open the user menu dropdown by clicking the avatar
78+ const userAvatar = wrapper . find ( '.user-menu .avatar' ) ;
79+ await userAvatar . trigger ( 'click' ) ;
80+
8281 // verify the anchor tag to accountsTbProfileUrl exists and has the correct href
83- const profileAnchor = wrapper . find ( ' a[href="' + testAccountsTbProfileUrl + '"]' ) ;
82+ const profileAnchor = wrapper . find ( ` a[href="${ import . meta . env . VITE_TB_ACCOUNT_DASHBOARD_URL } "]` ) ;
8483 expect ( profileAnchor . exists ( ) , 'expected anchor tag to accountsTbProfileUrl to be rendered' ) . toBe ( true ) ;
8584 } ) ;
8685
0 commit comments