diff --git a/core/Listener/FeedBackHandler.php b/core/Listener/FeedBackHandler.php
index d355b63f1bcc0..b0bedf3712ab8 100644
--- a/core/Listener/FeedBackHandler.php
+++ b/core/Listener/FeedBackHandler.php
@@ -52,7 +52,7 @@ public function handleRepairFeedback(Event $event): void {
} elseif ($event instanceof RepairInfoEvent) {
$this->eventSource->send('success', $this->l10n->t('Repair info:') . ' ' . $event->getMessage());
} elseif ($event instanceof RepairWarningEvent) {
- $this->eventSource->send('notice', $this->l10n->t('Repair warning:') . ' ' . $event->getMessage());
+ $this->eventSource->send('warning', $this->l10n->t('Repair warning:') . ' ' . $event->getMessage());
} elseif ($event instanceof RepairErrorEvent) {
$this->eventSource->send('error', $this->l10n->t('Repair error:') . ' ' . $event->getMessage());
}
diff --git a/core/src/views/UpdaterAdmin.spec.ts b/core/src/views/UpdaterAdmin.spec.ts
new file mode 100644
index 0000000000000..5a1161e30de6b
--- /dev/null
+++ b/core/src/views/UpdaterAdmin.spec.ts
@@ -0,0 +1,201 @@
+/**
+ * SPDX-FileCopyrightText: 2026 Nextcloud GmbH and Nextcloud contributors
+ * SPDX-License-Identifier: AGPL-3.0-or-later
+ */
+
+import { cleanup, fireEvent, render } from '@testing-library/vue'
+import { afterEach, beforeEach, describe, expect, it, vi } from 'vitest'
+import { nextTick } from 'vue'
+import UpdaterAdmin from './UpdaterAdmin.vue'
+
+class FakeEventSource extends EventTarget {
+ static instance: FakeEventSource
+ closed = false
+
+ constructor(public url: string) {
+ super()
+ FakeEventSource.instance = this
+ }
+
+ send(type: string, data: string) {
+ this.dispatchEvent(new MessageEvent(type, { data: JSON.stringify(data) }))
+ }
+
+ close() {
+ this.closed = true
+ }
+}
+
+const defaultInfo = {
+ appsToUpgrade: [],
+ incompatibleAppsList: [],
+ isAppsOnlyUpgrade: false,
+ oldTheme: null,
+ productName: 'Nextcloud',
+ version: '34.0.0',
+}
+
+function setUpdateInfo(info: object = {}) {
+ const input = document.createElement('input')
+ input.id = 'initial-state-core-updateInfo'
+ input.type = 'hidden'
+ input.value = btoa(JSON.stringify({ ...defaultInfo, ...info }))
+ document.head.appendChild(input)
+}
+
+async function startUpdate() {
+ const view = render(UpdaterAdmin)
+ await fireEvent.click(view.getByRole('button', { name: 'Start update' }))
+ return { view, source: FakeEventSource.instance }
+}
+
+describe('UpdaterAdmin', () => {
+ beforeEach(() => {
+ delete globalThis._nc_initial_state
+ vi.stubGlobal('EventSource', FakeEventSource)
+ document.head.dataset.requesttoken = 'test-token'
+ })
+
+ afterEach(() => {
+ cleanup()
+ document.getElementById('initial-state-core-updateInfo')?.remove()
+ delete globalThis._nc_initial_state
+ delete document.head.dataset.requesttoken
+ vi.useRealTimers()
+ vi.unstubAllGlobals()
+ })
+
+ it('shows apps to update even when there are no incompatible apps', () => {
+ setUpdateInfo({
+ appsToUpgrade: [{ id: 'calendar', name: 'Calendar', oldVersion: '1.0', version: '2.0' }],
+ })
+ const view = render(UpdaterAdmin)
+
+ expect(view.getByText('These apps will be updated:')).toBeInTheDocument()
+ expect(view.getByText('Calendar (calendar) from 1.0 to 2.0')).toBeInTheDocument()
+ expect(view.queryByText('These incompatible apps will be disabled:')).not.toBeInTheDocument()
+ })
+
+ it('does not show an empty update list when an incompatible app exists', () => {
+ setUpdateInfo({ incompatibleAppsList: [{ id: 'example', name: 'Example' }] })
+ const view = render(UpdaterAdmin)
+
+ expect(view.getByText('Example (example)')).toBeInTheDocument()
+ expect(view.queryByText('These apps will be updated:')).not.toBeInTheDocument()
+ })
+
+ it('shows success and starts the redirect countdown on done', async () => {
+ setUpdateInfo()
+ const { view, source } = await startUpdate()
+ vi.useFakeTimers()
+
+ expect(view.getByRole('button', { name: 'Continue to Nextcloud' })).toBeDisabled()
+ source.send('success', 'Preparing update')
+ source.send('done', '')
+ await nextTick()
+
+ expect(source.closed).toBe(true)
+ expect(view.getByText('The update completed successfully.')).toBeInTheDocument()
+ expect(view.getByText('You will be redirected to Nextcloud in 5 seconds.')).toBeInTheDocument()
+ vi.advanceTimersByTime(1000)
+ await nextTick()
+ expect(view.getByText('You will be redirected to Nextcloud in 4 seconds.')).toBeInTheDocument()
+ })
+
+ it('shows repair warnings and does not redirect automatically', async () => {
+ setUpdateInfo()
+ const { view, source } = await startUpdate()
+ vi.useFakeTimers()
+
+ source.send('warning', 'Repair warning: Unable to clear the frontend cache')
+ source.send('done', '')
+ await nextTick()
+
+ expect(view.getByText(/The update completed with warnings/)).toBeInTheDocument()
+ expect(view.getByText('Repair warning: Unable to clear the frontend cache')).toBeVisible()
+ expect(view.queryByText(/You will be redirected/)).not.toBeInTheDocument()
+ expect(vi.getTimerCount()).toBe(0)
+ })
+
+ it('keeps monitoring after a repair error until done', async () => {
+ setUpdateInfo()
+ const { view, source } = await startUpdate()
+
+ source.send('error', 'Repair error: step failed')
+ await nextTick()
+ expect(source.closed).toBe(false)
+ expect(view.getByRole('button', { name: 'Continue to Nextcloud' })).toBeDisabled()
+
+ source.send('success', 'Later step completed')
+ source.send('done', '')
+ await nextTick()
+ expect(source.closed).toBe(true)
+ expect(view.getByText(/The update ended with errors/)).toBeInTheDocument()
+ expect(view.getByText('Repair error: step failed')).toBeVisible()
+ expect(view.getByText('Later step completed')).toBeVisible()
+ expect(view.queryByText(/You will be redirected/)).not.toBeInTheDocument()
+ })
+
+ it('keeps monitoring after a failure that is followed by done', async () => {
+ setUpdateInfo()
+ const { view, source } = await startUpdate()
+
+ source.send('failure', 'An app could not be installed')
+ source.send('success', 'Later step completed')
+ await nextTick()
+ expect(source.closed).toBe(false)
+ expect(view.getByRole('button', { name: 'Continue to Nextcloud' })).toBeDisabled()
+
+ source.send('done', '')
+ await nextTick()
+ expect(view.getByText(/The update ended with errors/)).toBeInTheDocument()
+ expect(view.getByText('An app could not be installed')).toBeVisible()
+ expect(view.getByText('Later step completed')).toBeVisible()
+ expect(view.queryByText(/You will be redirected/)).not.toBeInTheDocument()
+ })
+
+ it('finishes with an error when the server closes after a failure without done', async () => {
+ setUpdateInfo()
+ const { view, source } = await startUpdate()
+
+ source.send('failure', 'Upgrade failed')
+ await nextTick()
+ expect(view.getByRole('button', { name: 'Continue to Nextcloud' })).toBeDisabled()
+ source.send('__internal__', 'close')
+ await nextTick()
+
+ expect(source.closed).toBe(true)
+ expect(view.getByText(/The update ended with errors/)).toBeInTheDocument()
+ expect(view.getByText('Upgrade failed')).toBeVisible()
+ expect(view.getByRole('button', { name: 'Continue to Nextcloud' })).toBeEnabled()
+ expect(view.queryByText(/You will be redirected/)).not.toBeInTheDocument()
+ })
+
+ it('treats a server close without done or an error as an unknown outcome', async () => {
+ setUpdateInfo()
+ const { view, source } = await startUpdate()
+
+ source.send('__internal__', 'close')
+ await nextTick()
+ expect(source.closed).toBe(true)
+ expect(view.getByText(/update status is unknown/)).toBeInTheDocument()
+ expect(view.getByRole('button', { name: 'Continue to Nextcloud' })).toBeDisabled()
+ })
+
+ it('treats a transport error as an unknown outcome', async () => {
+ setUpdateInfo()
+ const { view, source } = await startUpdate()
+
+ source.dispatchEvent(new Event('error'))
+ await nextTick()
+
+ expect(source.closed).toBe(true)
+ expect(view.getByText(/update status is unknown/)).toBeInTheDocument()
+ expect(view.getByRole('button', { name: 'Continue to Nextcloud' })).toBeDisabled()
+ expect(view.queryByText(/The update completed/)).not.toBeInTheDocument()
+ expect(view.queryByText(/You will be redirected/)).not.toBeInTheDocument()
+ const beforeUnload = new Event('beforeunload', { cancelable: true })
+ window.dispatchEvent(beforeUnload)
+ expect(beforeUnload.defaultPrevented).toBe(true)
+ })
+})
diff --git a/core/src/views/UpdaterAdmin.vue b/core/src/views/UpdaterAdmin.vue
index a5a9be93de9d2..bb7191af79cbd 100644
--- a/core/src/views/UpdaterAdmin.vue
+++ b/core/src/views/UpdaterAdmin.vue
@@ -35,6 +35,7 @@ const updateInfo = loadState<{
const isShowingDetails = ref(false)
const isUpdateRunning = ref(false)
const isUpdateDone = ref(false)
+const isOutcomeUnknown = ref(false)
const messages = ref<{ message: string, type: string }[]>([])
const wasSuccessfull = computed(() => messages.value.every((msg) => msg.type === 'success' || msg.type === 'notice'))
@@ -42,8 +43,13 @@ const hasErrors = computed(() => messages.value.some((msg) => msg.type === 'erro
const resultIcon = computed(() => wasSuccessfull.value ? mdiCheckCircleOutline : (hasErrors.value ? mdiCloseCircleOutline : mdiAlertCircleOutline))
const statusMessage = computed(() => {
+ if (isOutcomeUnknown.value) {
+ return t('core', 'The connection was lost and the update status is unknown. The update may still be running. Check the server logs and process status before reloading or retrying.')
+ }
if (isUpdateDone.value) {
- if (!wasSuccessfull.value) {
+ if (hasErrors.value) {
+ return t('core', 'The update ended with errors. Please check the details for more information.')
+ } else if (!wasSuccessfull.value) {
return t('core', 'The update completed with warnings. Please check the details for more information.')
} else {
return t('core', 'The update completed successfully.')
@@ -89,7 +95,7 @@ function getSeverityIcon(type: string) {
* Start the update process
*/
async function onStartUpdate() {
- if (isUpdateRunning.value || isUpdateDone.value) {
+ if (isUpdateRunning.value || isUpdateDone.value || isOutcomeUnknown.value) {
return
}
@@ -101,19 +107,38 @@ async function onStartUpdate() {
eventSource.listen('notice', (message) => {
messages.value.push({ message, type: 'notice' })
})
- eventSource.listen('error', (message) => {
- messages.value.push({ message, type: 'error' })
- isUpdateRunning.value = false
- isUpdateDone.value = true
+ eventSource.listen('warning', (message) => {
+ messages.value.push({ message, type: 'warning' })
+ })
+ eventSource.source.addEventListener('error', (event) => {
+ if (event instanceof MessageEvent) {
+ messages.value.push({ message: JSON.parse(event.data), type: 'error' })
+ return
+ }
eventSource.close()
+ isUpdateRunning.value = false
+ isOutcomeUnknown.value = true
+ isShowingDetails.value = true
})
eventSource.listen('failure', (message) => {
messages.value.push({ message, type: 'failure' })
})
+ eventSource.listen('__internal__', (message) => {
+ if (message === 'close' && !isUpdateDone.value && !isOutcomeUnknown.value) {
+ isUpdateRunning.value = false
+ if (hasErrors.value) {
+ isUpdateDone.value = true
+ } else {
+ isOutcomeUnknown.value = true
+ }
+ isShowingDetails.value = true
+ }
+ })
eventSource.listen('done', () => {
isUpdateRunning.value = false
isUpdateDone.value = true
eventSource.close()
+ isShowingDetails.value = !wasSuccessfull.value
updateCountdown()
})
}
@@ -139,7 +164,7 @@ function updateCountdown() {
* @param event - The beforeunload event object.
*/
function onUnload(event: BeforeUnloadEvent) {
- if (isUpdateRunning.value) {
+ if (isUpdateRunning.value || isOutcomeUnknown.value) {
event.preventDefault()
event.returnValue = t('core', 'The update is in progress, leaving this page might interrupt the process in some environments.')
}
@@ -174,7 +199,7 @@ function reloadPage() {
-