Skip to content

Commit e4f6fa9

Browse files
refactor(vue3): migrate ConfigureCheck to script setup ts
Signed-off-by: Vitor Mattos <1079143+vitormattos@users.noreply.github.com>
1 parent 9fdd868 commit e4f6fa9

2 files changed

Lines changed: 71 additions & 11 deletions

File tree

Lines changed: 66 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,66 @@
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+
})

src/views/Settings/ConfigureCheck.vue

Lines changed: 5 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -30,24 +30,18 @@
3030
</table>
3131
</NcSettingsSection>
3232
</template>
33-
<script>
33+
<script setup lang="ts">
3434
import NcRichText from '@nextcloud/vue/components/NcRichText'
3535
import NcSettingsSection from '@nextcloud/vue/components/NcSettingsSection'
3636
import { t } from '@nextcloud/l10n'
3737
3838
import { useConfigureCheckStore } from '../../store/configureCheck.js'
3939
40-
export default {
40+
defineOptions({
4141
name: 'ConfigureCheck',
42-
components: {
43-
NcRichText,
44-
NcSettingsSection,
45-
},
46-
setup() {
47-
const configureCheckStore = useConfigureCheckStore()
48-
return { t, configureCheckStore }
49-
},
50-
}
42+
})
43+
44+
const configureCheckStore = useConfigureCheckStore()
5145
</script>
5246
<style lang="scss" scoped>
5347
table {

0 commit comments

Comments
 (0)