mirror of
https://github.com/nextcloud/server.git
synced 2026-06-09 00:32:29 -04:00
fix(settings): satisfy stable32 lint and drop test of missing util
Signed-off-by: Peter Ringelmann <peter.ringelmann@nextcloud.com>
This commit is contained in:
parent
6a62a23598
commit
3ba738e717
3 changed files with 12 additions and 66 deletions
|
|
@ -3,32 +3,30 @@
|
|||
* SPDX-License-Identifier: AGPL-3.0-or-later
|
||||
*/
|
||||
|
||||
import type { IToken } from '../store/authtoken.ts'
|
||||
|
||||
import { createTestingPinia } from '@pinia/testing'
|
||||
import NcNoteCard from '@nextcloud/vue/components/NcNoteCard'
|
||||
import { mount } from '@vue/test-utils'
|
||||
import { beforeEach, describe, expect, it, vi } from 'vitest'
|
||||
import AuthToken from './AuthToken.vue'
|
||||
import AuthTokenDeleteDialog from './AuthTokenDeleteDialog.vue'
|
||||
import { TokenType, useAuthTokenStore } from '../store/authtoken.ts'
|
||||
|
||||
// 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.
|
||||
// is hoisted by Vitest above the imports at transform time, so this 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' }
|
||||
})
|
||||
|
||||
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.
|
||||
// synchronously in tests. Hoisted alongside the rest.
|
||||
const showConfirmationMock = vi.hoisted(() => vi.fn())
|
||||
vi.mock('@nextcloud/dialogs', () => ({
|
||||
showConfirmation: showConfirmationMock,
|
||||
}))
|
||||
|
||||
import NcNoteCard from '@nextcloud/vue/components/NcNoteCard'
|
||||
import AuthToken from './AuthToken.vue'
|
||||
import AuthTokenDeleteDialog from './AuthTokenDeleteDialog.vue'
|
||||
import { TokenType, useAuthTokenStore } from '../store/authtoken.ts'
|
||||
import { detect } from '../utils/userAgentDetect.ts'
|
||||
|
||||
function makeToken(overrides: Partial<IToken> = {}): IToken {
|
||||
return {
|
||||
id: 1,
|
||||
|
|
@ -44,7 +42,6 @@ function makeToken(overrides: Partial<IToken> = {}): IToken {
|
|||
|
||||
function mountAuthToken(token: IToken) {
|
||||
return mount(AuthToken, {
|
||||
// Vue Test Utils v1 (legacy pipeline) uses propsData; v2 also accepts it
|
||||
propsData: { token },
|
||||
mocks: {
|
||||
t: (_: string, text: string) => text,
|
||||
|
|
@ -192,51 +189,3 @@ describe('AuthTokenDeleteDialog wipe-pending warning', () => {
|
|||
expect(noteCard.text()).toMatch(/wipe/i)
|
||||
})
|
||||
})
|
||||
|
||||
describe('Android Chrome detection', () => {
|
||||
it('modern Android Chrome (no Build/ string, post-2021) should match androidChrome', () => {
|
||||
const ua = 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Mobile Safari/537.36'
|
||||
expect(detect(ua)).toEqual({
|
||||
id: 'androidChrome',
|
||||
version: '132',
|
||||
})
|
||||
})
|
||||
|
||||
it('legacy Android Chrome (with Build/ string, pre-2021) should match androidChrome', () => {
|
||||
const ua = 'Mozilla/5.0 (Linux; Android 10; SM-G973F Build/QP1A) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Mobile Safari/537.36'
|
||||
expect(detect(ua)).toEqual({
|
||||
id: 'androidChrome',
|
||||
version: '130',
|
||||
})
|
||||
})
|
||||
|
||||
it('Android Chrome on tablet (no "Mobile" in UA) should match androidChrome', () => {
|
||||
const ua = 'Mozilla/5.0 (Linux; Android 13) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36'
|
||||
expect(detect(ua)).toEqual({
|
||||
id: 'androidChrome',
|
||||
version: '131',
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('Desktop Chrome regression tests', () => {
|
||||
it('Desktop Chrome on Linux should still match chrome', () => {
|
||||
const ua = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36'
|
||||
expect(detect(ua)).toEqual({
|
||||
id: 'chrome',
|
||||
version: '132',
|
||||
os: 'Linux',
|
||||
})
|
||||
})
|
||||
})
|
||||
|
||||
describe('Desktop Firefox regression tests', () => {
|
||||
it('Desktop Firefox on Linux should still match firefox', () => {
|
||||
const ua = 'Mozilla/5.0 (X11; Linux x86_64; rv:124.0) Gecko/20100101 Firefox/124.0'
|
||||
expect(detect(ua)).toEqual({
|
||||
id: 'firefox',
|
||||
version: '124',
|
||||
os: 'Linux',
|
||||
})
|
||||
})
|
||||
})
|
||||
|
|
|
|||
|
|
@ -73,8 +73,7 @@
|
|||
</template>
|
||||
</NcActions>
|
||||
</td>
|
||||
<AuthTokenDeleteDialog
|
||||
v-if="deleteDialogOpen"
|
||||
<AuthTokenDeleteDialog v-if="deleteDialogOpen"
|
||||
:token="token"
|
||||
:open.sync="deleteDialogOpen"
|
||||
@confirm="confirmDelete" />
|
||||
|
|
|
|||
|
|
@ -60,14 +60,12 @@ const buttons = computed<IDialogButton[]>(() => [
|
|||
</script>
|
||||
|
||||
<template>
|
||||
<NcDialog
|
||||
:open="open"
|
||||
<NcDialog :open="open"
|
||||
:name="messages.title"
|
||||
:buttons="buttons"
|
||||
size="normal"
|
||||
@update:open="emit('update:open', $event)">
|
||||
<NcNoteCard
|
||||
v-if="wiping"
|
||||
<NcNoteCard v-if="wiping"
|
||||
:heading="t('settings', 'Remote wipe has not started yet.')"
|
||||
type="error">
|
||||
{{ t('settings', 'Revoking now cancels the wipe. The device keeps its synced data.') }}
|
||||
|
|
|
|||
Loading…
Reference in a new issue