1+ /*
2+ * SPDX-FileCopyrightText: 2026 LibreSign contributors
3+ * SPDX-License-Identifier: AGPL-3.0-or-later
4+ */
5+
6+ import { beforeEach , describe , expect , it , vi } from 'vitest'
7+ import { mount } from '@vue/test-utils'
8+
9+ import ConfigureCheck from '../../../views/Settings/ConfigureCheck.vue'
10+
11+ const useConfigureCheckStoreMock = vi . fn ( )
12+
13+ vi . mock ( '@nextcloud/l10n' , ( ) => ( {
14+ t : vi . fn ( ( _app : string , text : string ) => text ) ,
15+ translate : vi . fn ( ( _app : string , text : string ) => text ) ,
16+ translatePlural : vi . fn ( ( _app : string , singular : string , plural : string , count : number ) => ( count === 1 ? singular : plural ) ) ,
17+ n : vi . fn ( ( _app : string , singular : string , plural : string , count : number ) => ( count === 1 ? singular : plural ) ) ,
18+ getLanguage : vi . fn ( ( ) => 'en' ) ,
19+ getLocale : vi . fn ( ( ) => 'en' ) ,
20+ isRTL : vi . fn ( ( ) => false ) ,
21+ } ) )
22+
23+ vi . mock ( '../../../store/configureCheck.js' , ( ) => ( {
24+ useConfigureCheckStore : ( ...args : unknown [ ] ) => useConfigureCheckStoreMock ( ...args ) ,
25+ } ) )
26+
27+ describe ( 'ConfigureCheck.vue' , ( ) => {
28+ beforeEach ( ( ) => {
29+ vi . clearAllMocks ( )
30+ } )
31+
32+ function createWrapper ( items : Array < Record < string , string > > ) {
33+ useConfigureCheckStoreMock . mockReturnValue ( { items } )
34+
35+ return mount ( ConfigureCheck , {
36+ global : {
37+ stubs : {
38+ NcSettingsSection : { template : '<div><slot /></div>' } ,
39+ NcRichText : { props : [ 'text' ] , template : '<div class="rich-text">{{ text }}</div>' } ,
40+ } ,
41+ } ,
42+ } )
43+ }
44+
45+ it ( 'renders nothing when there are no configuration items' , ( ) => {
46+ const wrapper = createWrapper ( [ ] )
47+
48+ expect ( wrapper . find ( 'table' ) . exists ( ) ) . toBe ( false )
49+ } )
50+
51+ it ( 'renders the configuration rows from the store' , ( ) => {
52+ const wrapper = createWrapper ( [
53+ {
54+ status : 'error' ,
55+ message : 'Missing Java runtime' ,
56+ resource : 'java' ,
57+ tip : 'Install Java' ,
58+ } ,
59+ ] )
60+
61+ expect ( wrapper . text ( ) ) . toContain ( 'Missing Java runtime' )
62+ expect ( wrapper . text ( ) ) . toContain ( 'java' )
63+ expect ( wrapper . text ( ) ) . toContain ( 'Install Java' )
64+ expect ( wrapper . find ( 'td.error' ) . exists ( ) ) . toBe ( true )
65+ } )
66+ } )
0 commit comments