Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
129 commits
Select commit Hold shift + click to select a range
6d9e561
test: add shared l10n mock helper
vitormattos Mar 16, 2026
59aade6
test: cover shared l10n mock helper
vitormattos Mar 16, 2026
a6da73a
test: align nextcloud runtime mocks
vitormattos Mar 16, 2026
18ff912
test: drop redundant l10n mock in init spec
vitormattos Mar 16, 2026
a082256
test: standardize l10n mock in components/Draw/FileUpload
vitormattos Mar 16, 2026
6f25bf2
test: standardize l10n mock in components/FileEntry/FileEntrySigners
vitormattos Mar 16, 2026
3139d06
test: standardize l10n mock in components/FileEntry/FileEntryStatus
vitormattos Mar 16, 2026
c6c5655
test: standardize l10n mock in components/FooterTemplateEditor
vitormattos Mar 16, 2026
c8fa92f
test: standardize l10n mock in utils/fileStatus
vitormattos Mar 16, 2026
e57320e
test: standardize l10n mock in utils/timePresets
vitormattos Mar 16, 2026
d7668c6
test: standardize l10n mock in views/CrlManagement/CrlManagement
vitormattos Mar 16, 2026
845e6c8
test: standardize l10n mock in views/DefaultPageError
vitormattos Mar 16, 2026
35d5f49
test: standardize l10n mock in views/Documents/IdDocsValidation
vitormattos Mar 16, 2026
49fe7bc
test: standardize l10n mock in views/FilesList/FilesList
vitormattos Mar 16, 2026
c3b4c75
test: standardize l10n mock in views/FilesList/FileListFilters
vitormattos Mar 16, 2026
bbf2137
test: standardize l10n mock in views/FilesList/FileListFilter/FileLis…
vitormattos Mar 16, 2026
6c944e4
test: standardize l10n mock in views/FilesList/FileListFilter/FileLis…
vitormattos Mar 16, 2026
b3da425
test: standardize l10n mock in views/FilesList/FileListFilter/FileLis…
vitormattos Mar 16, 2026
ccad59a
test: standardize l10n mock in views/SignatureElementsManagement
vitormattos Mar 16, 2026
f25e397
test: standardize l10n mock in views/Settings/SignatureStamp
vitormattos Mar 16, 2026
baca651
test: standardize l10n mock in store/files
vitormattos Mar 16, 2026
5a2ca56
test: standardize l10n mock in views/FilesList/FileEntryActions
vitormattos Mar 16, 2026
b01d65d
test: standardize l10n mock in views/FilesList/FilesListVirtual
vitormattos Mar 16, 2026
82a6f19
test: standardize l10n mock in views/FilesList/FilesListTableHeaderAc…
vitormattos Mar 16, 2026
eb910b1
test: standardize l10n mock in views/FilesList/FileListFilter/FileLis…
vitormattos Mar 16, 2026
4572956
test: standardize l10n mock in views/ReadCertificate/ReadCertificate
vitormattos Mar 16, 2026
543a8fe
test: standardize l10n mock in components/validation/SigningProgress
vitormattos Mar 16, 2026
a3aecfb
test: standardize l10n mock in components/validation/EnvelopeValidation
vitormattos Mar 16, 2026
3582a3b
test: standardize l10n mock in components/validation/FileStatusList
vitormattos Mar 16, 2026
9bf1d89
test: standardize l10n mock in helpers/certification
vitormattos Mar 16, 2026
11e3386
test: standardize l10n mock in views/Settings/CertificatePolicy
vitormattos Mar 16, 2026
171e359
test: standardize l10n mock in views/Settings/DefaultUserFolder
vitormattos Mar 16, 2026
2355c51
test: standardize l10n mock in views/ResetPassword
vitormattos Mar 16, 2026
30f023e
test: standardize l10n mock in views/ReadCertificate/CertificateContent
vitormattos Mar 16, 2026
a6739b4
test: standardize l10n mock in views/Settings/SupportProject
vitormattos Mar 16, 2026
b2802c9
test: standardize l10n mock in views/Settings/DownloadBinaries
vitormattos Mar 16, 2026
1cf59b9
test: standardize l10n mock in views/Settings/Validation
vitormattos Mar 16, 2026
fe2084d
test: standardize l10n mock in views/Settings/IdentificationFactors
vitormattos Mar 16, 2026
b1863a0
test: standardize l10n mock in views/Settings/ActiveSignings
vitormattos Mar 16, 2026
e0da874
test: standardize l10n mock in App
vitormattos Mar 16, 2026
4a14431
test: standardize l10n mock in views/Account/Account
vitormattos Mar 16, 2026
731f8c2
test: standardize l10n mock in views/Account/partials/UserImage
vitormattos Mar 16, 2026
ebaf70e
test: standardize l10n mock in views/Account/partials/Signatures
vitormattos Mar 16, 2026
acb0777
test: standardize l10n mock in views/RenewEmail
vitormattos Mar 16, 2026
60ff84a
test: standardize l10n mock in components/CodeEditor
vitormattos Mar 16, 2026
f57c853
test: standardize l10n mock in components/File/File
vitormattos Mar 16, 2026
ee8f088
test: standardize l10n mock in components/MarkdownEditor
vitormattos Mar 16, 2026
d69bb8d
test: standardize l10n mock in components/Request/SignDetail/partials…
vitormattos Mar 16, 2026
44a0c4b
test: standardize l10n mock in components/Request/SignDetail/partials…
vitormattos Mar 16, 2026
deddd75
test: standardize l10n mock in components/FileStatusList
vitormattos Mar 16, 2026
74deace
test: standardize l10n mock in App
vitormattos Mar 16, 2026
8999932
test: standardize l10n mock in ExternalApp
vitormattos Mar 16, 2026
c0df02e
test: standardize l10n mock in actions/openInLibreSignAction
vitormattos Mar 16, 2026
c898a30
test: standardize l10n mock in components/CodeEditor
vitormattos Mar 16, 2026
ae9644a
test: standardize l10n mock in components/File/File
vitormattos Mar 16, 2026
62e1fbc
test: standardize l10n mock in components/FileStatusList
vitormattos Mar 16, 2026
199c7e5
test: standardize l10n mock in components/LeftSidebar/LeftSidebar
vitormattos Mar 16, 2026
f8cde95
test: standardize l10n mock in components/MarkdownEditor
vitormattos Mar 16, 2026
cae1d35
test: standardize l10n mock in components/PdfEditor/SignatureBox
vitormattos Mar 16, 2026
c6ea4ce
test: standardize l10n mock in components/PreviewSignature/PreviewSig…
vitormattos Mar 16, 2026
5d0058e
test: standardize l10n mock in components/Request/IdentifySigner
vitormattos Mar 16, 2026
983a2f6
test: standardize l10n mock in components/Request/SignDetail/partials…
vitormattos Mar 16, 2026
b5a1712
test: standardize l10n mock in components/Request/SignDetail/partials…
vitormattos Mar 16, 2026
401eedb
test: standardize l10n mock in components/Request/SignerSelect
vitormattos Mar 16, 2026
a60a000
test: standardize l10n mock in components/RightSidebar/EnvelopeFilesList
vitormattos Mar 16, 2026
c7e4ac7
test: standardize l10n mock in components/RightSidebar/RightSidebar
vitormattos Mar 16, 2026
1cd2619
test: standardize l10n mock in components/Settings/Settings
vitormattos Mar 16, 2026
2f0b530
test: standardize l10n mock in components/Signers/Signer
vitormattos Mar 16, 2026
ff4bbfe
test: standardize l10n mock in components/validation/CertificateChain
vitormattos Mar 16, 2026
d42be46
test: standardize l10n mock in components/validation/DocumentValidati…
vitormattos Mar 16, 2026
ef52640
test: standardize l10n mock in components/validation/EnvelopeValidation
vitormattos Mar 16, 2026
de6ce4f
test: standardize l10n mock in components/validation/FileStatusList
vitormattos Mar 16, 2026
43ce081
test: standardize l10n mock in components/validation/FileValidation
vitormattos Mar 16, 2026
cc360f7
test: standardize l10n mock in components/validation/SignersList
vitormattos Mar 16, 2026
4edc65c
test: standardize l10n mock in components/validation/SigningProgress
vitormattos Mar 16, 2026
de9458b
test: standardize l10n mock in store/files
vitormattos Mar 16, 2026
1923863
test: extend shared l10n helper coverage
vitormattos Mar 16, 2026
950c562
test: standardize l10n mock in views/Account/Account
vitormattos Mar 16, 2026
8871958
test: standardize l10n mock in views/Account/partials/Documents
vitormattos Mar 16, 2026
7fffdc9
test: standardize l10n mock in views/Account/partials/ManagePassword
vitormattos Mar 16, 2026
0d400f3
test: standardize l10n mock in views/Account/partials/Signature
vitormattos Mar 16, 2026
0179391
test: standardize l10n mock in views/Account/partials/Signatures
vitormattos Mar 16, 2026
c718784
test: standardize l10n mock in views/Account/partials/UserImage
vitormattos Mar 16, 2026
228614a
test: standardize l10n mock in views/FilesList/FileEntry/FileEntryChe…
vitormattos Mar 16, 2026
a1d2480
test: standardize l10n mock in views/FilesList/FileEntryActions
vitormattos Mar 16, 2026
1bac149
test: standardize l10n mock in views/FilesList/FileEntryName
vitormattos Mar 16, 2026
d89bcb3
test: standardize l10n mock in views/FilesList/FileListFilter/FileLis…
vitormattos Mar 16, 2026
3b966a1
test: standardize l10n mock in views/FilesList/FilesListTableFooter
vitormattos Mar 16, 2026
f1126db
test: standardize l10n mock in views/FilesList/FilesListTableHeader
vitormattos Mar 16, 2026
2c7e160
test: standardize l10n mock in views/FilesList/FilesListTableHeaderAc…
vitormattos Mar 16, 2026
35319ee
test: standardize l10n mock in views/FilesList/FilesListVirtual
vitormattos Mar 16, 2026
fd5542f
test: standardize l10n mock in views/FilesList/VirtualList
vitormattos Mar 16, 2026
c74947d
test: standardize l10n mock in views/IncompleteCertification
vitormattos Mar 16, 2026
6c0fbfd
test: standardize l10n mock in views/ReadCertificate/CertificateContent
vitormattos Mar 16, 2026
0cfa1c6
test: standardize l10n mock in views/ReadCertificate/ReadCertificate
vitormattos Mar 16, 2026
d02858e
test: standardize l10n mock in views/RenewEmail
vitormattos Mar 16, 2026
a92b783
test: standardize l10n mock in views/Request
vitormattos Mar 16, 2026
f5a4ccc
test: standardize l10n mock in views/ResetPassword
vitormattos Mar 16, 2026
8aff437
test: standardize l10n mock in views/Settings/ActiveSignings
vitormattos Mar 16, 2026
ab2df3b
test: standardize l10n mock in views/Settings/AllowedGroups
vitormattos Mar 16, 2026
38069bb
test: standardize l10n mock in views/Settings/CertificateCustonOptions
vitormattos Mar 16, 2026
1a5be1e
test: standardize l10n mock in views/Settings/CertificateEngine
vitormattos Mar 16, 2026
794b189
test: standardize l10n mock in views/Settings/CertificatePolicy
vitormattos Mar 16, 2026
cef6530
test: standardize l10n mock in views/Settings/CollectMetadata
vitormattos Mar 16, 2026
20a2023
test: standardize l10n mock in views/Settings/Confetti
vitormattos Mar 16, 2026
0daf28d
test: standardize l10n mock in views/Settings/ConfigureCheck
vitormattos Mar 16, 2026
3ab332d
test: standardize l10n mock in views/Settings/CrlValidation
vitormattos Mar 16, 2026
11dac1d
test: standardize l10n mock in views/Settings/DefaultUserFolder
vitormattos Mar 16, 2026
fc1e0ea
test: standardize l10n mock in views/Settings/DocMDP
vitormattos Mar 16, 2026
9345486
test: standardize l10n mock in views/Settings/DownloadBinaries
vitormattos Mar 16, 2026
efd6079
test: standardize l10n mock in views/Settings/Envelope
vitormattos Mar 16, 2026
4ab08cc
test: standardize l10n mock in views/Settings/ExpirationRules
vitormattos Mar 16, 2026
e45d522
test: standardize l10n mock in views/Settings/IdentificationDocuments
vitormattos Mar 16, 2026
6497361
test: standardize l10n mock in views/Settings/IdentificationFactors
vitormattos Mar 16, 2026
1434530
test: standardize l10n mock in views/Settings/LegalInformation
vitormattos Mar 16, 2026
ad2778d
test: standardize l10n mock in views/Settings/Reminders
vitormattos Mar 16, 2026
213b9a5
test: standardize l10n mock in views/Settings/RootCertificateCfssl
vitormattos Mar 16, 2026
4374fe0
test: standardize l10n mock in views/Settings/RootCertificateOpenSsl
vitormattos Mar 16, 2026
51e59e6
test: standardize l10n mock in views/Settings/SignatureEngine
vitormattos Mar 16, 2026
7b32cc4
test: standardize l10n mock in views/Settings/SignatureFlow
vitormattos Mar 16, 2026
f251fc7
test: standardize l10n mock in views/Settings/SignatureHashAlgorithm
vitormattos Mar 16, 2026
82e732a
test: standardize l10n mock in views/Settings/SigningMode
vitormattos Mar 16, 2026
9454bcc
test: standardize l10n mock in views/Settings/SupportProject
vitormattos Mar 16, 2026
9f12d47
test: standardize l10n mock in views/Settings/TSA
vitormattos Mar 16, 2026
a214d37
test: standardize l10n mock in views/Settings/Validation
vitormattos Mar 16, 2026
c880882
test: standardize l10n mock in views/UploadCertificate
vitormattos Mar 16, 2026
fffeed3
test: standardize l10n mock in views/Validation
vitormattos Mar 16, 2026
e6c435c
test: type l10n helper overrides
vitormattos Mar 16, 2026
17c7d25
test: type l10n helper spec callback
vitormattos Mar 16, 2026
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 2 additions & 9 deletions src/tests/App.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

import { beforeEach, describe, expect, it, vi } from 'vitest'
import { createL10nMock } from './testHelpers/l10n.js'
import { mount } from '@vue/test-utils'

import { initialActionCode, ACTION_CODES } from '../helpers/ActionMapping'
Expand All @@ -30,15 +31,7 @@ vi.mock('vue-router', async () => {
}
})

vi.mock('@nextcloud/l10n', () => ({
t: vi.fn((_app: string, text: string) => text),
translate: vi.fn((_app: string, text: string) => text),
translatePlural: vi.fn((_app: string, singular: string, plural: string, count: number) => (count === 1 ? singular : plural)),
n: vi.fn((_app: string, singular: string, plural: string, count: number) => (count === 1 ? singular : plural)),
isRTL: vi.fn(() => false),
getLanguage: vi.fn(() => 'en'),
getLocale: vi.fn(() => 'en'),
}))
vi.mock('@nextcloud/l10n', () => createL10nMock())

vi.mock('@nextcloud/vue/components/NcContent', () => ({
default: { name: 'NcContent', template: '<div class="nc-content"><slot /></div>', props: ['appName'] },
Expand Down
11 changes: 2 additions & 9 deletions src/tests/ExternalApp.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

import { beforeEach, describe, expect, it, vi } from 'vitest'
import { createL10nMock } from './testHelpers/l10n.js'
import { mount } from '@vue/test-utils'

import { initialActionCode, ACTION_CODES } from '../helpers/ActionMapping'
Expand All @@ -12,15 +13,7 @@ vi.mock('@nextcloud/initial-state', () => ({
loadState: vi.fn((app, key, defaultValue) => defaultValue),
}))

vi.mock('@nextcloud/l10n', () => ({
t: vi.fn((_app: string, text: string) => text),
translate: vi.fn((_app: string, text: string) => text),
translatePlural: vi.fn((_app: string, singular: string, plural: string, count: number) => (count === 1 ? singular : plural)),
n: vi.fn((_app: string, singular: string, plural: string, count: number) => (count === 1 ? singular : plural)),
isRTL: vi.fn(() => false),
getLanguage: vi.fn(() => 'en'),
getLocale: vi.fn(() => 'en'),
}))
vi.mock('@nextcloud/l10n', () => createL10nMock())

import ExternalApp from '../ExternalApp.vue'

Expand Down
11 changes: 2 additions & 9 deletions src/tests/actions/openInLibreSignAction.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

import { describe, expect, it, beforeEach, vi, afterEach } from 'vitest'
import { createL10nMock } from '../testHelpers/l10n.js'

// Mock @nextcloud/logger to avoid import-time errors with @nextcloud/vue
vi.mock('@nextcloud/logger', () => ({
Expand Down Expand Up @@ -82,15 +83,7 @@ vi.mock('@nextcloud/initial-state', () => ({
}),
}))

vi.mock('@nextcloud/l10n', () => ({
translate: vi.fn((_app: string, text: string) => text),
translatePlural: vi.fn((_app: string, singular: string, plural: string, count: number) => (count === 1 ? singular : plural)),
t: vi.fn((_app: string, text: string) => text),
n: vi.fn((_app: string, singular: string, plural: string, count: number) => (count === 1 ? singular : plural)),
getLanguage: vi.fn(() => 'en'),
getLocale: vi.fn(() => 'en'),
isRTL: vi.fn(() => false),
}))
vi.mock('@nextcloud/l10n', () => createL10nMock())

vi.mock('@nextcloud/vue/functions/dialog', () => ({
spawnDialog: vi.fn(() => Promise.resolve('Test Envelope')),
Expand Down
11 changes: 2 additions & 9 deletions src/tests/components/CodeEditor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,12 @@
*/

import { beforeEach, describe, expect, it, vi } from 'vitest'
import { createL10nMock } from '../testHelpers/l10n.js'
import { mount } from '@vue/test-utils'

import CodeEditor from '../../components/CodeEditor.vue'

vi.mock('@nextcloud/l10n', () => ({
translate: vi.fn((_app: string, text: string) => text),
translatePlural: vi.fn((_app: string, singular: string, plural: string, count: number) => (count === 1 ? singular : plural)),
t: vi.fn((_app: string, text: string) => text),
n: vi.fn((_app: string, singular: string, plural: string, count: number) => (count === 1 ? singular : plural)),
getLanguage: vi.fn(() => 'en'),
getLocale: vi.fn(() => 'en'),
isRTL: vi.fn(() => false),
}))
vi.mock('@nextcloud/l10n', () => createL10nMock())

vi.mock('@ssddanbrown/codemirror-lang-twig', () => ({
twig: vi.fn(() => ({ name: 'twig-extension' })),
Expand Down
4 changes: 0 additions & 4 deletions src/tests/components/Draw/FileUpload.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,6 @@ import { beforeEach, describe, expect, it, vi } from 'vitest'
import { mount } from '@vue/test-utils'
import FileUpload from '../../../components/Draw/FileUpload.vue'

vi.mock('@nextcloud/l10n', () => ({
t: vi.fn((_app: string, text: string) => text),
}))

vi.mock('@nextcloud/capabilities', () => ({
getCapabilities: vi.fn(() => ({
libresign: {
Expand Down
8 changes: 2 additions & 6 deletions src/tests/components/File/File.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

import { beforeEach, describe, expect, it, vi } from 'vitest'
import { createL10nMock } from '../../testHelpers/l10n.js'
import { mount } from '@vue/test-utils'

import File from '../../../components/File/File.vue'
Expand Down Expand Up @@ -36,12 +37,7 @@ const sidebarStoreMock = {
activeRequestSignatureTab: vi.fn(),
}

vi.mock('@nextcloud/l10n', () => ({
t: vi.fn((_app: string, text: string) => text),
getLanguage: vi.fn(() => 'en'),
getLocale: vi.fn(() => 'en'),
isRTL: vi.fn(() => false),
}))
vi.mock('@nextcloud/l10n', () => createL10nMock())

vi.mock('@nextcloud/router', () => ({
generateOcsUrl: vi.fn((path: string, params?: Record<string, string | number>) => {
Expand Down
5 changes: 0 additions & 5 deletions src/tests/components/FileEntry/FileEntrySigners.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -27,11 +27,6 @@ type FileEntrySignersWrapper = VueWrapper<any> & {

let FileEntrySigners: any

vi.mock('@nextcloud/l10n', () => ({
translate: vi.fn((_app: string, text: string) => text),
isRTL: vi.fn(() => false),
}))

beforeAll(async () => {
;({ default: FileEntrySigners } = await import('../../../views/FilesList/FileEntry/FileEntrySigners.vue'))
})
Expand Down
5 changes: 0 additions & 5 deletions src/tests/components/FileEntry/FileEntryStatus.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ type FileEntryStatusWrapper = VueWrapper<any> & {

let FileEntryStatus: any

vi.mock('@nextcloud/l10n', () => ({
translate: vi.fn((_app: string, text: string) => text),
isRTL: vi.fn(() => false),
}))

vi.mock('vue-select', () => ({
default: {
name: 'VSelect',
Expand Down
6 changes: 2 additions & 4 deletions src/tests/components/FileStatusList.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,16 +4,14 @@
*/

import { beforeEach, describe, expect, it, vi } from 'vitest'
import { createL10nMock } from '../testHelpers/l10n.js'
import { mount } from '@vue/test-utils'

import FileStatusList from '../../components/FileStatusList.vue'

const axiosGetMock = vi.fn()

vi.mock('@nextcloud/l10n', () => ({
t: vi.fn((_app: string, text: string) => text),
n: vi.fn((_app: string, singular: string, plural: string, count: number) => (count === 1 ? singular : plural)),
}))
vi.mock('@nextcloud/l10n', () => createL10nMock())

vi.mock('@nextcloud/files', () => ({
formatFileSize: vi.fn((size: number) => `${size}B`),
Expand Down
4 changes: 0 additions & 4 deletions src/tests/components/FooterTemplateEditor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ vi.mock('debounce', () => ({
default: vi.fn((fn: (...args: unknown[]) => unknown) => fn),
}))

vi.mock('@nextcloud/l10n', () => ({
t: vi.fn((_app: string, text: string) => text),
}))

vi.mock('@nextcloud/axios', () => ({
default: {
get: vi.fn((...args: unknown[]) => axiosGetMock(...args)),
Expand Down
11 changes: 2 additions & 9 deletions src/tests/components/LeftSidebar/LeftSidebar.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

import { beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'
import { createL10nMock } from '../../testHelpers/l10n.js'
import { mount } from '@vue/test-utils'

const loadStateMock = vi.fn()
Expand All @@ -18,15 +19,7 @@ vi.mock('@nextcloud/auth', () => ({
getCurrentUser: () => getCurrentUserMock(),
}))

vi.mock('@nextcloud/l10n', () => ({
t: vi.fn((_app: string, text: string) => text),
translate: vi.fn((_app: string, text: string) => text),
translatePlural: vi.fn((_app: string, singular: string, plural: string, count: number) => (count === 1 ? singular : plural)),
n: vi.fn((_app: string, singular: string, plural: string, count: number) => (count === 1 ? singular : plural)),
isRTL: vi.fn(() => false),
getLanguage: vi.fn(() => 'en'),
getLocale: vi.fn(() => 'en'),
}))
vi.mock('@nextcloud/l10n', () => createL10nMock())

vi.mock('../../../store/files.js', () => ({
useFilesStore: () => ({
Expand Down
11 changes: 2 additions & 9 deletions src/tests/components/MarkdownEditor.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

import { beforeAll, beforeEach, describe, expect, it, vi } from 'vitest'
import { createL10nMock } from '../testHelpers/l10n.js'
import { mount, flushPromises } from '@vue/test-utils'
import type { VueWrapper } from '@vue/test-utils'

Expand All @@ -29,15 +30,7 @@ type MarkdownEditorWrapper = VueWrapper<any> & {

let MarkdownEditor: any

vi.mock('@nextcloud/l10n', () => ({
translate: vi.fn((_app: string, text: string) => text),
translatePlural: vi.fn((_app: string, singular: string, plural: string, count: number) => (count === 1 ? singular : plural)),
t: vi.fn((_app: string, text: string) => text),
n: vi.fn((_app: string, singular: string, plural: string, count: number) => (count === 1 ? singular : plural)),
getLanguage: vi.fn(() => 'en'),
getLocale: vi.fn(() => 'en'),
isRTL: vi.fn(() => false),
}))
vi.mock('@nextcloud/l10n', () => createL10nMock())

beforeAll(async () => {
;({ default: MarkdownEditor } = await import('../../components/MarkdownEditor.vue'))
Expand Down
28 changes: 12 additions & 16 deletions src/tests/components/PdfEditor/SignatureBox.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

import { describe, expect, it, vi } from 'vitest'
import { createL10nMock, interpolateL10n } from '../../testHelpers/l10n.js'
import { mount } from '@vue/test-utils'
import type { SignerSummaryRecord } from '../../../types/index'

Expand All @@ -21,22 +22,17 @@ const createSigner = (overrides: Partial<SignerSummaryRecord> = {}): SignerSumma

const usernameToColorMock = vi.fn((_seed: string) => ({ r: 10, g: 20, b: 30 }))

vi.mock('@nextcloud/l10n', () => ({
t: vi.fn((_app: string, text: string, params?: Record<string, string>) => {
if (!params) {
return text
}

return Object.entries(params).reduce((message, [key, value]) => {
return message.replace(`{${key}}`, value)
}, text)
}),
translate: vi.fn((_app: string, text: string) => text),
translatePlural: vi.fn((_app: string, singular: string, plural: string, count: number) => (count === 1 ? singular : plural)),
n: vi.fn((_app: string, singular: string, plural: string, count: number) => (count === 1 ? singular : plural)),
getLanguage: vi.fn(() => 'en'),
getLocale: vi.fn(() => 'en'),
isRTL: vi.fn(() => false),
vi.mock('@nextcloud/l10n', () => createL10nMock({
t: (_app: string, text: string, vars?: Record<string, string | number>) => interpolateL10n(text, vars),
n: (_app: string, singular: string, plural: string, count: number, vars?: Record<string, string | number>) => {
const template = count === 1 ? singular : plural
return interpolateL10n(template, { count, ...(vars ?? {}) })
},
translate: (_app: string, text: string, vars?: Record<string, string | number>) => interpolateL10n(text, vars),
translatePlural: (_app: string, singular: string, plural: string, count: number, vars?: Record<string, string | number>) => {
const template = count === 1 ? singular : plural
return interpolateL10n(template, { count, ...(vars ?? {}) })
},
}))

vi.mock('@nextcloud/vue/functions/usernameToColor', () => ({
Expand Down
11 changes: 2 additions & 9 deletions src/tests/components/PreviewSignature/PreviewSignature.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

import { beforeEach, describe, expect, it, vi } from 'vitest'
import { createL10nMock } from '../../testHelpers/l10n.js'
import { mount } from '@vue/test-utils'

import PreviewSignature from '../../../components/PreviewSignature/PreviewSignature.vue'
Expand All @@ -27,15 +28,7 @@ vi.mock('@nextcloud/capabilities', () => ({
})),
}))

vi.mock('@nextcloud/l10n', () => ({
t: vi.fn((_app: string, text: string) => text),
translate: vi.fn((_app: string, text: string) => text),
translatePlural: vi.fn((_app: string, singular: string, plural: string, count: number) => (count === 1 ? singular : plural)),
n: vi.fn((_app: string, singular: string, plural: string, count: number) => (count === 1 ? singular : plural)),
getLanguage: vi.fn(() => 'en'),
getLocale: vi.fn(() => 'en'),
isRTL: vi.fn(() => false),
}))
vi.mock('@nextcloud/l10n', () => createL10nMock())

describe('PreviewSignature.vue', () => {
beforeEach(() => {
Expand Down
11 changes: 2 additions & 9 deletions src/tests/components/Request/IdentifySigner.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

import { describe, expect, it, beforeEach, vi } from 'vitest'
import { createL10nMock } from '../../testHelpers/l10n.js'
import { mount } from '@vue/test-utils'
import type { VueWrapper } from '@vue/test-utils'
import { createPinia, setActivePinia } from 'pinia'
Expand Down Expand Up @@ -82,15 +83,7 @@ vi.mock('../../../store/files.js', () => ({
useFilesStore: vi.fn(() => filesStore),
}))

vi.mock('@nextcloud/l10n', () => ({
translate: vi.fn((_app: string, text: string) => text),
translatePlural: vi.fn((_app: string, singular: string, plural: string, count: number) => (count === 1 ? singular : plural)),
t: vi.fn((_app: string, text: string) => text),
n: vi.fn((_app: string, singular: string, plural: string, count: number) => (count === 1 ? singular : plural)),
getLanguage: vi.fn(() => 'en'),
getLocale: vi.fn(() => 'en'),
isRTL: vi.fn(() => false),
}))
vi.mock('@nextcloud/l10n', () => createL10nMock())

vi.mock('@mdi/svg/svg/account.svg?raw', () => ({ default: '<svg></svg>' }))
vi.mock('@mdi/svg/svg/email.svg?raw', () => ({ default: '<svg></svg>' }))
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,12 @@
*/

import { describe, expect, it, vi } from 'vitest'
import { createL10nMock } from '../../../../testHelpers/l10n.js'
import { mount } from '@vue/test-utils'

import PageNavigation from '../../../../../components/Request/SignDetail/partials/PageNavigation.vue'

vi.mock('@nextcloud/l10n', () => ({
t: vi.fn((_app: string, text: string) => text),
translate: vi.fn((_app: string, text: string) => text),
translatePlural: vi.fn((_app: string, singular: string, plural: string, count: number) => (count === 1 ? singular : plural)),
n: vi.fn((_app: string, singular: string, plural: string, count: number) => (count === 1 ? singular : plural)),
getLanguage: vi.fn(() => 'en'),
getLocale: vi.fn(() => 'en'),
isRTL: vi.fn(() => false),
}))
vi.mock('@nextcloud/l10n', () => createL10nMock())

describe('PageNavigation.vue', () => {
function createWrapper(modelValue = 2) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,19 +4,12 @@
*/

import { describe, expect, it, vi } from 'vitest'
import { createL10nMock } from '../../../../testHelpers/l10n.js'
import { mount } from '@vue/test-utils'

import SignerRow from '../../../../../components/Request/SignDetail/partials/SignerRow.vue'

vi.mock('@nextcloud/l10n', () => ({
t: vi.fn((_app: string, text: string) => text),
translate: vi.fn((_app: string, text: string) => text),
translatePlural: vi.fn((_app: string, singular: string, plural: string, count: number) => (count === 1 ? singular : plural)),
n: vi.fn((_app: string, singular: string, plural: string, count: number) => (count === 1 ? singular : plural)),
isRTL: vi.fn(() => false),
getLanguage: vi.fn(() => 'en'),
getLocale: vi.fn(() => 'en'),
}))
vi.mock('@nextcloud/l10n', () => createL10nMock())

vi.mock('@nextcloud/event-bus', () => ({
emit: vi.fn(),
Expand Down
11 changes: 2 additions & 9 deletions src/tests/components/Request/SignerSelect.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
*/

import { describe, expect, it, vi, beforeEach } from 'vitest'
import { createL10nMock } from '../../testHelpers/l10n.js'
import { mount } from '@vue/test-utils'
import SignerSelect from '../../../components/Request/SignerSelect.vue'

Expand Down Expand Up @@ -31,15 +32,7 @@ vi.mock('@nextcloud/router', () => ({
generateOcsUrl: vi.fn((path: string) => path),
}))

vi.mock('@nextcloud/l10n', () => ({
t: vi.fn((_app: string, text: string) => text),
translate: vi.fn((_app: string, text: string) => text),
translatePlural: vi.fn((_app: string, singular: string, plural: string, count: number) => (count === 1 ? singular : plural)),
n: vi.fn((_app: string, singular: string, plural: string, count: number) => (count === 1 ? singular : plural)),
isRTL: vi.fn(() => false),
getLanguage: vi.fn(() => 'en'),
getLocale: vi.fn(() => 'en'),
}))
vi.mock('@nextcloud/l10n', () => createL10nMock())

describe('SignerSelect.vue', () => {
beforeEach(() => {
Expand Down
Loading
Loading