@@ -258,6 +258,54 @@ describe('Settings', () => {
258258 } )
259259 } )
260260
261+ describe ( 'RULE: unauthenticated users (signing via email link) do not crash the component' , ( ) => {
262+ const createUnauthenticatedWrapper = ( ) => {
263+ getCurrentUserMock . mockReturnValue ( null )
264+
265+ return mount ( Settings , {
266+ global : {
267+ stubs : {
268+ NcAppNavigationItem : {
269+ name : 'NcAppNavigationItem' ,
270+ props : [ 'name' , 'to' , 'href' , 'icon' ] ,
271+ template : '<li><slot name="icon" /><span class="item-name">{{ name }}</span><slot /></li>' ,
272+ } ,
273+ AccountIcon : { template : '<div class="account-icon"></div>' } ,
274+ StarIcon : { template : '<div class="star-icon"></div>' } ,
275+ TuneIcon : { template : '<div class="tune-icon"></div>' } ,
276+ } ,
277+ mocks : { t } ,
278+ } ,
279+ } )
280+ }
281+
282+ it ( 'mounts without throwing when getCurrentUser returns null' , ( ) => {
283+ expect ( ( ) => createUnauthenticatedWrapper ( ) ) . not . toThrow ( )
284+ } )
285+
286+ it ( 'isAdmin is false when getCurrentUser returns null' , ( ) => {
287+ wrapper = createUnauthenticatedWrapper ( )
288+
289+ expect ( getWrapper ( ) . vm . isAdmin ) . toBe ( false )
290+ } )
291+
292+ it ( 'hides the Administration link when user is unauthenticated' , ( ) => {
293+ wrapper = createUnauthenticatedWrapper ( )
294+ const items = getItems ( )
295+ const adminItem = findItemByName ( items , 'Administration' )
296+
297+ expect ( adminItem ) . toBeUndefined ( )
298+ } )
299+
300+ it ( 'shows 2 navigation items for unauthenticated user' , ( ) => {
301+ wrapper = createUnauthenticatedWrapper ( )
302+ const items = getItems ( )
303+
304+ // Account + Rate = 2
305+ expect ( items . length ) . toBe ( 2 )
306+ } )
307+ } )
308+
261309 describe ( 'RULE: navigation items count depends on admin status' , ( ) => {
262310 it ( 'shows 2 items for non-admin' , ( ) => {
263311 wrapper = createWrapper ( false )
0 commit comments