Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
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
1 change: 1 addition & 0 deletions eslint.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -41,5 +41,6 @@ module.exports = defineConfig([{
'import/default': 'off', // disable default import checking to avoid parser requirement
'import/no-named-as-default': 'off', // disable named-as-default checking to avoid parser requirement
'import/no-named-as-default-member': 'off', // disable named-as-default-member checking to avoid parser requirement
'no-console': ['error', { allow: ['warn', 'error', 'info', 'debug', 'trace', 'group', 'groupEnd'] }],
},
}])
30 changes: 23 additions & 7 deletions jest.config.js
Original file line number Diff line number Diff line change
@@ -1,17 +1,33 @@
const path = require('path')

module.exports = {
// Define how different file types should be transformed before testing
transform: {
'^.+\\.vue$': '@vue/vue2-jest',
'^.+\\.js$': 'babel-jest',
'^.+\\.ts$': 'ts-jest',
'.+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$': 'jest-transform-stub',
'^.+\\.vue$': '@vue/vue2-jest', // Compile Vue SFCs using the Vue 2 jest transformer
'^.+\\.js$': ['babel-jest', { configFile: path.resolve(__dirname, '.babelrc') }], // Transpile JS using our local .babelrc config
'^.+\\.ts$': ['ts-jest', { diagnostics: false }], // Transpile TS without type-checking (faster tests)
'.+\\.(css|styl|less|sass|scss|png|jpg|ttf|woff|woff2)$': 'jest-transform-stub', // Stub out static assets that can't be executed
},
moduleFileExtensions: ['js', 'json', 'vue', 'ts'],
testEnvironment: 'jest-environment-jsdom',
testEnvironment: 'jest-environment-jsdom', // Simulate a browser DOM for component tests
roots: [
'<rootDir>',
'<rootDir>/../nextcloud-vue/src', // Include the local nextcloud-vue source so its components can be resolved
],
moduleNameMapper: {
'^@/(.*)$': '<rootDir>/src/$1',
'^@/(.*)$': '<rootDir>/src/$1', // Map the @ alias to src/ (mirrors webpack resolve)
'^@conduction/nextcloud-vue$': '<rootDir>/tests/__mocks__/@conduction/nextcloud-vue.js', // Use a manual mock for the shared Vue lib in tests
'^pinia$': '<rootDir>/node_modules/pinia', // Force pinia to resolve to our local copy to avoid duplicate instances
'\\.(css|less|sass|scss)$': 'jest-transform-stub', // Stub stylesheet imports so they don't break tests
},
transformIgnorePatterns: [
'/node_modules/(?!(@nextcloud|pinia)/)', // Transform @nextcloud and pinia packages (they ship raw ESM that Jest can't run directly)
],
setupFiles: [
'<rootDir>/tests/setup.js', // Global test setup (e.g. mocking Nextcloud globals)
],
coveragePathIgnorePatterns: [
'index.js',
'index.js', // Exclude barrel files from coverage — they only re-export
'index.ts',
],
coverageDirectory: '<rootDir>/coverage-frontend/',
Expand Down
4 changes: 2 additions & 2 deletions src/components/cards/ApplicationCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -14,14 +14,14 @@
<DotsHorizontal :size="20" />
</template>
<NcActionButton close-after-click
@click="applicationStore.setApplicationItem(item); navigationStore.setModal('editApplication')">
@click="applicationStore.setItem(item); navigationStore.setModal('editApplication')">
<template #icon>
<Pencil :size="20" />
</template>
Edit
</NcActionButton>
<NcActionButton close-after-click
@click="applicationStore.setApplicationItem(item); navigationStore.setDialog('deleteApplication')">
@click="applicationStore.setItem(item); navigationStore.setDialog('deleteApplication')">
<template #icon>
<TrashCanOutline :size="20" />
</template>
Expand Down
16 changes: 8 additions & 8 deletions src/components/cards/ConfigurationCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -359,7 +359,7 @@ export default {
if (!this.importedConfigId) return null

// Try to find in store first (fast)
const found = configurationStore.configurationList.find(
const found = configurationStore.list.find(
config => config.id === this.importedConfigId,
)

Expand Down Expand Up @@ -627,11 +627,11 @@ export default {
this.importedConfigId = importedConfig.id

// Add to store if not already there (for pagination support)
const existsInStore = configurationStore.configurationList.find(
const existsInStore = configurationStore.list.find(
c => c.id === importedConfig.id,
)
if (!existsInStore) {
configurationStore.configurationList.push(importedConfig)
configurationStore.list.push(importedConfig)
}
} else {
// Not imported
Expand Down Expand Up @@ -702,7 +702,7 @@ export default {
handleView() {
if (this.isDiscovered && this.existingConfiguration) {
// For discovered configs that are imported, open the local one
configurationStore.setConfigurationItem(this.existingConfiguration)
configurationStore.setItem(this.existingConfiguration)
navigationStore.setModal('viewConfiguration')
} else {
this.$emit('view', this.existingConfiguration || this.displayConfiguration)
Expand All @@ -713,7 +713,7 @@ export default {
*/
handleEdit() {
if (this.isDiscovered && this.existingConfiguration) {
configurationStore.setConfigurationItem(this.existingConfiguration)
configurationStore.setItem(this.existingConfiguration)
navigationStore.setModal('editConfiguration')
} else {
this.$emit('edit', this.existingConfiguration || this.displayConfiguration)
Expand All @@ -724,7 +724,7 @@ export default {
*/
handleExport() {
if (this.isDiscovered && this.existingConfiguration) {
configurationStore.setConfigurationItem(this.existingConfiguration)
configurationStore.setItem(this.existingConfiguration)
navigationStore.setModal('exportConfiguration')
} else {
this.$emit('export', this.existingConfiguration || this.displayConfiguration)
Expand All @@ -735,7 +735,7 @@ export default {
*/
handlePublish() {
const config = this.existingConfiguration || this.displayConfiguration
configurationStore.setConfigurationItem(config)
configurationStore.setItem(config)
navigationStore.setModal('publishConfiguration')
},
/**
Expand All @@ -755,7 +755,7 @@ export default {
*/
handlePreviewUpdate() {
if (this.isDiscovered && this.existingConfiguration) {
configurationStore.setConfigurationItem(this.existingConfiguration)
configurationStore.setItem(this.existingConfiguration)
navigationStore.setModal('previewConfiguration')
} else {
this.$emit('preview-update', this.existingConfiguration || this.displayConfiguration)
Expand Down
28 changes: 14 additions & 14 deletions src/components/cards/RegisterSchemaCard.vue
Original file line number Diff line number Diff line change
Expand Up @@ -55,13 +55,13 @@ import { dashboardStore, registerStore, schemaStore, navigationStore, configurat
</NcActionButton>
<!-- Register-only actions -->
<template v-if="type === 'register'">
<NcActionButton close-after-click @click="registerStore.setRegisterItem(item); navigationStore.setModal('publishRegister')">
<NcActionButton close-after-click @click="registerStore.setItem(item); navigationStore.setModal('publishRegister')">
<template #icon>
<CloudUploadOutline :size="20" />
</template>
Publish OAS
</NcActionButton>
<NcActionButton close-after-click @click="registerStore.setRegisterItem(item); navigationStore.setModal('importRegister')">
<NcActionButton close-after-click @click="registerStore.setItem(item); navigationStore.setModal('importRegister')">
<template #icon>
<Upload :size="20" />
</template>
Expand Down Expand Up @@ -195,15 +195,15 @@ import { dashboardStore, registerStore, schemaStore, navigationStore, configurat
</NcActionButton>
<NcActionButton
close-after-click
@click="registerStore.setRegisterItem(item); schemaStore.setSchemaItem(schema); navigationStore.setModal('exportRegister')">
@click="registerStore.setItem(item); schemaStore.setItem(schema); navigationStore.setModal('exportRegister')">
<template #icon>
<Export :size="20" />
</template>
{{ t('openregister', 'Export') }}
</NcActionButton>
<NcActionButton
close-after-click
@click="registerStore.setRegisterItem(item); schemaStore.setSchemaItem(schema); navigationStore.setModal('importRegister')">
@click="registerStore.setItem(item); schemaStore.setItem(schema); navigationStore.setModal('importRegister')">
<template #icon>
<Upload :size="20" />
</template>
Expand Down Expand Up @@ -418,12 +418,12 @@ export default {
managingConfiguration() {
if (!this.item || !this.item.id) return null
if (this.type === 'register') {
return configurationStore.configurationList.find(
return configurationStore.list.find(
config => config.registers && config.registers.includes(this.item.id),
) || null
}
// Schema: config.schemas is an array of objects with .id
return configurationStore.configurationList.find(
return configurationStore.list.find(
config => config.schemas && config.schemas.some(s => s.id === this.item.id),
) || null
},
Expand Down Expand Up @@ -516,7 +516,7 @@ export default {
if (this.type === 'register') {
this.showEditRegisterDialog = true
} else {
schemaStore.setSchemaItem(this.item)
schemaStore.setItem(this.item)
navigationStore.setModal('editSchema')
}
},
Expand Down Expand Up @@ -551,8 +551,8 @@ export default {
async loadSchemaOptions() {
this.schemasLoading = true
try {
await schemaStore.refreshSchemaList()
this.schemaSelectOptions = schemaStore.schemaList.map(s => ({ id: s.id, label: s.title }))
await schemaStore.refreshList()
this.schemaSelectOptions = schemaStore.list.map(s => ({ id: s.id, label: s.title }))
} catch (error) {
console.error('Failed to load schemas:', error)
} finally {
Expand All @@ -569,7 +569,7 @@ export default {
},
async onSaveRegister(formData) {
try {
await registerStore.saveRegister({
await registerStore.save({
...formData,
schemas: (formData.schemas || []).map(s => typeof s === 'object' ? s.id : s),
})
Expand All @@ -581,10 +581,10 @@ export default {
},
openDelete() {
if (this.type === 'register') {
registerStore.setRegisterItem(this.item)
registerStore.setItem(this.item)
navigationStore.setDialog('deleteRegister')
} else {
schemaStore.setSchemaItem(this.item)
schemaStore.setItem(this.item)
navigationStore.setDialog('deleteSchema')
}
},
Expand All @@ -596,7 +596,7 @@ export default {

// Register-only methods
viewRegisterDetails() {
registerStore.setRegisterItem({ id: this.item.id })
registerStore.setItem({ id: this.item.id })
this.$router.push(`/registers/${this.item.id}`)
},

Expand Down Expand Up @@ -888,7 +888,7 @@ export default {
}

await Promise.all([
registerStore.refreshRegisterList(),
registerStore.refreshList(),
dashboardStore.fetchRegisters(),
])
} catch (error) {
Expand Down
4 changes: 2 additions & 2 deletions src/modals/agent/DeleteAgent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import { agentStore, navigationStore } from '../../store/store.js'
:can-close="true"
@update:open="closeDialog">
<div class="dialog-content">
<p>Are you sure you want to delete the agent <strong>{{ agentStore.agentItem?.name }}</strong>?</p>
<p>Are you sure you want to delete the agent <strong>{{ agentStore.item?.name }}</strong>?</p>
<p class="warning-text">
This action cannot be undone.
</p>
Expand Down Expand Up @@ -60,7 +60,7 @@ export default {
this.loading = true

try {
await agentStore.deleteAgent(agentStore.agentItem)
await agentStore.deleteOne(agentStore.item)
this.closeDialog()
} catch (error) {
console.error('Error deleting agent:', error)
Expand Down
14 changes: 7 additions & 7 deletions src/modals/agent/EditAgent.vue
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import { agentStore, navigationStore } from '../../store/store.js'
</script>

<template>
<NcDialog :name="agentStore.agentItem?.uuid ? 'Edit Agent' : 'Create Agent'"
<NcDialog :name="agentStore.item?.uuid ? 'Edit Agent' : 'Create Agent'"
size="large"
:can-close="true"
@update:open="handleDialogClose">
<NcNoteCard v-if="success" type="success">
<p>Agent successfully {{ agentStore.agentItem?.uuid ? 'updated' : 'created' }}</p>
<p>Agent successfully {{ agentStore.item?.uuid ? 'updated' : 'created' }}</p>
</NcNoteCard>
<NcNoteCard v-if="error" type="error">
<p>{{ error }}</p>
Expand Down Expand Up @@ -360,7 +360,7 @@ import { agentStore, navigationStore } from '../../store/store.js'
<NcLoadingIcon v-if="loading" :size="20" />
<ContentSaveOutline v-else :size="20" />
</template>
{{ agentStore.agentItem?.uuid ? 'Update' : 'Create' }}
{{ agentStore.item?.uuid ? 'Update' : 'Create' }}
</NcButton>
</template>
</NcDialog>
Expand Down Expand Up @@ -477,12 +477,12 @@ export default {
},
methods: {
initializeAgent() {
if (agentStore.agentItem) {
if (agentStore.item) {
// Deep copy to avoid reactivity issues
const sourceTools = agentStore.agentItem.tools || []
const sourceTools = agentStore.item.tools || []
const toolsArray = Array.isArray(sourceTools) ? [...sourceTools] : []

this.agentItem = { ...agentStore.agentItem }
this.agentItem = { ...agentStore.item }
// Force set the tools array to ensure reactivity
this.$set(this.agentItem, 'tools', toolsArray)
this.selectedType = this.agentTypes.find(t => t.value === this.agentItem.type)
Expand Down Expand Up @@ -757,7 +757,7 @@ export default {
this.error = null

try {
await agentStore.saveAgent(this.agentItem)
await agentStore.save(this.agentItem)
this.success = true
setTimeout(() => {
this.closeModal()
Expand Down
4 changes: 2 additions & 2 deletions src/modals/application/DeleteApplication.vue
Original file line number Diff line number Diff line change
Expand Up @@ -43,14 +43,14 @@ export default {
computed: {
deleteMessage() {
return t('openregister', 'Are you sure you want to delete the application "{name}"? This action cannot be undone.', {
name: applicationStore.applicationItem?.name || t('openregister', 'this application'),
name: applicationStore.item?.name || t('openregister', 'this application'),
})
},
},
methods: {
async deleteApplication() {
try {
await applicationStore.deleteApplication(applicationStore.applicationItem)
await applicationStore.deleteOne(applicationStore.item)
navigationStore.setDialog(false)
} catch (error) {
console.error('Error deleting application:', error)
Expand Down
10 changes: 5 additions & 5 deletions src/modals/application/EditApplication.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ import { applicationStore, organisationStore, navigationStore } from '../../stor
<CnTabbedFormDialog
ref="dialog"
:tabs="dialogTabs"
:item="applicationStore.applicationItem?.uuid ? applicationStore.applicationItem : null"
:item="applicationStore.item?.uuid ? applicationStore.item : null"
entity-name="Application"
:show-create-another="true"
:disable-save="!applicationItem.name.trim()"
Expand Down Expand Up @@ -216,7 +216,7 @@ export default {
* @return {Promise<void>}
*/
async fetchOrganisations() {
await organisationStore.refreshOrganisationList()
await organisationStore.refreshList()
},

/**
Expand Down Expand Up @@ -313,10 +313,10 @@ export default {
* @return {void}
*/
initializeApplicationItem() {
if (applicationStore.applicationItem?.uuid) {
if (applicationStore.item?.uuid) {
this.applicationItem = {
...this.applicationItem, // Keep default structure
...applicationStore.applicationItem,
...applicationStore.item,
}

// Organisation is automatically set by backend based on active organisation
Expand Down Expand Up @@ -520,7 +520,7 @@ export default {
}

try {
const { response } = await applicationStore.saveApplication({
const { response } = await applicationStore.save({
...this.applicationItem,
})

Expand Down
4 changes: 2 additions & 2 deletions src/modals/configuration/DeleteConfiguration.vue
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
</NcNoteCard>

<div class="formContainer">
<p>Are you sure you want to delete the configuration "{{ configurationStore.configurationItem?.title }}"?</p>
<p>Are you sure you want to delete the configuration "{{ configurationStore.item?.title }}"?</p>
<p>This action cannot be undone.</p>
</div>

Expand Down Expand Up @@ -77,7 +77,7 @@ export default {
this.error = null

try {
await configurationStore.deleteConfiguration(configurationStore.configurationItem)
await configurationStore.deleteOne(configurationStore.item)
this.closeModal()
} catch (error) {
this.error = error.message || 'Failed to delete configuration'
Expand Down
Loading
Loading