Skip to content

Commit 3ba738e

Browse files
committed
fix(settings): satisfy stable32 lint and drop test of missing util
Signed-off-by: Peter Ringelmann <peter.ringelmann@nextcloud.com>
1 parent 6a62a23 commit 3ba738e

3 files changed

Lines changed: 12 additions & 66 deletions

File tree

apps/settings/src/components/AuthToken.spec.ts

Lines changed: 9 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -3,32 +3,30 @@
33
* SPDX-License-Identifier: AGPL-3.0-or-later
44
*/
55

6+
import type { IToken } from '../store/authtoken.ts'
7+
68
import { createTestingPinia } from '@pinia/testing'
9+
import NcNoteCard from '@nextcloud/vue/components/NcNoteCard'
710
import { mount } from '@vue/test-utils'
811
import { beforeEach, describe, expect, it, vi } from 'vitest'
12+
import AuthToken from './AuthToken.vue'
13+
import AuthTokenDeleteDialog from './AuthTokenDeleteDialog.vue'
14+
import { TokenType, useAuthTokenStore } from '../store/authtoken.ts'
915

1016
// AuthToken.vue reads window.oc_defaults at module evaluation time. vi.hoisted
11-
// runs before imports, so this guarantees the property is set on the existing
12-
// jsdom window before the SFC is first parsed.
17+
// is hoisted by Vitest above the imports at transform time, so this is set
18+
// on the existing jsdom window before the SFC is first parsed.
1319
vi.hoisted(() => {
1420
(window as unknown as { oc_defaults: { productName: string } }).oc_defaults = { productName: 'Nextcloud' }
1521
})
1622

17-
import type { IToken } from '../store/authtoken.ts'
18-
1923
// Mock @nextcloud/dialogs so the wipe action's showConfirmation call resolves
20-
// synchronously in tests. Hoisted so it's installed before AuthToken.vue imports.
24+
// synchronously in tests. Hoisted alongside the rest.
2125
const showConfirmationMock = vi.hoisted(() => vi.fn())
2226
vi.mock('@nextcloud/dialogs', () => ({
2327
showConfirmation: showConfirmationMock,
2428
}))
2529

26-
import NcNoteCard from '@nextcloud/vue/components/NcNoteCard'
27-
import AuthToken from './AuthToken.vue'
28-
import AuthTokenDeleteDialog from './AuthTokenDeleteDialog.vue'
29-
import { TokenType, useAuthTokenStore } from '../store/authtoken.ts'
30-
import { detect } from '../utils/userAgentDetect.ts'
31-
3230
function makeToken(overrides: Partial<IToken> = {}): IToken {
3331
return {
3432
id: 1,
@@ -44,7 +42,6 @@ function makeToken(overrides: Partial<IToken> = {}): IToken {
4442

4543
function mountAuthToken(token: IToken) {
4644
return mount(AuthToken, {
47-
// Vue Test Utils v1 (legacy pipeline) uses propsData; v2 also accepts it
4845
propsData: { token },
4946
mocks: {
5047
t: (_: string, text: string) => text,
@@ -192,51 +189,3 @@ describe('AuthTokenDeleteDialog wipe-pending warning', () => {
192189
expect(noteCard.text()).toMatch(/wipe/i)
193190
})
194191
})
195-
196-
describe('Android Chrome detection', () => {
197-
it('modern Android Chrome (no Build/ string, post-2021) should match androidChrome', () => {
198-
const ua = 'Mozilla/5.0 (Linux; Android 10; K) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Mobile Safari/537.36'
199-
expect(detect(ua)).toEqual({
200-
id: 'androidChrome',
201-
version: '132',
202-
})
203-
})
204-
205-
it('legacy Android Chrome (with Build/ string, pre-2021) should match androidChrome', () => {
206-
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'
207-
expect(detect(ua)).toEqual({
208-
id: 'androidChrome',
209-
version: '130',
210-
})
211-
})
212-
213-
it('Android Chrome on tablet (no "Mobile" in UA) should match androidChrome', () => {
214-
const ua = 'Mozilla/5.0 (Linux; Android 13) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36'
215-
expect(detect(ua)).toEqual({
216-
id: 'androidChrome',
217-
version: '131',
218-
})
219-
})
220-
})
221-
222-
describe('Desktop Chrome regression tests', () => {
223-
it('Desktop Chrome on Linux should still match chrome', () => {
224-
const ua = 'Mozilla/5.0 (X11; Linux x86_64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/132.0.0.0 Safari/537.36'
225-
expect(detect(ua)).toEqual({
226-
id: 'chrome',
227-
version: '132',
228-
os: 'Linux',
229-
})
230-
})
231-
})
232-
233-
describe('Desktop Firefox regression tests', () => {
234-
it('Desktop Firefox on Linux should still match firefox', () => {
235-
const ua = 'Mozilla/5.0 (X11; Linux x86_64; rv:124.0) Gecko/20100101 Firefox/124.0'
236-
expect(detect(ua)).toEqual({
237-
id: 'firefox',
238-
version: '124',
239-
os: 'Linux',
240-
})
241-
})
242-
})

apps/settings/src/components/AuthToken.vue

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,8 +73,7 @@
7373
</template>
7474
</NcActions>
7575
</td>
76-
<AuthTokenDeleteDialog
77-
v-if="deleteDialogOpen"
76+
<AuthTokenDeleteDialog v-if="deleteDialogOpen"
7877
:token="token"
7978
:open.sync="deleteDialogOpen"
8079
@confirm="confirmDelete" />

apps/settings/src/components/AuthTokenDeleteDialog.vue

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -60,14 +60,12 @@ const buttons = computed<IDialogButton[]>(() => [
6060
</script>
6161

6262
<template>
63-
<NcDialog
64-
:open="open"
63+
<NcDialog :open="open"
6564
:name="messages.title"
6665
:buttons="buttons"
6766
size="normal"
6867
@update:open="emit('update:open', $event)">
69-
<NcNoteCard
70-
v-if="wiping"
68+
<NcNoteCard v-if="wiping"
7169
:heading="t('settings', 'Remote wipe has not started yet.')"
7270
type="error">
7371
{{ t('settings', 'Revoking now cancels the wipe. The device keeps its synced data.') }}

0 commit comments

Comments
 (0)