fix: Port away from removed oc_default

Signed-off-by: Carl Schwan <carl@carlschwan.eu>
pull/62886/head
Carl Schwan 2 weeks ago committed by nextcloud-command
parent b74e28c41e
commit e08d48acff
  1. 12
      apps/settings/src/components/AuthToken.spec.ts
  2. 10
      apps/settings/src/components/AuthToken.vue

@ -3,19 +3,19 @@
* SPDX-License-Identifier: AGPL-3.0-or-later
*/
import type { IToken } from '../store/authtoken.ts'
import { createTestingPinia } from '@pinia/testing'
import { mount } from '@vue/test-utils'
import { beforeEach, describe, expect, it, vi } from 'vitest'
// AuthToken.vue reads window.oc_defaults at module evaluation time. vi.hoisted
// runs before imports, so this guarantees the property is set on the existing
// jsdom window before the SFC is first parsed.
// AuthToken.vue reads window.OC.theme.productName at module evaluation time.
// vi.hoisted runs before imports, so this guarantees the property is set on
// the existing jsdom window before the SFC is first parsed.
vi.hoisted(() => {
(window as unknown as { oc_defaults: { productName: string } }).oc_defaults = { productName: 'Nextcloud' }
(window as unknown as { OC: { theme: { productName: string } } }).OC.theme = { productName: 'Nextcloud' }
})
import type { IToken } from '../store/authtoken.ts'
// Mock @nextcloud/dialogs so the wipe action's showConfirmation call resolves
// synchronously in tests. Hoisted so it's installed before AuthToken.vue imports.
const showConfirmationMock = vi.hoisted(() => vi.fn())

@ -109,6 +109,8 @@ import AuthTokenDeleteDialog from './AuthTokenDeleteDialog.vue'
import { TokenType, useAuthTokenStore } from '../store/authtoken.ts'
import { detect } from '../utils/userAgentDetect.ts'
const productName = window.OC.theme.productName as string
const nameMap = {
edge: 'Microsoft Edge',
firefox: 'Firefox',
@ -117,10 +119,10 @@ const nameMap = {
androidChrome: t('settings', 'Google Chrome for Android'),
iphone: 'iPhone',
ipad: 'iPad',
iosClient: t('settings', '{productName} iOS app', { productName: window.oc_defaults.productName }),
androidClient: t('settings', '{productName} Android app', { productName: window.oc_defaults.productName }),
iosTalkClient: t('settings', '{productName} Talk for iOS', { productName: window.oc_defaults.productName }),
androidTalkClient: t('settings', '{productName} Talk for Android', { productName: window.oc_defaults.productName }),
iosClient: t('settings', '{productName} iOS app', { productName }),
androidClient: t('settings', '{productName} Android app', { productName }),
iosTalkClient: t('settings', '{productName} Talk for iOS', { productName }),
androidTalkClient: t('settings', '{productName} Talk for Android', { productName }),
syncClient: t('settings', 'Sync client'),
davx5: 'DAVx5',
webPirate: 'WebPirate',

Loading…
Cancel
Save